# Explicitly allocating shards to nodes

**URL:** <https://discuss.elastic.co/t/explicitly-allocating-shards-to-nodes/11421>\
**Category:** Elasticsearch\
**Created:** [April 2, 2013, 10:47pm UTC](https://discuss.elastic.co/t/explicitly-allocating-shards-to-nodes/11421 "2013-04-02T22:47:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Garth](https://avatars.discourse-cdn.com/v4/letter/g/ba9def/32.png) [@Garth](https://discuss.elastic.co/u/Garth)\
**Post date:** [April 2, 2013, 10:47pm UTC](https://discuss.elastic.co/t/explicitly-allocating-shards-to-nodes/11421/1 "2013-04-02T22:47:14Z")

</div>

I am running ES 0.20.4. I want to physically tell the shards which node to  
allocate to.

Set the following in elasticsearch.yml:  
cluster.routing.allocation.disable\_new\_allocation: true  
cluster.routing.allocation.disable\_allocation: true

I create an index. The shards+replicas are not allocated. In \*  
reference/api/admin-cluster-reroute.html\* the following statement:

“The cluster can be set to disable allocations, which means that only the  
explicitly allocations will be performed. Obviously, only once all commands  
has been applied, the cluster will aim to be re-balance its state.”

Makes me think that the if I change “c.r.a.disable\_allocation: false”  
through “transient” in the following command:

curl -XPUT localhost:9200/\_cluster/settings -d  
'{"transient":{"cluster.routing.allocation.disable\_allocation":false}}'

that it should allow me to then allocate the shards with the command below:

curl -XPOST 'localhost:9200/\_cluster/reroute' -d '{  
"commands":[{"allocate": {"index":"x30","shard":0,"node":"node1" }}]  
}'

but instead I receive the following error:

{"error":"RemoteTransportException[[node2][inet[/172.16.195.220:9300]][cluster/reroute]];  
nested: ElasticSearchIllegalArgumentException[[allocate] trying to allocate  
a primary shard [x30][0]], which is disabled]; ","status":400}

What am I doing wrong?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [April 3, 2013, 9:48am UTC](https://discuss.elastic.co/t/explicitly-allocating-shards-to-nodes/11421/2 "2013-04-03T09:48:29Z")

</div>

Hi,

The `allow_primary` needs to be set to `true`, it defaults to `false`:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On 3 April 2013 00:47, Garth [ghershfield.bah@gmail.com](mailto:ghershfield.bah@gmail.com) wrote:

> I am running ES 0.20.4. I want to physically tell the shards which node to  
> allocate to.
> 
> Set the following in elasticsearch.yml:  
> cluster.routing.allocation.disable\_new\_allocation: true  
> cluster.routing.allocation.disable\_allocation: true
> 
> * * *
> 
> I create an index. The shards+replicas are not allocated. In \*  
> reference/api/admin-cluster-reroute.html\* the following statement:
> 
> * * *
> 
> “The cluster can be set to disable allocations, which means that only the  
> explicitly allocations will be performed. Obviously, only once all commands  
> has been applied, the cluster will aim to be re-balance its state.”\*\*\*\*
> 
> Makes me think that the if I change “c.r.a.disable\_allocation: false”  
> through “transient” in the following command:\*\*\*\*
> 
> curl -XPUT localhost:9200/\_cluster/settings -d  
> '{"transient":{"cluster.routing.allocation.disable\_allocation":false}}'
> 
> * * *
> 
> that it should allow me to then allocate the shards with the command below:
> 
> * * *
> 
> curl -XPOST 'localhost:9200/\_cluster/reroute' -d '{  
> "commands":[{"allocate": {"index":"x30","shard":0,"node":"node1" }}]  
> }'
> 
> * * *
> 
> but instead I receive the following error:
> 
> * * *
> 
> {"error":"RemoteTransportException[[node2][inet[/172.16.195.220:9300]][cluster/reroute]];  
> nested: ElasticSearchIllegalArgumentException[[allocate] trying to allocate  
> a primary shard [x30][0]], which is disabled]; ","status":400}
> 
> * * *
> 
> What am I doing wrong?
> 
> * * *
> 
> * * *
> 
> * * *
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Garth](https://avatars.discourse-cdn.com/v4/letter/g/ba9def/32.png) [@Garth](https://discuss.elastic.co/u/Garth)\
**Post date:** [April 3, 2013, 2:00pm UTC](https://discuss.elastic.co/t/explicitly-allocating-shards-to-nodes/11421/3 "2013-04-03T14:00:33Z")

</div>

Set the following in elasticsearch.yml on all nodes:  
cluster.routing.allocation.disable\_new\_allocation: true  
cluster.routing.allocation.disable\_allocation: true  
cluster.routing.allocation.allow\_primary: true

Restarted them and fired off:  
curl -XPOST 'localhost:9200/\_cluster/reroute' -d '{  
"commands":[{"allocate": {"index":"x30","shard":0,"node":"node1"}}]  
}'

Get the same error:  
{"error":"RemoteTransportException[[node3][inet[/172.16.195.222:9300]][cluster/reroute]];  
nested: ElasticSearchIllegalArgumentException[[allocate] trying to allocate  
a primary shard [x30][0]], which is disabled]; ","status":400}

On Wednesday, April 3, 2013 5:48:29 AM UTC-4, Martijn v Groningen wrote:

> Hi,
> 
> The `allow_primary` needs to be set to `true`, it defaults to `false`:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-cluster-reroute/)
> 
> On 3 April 2013 00:47, Garth \<[ghershf...@gmail.com](mailto:ghershf...@gmail.com) \<javascript:\>\> wrote:
> 
> > I am running ES 0.20.4. I want to physically tell the shards which node  
> > to allocate to.
> > 
> > Set the following in elasticsearch.yml:  
> > cluster.routing.allocation.disable\_new\_allocation: true  
> > cluster.routing.allocation.disable\_allocation: true
> > 
> > * * *
> > 
> > I create an index. The shards+replicas are not allocated. In \*  
> > reference/api/admin-cluster-reroute.html\* the following statement:
> > 
> > * * *
> > 
> > “The cluster can be set to disable allocations, which means that only the  
> > explicitly allocations will be performed. Obviously, only once all commands  
> > has been applied, the cluster will aim to be re-balance its state.”\*\*\*\*
> > 
> > Makes me think that the if I change “c.r.a.disable\_allocation: false”  
> > through “transient” in the following command:\*\*\*\*
> > 
> > curl -XPUT localhost:9200/\_cluster/settings -d  
> > '{"transient":{"cluster.routing.allocation.disable\_allocation":false}}'
> > 
> > * * *
> > 
> > that it should allow me to then allocate the shards with the command  
> > below:
> > 
> > * * *
> > 
> > curl -XPOST 'localhost:9200/\_cluster/reroute' -d '{  
> > "commands":[{"allocate": {"index":"x30","shard":0,"node":"node1" }}]  
> > }'
> > 
> > * * *
> > 
> > but instead I receive the following error:
> > 
> > * * *
> > 
> > {"error":"RemoteTransportException[[node2][inet[/172.16.195.220:9300]][cluster/reroute]];  
> > nested: ElasticSearchIllegalArgumentException[[allocate] trying to allocate  
> > a primary shard [x30][0]], which is disabled]; ","status":400}
> > 
> > * * *
> > 
> > What am I doing wrong?
> > 
> > * * *
> > 
> > * * *
> > 
> > * * *
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> Met vriendelijke groet,
> 
> Martijn van Groningen

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [April 3, 2013, 2:04pm UTC](https://discuss.elastic.co/t/explicitly-allocating-shards-to-nodes/11421/4 "2013-04-03T14:04:33Z")

</div>

I think you need to use it in the request it self like this:  
curl -XPOST 'localhost:9200/\_cluster/reroute' -d '{  
"commands":[{"allocate": {"index":"x30","shard":0,"node":"node1",  
"allow\_primary" : true}}]  
}'

