Loading...

Disable shard allocation of your Elasticsearch nodes

If you going to upgrade your cluster or restart a node, it is wise to disable the shard allocation on that node. This prevents Elasticsearch from rebalancing missing shards until you tell it otherwise. This post demonstrates how to disable and enable shard allocation.

Disable it:

vinh@cinhtau:~> curl -XPUT 'http://localhost:9200/_cluster/settings' -d '{
    "transient" : {
        "cluster.routing.allocation.enable" : "none"
    }
}'
{"acknowledged":true,"persistent":{},"transient":{"cluster":{"routing":{"allocation":{"enable":"none"}}}}}

Perform the upgrade and after the restart enable it:

vinh@cinhtau:~> curl -XPUT 'http://localhost:9200/_cluster/settings' -d '{
    "transient" : {
        "cluster.routing.allocation.enable" : "all"
    }
}'