# 解决ElasticSearch的maximum shards open问题 ### 问题: > ValidationException[Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [999]/[1000] maximum shards open;] ### 原因: > 这是因为集群最大shard(分片)数不足引起的,从Elasticsearch v7.0 开始,集群中的每个节点默认限制1000个分片。 ### 解决: #### 方案1、在elasticsearch.yml中定义 ```bash > cluster.max_shards_per_node: 10000 ``` #### 方案2、在kibana控制台执行: ```bash PUT /_cluster/settings { "transient": { "cluster": { "max_shards_per_node":10000 } } } ``` #### 方案3、在linux控制台执行: ```bash curl -XPUT http://localhost:9200/_cluster/settings \ -u elastic:password \ -H "Content-Type: application/json" \ -d '{"transient":{"cluster":{"max_shards_per_node":10000}}}' ``` ### 结果: 返回`{"acknowledged":true,"persistent":{},"transient":{"cluster":{"max_shards_per_node":"10000"}}}`表示执行成功! ## 查询 ```bash GET /_cluster/settings ``` 返回 ```json { "persistent" : { }, "transient" : { "cluster" : { "max_shards_per_node" : "10000" } } } ```