# How to prevent both primary and replica shards to be in the same rack/hypervisor?

**URL:** <https://discuss.elastic.co/t/how-to-prevent-both-primary-and-replica-shards-to-be-in-the-same-rack-hypervisor/186366>\
**Category:** Elasticsearch\
**Created:** [June 19, 2019, 3:26am UTC](https://discuss.elastic.co/t/how-to-prevent-both-primary-and-replica-shards-to-be-in-the-same-rack-hypervisor/186366 "2019-06-19T03:26:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TsuWeiQuan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsuweiquan/32/46252_2.png) [@TsuWeiQuan](https://discuss.elastic.co/u/TsuWeiQuan)\
**Post date:** [June 19, 2019, 3:26am UTC](https://discuss.elastic.co/t/how-to-prevent-both-primary-and-replica-shards-to-be-in-the-same-rack-hypervisor/186366/1 "2019-06-19T03:26:50Z")

</div>

Hello,

I was wondering if given a case where i set  
Primary Shard : 1  
Replica Shard : 1

with this setup

![image](https://us1.discourse-cdn.com/elastic/original/3X/f/d/fde69f12dcc3032ab617f7847e21eddc0d89fe5b.png)

What if my primary shad is in node 4 while my replica shad is in node 5 and when rack 1 goes down, I would result in data loss.

How can I ensure that the primary shard and replica shard would not be in the same rack?

---

<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:** [June 19, 2019, 3:28am UTC](https://discuss.elastic.co/t/how-to-prevent-both-primary-and-replica-shards-to-be-in-the-same-rack-hypervisor/186366/2 "2019-06-19T03:28:23Z")

</div>

Check out [https://www.elastic.co/guide/en/elasticsearch/reference/7.1/allocation-awareness.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.1/allocation-awareness.html)

---

<div class="post-metadata">

**Author:** ![TsuWeiQuan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsuweiquan/32/46252_2.png) [@TsuWeiQuan](https://discuss.elastic.co/u/TsuWeiQuan)\
**Post date:** [June 19, 2019, 3:31am UTC](https://discuss.elastic.co/t/how-to-prevent-both-primary-and-replica-shards-to-be-in-the-same-rack-hypervisor/186366/3 "2019-06-19T03:31:05Z")

</div>

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:** [July 17, 2019, 3:31am UTC](https://discuss.elastic.co/t/how-to-prevent-both-primary-and-replica-shards-to-be-in-the-same-rack-hypervisor/186366/4 "2019-07-17T03:31:10Z")

</div>

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