To remove an Elasticsearch node from the cluster. Just run the following command:
curl -XPUT P.P.P.P:9200/_cluster/settings -H 'Content-Type: application/json' -d '{
"transient" :{
"cluster.routing.allocation.exclude._ip" : "X.X.X.X"
}
}';echo
Here P.P.P.P
is the private IP address of the master node. You may also use the localhost
if Elasticsearch is running on localhost
. X.X.X.X
is the private IP address of the node to be removed from the cluster.
This command will give acknowledgement
true
if the node is accepted to be removed and the data relocation will start. Check if the data relocation is over and the node doesn't have any shards left on it. Then stop the elasticsearch
process and stop/terminate
the instance.
The commands to check data relocation and shards left can be found in this article.