elasticsearch 群集已打开最大分片数

watbbzwu  于 2023-05-06  发布在  ElasticSearch
关注(0)|答案(5)|浏览(139)

我使用的是Windows 10,
Elasticsearch exception [type=validation_exception,reason=Validation Failed:1:此操作将增加[2]个分片总数,但该集群当前最多打开[1000]/[1000]个分片;]
我该如何解决这个问题?我不介意我丢失数据,因为它只在本地运行。

ebdffaop

ebdffaop1#

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

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

此外,下面的代码可能很有用,当然应该使用CAUTION进行

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

小心使用

  • 删除集群(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/{}"
tpgth1q7

tpgth1q72#

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

5jdjgkvh

5jdjgkvh3#

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

GET /_cat/indices/

您可以在模式中删除,如下所示:

DELETE /<index-name>

例如:

DELETE /logstash-2020-10*
ffx8fchx

ffx8fchx4#

你可能每个节点有太多的分片。
我建议您查看以下有关规模调整的资源:
https://www.elastic.co/elasticon/conf/2016/sf/quantitative-cluster-sizing

t2a7ltrp

t2a7ltrp5#

我只是有同样的错误,“最大的碎片开放”,所以 * 关闭 * 索引也可以工作,如果你想以后保留它们,不需要删除它们。无法查询已关闭的索引,但数据仍保留。

相关问题