How to move from 3 node cluster to single node

i have a three node cluster below is the config

cluster.name: hotels-autosuggest
node.name: "es-autosuggest-3"
path.logs: /var/log/elasticsearch
path.data: /data/elasticsearch/data
bootstrap.memory_lock: true
network.host: 0.0.0.0
#discovery.zen.minimum_master_nodes: 2
discovery.seed_hosts: ["es-autosuggest-1.com","es-autosuggest-2.com","es-autosuggest-3.com"]
cluster.initial_master_nodes: ["es-autosuggest-1.com","es-autosuggest-2.com","es-autosuggest-3.com"]
http.port: 9200
xpack.security.enabled: false

i want to know how can we shift from this to single node without breaking any flow or loss of data

it would be very helpful if anybody can answer this , as we want to do this activity to reduce cost in qa env

Hi,

you can setting the number of replicas to 2 so that there's a copy of the data on each node before shutting down the other two nodes is indeed a viable idea. However, keep in mind that once you transition to a single-node cluster, you won't need replicas, so you'll need to reduce the number of replicas back to 0.

So the steps:
Set the number of replicas to 2
Wait for the replicas to be allocated
Shut down two nodes
Set the number of replicas to 0

Regards

thanks for the reply

but will the sharded data in node 2 and node 3 be present in node 1.

if so i can disconnect 2 and 3 nodes right?

This is not something simple to do because all your nodes are master eligible, and if you remove two nodes from your cluster it will not work anymore

Also, you can not do that without stopping the nodes, this is not possible, you will need to stop it to change some configurations.

First thing would be to exclude the 2 nodes you want to remove from allocation following the documentation.

Just run the following request on Kibana dev tools:

PUT _cluster/settings
{
  "persistent" : {
    "cluster.routing.allocation.exclude._ip" : "NODE-IP, ANOTHER-NODE-IP"
  }
}

This will make the shards move from these 2 nodes to the remaining nodes, this can take time and you need to make sure that the remaining node has enough space to have all your data or else this will not work.

Also, Before doing that you will need to set the number of replicas to zero in all your indices:

Something like this:

PUT /*/_settings
{
    "index" : {
        "number_of_replicas" : 0
    }
}

After all the shards are moved out from the 2 nodes that will be excluded you will to stop all the nodes and change the configuration of the remaining node before starting it again.

Basically you will need this config, assuming that the remaining node is the es-autosuggest-1.

cluster.name: hotels-autosuggest
node.name: "es-autosuggest-1"
path.logs: /var/log/elasticsearch
path.data: /data/elasticsearch/data
bootstrap.memory_lock: true
network.host: 0.0.0.0
discovery.seed_hosts: ["es-autosuggest-1.com"]
discovery.type: "single-node"
http.port: 9200
xpack.security.enabled: false

I did not test this, so you will need to test to see if this work, I recommend to have a snapshot of your data to avoid any issue.

2 Likes

Also, if I'm not wrong you will also need to remove the nodes that will be excluded from voting before stopping them.

This is the documentation.

Basically something like this:

POST /_cluster/voting_config_exclusions?node_names=NODE-NAME,ANOTHER-NODE-NAME
1 Like

thanks bro let me test this

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.