Tuesday, May 10, 2016

How to resolve elasticsearch status red ?

Had a similar issue. I managed to recover all my unassigned shards and get the cluster back to a green status using the following procedure. It could probably be streamlined but it works.

1.  Dump list of unassigned shards to text file. Using the following command
curl -XGET http://localhost:9200/_cluster/state?pretty=true >> /tmp/unassign.txt
2. VI unassign.txt
3. Search the file for UNASSIGNED
4. Running the following command on each unassigned shard
curl XPOST -s 'http://localhost:9200/_cluster/reroute?pretty=true' -d '{ "commands" : [ { "allocate" : {
              "index" : "INDEX TO WISH TO REASSIGN", "shard" : 0 , "node" : "NODE YOU WISH TO ASSIGN IT TO", "allow_primary" : 1 } 
        }
    ]
}’
If the shard is a number other than 0 change it to reflex that as well.

No comments:

Post a Comment