Skip to content

Elasticsearch UNASSIGNED shards

Symptoms

$ curl localhost:9200/_cat/allocation?v
shards disk.indices disk.used disk.avail disk.total disk.percent host      ip        node
    97        2.2gb    39.2gb     29.4gb     68.7gb           57 10.0.1.1  10.0.1.1  es-cluster
   192                                                                               UNASSIGNED

Check other values

curl localhost:9200/_cluster/health?pretty

curl -s localhost:9200/_cat/shards | grep INIT

curl -s localhost:9200/_cluster/allocation/explain?pretty

curl localhost:9200/_nodes/hot_threads

Fix 1

curl -X PUT 'http://localhost:9200/_all/_settings' -H 'Content-Type: application/json' \
-d '{"blocks.read_only_allow_delete": null}' 

curl -X PUT localhost:9200/_settings -H 'Content-Type: application/json' -d '{"index":{"number_of_replicas":0}}'

# for cluster with 3 data nodes
curl -X PUT localhost:9200/_settings -H 'Content-Type: application/json' -d '{"index":{"number_of_replicas":2}}'

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