本文主要是介绍解决es报错:the shard cannot be allocated to the same node on which a copy of the shard already exists,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一:报错信息
通过命令:
curl -XGET "http://{ip}:9200/_cluster/allocation/explain"
查看集群状态:
可以看到其active_shards_percent为36.1%,elasticsearch健康状态为yellow,原因就是其存在UNASSIGNED shards的情况,而此时也影响到了es的正常使用。
二、分析原因:
如果我们只有一台机器,部署运行了es,但是却在index的settings中设置了replica为1,那么这个replica shard就会成为unassigned shards,因为分片不能分配到已经存在分片副本的同一节点.
而当我们在查看原因的时候就会如上图显示的那样:
the shard cannot be allocated to the same node on which a copy of the shard already exists
三、定位问题:
既然想到了,那肯定要验证一下。
使用命令:
curl -X GET -s {ip}:9200/_cat/shards?h=index,shard,prirep,state,unassigned.reason
四、解决问题:
解决方案:解决es报错,索引无法分片的问题 | 骐晔
这篇关于解决es报错:the shard cannot be allocated to the same node on which a copy of the shard already exists的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!