# Move all my shards from data-master nodes to new Data-only nodes?

**URL:** <https://discuss.elastic.co/t/move-all-my-shards-from-data-master-nodes-to-new-data-only-nodes/36776>\
**Category:** Elasticsearch\
**Created:** [December 9, 2015, 5:18pm UTC](https://discuss.elastic.co/t/move-all-my-shards-from-data-master-nodes-to-new-data-only-nodes/36776 "2015-12-09T17:18:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Medyagh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medyagh/32/6523_2.png) [@Medyagh](https://discuss.elastic.co/u/Medyagh)\
**Post date:** [December 9, 2015, 5:18pm UTC](https://discuss.elastic.co/t/move-all-my-shards-from-data-master-nodes-to-new-data-only-nodes/36776/1 "2015-12-09T17:18:40Z")

</div>

Hi I am new to ES,

I have cluster of master-data-clients nodes, I am adding 3 data nodes (only data nodes and not master)  
and I wanna migrate all my shards to these new data nodes, so I can destroy my older data-master nodes, is there a query that can do that for me ?

the query should move all my data from old data-master shards to new only data nodes. let say I had 5 data-master nodes and I wanna move them to 3 new only data nodes.

---

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [December 9, 2015, 6:05pm UTC](https://discuss.elastic.co/t/move-all-my-shards-from-data-master-nodes-to-new-data-only-nodes/36776/2 "2015-12-09T18:05:42Z")

</div>

I believe you can close your index first or better to switch off ES, then move Linux folders where you ES data are located. Keep in mind a shard is just a Lucene index.

---

<div class="post-metadata">

**Author:** ![tinle](https://avatars.discourse-cdn.com/v4/letter/t/c77e96/32.png) [@tinle](https://discuss.elastic.co/u/tinle)\
**Post date:** [December 9, 2015, 6:20pm UTC](https://discuss.elastic.co/t/move-all-my-shards-from-data-master-nodes-to-new-data-only-nodes/36776/3 "2015-12-09T18:20:38Z")

</div>

Use the routing API.

```
> curl -XPUT "http://any-master-node-in-cluster:9200/_cluster/settings" -d '{
> "transient" : {
> "cluster.routing.allocation.exclude._ip" : "IP1, IP2, IP3, etc."
> }
> }'

```

Where IP1, IP2 and so on are addresses of the nodes you want to migrate shards away from.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 9, 2015, 7:12pm UTC](https://discuss.elastic.co/t/move-all-my-shards-from-data-master-nodes-to-new-data-only-nodes/36776/4 "2015-12-09T19:12:31Z")

</div>

> [@tinle](#):
>
> Use the routing API.

This. I've used this when removing nodes from the cluster. I've used it when we had to replace the disks and we wanted to bring three nodes down at a time. Just remember this request is honored asynchronously. You can check in the `_cat` APIs for how many shards a node is hosting.

---

<div class="post-metadata">

**Author:** ![Medyagh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medyagh/32/6523_2.png) [@Medyagh](https://discuss.elastic.co/u/Medyagh)\
**Post date:** [December 9, 2015, 8:43pm UTC](https://discuss.elastic.co/t/move-all-my-shards-from-data-master-nodes-to-new-data-only-nodes/36776/5 "2015-12-09T20:43:14Z")

</div>

@tinle @nik9000  
I tried this but it did move the data to one of the excluded ips after I shutdown one of the nodes, any idea why? I even trying shutting down one node or whole cluster.  
I tried both include and exclude \_ip ...none of them force the data go to the desired places. how can I troubleshoot ?  
my ES version is 1.7

---

<div class="post-metadata">

**Author:** ![Medyagh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medyagh/32/6523_2.png) [@Medyagh](https://discuss.elastic.co/u/Medyagh)\
**Post date:** [December 9, 2015, 9:17pm UTC](https://discuss.elastic.co/t/move-all-my-shards-from-data-master-nodes-to-new-data-only-nodes/36776/6 "2015-12-09T21:17:21Z")

</div>

after I set the include it wont move the shards and when I try to manually move a shard to that desired host it tells me  
NO(node does not match global include filters)

but its totally wrong, both ip and host match the filters

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 9, 2015, 9:58pm UTC](https://discuss.elastic.co/t/move-all-my-shards-from-data-master-nodes-to-new-data-only-nodes/36776/7 "2015-12-09T21:58:43Z")

</div>

> [@Medyagh](#):
>
> NO(node does not match global include filters)

Sounds like you set exclude to the ips you wanted it to move **to** rather than from? I can't really tell though. I've certainly used this in the past and it worked.

Manually asking elaticsearch to move shards tends to be futile because it'll start moving shards back to the node that lost the shard in an effort to balance the nodes again.

---

<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:32pm UTC](https://discuss.elastic.co/t/move-all-my-shards-from-data-master-nodes-to-new-data-only-nodes/36776/8 "2017-07-05T23:32:11Z")

</div>


