# Data nodes HA and Shards allocation/creation

**URL:** <https://discuss.elastic.co/t/data-nodes-ha-and-shards-allocation-creation/151150>\
**Category:** Elasticsearch\
**Created:** [October 5, 2018, 5:15am UTC](https://discuss.elastic.co/t/data-nodes-ha-and-shards-allocation-creation/151150 "2018-10-05T05:15:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mruthyu](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@mruthyu](https://discuss.elastic.co/u/mruthyu)\
**Post date:** [October 5, 2018, 5:15am UTC](https://discuss.elastic.co/t/data-nodes-ha-and-shards-allocation-creation/151150/1 "2018-10-05T05:15:06Z")

</div>

If we have two data nodes and replica has been set to 1, and if a node down whether the shards will be created in other node newly and will require the same amount of additional disk space which has been lost due to the unavailability of the other node?

Also what happens when the other node comes up and the shards have been synchronized to have the latest data, whether the newly created shards in other node will be deleted and will free up the disk space?

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 5, 2018, 7:57am UTC](https://discuss.elastic.co/t/data-nodes-ha-and-shards-allocation-creation/151150/2 "2018-10-05T07:57:31Z")

</div>

Elasticsearch will not allocate two copies of a shard to the same node. To do so would cost resources (particularly disk space and IO) without giving any resilience benefit. In a two-node setup if one of the nodes becomes unavailable then all the replica shards will simply be unassigned and your cluster health will show as `YELLOW`. When the other node returns the replicas will be allocated to it again and will sync up with their primaries.

---

<div class="post-metadata">

**Author:** ![mruthyu](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@mruthyu](https://discuss.elastic.co/u/mruthyu)\
**Post date:** [October 5, 2018, 9:57am UTC](https://discuss.elastic.co/t/data-nodes-ha-and-shards-allocation-creation/151150/3 "2018-10-05T09:57:37Z")

</div>

Thanks. Would like to know whether it will be the same behavior if 3 or more nodes are there and one node goes down.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 5, 2018, 10:28am UTC](https://discuss.elastic.co/t/data-nodes-ha-and-shards-allocation-creation/151150/4 "2018-10-05T10:28:48Z")

</div>

Roughly speaking, no. The master will try and allocate any unallocated shards to bring your cluster back into a resilient state; in the 2-node case the rule "do not allocate more than one copy of a shard to a node" prevents it from doing so, but if there is somewhere to allocate the unallocated shards then it will use it.

However there are features such as [delayed allocation](https://www.elastic.co/guide/en/elasticsearch/reference/current/delayed-allocation.html) to prevent this from happening immediately, in case the node comes back quickly, and [various other settings](https://www.elastic.co/guide/en/elasticsearch/reference/current/shards-allocation.html) that control how the shard recoveries take place, how many recoveries can happen concurrently and so on.

---

<div class="post-metadata">

**Author:** ![mruthyu](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@mruthyu](https://discuss.elastic.co/u/mruthyu)\
**Post date:** [October 5, 2018, 12:50pm UTC](https://discuss.elastic.co/t/data-nodes-ha-and-shards-allocation-creation/151150/5 "2018-10-05T12:50:26Z")

</div>

Thank you. How the behavior will be in case of hot and warm data nodes architecture where 2 hot nodes and 2 warm nodes are present? Weather they will work in isolation in case of one node goes in each type?

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 5, 2018, 4:06pm UTC](https://discuss.elastic.co/t/data-nodes-ha-and-shards-allocation-creation/151150/6 "2018-10-05T16:06:26Z")

</div>

The [hot/warm architecture](https://www.elastic.co/blog/hot-warm-architecture-in-elasticsearch-5-x) uses allocation filtering, which imposes other strict rules that the master will obey when it is trying to find somewhere to allocate shards alongside the "do not allocate more than one copy of a shard to a node" rule. So the shards of a hot index will only be allocated to hot nodes and similarly for the warm ones, and if you lose a warm node then its shards will remain unallocated until the node comes back online and will not be allocated to one of the hot nodes.

---

<div class="post-metadata">

**Author:** ![mruthyu](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@mruthyu](https://discuss.elastic.co/u/mruthyu)\
**Post date:** [October 24, 2018, 6:58am UTC](https://discuss.elastic.co/t/data-nodes-ha-and-shards-allocation-creation/151150/7 "2018-10-24T06:58:42Z")

</div>

Thanks for the clarification. In a 3 data node scenario one data node goes down and after allocating the shards from the node which went down to the available data nodes the cluster status will turn back to GREEN from YELLOW. After this when the node which was down is back up whether the shards which have been allocated on other nodes will be deleted hence freeing up the disk space?

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 24, 2018, 11:48am UTC](https://discuss.elastic.co/t/data-nodes-ha-and-shards-allocation-creation/151150/8 "2018-10-24T11:48:08Z")

</div>

> [@mruthyu](#):
>
> whether the shards which have been allocated on other nodes will be deleted hence freeing up the disk space?

Pretty much, yes. I'm not sure if that is guaranteed to happen immediately, because the cluster may decide to rebalance by relocating some shards onto the newly-restored node first, and it can speed up these recoveries if it can make use of any data that's already there. Eventually it'll settle down and delete any unnecessary shard copies to free up their disk space.

If no such rebalancing takes place (e.g. it's disabled) and the cluster health is `GREEN` then any unnecessary shard copies will be removed, freeing up the disk space, pretty soon.

---

<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:** [November 21, 2018, 11:48am UTC](https://discuss.elastic.co/t/data-nodes-ha-and-shards-allocation-creation/151150/9 "2018-11-21T11:48:12Z")

</div>

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