# How to get back my Primary shards?

**URL:** <https://discuss.elastic.co/t/how-to-get-back-my-primary-shards/39954>\
**Category:** Elasticsearch\
**Created:** [January 23, 2016, 6:47pm UTC](https://discuss.elastic.co/t/how-to-get-back-my-primary-shards/39954 "2016-01-23T18:47:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![klahnakoski](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klahnakoski/32/3679_2.png) [@klahnakoski](https://discuss.elastic.co/u/klahnakoski)\
**Post date:** [January 23, 2016, 6:47pm UTC](https://discuss.elastic.co/t/how-to-get-back-my-primary-shards/39954/1 "2016-01-23T18:47:27Z")

</div>

After disabling allocation

```
curl -X PUT -d "{\"persistent\": {\"cluster.routing.allocation.enable\": \"none\"}}" http://localhost:9200/_cluster/settings

```

I shutdown one of my nodes for service. Now that it is back up, the PRIMARY shards remained unassigned. The data is still on the drive. What is the command to tell ES that, "yes, you got a whole shard, please use it"?

I tried a `/_cluster/reroute` command on a single shard of an unimportant index. `"allow_primary": false` reports an error. And `"allow_primary": true` erases everything on that shard.

Thanks

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [January 23, 2016, 6:50pm UTC](https://discuss.elastic.co/t/how-to-get-back-my-primary-shards/39954/2 "2016-01-23T18:50:09Z")

</div>

You did reenable allocations after the node came back up, right?

---

<div class="post-metadata">

**Author:** ![klahnakoski](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klahnakoski/32/3679_2.png) [@klahnakoski](https://discuss.elastic.co/u/klahnakoski)\
**Post date:** [January 23, 2016, 7:07pm UTC](https://discuss.elastic.co/t/how-to-get-back-my-primary-shards/39954/3 "2016-01-23T19:07:14Z")

</div>

My ES version is 1.7.1.

I will reenable allocations, and get back to you

---

<div class="post-metadata">

**Author:** ![klahnakoski](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klahnakoski/32/3679_2.png) [@klahnakoski](https://discuss.elastic.co/u/klahnakoski)\
**Post date:** [January 23, 2016, 7:15pm UTC](https://discuss.elastic.co/t/how-to-get-back-my-primary-shards/39954/4 "2016-01-23T19:15:38Z")

</div>

By enabling allocation, the serviced node will start replicating nodes from the others, but the primary shards remain unassigned.

---

<div class="post-metadata">

**Author:** ![klahnakoski](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klahnakoski/32/3679_2.png) [@klahnakoski](https://discuss.elastic.co/u/klahnakoski)\
**Post date:** [January 23, 2016, 7:36pm UTC](https://discuss.elastic.co/t/how-to-get-back-my-primary-shards/39954/5 "2016-01-23T19:36:29Z")

</div>

Plus, once allocation is enabled I get

```auto
[2016-01-23 19:08:18,962][INFO][cluster.routing.allocation.decider] [primary] updating [cluster.routing.allocation.enable] from [NONE] to [ALL]
[2016-01-23 19:08:18,970][INFO][indices.store] [primary] Failed to open / find files while reading metadata snapshot
[2016-01-23 19:08:18,971][INFO][indices.store] [primary] Failed to open / find files while reading metadata snapshot
[2016-01-23 19:08:18,973][INFO][indices.store] [primary] Failed to open / find files while reading metadata snapshot
[2016-01-23 19:08:18,973][INFO][indices.store] [primary] Failed to open / find files while reading metadata snapshot
[2016-01-23 19:08:18,974][INFO][indices.store] [primary] Failed to open / find files while reading metadata snapshot

```

---

<div class="post-metadata">

**Author:** ![klahnakoski](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klahnakoski/32/3679_2.png) [@klahnakoski](https://discuss.elastic.co/u/klahnakoski)\
**Post date:** [January 23, 2016, 8:06pm UTC](https://discuss.elastic.co/t/how-to-get-back-my-primary-shards/39954/6 "2016-01-23T20:06:54Z")

</div>

I disabled shard allocation, shutdown the problem node, and tried removing the translogs

```
sudo find /data1 -name translog-* -exec rm -rf {} \;

```

I started the node, enabled allocation, and the primary shards still do not come back

```auto

[2016-01-23 19:59:52,626][INFO][cluster.routing.allocation.decider] [primary] updating [cluster.routing.allocation.enable] from [ALL] to [NONE]
[2016-01-23 19:59:52,659][INFO][http] [primary] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/172.31.0.196:9200]}
[2016-01-23 19:59:52,662][INFO][node] [primary] started
[2016-01-23 20:01:51,095][INFO][cluster.routing.allocation.decider] [primary] updating [cluster.routing.allocation.enable] from [NONE] to [ALL]
[2016-01-23 20:01:51,108][INFO][indices.store] [primary] Failed to open / find files while reading metadata snapshot
[2016-01-23 20:01:51,113][INFO][indices.store] [primary] Failed to open / find files while reading metadata snapshot
[2016-01-23 20:01:51,110][INFO][indices.store] [primary] Failed to open / find files while reading metadata snapshot
[2016-01-23 20:01:51,131][INFO][indices.store] [primary] Failed to open / find files while reading metadata snapshot
[2016-01-23 20:01:51,109][INFO][indices.store] [primary] Failed to open / find files while reading metadata snapshot

```

---

<div class="post-metadata">

**Author:** ![klahnakoski](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klahnakoski/32/3679_2.png) [@klahnakoski](https://discuss.elastic.co/u/klahnakoski)\
**Post date:** [January 23, 2016, 8:44pm UTC](https://discuss.elastic.co/t/how-to-get-back-my-primary-shards/39954/7 "2016-01-23T20:44:55Z")

</div>

In an attempt to increase the available space on my node I change my \*yml file from

```
path.data: /data1, /data2, /data3

```

to

```
path.data: /data1, /data2, /data3, /data4

```

undoing this change, and restarting the node, got back most of my PRIMARY shards, except one.

---

<div class="post-metadata">

**Author:** ![klahnakoski](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klahnakoski/32/3679_2.png) [@klahnakoski](https://discuss.elastic.co/u/klahnakoski)\
**Post date:** [January 25, 2016, 12:55am UTC](https://discuss.elastic.co/t/how-to-get-back-my-primary-shards/39954/8 "2016-01-25T00:55:26Z")

</div>

In summary, before version 2.0, you can not change the `path.data` or you will loose data. It appears the older versions of ES were striping data over the paths, so changing the number confused it. Lucky that the data was simply considered unusable, and not removed from the drive: Reverting the `path.data` let the shards recover.

---

<div class="post-metadata">

**Author:** ![bleskes](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@bleskes](https://discuss.elastic.co/u/bleskes)\
**Post date:** [January 25, 2016, 1:34pm UTC](https://discuss.elastic.co/t/how-to-get-back-my-primary-shards/39954/9 "2016-01-25T13:34:00Z")

</div>

For the recorde - adding paths to the list shouldn't cause data to go away. Something else is going on here. Also, I know in the past that people recommended (including me :)) to delete the translog on recovery problem but this is _only_ when you run into translog corruption on old ES version, where we didn't shut down correctly and corruption was expected. These days are long gone and newer version will refuse to open a primary if the translog is missing.

I presume there is no way to dig deeper now and the data is long gone. If not please ping me and we can research.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:21pm UTC](https://discuss.elastic.co/t/how-to-get-back-my-primary-shards/39954/10 "2017-07-05T23:21:57Z")

</div>


