# ES 常见错误

### 报错 maximum shards open

**问题描述**

创建索引时，报错显示this action would add \[2] total shards, but this cluster currently has \[1000]/\[1000] maximum shards open。

查看分片数量

> GET /\_cluster/settings?filter\_path=transient.cluster.max\_shards\_per\_node,persistent.cluste.max\_shards\_per\_node

```bash
{
  "transient" : {
    "cluster" : {
      "max_shards_per_node" : "1000"
    }
  }
}

```

**问题原因**

由于节点shard数量超过最大值限制，ES默认每个节点的shard数量是1000，如果shard数量超过这个值创建索引会报错。

**解决方案**

1. 关闭或者删除不用的索引，减少shard数量。
2. 修改节点的shard数量的限制，这里设置 3000。

   ```json
   PUT _cluster/settings
   {
     "persistent": {
       "cluster": {
       "max_shards_per_node": 2000
       }
     }
   }
   ```

或者

```shell
curl -X PUT localhost:9200/_cluster/settings -H "Content-Type: application/json" -d '{ "persistent": { "cluster.max_shards_per_node": "3000" } }'
```

**文章参考**

[CSS创建索引报错maximum shards open\_云搜索服务 CSS\_故障排除\_功能使用类 (huaweicloud.com)](https://support.huaweicloud.com/trouble-css/css_10_0012.html)

### 报错 org.elasticsearch.action.search.SearchPhaseExecutionException: all shards failed

**问题表述描述**

<figure><img src="https://2134947750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvILwbD2PrkBCkSitM3m4%2Fuploads%2F0VwYFde3go8YZPRRwpIN%2Fimage.png?alt=media&#x26;token=1643d5a6-e076-42c4-9b83-0dddc8389344" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2134947750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvILwbD2PrkBCkSitM3m4%2Fuploads%2FxTEhs5uSQSHbOSEObG6f%2Fimage.png?alt=media&#x26;token=3681d9c8-0de7-4c2c-b196-7452d21ec033" alt=""><figcaption></figcaption></figure>

**如何处理**

```bash
curl -X GET "http://localhost:9200/_cat/indices/.kibana_task_manager?v" # 检查 .kibana_task_manager索引状态和健康状况
curl -X GET "http://localhost:9200/_cluster/health?pretty"               # 确保索引状态为 open，并检查其健康状态
curl -X POST "http://localhost:9200/.kibana_task_manager/_refresh"       # 刷新索引
curl -X GET "http://localhost:9200/_cat/shards/.kibana_task_manager?v"   # 检查分片状态

```

<figure><img src="https://2134947750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvILwbD2PrkBCkSitM3m4%2Fuploads%2FzyLzrxVo5ER8K1AbtZ84%2Fimage.png?alt=media&#x26;token=05348c88-203a-47bc-9971-915ddf009647" alt=""><figcaption></figcaption></figure>

<mark style="color:red;">**如果问题持续，考虑删除并重建索引, UI中，重新创建索引**</mark>
