Restart elasticsearch node

108,743

Solution 1

The correct way to restart a node is to shut it down, using either the shutdown API or sending a TERM signal to the process (eg with kill $PID).

Once shut down, you can start a new node using whatever you use to run elasticsearch, eg the service wrapper, or just starting it from the command line.

If you are using the service wrapper, you can restart a node by passing it the restart command: eg /etc/init.d/elasticsearch restart but that is just a convenience wrapper for the above.

The restart API has been disabled since version 0.11 as it was problematic.

Solution 2

Every time a node goes down and/or and new node comes up, the cluster redistributes the shards, which may not be desired when you just need to restart a node, therefore you can make use of Rolling restart:

  1. first disable shard allocation:

    PUT /_cluster/settings { "transient" : { "cluster.routing.allocation.enable" : "none" } }

  2. restart the node service elasticsearch restart

  3. Enable shard allocation:

    PUT /_cluster/settings { "transient" : { "cluster.routing.allocation.enable" : "all" } }

More on this: Here

Solution 3

There is a restart API analogous to the shutdown API. Just replace "shutdown" with "restart". See also the issue on github.

Solution 4

For restarting elasticserch service, first check the status and then restart that would give a clear picture

sudo service elasticsearch.service status -l    
sudo service elasticsearch.service restart
Share:
108,743
Admin
Author by

Admin

Updated on July 08, 2022

Comments

  • Admin
    Admin almost 2 years

    What is the proper way to restart node in elasticsearch? (preferably via the REST API, java API might be ok too)

  • Admin
    Admin over 11 years
    I just read your answer and I thought - too bad it is not documented anywhere.. then I opened the link and I saw you just wrote it there :) Thanks!
  • dadoonet
    dadoonet over 11 years
    @tzofia Did you succeed with the _restart API? Do you run your ES instance from the service layer? I'm asking that because under windows, I got the following error: ElasticSearchIllegalStateException[restart is disabled (for now) ....]
  • Admin
    Admin over 11 years
    @dadoonet Actually I saw it was written by Shay Banon so I relied on it and didn't check it yet. I checked it just now and I get the same error as you (on ubuntu) .... Any suggestions??
  • dadoonet
    dadoonet over 11 years
    I added a comment on the issue about that: github.com/elasticsearch/elasticsearch/issues/… Wait & see Shay's answer. ;-)
  • Larry Silverman
    Larry Silverman over 9 years
    Restarting using the usual linux service restart tool results in a shard re-allocation process (which I watch using the elasticsearch-head plugin). In my environment, I see all the shards assigned to the restarted node go into the UNASSIGNED state and gradually get re-assigned. Is there a cleaner way to restart the service such that the hit of the full shard reallocation process can be lessened?
  • Brian Olsen
    Brian Olsen almost 5 years
    Note: shutdown API has been removed as of elasticsearch version 2.0. elastic.co/guide/en/elasticsearch/reference/2.0/…
  • Wenzhong
    Wenzhong almost 5 years
    shutdown API is deprecated in latest release 7.3.0 (or earlier version).
  • direvus
    direvus over 4 years
    This advice doesn't seem to be working for me in ES 6.8. When I restart the node, the cluster still goes into "yellow" status and then after I restore the settings I have to wait 20 minutes while ES farts about reallocating shards.
  • kaskelotti
    kaskelotti over 4 years
    This answer would improve a lot if you'd add a little context related to the commands you've provided.
  • Yagnesh bhalala
    Yagnesh bhalala over 4 years
    Very very nice answer. it's really helped me.
  • Sinux
    Sinux almost 4 years
    @direvus That is normal performance, since you stop allocation, data on different nodes are unbalancing, some shards might be unassigned. If you want to reduce relocate duration, try increase recovery speed or increase allocation concurrency:indices.recovery.max_bytes_per_sec and cluster.routing.allocation.node_concurrent_recoveries.