# Shard allocation - primaries allocated on same data nodes

**URL:** <https://discuss.elastic.co/t/shard-allocation-primaries-allocated-on-same-data-nodes/238338>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [June 23, 2020, 8:42pm UTC](https://discuss.elastic.co/t/shard-allocation-primaries-allocated-on-same-data-nodes/238338 "2020-06-23T20:42:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrezenun](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@andrezenun](https://discuss.elastic.co/u/andrezenun)\
**Post date:** [June 23, 2020, 8:42pm UTC](https://discuss.elastic.co/t/shard-allocation-primaries-allocated-on-same-data-nodes/238338/1 "2020-06-23T20:42:21Z")

</div>

Hello everyone!

I have a cluster, that I'm on the process of setup everything to go to production. I have six data nodes and 3 masters. I don't know why but for some reason that I cannot identify the shards are allocated not every shard in every available data node. Look at this example:

```auto
id shard sc dc sto n pr ur
F1uGxNwOQEyTps-rFVoxyQ 4 12 217034 24.6mb es05 p  
QL8h_hvuRU21XPKjl9Qc3g 3 4 216525 23.9mb es06 p  
F1uGxNwOQEyTps-rFVoxyQ 2 12 216258 26.8mb es05 p  
QL8h_hvuRU21XPKjl9Qc3g 1 6 216319 24mb es06 p  
QL8h_hvuRU21XPKjl9Qc3g 5 12 217263 23.9mb es06 p  
F1uGxNwOQEyTps-rFVoxyQ 0 7 216258 23.8mb es05 p 

```

I set up this attribute (cluster.routing.allocation.same\_shard.host) trying to force elastic, when creating new index (and its shards) allocate every primary shard on a "dedicated" data node. But this is not happening and every replica on a different data node also. My index template is using 6 primaries and 1 replica.

```auto
PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.same_shard.host": "true"
  }
}

```

I was wondering that elastic would do this "balance" by default since we don't want to have same shard allocated on the same data node. Is there any specific configuration I have to do to elastic do this? Do I need to use shard allocation awareness?

I'm using elastic 7.7.1.

Thanks!!

---

<div class="post-metadata">

**Author:** ![andrezenun](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@andrezenun](https://discuss.elastic.co/u/andrezenun)\
**Post date:** [June 23, 2020, 8:56pm UTC](https://discuss.elastic.co/t/shard-allocation-primaries-allocated-on-same-data-nodes/238338/2 "2020-06-23T20:56:31Z")

</div>

Look at this image. I have the nodes but the majority of the processing is happening on two nodes.

 ![Captura de Tela 2020-06-23 às 17.51.06](https://us1.discourse-cdn.com/elastic/original/3X/5/5/55d1d582971581343eb59c9fceb8f4f1efe321d8.png)

This is a recently created shard. almost all primary shards are allocated on two nodes.

```auto
id shard sc dc sto n pr ur
C7mw9mtwT9OmZ787IOKLOw 1 7 436970 47.9mb es01 r  
LpEzk671SuqdDFE_JYmdCA 3 5 438570 47.5mb es02 r  
YpNbjM6NTem0OS1aLy7nLA 0 5 437816 46.3mb es03 r  
3qKMd8-VTGqX8ZNLRbD6vw 2 11 437355 46.2mb es04 r  
F1uGxNwOQEyTps-rFVoxyQ 4 8 438884 47.1mb es05 p  
F1uGxNwOQEyTps-rFVoxyQ 2 13 437355 46.3mb es05 p  
F1uGxNwOQEyTps-rFVoxyQ 5 es05 r INDEX_CREATED
F1uGxNwOQEyTps-rFVoxyQ 0 6 437863 46.2mb es05 p  
QL8h_hvuRU21XPKjl9Qc3g 4 es06 r INDEX_CREATED
QL8h_hvuRU21XPKjl9Qc3g 3 11 438709 47.4mb es06 p  
QL8h_hvuRU21XPKjl9Qc3g 1 11 437299 47.7mb es06 p  
QL8h_hvuRU21XPKjl9Qc3g 5 10 439489 52.9mb es06 p 

```

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:** [June 23, 2020, 10:15pm UTC](https://discuss.elastic.co/t/shard-allocation-primaries-allocated-on-same-data-nodes/238338/3 "2020-06-23T22:15:57Z")

</div>

> [@andrezenun](#):
>
> allocate every primary shard on a "dedicated" data node

Why do you want this? It's not something we recommend forcing.

---

<div class="post-metadata">

**Author:** ![andrezenun](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@andrezenun](https://discuss.elastic.co/u/andrezenun)\
**Post date:** [June 24, 2020, 3:34am UTC](https://discuss.elastic.co/t/shard-allocation-primaries-allocated-on-same-data-nodes/238338/4 "2020-06-24T03:34:09Z")

</div>

> [@warkolm](#):
>
> Why do you want this? It's not something we recommend forcing.

Hi warkolm, thanks for your reply. This is exactly what I dont want. I dont want to have two (or more) primaries of the same index on the same host. And this is what is happening. Any ideas on why this is happening? Thanks

---

<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:** [June 24, 2020, 3:42am UTC](https://discuss.elastic.co/t/shard-allocation-primaries-allocated-on-same-data-nodes/238338/5 "2020-06-24T03:42:23Z")

</div>

The cluster can promote replica shards to become primary shards if nodes are lost or unavailable so this is something you can not completely control. If a node becomes unavailable or is restarted shards on other nodes will be promoted to primary shards. When the node rejoins the cluster it will get replica shards assigned but will likely hold no primary shards.

---

<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 22, 2020, 3:42am UTC](https://discuss.elastic.co/t/shard-allocation-primaries-allocated-on-same-data-nodes/238338/6 "2020-07-22T03:42:24Z")

</div>

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