What's Actually Happening
Elasticsearch shards are in FAILED state and cannot be allocated.
The Error You'll See
```bash $ curl localhost:9200/_cat/shards?v
index shard prirep state docs store ip myindex 0 p FAILED myindex 1 r UNASSIGNED ```
Why This Happens
- 1.Node failure - Node holding shard left cluster
- 2.Corrupted shard - Shard data corrupted
- 3.Disk full - No space for shard allocation
- 4.Allocation deciders - Rules preventing allocation
Step 1: Check Shard Explanation
# Get allocation explanation:
curl -XGET 'localhost:9200/_cluster/allocation/explain?pretty' -d '{
"index": "myindex",
"shard": 0,
"primary": true
}'Step 2: Reroute Shard
# Reroute failed shard:
curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -d '{
"commands": [{
"allocate_stale_primary": {
"index": "myindex",
"shard": 0,
"node": "node-1",
"accept_data_loss": true
}
}]
}'Step 3: Check Disk Space
# Check disk per node:
curl localhost:9200/_cat/allocation?vStep 4: Restore from Snapshot
# Restore index:
curl -XPOST 'localhost:9200/_snapshot/mybackup/snap1/_restore' -d '{
"indices": "myindex"
}'Elasticsearch Shard Checklist
| Check | Command | Expected |
|---|---|---|
| Shard state | _cat/shards | STARTED |
| Allocation | _cluster/allocation | Possible |
| Disk space | _cat/allocation | Available |
Verify the Fix
curl localhost:9200/_cat/shards/myindex?v
# Output: All shards STARTEDRelated Issues
- [Fix Elasticsearch Cluster Red Status](/articles/fix-elasticsearch-cluster-red-status)
- [Fix Elasticsearch Index Readonly](/articles/fix-elasticsearch-index-readonly)