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.