# Where should "cluster.routing.allocation.same\_shard.host" be set?

**URL:** <https://discuss.elastic.co/t/where-should-cluster-routing-allocation-same-shard-host-be-set/38346>\
**Category:** Elasticsearch\
**Created:** [January 4, 2016, 8:40pm UTC](https://discuss.elastic.co/t/where-should-cluster-routing-allocation-same-shard-host-be-set/38346 "2016-01-04T20:40:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Fraschetti](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@Chris\_Fraschetti](https://discuss.elastic.co/u/Chris_Fraschetti)\
**Post date:** [January 4, 2016, 8:40pm UTC](https://discuss.elastic.co/t/where-should-cluster-routing-allocation-same-shard-host-be-set/38346/1 "2016-01-04T20:40:25Z")

</div>

Hi Folks.

Can anyone confirm that when I have dedicated masters, "cluster.routing.allocation.same\_shard.host" is only relevant on the master nodes?

Also, can I assume _all_ cluster.routing.\* settings only apply to the node(s) serving as the master?

---

<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:** [January 4, 2016, 10:19pm UTC](https://discuss.elastic.co/t/where-should-cluster-routing-allocation-same-shard-host-be-set/38346/2 "2016-01-04T22:19:54Z")

</div>

Allocation applies to any node that holds data.

---

<div class="post-metadata">

**Author:** ![Chris\_Fraschetti](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@Chris\_Fraschetti](https://discuss.elastic.co/u/Chris_Fraschetti)\
**Post date:** [January 4, 2016, 11:18pm UTC](https://discuss.elastic.co/t/where-should-cluster-routing-allocation-same-shard-host-be-set/38346/3 "2016-01-04T23:18:51Z")

</div>

That makes sense but which node roles (master vs. data) is this setting actually relevant?

Assuming you had:  
-10 data nodes (not eligible for the master role)  
-3 master nodes (not eligible for the data role)

Would same\_shard.host be required on the data nodes? master nodes? both?

I've yet to find the time to dig into the ES source to understand shard allocations in detail.

1. Do the masters read the state of the cluster and make all shard allocation decisions internally?  
-In this scenario, same\_shard.host seems like it would be only relevant on the master where the decisions are being made  
or
2. Do the masters ask the individual data nodes to make the allocation decisions?  
-In this scenario, the same\_shard.host could be relevant on the data nodes or master nodes (depending on implementation)

My assumption would be #1 - but I didn't build ES so I need to ask.

Doing a quick google search for this setting suggests the ES file below is where this setting is consumed. Perhaps a more direct question would be - Does the master or data role use this class/code?

/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java

---

<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:** [January 5, 2016, 12:24am UTC](https://discuss.elastic.co/t/where-should-cluster-routing-allocation-same-shard-host-be-set/38346/4 "2016-01-05T00:24:52Z")

</div>

1. The elected master does, yes (the others are there for redundancy and don't play a part in allocation).
2. No, the master node makes those decisions.

`cluster.routing.allocation.same_shard.host` really only applies if you have multiple ES instances (nodes) running on the same underlying physical/virtual host. See [here](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/shards-allocation.html).

---

<div class="post-metadata">

**Author:** ![Chris\_Fraschetti](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@Chris\_Fraschetti](https://discuss.elastic.co/u/Chris_Fraschetti)\
**Post date:** [January 5, 2016, 3:43am UTC](https://discuss.elastic.co/t/where-should-cluster-routing-allocation-same-shard-host-be-set/38346/5 "2016-01-05T03:43:30Z")

</div>

Thanks, Mark.

As I expected, that setting is relevant to the master nodes and that explains my issue.  
I'm transitioning my cluster to new hardware where I'm running multiple ES instances per machine. The nodes themselves have same\_shard.host set but not the existing cluster master(s). We noticed the shard allocation was not respecting this flag which makes sense if it's a setting relevant to the master.

For background, I'm in 1.7.1 and for a few reasons not worth going into, my masters aren't in a position to be restarted (with the same\_shard.host setting) just yet. For now I'll use the shard allocation awareness settings to try to pull this off. I have significantly more physical machines than shards per index so this shouldn't be an issue.

Thanks again.

---

<div class="post-metadata">

**Author:** ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)\
**Post date:** [May 24, 2016, 7:56pm UTC](https://discuss.elastic.co/t/where-should-cluster-routing-allocation-same-shard-host-be-set/38346/6 "2016-05-24T19:56:48Z")

</div>

I have the same question and it looks like I haven't found a final answer.

So if I run multiple data nodes on a single server, which elasticsearch.yml should I put `cluster.routing.allocation.same_shard.host` in?

1. Only data nodes
2. Only eligible master nodes (dedicated)?
3. Both data nodes and eligible master nodes?

Even though I'm using Shard Allocation Awareness now, knowing the answer to this setting is helpful in the future.

---

<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 24, 2016, 8:00pm UTC](https://discuss.elastic.co/t/where-should-cluster-routing-allocation-same-shard-host-be-set/38346/7 "2016-05-24T20:00:44Z")

</div>

> [@anhlqn](#):
>
> So if I run multiple data nodes on a single server, which elasticsearch.yml should I put cluster.routing.allocation.same\_shard.host in?

All of them.

---

<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, 10:49pm UTC](https://discuss.elastic.co/t/where-should-cluster-routing-allocation-same-shard-host-be-set/38346/8 "2017-07-05T22:49:22Z")

</div>


