# ElasticsearchException: 创建索引 [my_index] 失败 - 集群 [my_cluster] 的分片总数限制 [1000] 已超出

- **ID:** `elasticsearch/shards-limit-exceeded`
- **领域:** elasticsearch
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

集群已达到允许的最大分片数量（默认每节点或集群级别限制为1000），阻止索引创建或打开。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.10.0 | active | — | — |
| 7.17.0 | active | — | — |
| 8.0.0 | active | — | — |
| 8.5.0 | active | — | — |

## 解决方案

1. ```
   Increase the cluster-level shard limit dynamically: PUT _cluster/settings { "persistent": { "cluster.max_shards_per_node": 2000 } }
   ```
2. ```
   Reduce shard count by merging small indices or deleting unused indices: POST _cat/indices?v | awk '{print $3}' | xargs -I {} curl -XDELETE 'http://localhost:9200/{}'
   ```
3. ```
   Set a per-index shard limit to prevent future overflow: PUT _cluster/settings { "persistent": { "cluster.max_shards_per_node.frozen": 500 } }
   ```

## 无效尝试

- **** — Shard counts are persisted in cluster state and metadata, not reset on restart; this only causes temporary downtime without fixing the limit. (95% 失败率)
- **** — The limit applies to the entire cluster, not just one index. Deleting a single index does not free enough shards if the cluster is at capacity. (70% 失败率)
- **** — Adding replicas increases total shard count, making the problem worse. The limit caps total shards including replicas. (90% 失败率)
