# How to shrink a cluster

**URL:** <https://discuss.elastic.co/t/how-to-shrink-a-cluster/33163>\
**Category:** Elasticsearch\
**Created:** [October 28, 2015, 4:07pm UTC](https://discuss.elastic.co/t/how-to-shrink-a-cluster/33163 "2015-10-28T16:07:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marjana](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@Marjana](https://discuss.elastic.co/u/Marjana)\
**Post date:** [October 28, 2015, 4:07pm UTC](https://discuss.elastic.co/t/how-to-shrink-a-cluster/33163/1 "2015-10-28T16:07:53Z")

</div>

Hello,  
We are trying to replace our VM nodes with bare metal. We keep data for max 2 weeks. Is there a way to add new bare metal nodes to the cluster and use only those for adding new indices? As 2 weeks pass by, we can remove all indices on VM nodes and shut down those nodes. From what I've read, excluding a node with "cluster.routing.allocation.exclude.\_ip" will cause shards to be moved from it, which we'd like to avoid (why bother moving a lot of data when it can all be removed 2 weeks later?).  
Thanks

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [October 28, 2015, 5:16pm UTC](https://discuss.elastic.co/t/how-to-shrink-a-cluster/33163/2 "2015-10-28T17:16:52Z")

</div>

You can use shard allocation filtering, assign labels to your nodes (requires restarting the nodes to take effect) and matching labels to your indices, so that e.g. only old indices will go to old nodes and new indices will only go to new nodes.

Cheers  
Luca

---

<div class="post-metadata">

**Author:** ![Marjana](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@Marjana](https://discuss.elastic.co/u/Marjana)\
**Post date:** [October 28, 2015, 9:26pm UTC](https://discuss.elastic.co/t/how-to-shrink-a-cluster/33163/3 "2015-10-28T21:26:51Z")

</div>

Thanks Luca.  
So I guess I'd say something like this for 2 vm nodes and 2 bare metal nodes:  
node.label: vm1  
node.label: vm2  
node.label: bm1  
node.label.bm2

Indexes are created every hour. In my index templates setting I'd add "index.routing.allocation.include.label" : "bm1,bm2"

Now how would I prevent any allocation going to vm nodes?  
I can create another attribute , let's say called server\_type that would have a value of vm or baremetal and use  
cluster.routing.allocation.awareness.attributes: server\_type with cluster.routing.allocation.awareness.force.server\_type.values: baremetal

or if I use allocation.aweness like this, I don't even need to label each node differently? Still don't know how to prevent any allocation during rebalance or recovery to go to vm nodes.  
I am VERY new to ElasticSearch so I apologize if i am asking basic questions.  
Thanks!

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 28, 2015, 9:37pm UTC](https://discuss.elastic.co/t/how-to-shrink-a-cluster/33163/4 "2015-10-28T21:37:01Z")

</div>

Why not just add the new nodes, then use the exclude IP routing to everything off the VMs to the physicals and then remove the VMs altogether? Seems a lot simpler 🙂

---

<div class="post-metadata">

**Author:** ![Marjana](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@Marjana](https://discuss.elastic.co/u/Marjana)\
**Post date:** [October 29, 2015, 2:18am UTC](https://discuss.elastic.co/t/how-to-shrink-a-cluster/33163/5 "2015-10-29T02:18:30Z")

</div>

Because I want to avoid moving data (a LOT of it). I'd rather not move off VMs, but just leave what's there, and once it's not needed any more (2 weeks later), delete it.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 29, 2015, 2:52am UTC](https://discuss.elastic.co/t/how-to-shrink-a-cluster/33163/6 "2015-10-29T02:52:21Z")

</div>

> [@Marjana](#):
>
> node.label: vm1node.label: vm2node.label: bm1node.label.bm2
> 
> Indexes are created every hour. In my index templates setting I'd add "index.routing.allocation.include.label" : "bm1,bm2"

This is all you need to do 🙂

---

<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:41pm UTC](https://discuss.elastic.co/t/how-to-shrink-a-cluster/33163/7 "2017-07-05T23:41:57Z")

</div>


