Skip to content

Instantly share code, notes, and snippets.

@denzhel
Last active January 15, 2023 11:33
Show Gist options
  • Select an option

  • Save denzhel/7d8aebe994f018f846c7543bcd527f5d to your computer and use it in GitHub Desktop.

Select an option

Save denzhel/7d8aebe994f018f846c7543bcd527f5d to your computer and use it in GitHub Desktop.
elasticsearch disable shard allocation

I used this on a ES 5.5 cluster to disable shard allocation and do some maintainance work:

curl -X PUT "http://localhost:9250/_cluster/settings?pretty" \
-H 'Content-Type: application/json' -d \
'{   "persistent": {     "cluster.routing.allocation.enable": "none"   } }'

Then enable shard allocation:

curl -X PUT "http://localhost:9250/_cluster/settings?pretty" \
-H 'Content-Type: application/json' -d \
'{   "persistent": {     "cluster.routing.allocation.enable": "all"   } }'

Used this for ES 1.7:

 curl -XPUT -H "Content-Type: application/json" 'http://localhost:9200/_cluster/settings' -d '{
    "transient" : {
        "cluster.routing.allocation.disable_allocation": "true",
        "cluster.routing.allocation.enable": "none",
        "index.unassigned.node_left.delayed_timeout": "60m"
    }
}'

and to re-enable the shard allocation:

curl -XPUT -H "Content-Type: application/json" 'http://localhost:9200/_cluster/settings' -d '{
    "transient" : {
        "cluster.routing.allocation.disable_allocation": "false",
        "cluster.routing.allocation.enable": "all",
        "index.unassigned.node_left.delayed_timeout": "1m"
    }
}'

Finally, checked the cluster health using:

curl -s localhost:9200/_cat/allocation?v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment