ElasticsearchException: 创建索引 [my_index] 失败 - 集群 [my_cluster] 的分片总数限制 [1000] 已超出
ElasticsearchException: failed to create index [my_index] - limit of total shards [1000] for cluster [my_cluster] exceeded
ID: elasticsearch/shards-limit-exceeded
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 7.10.0 | active | — | — | — |
| 7.17.0 | active | — | — | — |
| 8.0.0 | active | — | — | — |
| 8.5.0 | active | — | — | — |
根因分析
集群已达到允许的最大分片数量(默认每节点或集群级别限制为1000),阻止索引创建或打开。
English
The cluster has reached its maximum allowed number of shards (default 1000 per node or cluster-level limit), preventing index creation or opening.
官方文档
https://www.elastic.co/guide/en/elasticsearch/reference/current/misc-cluster-settings.html#cluster-shard-limit解决方案
-
Increase the cluster-level shard limit dynamically: PUT _cluster/settings { "persistent": { "cluster.max_shards_per_node": 2000 } } -
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/{}' -
Set a per-index shard limit to prevent future overflow: PUT _cluster/settings { "persistent": { "cluster.max_shards_per_node.frozen": 500 } }
无效尝试
常见但无效的做法:
-
95% 失败
Shard counts are persisted in cluster state and metadata, not reset on restart; this only causes temporary downtime without fixing the limit.
-
70% 失败
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.
-
90% 失败
Adding replicas increases total shard count, making the problem worse. The limit caps total shards including replicas.