Elasticsearch Removing a Node from an Elasticsearch Cluster

By Opster Team

Updated: Mar 17, 2025

| 2 min read

Introduction 

When managing an Elasticsearch cluster, there may be situations where you need to remove a node from the cluster. This could be due to hardware issues, maintenance, or scaling down the cluster. In this article, we will discuss the steps to safely remove a node from an Elasticsearch cluster without causing any data loss or impacting the cluster’s performance. If you want to learn about the concept of Elasticsearch nodes and the types of roles, check out this guide.

Steps to safely remove a node from an Elasticsearch cluster

Step 1: Stop indexing and perform a synced flush (optional)

If you can afford to stop indexing for a short period, it is recommended to perform a synced flush. This operation helps to speed up the recovery process when the cluster restarts after the node removal. To perform a synced flush, execute the following command:

POST _flush/synced

Note that this step is optional and can be skipped if stopping indexing is not feasible.

Step 2: Retrieve the node name

To remove a node from the cluster, you need to know its node name. You can retrieve the node name by executing the following command:

GET _cat/nodes?v

This command will return a list of nodes in the cluster along with their node names. Identify the node you want to remove and note down its node name.

Step 3: Remove the node from the cluster

To remove the node from the cluster, you need to update the cluster settings to exclude the node using its node name. Execute the following command, replacing `<node_name>` with the node name you retrieved in the previous step:

PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.exclude._name": "<node_name>"
  }
}

This command will instruct Elasticsearch to move all shards from the specified node to other nodes in the cluster. You can monitor the progress of shard relocation by executing the following command:

GET _cat/recovery?v&active_only=true

Wait for the shard relocation process to complete before proceeding to the next step.

Step 4: Stop the Elasticsearch process on the node

After enabling shard allocation, you can safely stop the Elasticsearch process on the node you want to remove. Depending on your installation method and operating system, the command to stop Elasticsearch may vary. For example, if you are using systemd on a Linux system, you can execute the following command:

sudo systemctl stop elasticsearch

Step 5: Verify the cluster health

Finally, verify the health of the cluster by executing the following command:

GET _cluster/health

Ensure that the cluster status is “green” and the number of nodes in the cluster has been reduced by one.

Conclusion

In conclusion, removing a node from an Elasticsearch cluster involves disabling shard allocation, optionally performing a synced flush, excluding the node from the cluster, and stopping the Elasticsearch process on the node. By following these steps, you can safely remove a node without impacting the cluster’s performance or causing data loss.


Opster
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.