# ElasticsearchException：创建索引 [logs-2025.03] 失败 - 此操作将增加 [2] 个分片，但集群当前已有 [1000]/[1000] 个最大打开分片

- **ID:** `elasticsearch/shard-limit-exceeded-for-node`
- **领域:** elasticsearch
- **类别:** resource_error
- **错误码:** `shard_limit_exceeded`
- **验证级别:** ai_generated
- **修复率:** 78%

## 根因

集群已达到允许的最大分片数，无法创建新索引。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Elasticsearch 7.17.0 | active | — | — |
| Elasticsearch 8.11.0 | active | — | — |
| Elasticsearch 8.15.0 | active | — | — |

## 解决方案

1. ```
   Reduce the number of shards per index by reindexing with fewer primary shards. For example, use `POST /_reindex` with a target index that has 1 primary shard instead of 5: `{"source": {"index": "logs-2025.03"}, "dest": {"index": "logs-2025.03-compact", "number_of_shards": 1}}`
   ```
2. ```
   Increase `cluster.max_shards_per_node` cautiously after auditing shard distribution. Run `GET _cluster/settings` to check current limit, then set via `PUT _cluster/settings` with `{"persistent": {"cluster.max_shards_per_node": 1500}}`. Ensure enough heap per node.
   ```

## 无效尝试

- **** — This only delays the problem and can cause severe performance degradation because each node handles too many shards, leading to heap pressure and slow recovery. (70% 失败率)
- **** — Deleting indices may not free up shard slots if the cluster-level limit is still hit due to node distribution; also risks data loss. (45% 失败率)
