I setup elasticsearch cluster and I did not explicitly setup the role (node.roles:). Now ,I have gone back and edit one of the node config and assign to master (node.roles:[master].
However, when I restart I get the error:
java.lang.IllegalStateException: node does not have the data role but has shard data: [/opt/elasticsearch/data/nodes
How can I set the role explicitly?
CodePudding user response:
By default, a node gets the master and data role. So if you have started it already, it should already contain some data, and thus, cannot be transformed to a master node unless you first move all the data it contains on another node.
You first need to decommission the node by running this command (use the right IP address for your node) in order to move all the data it contains on other data nodes:
PUT _cluster/settings
{
"transient" : {
"cluster.routing.allocation.exclude._ip" : "10.0.0.1"
}
}
When the node doesn't contain any data anymore, you can shut it down, change node.roles to master and restart it.