On 3 April 2013 16:00, Garth [ghershfield.bah@gmail.com](mailto:ghershfield.bah@gmail.com) wrote:

> Set the following in elasticsearch.yml on all nodes:  
> cluster.routing.allocation.\*\*disable\_new\_allocation: true  
> cluster.routing.allocation.\*\*disable\_allocation: true  
> cluster.routing.allocation.allow\_primary: true
> 
> Restarted them and fired off:  
> curl -XPOST 'localhost:9200/\_cluster/reroute' -d '{  
> "commands":[{"allocate": {"index":"x30","shard":0,"node":"node1"}}]  
> }'
> 
> Get the same error:  
> {"error":"RemoteTransportException[[node3][inet[/172.16.195.222:9300]][cluster/reroute]];  
> nested: ElasticSearchIllegalArgumentException[[allocate] trying to allocate  
> a primary shard [x30][0]], which is disabled]; ","status":400}
> 
> On Wednesday, April 3, 2013 5:48:29 AM UTC-4, Martijn v Groningen wrote:
> 
> > Hi,
> > 
> > The `allow_primary` needs to be set to `true`, it defaults to `false`:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/**guide/reference/api/admin-)\*\*  
> > cluster-reroute/[http://www.elasticsearch.org/guide/reference/api/admin-cluster-reroute/](http://www.elasticsearch.org/guide/reference/api/admin-cluster-reroute/)
> > 
> > On 3 April 2013 00:47, Garth [ghershf...@gmail.com](mailto:ghershf...@gmail.com) wrote:
> > 
> > > I am running ES 0.20.4. I want to physically tell the shards which node  
> > > to allocate to.
> > > 
> > > Set the following in elasticsearch.yml:  
> > > cluster.routing.allocation.\*\*disable\_new\_allocation: true  
> > > cluster.routing.allocation.\*\*disable\_allocation: true
> > > 
> > > * * *
> > > 
> > > I create an index. The shards+replicas are not allocated. In \*  
> > > reference/api/admin-cluster-reroute.html\* the following statement:
> > > 
> > > * * *
> > > 
> > > “The cluster can be set to disable allocations, which means that only  
> > > the explicitly allocations will be performed. Obviously, only once all  
> > > commands has been applied, the cluster will aim to be re-balance its state.”
> > > 
> > > * * *
> > > 
> > > Makes me think that the if I change “c.r.a.disable\_allocation: false”  
> > > through “transient” in the following command:\*\*\*\*
> > > 
> > > curl -XPUT localhost:9200/_cluster/\*\*settings -d  
> > > '{"transient":{"cluster.\*\*routing.allocation.disable_\*\*  
> > > allocation":false}}'
> > > 
> > > * * *
> > > 
> > > that it should allow me to then allocate the shards with the command  
> > > below:
> > > 
> > > * * *
> > > 
> > > curl -XPOST 'localhost:9200/\_cluster/\*\*reroute' -d '{  
> > > "commands":[{"allocate": {"index":"x30","shard":0,"\*\*node":"node1" }}]  
> > > }'
> > > 
> > > * * *
> > > 
> > > but instead I receive the following error:
> > > 
> > > * * *
> > > 
> > > {"error":"\*\*RemoteTransportException[[\*\*node2][inet[/172.16.195.220:**9300]][cluster/reroute]];  
> > > nested: ElasticSearchIllegalArgumentEx**ception[[allocate] trying to  
> > > allocate a primary shard [x30][0]], which is disabled]; ","status":400}
> > > 
> > > * * *
> > > 
> > > What am I doing wrong?
> > > 
> > > * * *
> > > 
> > > * * *
> > > 
> > > * * *
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > Met vriendelijke groet,
> > 
> > Martijn van Groningen

--  
Met vriendelijke groet,

Martijn van Groningen

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:43am UTC](https://discuss.elastic.co/t/explicitly-allocating-shards-to-nodes/11421/5 "2017-07-06T02:43:03Z")

</div>


