集群已打开最大分片

nic*_*las 8 elasticsearch

我正在使用 Windows 10 并且我得到

Elasticsearch 异常 [type=validation_exception, reason=Validation Failed: 1: 此操作将添加 [2] 个总分片,但该集群当前有 [1000]/[1000] 个最大分片打开;]

我该如何解决这个问题?我不介意丢失数据,因为它只在本地运行。

cod*_*diz 25

除了上面提到的答案之外,您还可以尝试增加分片,直到尝试重新架构节点

curl -X PUT localhost:9200/_cluster/settings -H "Content-Type: application/json" -d '{ "persistent": { "cluster.max_shards_per_node": "3000" } }'
Run Code Online (Sandbox Code Playgroud)

CAUTION此外,以下内容可能很有用,当然应该继续进行

  • 获取集群中未分配分片的总数
curl -XGET -u elasticuser:yourpassword http://localhost:9200/_cluster/health\?pretty | grep unassigned_shards
Run Code Online (Sandbox Code Playgroud)

谨慎使用

  • 删除集群中未分配的分片(USE WITH CAUTION)
curl -XGET -u elasticuser:yourpassword http://localhost:9200/_cat/shards | grep UNASSIGNED | awk {'print $1'} #(USE WITH CAUTION) | xargs -i curl  -XDELETE -u elasticuser:yourpassword "http://localhost:9200/{}"
Run Code Online (Sandbox Code Playgroud)

  • 不要运行删除未分配的分片命令:它会删除索引,而不是分片。 (3认同)

小智 13

如果您不介意数据丢失,请删除旧索引。最简单的方法是从 GUI Kibana > Management > DevTools执行此操作,然后获取所有索引:

GET /_cat/indices/
Run Code Online (Sandbox Code Playgroud)

您可以在如下所示的模式内删除:

DELETE /<index-name>
Run Code Online (Sandbox Code Playgroud)

例如:

DELETE /logstash-2020-10*
Run Code Online (Sandbox Code Playgroud)


Ami*_*mar 5

您已达到限制cluster.max_shards_per_node。添加更多数据节点或减少集群中的分片数量。

  • 尝试使用以下curl命令在正在运行的Elasticsearch集群上动态设置它:curl -XPUT $CLUSTER_URL/_cluster/settings -H 'Content-type: application/json' --data-binary $'{"transient":{"cluster. max_shards_per_node":5100}}' (7认同)