# Any way to force only primary shards on 1 site/zone?

**URL:** <https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098>\
**Category:** Elasticsearch\
**Created:** [May 9, 2018, 4:19am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098 "2018-05-09T04:19:30Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edmund\_Cheng](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Edmund\_Cheng](https://discuss.elastic.co/u/Edmund_Cheng)\
**Post date:** [May 9, 2018, 4:19am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/1 "2018-05-09T04:19:30Z")

</div>

Hi,  
Lets say we have 2 logical sites in a ES cluster. Can we allocate only primary shards on 1 site and only replicas on another ? With the combination of shard awareness I mean..

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:** [May 9, 2018, 4:36am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/2 "2018-05-09T04:36:39Z")

</div>

No, you can only ensure that you have a copy of each in each site.

---

<div class="post-metadata">

**Author:** ![Edmund\_Cheng](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Edmund\_Cheng](https://discuss.elastic.co/u/Edmund_Cheng)\
**Post date:** [May 9, 2018, 5:00am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/3 "2018-05-09T05:00:28Z")

</div>

Hi,  
Thanks for the response.

So you are saying we cannot force them each on 1 site and vice versa?  
Even these params wont give what I need?

e.g  
cluster.routing.allocation.enable  
[https://www.elastic.co/guide/en/elasticsearch/reference/2.4/shards-allocation.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/shards-allocation.html)

---

<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:** [May 9, 2018, 5:01am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/4 "2018-05-09T05:01:16Z")

</div>

You will have a copy of shard 1 on site a and on site b, but unless you manually allocate every shard, it will distribute the primary and replica between both.

---

<div class="post-metadata">

**Author:** ![Edmund\_Cheng](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Edmund\_Cheng](https://discuss.elastic.co/u/Edmund_Cheng)\
**Post date:** [May 9, 2018, 5:03am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/5 "2018-05-09T05:03:41Z")

</div>

Hi, yes i understand that we can have a copy of shard 1 each on different site, but we have no way of knowing when 1 site will hold either the pri or replica.

For the manual allocation part, can you enlighten me for a bit?

---

<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:** [May 9, 2018, 5:05am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/6 "2018-05-09T05:05:17Z")

</div>

Why do you want to do this?

---

<div class="post-metadata">

**Author:** ![Edmund\_Cheng](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Edmund\_Cheng](https://discuss.elastic.co/u/Edmund_Cheng)\
**Post date:** [May 9, 2018, 5:14am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/7 "2018-05-09T05:14:56Z")

</div>

Hi,  
We have some application running on a set of machines say in rack 1.  
And we wanted these machines to do our puts/indexing(locally) on the same site 1 instead of going to rack 2.  
The ES nodes are rack 2 would be only doing get/search requests.

Is this reasonable?

---

<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 9, 2018, 5:48am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/8 "2018-05-09T05:48:52Z")

</div>

Primaries and replicas mostly do the same work while indexing, so indexing load is likely to be evenly distributed no matter which side the primary is on. One exception is scripted updates, where a bit more work is done on the primary.

---

<div class="post-metadata">

**Author:** ![Edmund\_Cheng](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Edmund\_Cheng](https://discuss.elastic.co/u/Edmund_Cheng)\
**Post date:** [May 9, 2018, 6:05am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/9 "2018-05-09T06:05:08Z")

</div>

Hi,  
I thought replicas dont do indexing? they serve only get requests no?

---

<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 9, 2018, 6:09am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/10 "2018-05-09T06:09:52Z")

</div>

All data has to be indexed into primaries and replicas so all shards do indexing.

---

<div class="post-metadata">

**Author:** ![Edmund\_Cheng](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Edmund\_Cheng](https://discuss.elastic.co/u/Edmund_Cheng)\
**Post date:** [May 10, 2018, 2:34am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/11 "2018-05-10T02:34:47Z")

</div>

Hi,  
Thanks for the clarification.  
So just wanted to understand, by manual method, is this talking about cluster\_reroute?

---

<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 10, 2018, 6:24am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/12 "2018-05-10T06:24:08Z")

</div>

Yes, but Elasticsearch will promote replica shards to primary when necessary, so you can not really control this.

---

<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:** [June 7, 2018, 6:24am UTC](https://discuss.elastic.co/t/any-way-to-force-only-primary-shards-on-1-site-zone/131098/13 "2018-06-07T06:24:09Z")

</div>

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