# Elasticsearch hosts upgrade - options

**URL:** <https://discuss.elastic.co/t/elasticsearch-hosts-upgrade-options/331071>\
**Category:** Elasticsearch\
**Created:** [April 28, 2023, 3:36pm UTC](https://discuss.elastic.co/t/elasticsearch-hosts-upgrade-options/331071 "2023-04-28T15:36:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [April 28, 2023, 3:36pm UTC](https://discuss.elastic.co/t/elasticsearch-hosts-upgrade-options/331071/1 "2023-04-28T15:36:04Z")

</div>

Hello,

We have 3 Master nodes and 5 data nodes in our cluster.

The VMs hosting the entire cluster is undergoing an upgrade which will involve downtime (for few hours) and also IP change for the 3 Master nodes and 1 data node.

We have a choice of getting this upgrade done in piecemeal and are thinking of getting the whole exercise done in 2 phases.

What would be the best option to pick when it comes to selecting the nodes?

I was thinking of the following:

**1st Phase**

1 Master node and 3 data nodes

**2nd Phase**

2 Master nodes and 2 data nodes

Please guide.

Thanks

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [April 28, 2023, 3:47pm UTC](https://discuss.elastic.co/t/elasticsearch-hosts-upgrade-options/331071/2 "2023-04-28T15:47:19Z")

</div>

I would say that you will probably need to do this in more steps since the downtime can take hours.

The safest option is to [exclude the data node](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-cluster.html#cluster-shard-allocation-filtering) from allocation before shutting it down.

For example:

```auto
PUT _cluster/settings
{
  "persistent" : {
    "cluster.routing.allocation.exclude._name" : "node-name"
  }
}

```

After you run that request, the shards will start to move to the other nodes, after the node is empty you can shut it down.

When the upgrade is finished and the node is up again you need to clear the allocation settings to allow the node to receive shards again.

```auto
PUT _cluster/settings
{
  "persistent" : {
    "cluster.routing.allocation.exclude._name" : null
  }
}

```

When the shards are reallocated, you may repeate the process for the other data nodes.

If your master nodes are master-only, you do not need to exclude them from allocation and can just shutdown the node but you need to have at least **two** master nodes up at the same time.

---

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [April 28, 2023, 7:53pm UTC](https://discuss.elastic.co/t/elasticsearch-hosts-upgrade-options/331071/3 "2023-04-28T19:53:50Z")

</div>

thanks a lot! @leandrojmp

Can the "exclude data node" command take 2 nodes at a time (comma separated) as below:

```auto
PUT _cluster/settings
{
  "persistent" : {
    "cluster.routing.allocation.exclude._name" : ["node1-name", "node2-name"]
  }
}

```

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [April 28, 2023, 9:21pm UTC](https://discuss.elastic.co/t/elasticsearch-hosts-upgrade-options/331071/4 "2023-04-28T21:21:31Z")

</div>

> [@zaeemmasood](#):
>
> Can the "exclude data node" command take 2 nodes at a time (comma separated) as below

Yes, but it is not an array, it is just comma separated.

"node1-name, node2-name"

Also, to do that you need to make sure that the remaining nodes have enough free space to receive the data from the two nodes.

---

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [April 28, 2023, 9:23pm UTC](https://discuss.elastic.co/t/elasticsearch-hosts-upgrade-options/331071/5 "2023-04-28T21:23:19Z")

</div>

thank you!

I am trying this on one node in a lower environment and it is running for almost 2.5 hours now and still ~40% shards remain to be moved over

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [April 28, 2023, 10:44pm UTC](https://discuss.elastic.co/t/elasticsearch-hosts-upgrade-options/331071/6 "2023-04-28T22:44:13Z")

</div>

> [@zaeemmasood](#):
>
> I am trying this on one node in a lower environment and it is running for almost 2.5 hours now and still ~40% shards remain to be moved over

Yeah, it is normal, it can take time.

---

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [May 1, 2023, 1:29pm UTC](https://discuss.elastic.co/t/elasticsearch-hosts-upgrade-options/331071/7 "2023-05-01T13:29:38Z")

</div>

Thanks. It took 8 hours for 1512 shards to migrate from a node that had both roles (Master and data).

Would it take the same/ similar time if I choose to do 2 hosts/ nodes together; considering i have disk space available? These 2 nodes are **dedicated data nodes**.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 1, 2023, 1:36pm UTC](https://discuss.elastic.co/t/elasticsearch-hosts-upgrade-options/331071/8 "2023-05-01T13:36:58Z")

</div>

How many shards do you have in the cluster? What is the average shard size?

---

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [May 1, 2023, 11:42pm UTC](https://discuss.elastic.co/t/elasticsearch-hosts-upgrade-options/331071/9 "2023-05-01T23:42:27Z")

</div>

Hello Christian. 1465 Shards with 1.3GB size on the average

I calculated by executing the following and taking the average of the result. Hope this is the right way:

```auto
GET _cat/shards?v=true&h=index,prirep,shard,store&s=prirep,store&bytes=gb&s=store:desc

```

Thanks

---

<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:** [May 29, 2023, 11:42pm UTC](https://discuss.elastic.co/t/elasticsearch-hosts-upgrade-options/331071/10 "2023-05-29T23:42:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
