es修改默认分片数为1000的限制

334次阅读
没有评论

共计 853 个字符,预计需要花费 3 分钟才能阅读完成。

问题背景:新搭建了一个 es, 但是发现写入到一定索引后发现不会在写入,由于代码没有异常返回,进行了断点打印日志发现在 es 链接没有返回,于是手动创建了一个索引,创建索引方式为 curl,命令如下:
curl -X PUT "http://localhost:9200/my-index"

报错如下
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Validation Failed: 1: this action would add [6] shards, but this cluster currently has [2996]/[3000] maximum normal shards open;"}],"type":"illegal_argument_exception","reason":"Validation Failed: 1: this action would add [6] shards, but this cluster currently has [2996]/[3000] maximum normal shards open;"},"status":400}
意思是三个节点分片的最大限制为 3000 也就是每个节点限制为 1000,由于我设置的索引默认是三分片一副本,所以导致创建索引失败无法写入。
解决办法修改创建分片的最大数为合适的数目

curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'{"persistent": {"cluster.max_shards_per_node": 900000} }
注意设置后为永久生效,同时需要参考官网说明,设置最大有一定的弊端,参考官方博客的一个说明链接地址
https://www.elastic.co/cn/blog/how-many-shards-should-i-have-in-my-elasticsearch-cluster
`

正文完
 0
yx
版权声明:本站原创文章,由 yx 于2024-09-03发表,共计853字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码