# Quick recovery after node restart in elasticsearch

**URL:** <https://discuss.elastic.co/t/quick-recovery-after-node-restart-in-elasticsearch/11701>\
**Category:** Elasticsearch\
**Created:** [April 26, 2013, 8:10am UTC](https://discuss.elastic.co/t/quick-recovery-after-node-restart-in-elasticsearch/11701 "2013-04-26T08:10:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ovamsikrishna](https://avatars.discourse-cdn.com/v4/letter/o/e8c25b/32.png) [@ovamsikrishna](https://discuss.elastic.co/u/ovamsikrishna)\
**Post date:** [April 26, 2013, 8:10am UTC](https://discuss.elastic.co/t/quick-recovery-after-node-restart-in-elasticsearch/11701/1 "2013-04-26T08:10:44Z")

</div>

Consider the below settings in the elasticsearch.yml

gateway.recover\_after\_data\_nodes: 3  
gateway.recover\_after\_time: 5m  
gateway.expected\_data\_nodes: 3

Current setting: Say, I have 3 data nodes. Now if I decide to restart a data node(due to a small change in setting), the recovery will start immediately after node restart as per the expected\_data\_nodes setting. There will be many unassigned shards, which will get allocated slowly depending on the data it contains.

In order to avoid that, is there any way to allocate all the unassigned shards to a specific node?(in my case the restarted node) and once that is done, ES should take over the rebalancing.

Mainly I want to avoid the heavy timelag of the cluster state from yellow to green.(it is in the range of hours in my case)

Can I use the cluster reroute api for this purpose?

or is there any other api to transfer all the unassigned shards to specific node at one go?

---

<div class="post-metadata">

**Author:** ![Damien\_Hardy](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@Damien\_Hardy](https://discuss.elastic.co/u/Damien_Hardy)\
**Post date:** [April 26, 2013, 8:25am UTC](https://discuss.elastic.co/t/quick-recovery-after-node-restart-in-elasticsearch/11701/2 "2013-04-26T08:25:31Z")

</div>

My procedure to restart a node without shards reallocation is :

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

Shard keep analocated until  
"cluster.routing.allocation.disable\_allocation": false, then shards recover  
on the server just restarted (starting at size they were before shutdown)  
It is very quick.

Cheers,

--  
Damien

2013/4/26 ovamsikrishna [ovamsikrishna@gmail.com](mailto:ovamsikrishna@gmail.com)

> Consider the below settings in the elasticsearch.yml
> 
> gateway.recover\_after\_data\_nodes: 3  
> gateway.recover\_after\_time: 5m  
> gateway.expected\_data\_nodes: 3
> 
> Current setting: Say, I have 3 data nodes. Now if I decide to restart a  
> data  
> node(due to a small change in setting), the recovery will start immediately  
> after node restart as per the expected\_data\_nodes setting. There will be  
> many unassigned shards, which will get allocated slowly depending on the  
> data it contains.
> 
> In order to avoid that, is there any way to allocate all the unassigned  
> shards to a specific node?(in my case the restarted node) and once that is  
> done, ES should take over the rebalancing.
> 
> Mainly I want to avoid the heavy timelag of the cluster state from yellow  
> to  
> green.(it is in the range of hours in my case)
> 
> Can I use the cluster reroute api for this purpose?
> 
> or is there any other api to transfer all the unassigned shards to specific  
> node at one go?
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/quick-recovery-after-node-restart-in-elasticsearch-tp4033876.html](http://elasticsearch-users.115913.n3.nabble.com/quick-recovery-after-node-restart-in-elasticsearch-tp4033876.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> 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).

--  
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:** ![Pradeep\_Sanders](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pradeep_sanders/32/2326_2.png) [@Pradeep\_Sanders](https://discuss.elastic.co/u/Pradeep_Sanders)\
**Post date:** [April 27, 2013, 3:45am UTC](https://discuss.elastic.co/t/quick-recovery-after-node-restart-in-elasticsearch/11701/3 "2013-04-27T03:45:56Z")

</div>

Another option is to prepare the node ahead of time by excluding it using  
the shard placement API. The cluster will immediately begin moving shards  
off the node until it has none left, allowing you to restart it as many  
times as you want until it is ready for use again. Depending on why you  
need to restart it, that may be more useful to you as it prevents your  
cluster from every going into a degraded state at all.

-Pradeep

On Friday, April 26, 2013 1:25:31 AM UTC-7, Damien Hardy wrote:

> My procedure to restart a node without shards reallocation is :
> 
> curl -XPUT localhost:9200/\_cluster/settings -d  
> '{"transient":{"cluster.routing.allocation.disable\_allocation": true}}'  
> /etc/init.d/elasticsearch restart  
> curl -XPUT localhost:9200/\_cluster/settings -d  
> '{"transient":{"cluster.routing.allocation.disable\_allocation": false}}'
> 
> Shard keep analocated until  
> "cluster.routing.allocation.disable\_allocation": false, then shards recover  
> on the server just restarted (starting at size they were before shutdown)  
> It is very quick.
> 
> Cheers,
> 
> --  
> Damien
> 
> 2013/4/26 ovamsikrishna \<[ovamsi...@gmail.com](mailto:ovamsi...@gmail.com) \<javascript:\>\>
> 
> > Consider the below settings in the elasticsearch.yml
> > 
> > gateway.recover\_after\_data\_nodes: 3  
> > gateway.recover\_after\_time: 5m  
> > gateway.expected\_data\_nodes: 3
> > 
> > Current setting: Say, I have 3 data nodes. Now if I decide to restart a  
> > data  
> > node(due to a small change in setting), the recovery will start  
> > immediately  
> > after node restart as per the expected\_data\_nodes setting. There will be  
> > many unassigned shards, which will get allocated slowly depending on the  
> > data it contains.
> > 
> > In order to avoid that, is there any way to allocate all the unassigned  
> > shards to a specific node?(in my case the restarted node) and once that is  
> > done, ES should take over the rebalancing.
> > 
> > Mainly I want to avoid the heavy timelag of the cluster state from yellow  
> > to  
> > green.(it is in the range of hours in my case)
> > 
> > Can I use the cluster reroute api for this purpose?
> > 
> > or is there any other api to transfer all the unassigned shards to  
> > specific  
> > node at one go?
> > 
> > --  
> > View this message in context:  
> > [http://elasticsearch-users.115913.n3.nabble.com/quick-recovery-after-node-restart-in-elasticsearch-tp4033876.html](http://elasticsearch-users.115913.n3.nabble.com/quick-recovery-after-node-restart-in-elasticsearch-tp4033876.html)  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> > 
> > --  
> > 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).

--  
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:** ![ovamsikrishna](https://avatars.discourse-cdn.com/v4/letter/o/e8c25b/32.png) [@ovamsikrishna](https://discuss.elastic.co/u/ovamsikrishna)\
**Post date:** [May 3, 2013, 9:53am UTC](https://discuss.elastic.co/t/quick-recovery-after-node-restart-in-elasticsearch/11701/4 "2013-05-03T09:53:32Z")

</div>

Thanks a lot for all the replies. Will try the above allocation curl command next time before node restart...

Before that I need a small clarification. This command seems to be affecting entire cluster. But, in my case I want that to be done for a single node. Is that possible?

From the command it seems, the there will not be any further allocation in the entire cluster till we set it to false. I don't want like that. The allocation should be stopped only for that node. After restart everything should go into normal state in a faster pace.

Is it possible to specify the node in the above command?

---

<div class="post-metadata">

**Author:** ![Adrian\_2](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Adrian\_2](https://discuss.elastic.co/u/Adrian_2)\
**Post date:** [August 28, 2013, 2:55pm UTC](https://discuss.elastic.co/t/quick-recovery-after-node-restart-in-elasticsearch/11701/5 "2013-08-28T14:55:04Z")

</div>

On Fri, Apr 26, 2013 at 10:25:31AM +0200, Damien Hardy wrote:

Damien,

> My procedure to restart a node without shards reallocation is :
> 
> curl -XPUT localhost:9200/\_cluster/settings -d  
> '{"transient":{"cluster.routing.allocation.disable\_allocation": true}}'  
> /etc/init.d/elasticsearch restart  
> curl -XPUT localhost:9200/\_cluster/settings -d  
> '{"transient":{"cluster.routing.allocation.disable\_allocation": false}}'
> 
> Shard keep analocated until  
> "cluster.routing.allocation.disable\_allocation": false, then shards recover  
> on the server just restarted (starting at size they were before shutdown)  
> It is very quick.

I am quite new to elasticsearch, so this may be kind of newbeish. Does this  
also mean, if a primary shard would reside on that node, replica promotion will  
not happen?

Best regards, Adrian

--  
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:19am UTC](https://discuss.elastic.co/t/quick-recovery-after-node-restart-in-elasticsearch/11701/6 "2017-07-06T02:19:15Z")

</div>


