Removing a Node from a Cluster
To safely remove a node from a cluster, perform the following steps:
-
Before you remove a node, ensure that each index has at least one replica. You can use the OpenSearch Interact page to verify the replica count by choosing _cat/indices?v option in the Cluster API drop-down list.
-
Identify the IP address of the OpenSearch node that needs to be removed from the cluster.
Open a command prompt window and execute the following command where X.X.X.X stands for the IP address of the node that needs to be removed and also replace the host:port with the IP or port of any of the nodes in the cluster.
curl -XPUT “http://<username:password@host:port>/_cluster/settings” -d '{ "transient" :{ "cluster.routing.allocation.exclude._ip" : "X.X.X.X" } }' -
When the command is executed, OpenSearch tries to move the existing shards out of the node that will be removed and moves it to other nodes in the cluster.
-
In a command prompt window, execute the following command to ensure that the relocation is complete and to validate that the
relocating_shardsattribute shows value as 0 (zero). Alternatively, you may use the _cluster/health option from the Cluster API drop-down list on the OpenSearch Interact page.curl -XGET http://<username:password@host:port>/_cluster/health?prettyFor example, $>curl -XGET http://esadmin:esadmin@example.com:9200/_cluster/health?pretty.
{ "cluster_name" : "OS_CLUSTER1", "status" : "green", "timed_out" : false, "number_of_nodes" : 3, "number_of_data_nodes" : 3, "active_primary_shards" : 630, "active_shards" : 635, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0 } -
Shutdown the node that was identified for removal.
-
Set the exclusion rules to empty so that, in the future, the removed node can be added back to the cluster and can be used to hold the shards.
curl -XPUT “http://username:password@host:port/_cluster/settings” -d '{ "transient" :{ "cluster.routing.allocation.exclude._ip" : "" } }' -
On the Search Instance Properties page, delete the row corresponding to the removed node.