There are many possible reason why allocation won’t occur:
- You are running different versions of Elasticsearch on different nodes
- You only have one node in your cluster, but you have number of replicas set to something other than zero.
- You have insufficient disk space.
- You have shard allocation disabled.
- You have a firewall or SELinux enabled. With SELinux enabled but not configured properly, you will see shards stuck in INITIALIZING or RELOCATING forever.
As a general rule, you can troubleshoot things like this:
- Look at the nodes in your cluster:
curl -s 'localhost:9200/_cat/nodes?v'
. If you only have one node, you need to setnumber_of_replicas
to 0. (See ES documentation or other answers). - Look at the disk space available in your cluster:
curl -s 'localhost:9200/_cat/allocation?v'
- Check cluster settings:
curl 'http://localhost:9200/_cluster/settings?pretty'
and look forcluster.routing
settings - Look at which shards are UNASSIGNED
curl -s localhost:9200/_cat/shards?v | grep UNASS
-
Try to force a shard to be assigned
curl -XPOST -d '{ "commands" : [ { "allocate" : { "index" : ".marvel-2014.05.21", "shard" : 0, "node" : "SOME_NODE_HERE", "allow_primary":true } } ] }' http://localhost:9200/_cluster/reroute?pretty
-
Look at the response and see what it says. There will be a bunch of YES’s that are ok, and then a NO. If there aren’t any NO’s, it’s likely a firewall/SELinux problem.