Skip to main content

Excluding a node with master role

Please note!

A node with the master role can only be excluded if the total number of such nodes is even. In other words, the cluster must consist of an odd number of nodes with the master role to avoid potential conflicts between nodes.

To exclude a node from the cluster, follow the steps outlined in the sections below.

Determining the node Name

To obtain the name of the node that is planned for exclusion, execute the following command:

GET _cat/nodes?v&full_id&h=name,id,ip

Disabling the node from voting

You cannot simply disable the master role; first, you need to exclude the node being removed from the voting process. Using the node name, execute the following command:

POST _cluster/voting_config_exclusions?node_names=<node_name>

where <node_name> - node name you want to exclude.

The command does not produce an output. After entering the command, wait for 30 seconds because the node is not excluded instantly. Ensure that another node has become the master—after executing the command below, the output will display information about the master node:

GET _cat/cluster_manager

Changing OpenSearch configurations

Before shutting down the master node, it is necessary to change the OpenSearch configuration on each node. However, before doing this, you need to disable cluster allocation to avoid damaging or losing data. To do this, execute the following command:

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

Please note!

The following steps must be performed on all nodes of the cluster.

  • You need to edit the discovery.seed_hosts parameter in the /app/opensearch/config/opensearch.yml file, leaving only the IP addresses of the nodes that have the master role.
  • Restart the OpenSearch service:
    systemctl restart opensearch

And wait for the node to reconnect to the cluster:

GET _cat/nodes

Stopping the service and backing up the excluded node configuration

After disabling cluster allocation, you can stop the OpenSearch process on the excluded node:

systemctl stop opensearch

For safety, it is necessary to back up the directory containing the OpenSearch configurations:

sudo cp -r /app/opensearch/config /app/os_conf_backup

Enabling cluster allocation

It is necessary to re-enable cluster allocation:

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

And then wait for the cluster to reach the green status:

GET _cluster/health

Clearing exclusions

Since we previously added the node to the exclusions, we now need to remove it from there. First, check if the excluded node is in the list:

GET _cluster/state?filter_path=metadata.cluster_coordination.voting_config_exclusions

If the node that was excluded is present in the voting_config_exclusions field, you need to execute the command:

DELETE _cluster/voting_config_exclusions?wait_for_removal=false

Now, verify again that the excluded node is not present in the voting_config_exclusions field and that the cluster status is green:

GET _cluster/state?filter_path=metadata.cluster_coordination.voting_config_exclusions
GET _cluster/health