Use this code before performing a rolling restart of an Elasticsearch cluster. The transient
field means that the setting will be reset the next time Elasticsearch is restarted on the node.
PUT /_cluster/settings
{
"transient": {
"cluster.routing.allocation.enable": "none"
}
}
The response should look like this:
{
"acknowledged": true,
"persistent": {},
"transient": {
"cluster": {
"routing": {
"allocation": {
"enable": "none"
}
}
}
}
}
Now, if any data nodes are rebooted, the shards will not attempt to rebalance.
To turn it back on, use:
PUT /_cluster/settings
{
"transient": {
"cluster.routing.allocation.enable": "all"
}
}
The response will look like this:
{
"acknowledged": true,
"persistent": {},
"transient": {
"cluster": {
"routing": {
"allocation": {
"enable": "all"
}
}
}
}
}