Restart elasticsearch node

JavaScalaElasticsearch

Java Problem Overview


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

Java Solutions


Solution 1 - Java

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 - Java

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 - Java

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

Solution 4 - Java

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1768906View Question on Stackoverflow
Solution 1 - JavaDrTechView Answer on Stackoverflow
Solution 2 - JavaTiago LopoView Answer on Stackoverflow
Solution 3 - JavaKim StebelView Answer on Stackoverflow
Solution 4 - JavaAshish DadhichView Answer on Stackoverflow