elasticsearch resource_error ai_generated true

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

其他格式: JSON · Markdown 中文 · English
82%修复率
85%置信度
1证据数
2023-05-12首次发现

版本兼容性

版本状态引入弃用备注
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.

generic

官方文档

https://www.elastic.co/guide/en/elasticsearch/reference/current/misc-cluster-settings.html#cluster-shard-limit

解决方案

  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 } }

无效尝试

常见但无效的做法:

  1. 95% 失败

    Shard counts are persisted in cluster state and metadata, not reset on restart; this only causes temporary downtime without fixing the limit.

  2. 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.

  3. 90% 失败

    Adding replicas increases total shard count, making the problem worse. The limit caps total shards including replicas.