# Force shard reallocation

**URL:** <https://discuss.elastic.co/t/force-shard-reallocation/36839>\
**Category:** Elasticsearch\
**Created:** [December 10, 2015, 7:40am UTC](https://discuss.elastic.co/t/force-shard-reallocation/36839 "2015-12-10T07:40:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![yehosef](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yehosef/32/42175_2.png) [@yehosef](https://discuss.elastic.co/u/yehosef)\
**Post date:** [December 10, 2015, 7:40am UTC](https://discuss.elastic.co/t/force-shard-reallocation/36839/1 "2015-12-10T07:40:40Z")

</div>

Also if I know I have a node I want to take down - can I force all the primaries to migrate to other machines before hand to minimize any effect. This become more crucial when sometimes we have indices without replication (either because of size constraints or ingestion performance - the use case can tolerate failure/restarting.) Even though we can reindex if we need to - if we know we want to take a machine down - we would like to migrate all the primary/singular indices off that node to avoid needless downtime.

I see from [https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html) that I can reroute specific shard - but then the cluster will rebalance. It seems I can mitigate this - but I'm not sure how much. Further - I would like to do this globally for all shards on this node - not for individual shards.

Is this possible?

---

<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:** [December 10, 2015, 2:42pm UTC](https://discuss.elastic.co/t/force-shard-reallocation/36839/2 "2015-12-10T14:42:13Z")

</div>

you can use the allocation filtering to exclude a node , for example (by ip):

```
PUT test/_settings
{
  "index.routing.allocation.exclude._ip": "192.168.2.10"
}

```

see [https://www.elastic.co/guide/en/elasticsearch/reference/current/shard-allocation-filtering.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/shard-allocation-filtering.html)

---

<div class="post-metadata">

**Author:** ![yehosef](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yehosef/32/42175_2.png) [@yehosef](https://discuss.elastic.co/u/yehosef)\
**Post date:** [December 28, 2015, 1:46pm UTC](https://discuss.elastic.co/t/force-shard-reallocation/36839/3 "2015-12-28T13:46:06Z")

</div>

Does this reallocate the index if it's already on the node? I added this setting for one of the indices and it doesn't seem like it's reallocating.

---

<div class="post-metadata">

**Author:** ![yehosef](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yehosef/32/42175_2.png) [@yehosef](https://discuss.elastic.co/u/yehosef)\
**Post date:** [December 28, 2015, 11:38pm UTC](https://discuss.elastic.co/t/force-shard-reallocation/36839/4 "2015-12-28T23:38:46Z")

</div>

seems like the cluster setting is what I want. From [https://www.elastic.co/guide/en/elasticsearch/reference/1.7/index-modules-allocation.html](https://www.elastic.co/guide/en/elasticsearch/reference/1.7/index-modules-allocation.html)

```
curl -XPUT localhost:9200/_cluster/settings -d '{
    "transient" : {
        "cluster.routing.allocation.exclude._ip" : "10.0.0.1"
    }
}'

```

I'll try this again - the index level didn't work, but maybe the cluster level will.

---

<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 5, 2016, 9:30am UTC](https://discuss.elastic.co/t/force-shard-reallocation/36839/5 "2016-01-05T09:30:43Z")

</div>

It should move the index, if there is another place to put it. If no other node is available due to disk space, all nodes already have a shard copy or other conflicting filtering rules, the shard will not be moved.

---

<div class="post-metadata">

**Author:** ![yehosef](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yehosef/32/42175_2.png) [@yehosef](https://discuss.elastic.co/u/yehosef)\
**Post date:** [January 5, 2016, 9:50am UTC](https://discuss.elastic.co/t/force-shard-reallocation/36839/6 "2016-01-05T09:50:01Z")

</div>

Thanks - it worked in the end.

it would be really helpful to have some way to see how it's figuring out what to do with the allocations. There are several settings which can compete against each other which can sometimes result in strange allocations.

---

<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 5, 2016, 10:27am UTC](https://discuss.elastic.co/t/force-shard-reallocation/36839/7 "2016-01-05T10:27:05Z")

</div>

Agreed. You can issue a reroute with an explain flag: POST \_reroute?explain=true and it should give you some insight as to why shards are not moved.

---

<div class="post-metadata">

**Author:** ![yehosef](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yehosef/32/42175_2.png) [@yehosef](https://discuss.elastic.co/u/yehosef)\
**Post date:** [January 5, 2016, 12:26pm UTC](https://discuss.elastic.co/t/force-shard-reallocation/36839/8 "2016-01-05T12:26:53Z")

</div>

as usual, elasticsearch has thought of it - I'll try it out.

---

<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:26pm UTC](https://discuss.elastic.co/t/force-shard-reallocation/36839/9 "2017-07-05T23:26:59Z")

</div>


