1
votes

I have an elastic search cluster of 3 nodes (1 master and 2 data nodes), I have enabled xpack after that I was not able to start the master node. So I ran the elasticsearch-node repurpose command. And the cluster restarted.

But now I have the shards which are unassigned.

analytics-2019-11-19 0     p      UNASSIGNED
analytics-2019-11-19 0     r      UNASSIGNED

and the cluster status is red. I am new to elk. Let me know how to fix this and make the cluster green?

Thanks

1

1 Answers

3
votes

In order to resolve UNASSIGNED shards issue you have to follow these steps:

  1. Let's find out which shards are unassigned, and why run:

    curl -XGET localhost:9200/_cat/shards?h=index,shard,prirep,state,unassigned.reason| grep UNASSIGNED
    

    Via Kibana

    GET _cat/shards?h=index,shard,prirep,state,unassigned.reason| grep UNASSIGNED
    
  2. Let's use the cluster allocation explain API to try to garner more information about shard allocation issues

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

    Via Kibana

    GET _cluster/allocation/explain?pretty
    

The resulting output will provide helpful details about why certain shards in your cluster remain unassigned.

For example:

You might see this explanation: "explanation" : "the shard cannot be allocated to the same node on which a copy of the shard already exists" Meaning there is an index that you don’t need anymore and you can delete it to restore your cluster status to green.

If it is not the issue (the example) then it could be one of the following reasons:

-Shard allocation is purposefully delayed
-Too many shards, not enough nodes
-You need to re-enable shard allocation
-Shard data no longer exists in the cluster
-Low disk watermark
-Multiple Elasticsearch versions

Follow this guide to resolve unassigned shards issue

Hope this helps