解决es报错:the shard cannot be allocated to the same node on which a copy of the shard already exists

文章讲述了Elasticsearch健康状态显示黄色,由于存在UNASSIGNEDshards导致。原因可能是设置的replica分片无法在同一节点分配。通过`curl`命令检查集群状态和分片详情,确认问题并提出解决方案,即调整索引设置以避免分片副本在同节点上。
摘要由CSDN通过智能技术生成

一:报错信息

通过命令:

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报错,索引无法分片的问题 | 骐晔

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值