How to resolve the unassigned shards

  "cluster_name": "elastic",
  "status": "red",
  "timed_out": false,
  "number_of_nodes": 3,
  "number_of_data_nodes": 3,
  "active_primary_shards": 74,
  "active_shards": 147,
  "relocating_shards": 0,
  "initializing_shards": 0,
  "unassigned_shards": 5,
  "delayed_unassigned_shards": 0,
  "number_of_pending_tasks": 0,
  "number_of_in_flight_fetch": 0,
  "task_max_waiting_in_queue_millis": 0,
  "active_shards_percent_as_number": 96.71052631578947

Installed elastic cluster with 3 nodes with 5.4.0 version. I have noticed cluster health is red with couple of nodes disks got filled up and after increasing the disk space I see few unassigned shards. How to resolve the issue? I'm using default settings, and having 3 shards and 1 replica for each index

Use the reroute command to assign the unassigned shard to a node. If successful it will assign the shard. If there is a problem, it will return a large chunk of data that details each check it performed before assigning the shard. One of these checks must have failed (returned FALSE) and that should point you in the right direction to find your problem.

If your cluster is red then you probably have primary shards unassigned. The command below will allow you to reassign a shard that has gone "stale". This means that ES is not sure which copy of the shard has the most recent data and it will not assign one as primary because if another shard with newer data connects to the cluster later it will be overwritten. If your confident that the shard has all of the data you need then you can assign it to a node with the command below. Just be wary of data loss :wink:

curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -H 'Content-Type: application/json' -d'
"commands" : [
"allocate_stale_primary" : {
"index" : "test", "shard" : 1,
"node" : "node3",
"accept_data_loss" : true

Thanks @jcspino

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.