Elasticsearch8启动后报错:at least one primary shard for the index [.security-7] is unavailable解决方法

一、问题:

UnavailableShardsException: at least one primary shard for the index [.security-7] is unavailable.

二、原因:

.security-7的索引分片未分配。

三、解决方法:

1、查看集群健康状态:

curl --cacert http_ca.crt -u username:passwd -X GET "http://elasticsearch-host-IP:elasticsearch-port/_cat/health?v&pretty"

其中,/_cat/health 表示获集群健康状态信息,?v 表示输出详细信息(verbose),&pretty 表示以易读的格式输出。

注意,请将上述username和passwd替换为你的用户名和密码,elasticsearch-host-IP 和elasticsearch-port替换为你的实际值。我是在elasticsearch-8.10.2/config/certs/目录下运行的,请确保http_ca.crt在此路径下。

结果如下:

会发现集群状态为红色,unassign这一项为1,就是.security-7索引分片未分配。

2、查看.security-7索引的状态:

curl --cacert http_ca.crt -u username:passwd -X GET "http://elasticsearch-host-IP:elasticsearch-port/.security-7?v"

注意,请将上述username和passwd替换为你的用户名和密码,elasticsearch-host-IP 和elasticsearch-port替换为你的实际值。

结果如下:

会发现.security-7索引状态是unassigned,正常分配后的状态应该是这样:

3、尝试重新分配索引.security-7:

curl -u username:passwd -X POST "elasticsearch-host-IP:elasticsearch-port/_cluster/reroute" -H 'Content-Type: application/json' -d '{
  "commands": [
    {
      "allocate": {
        "index": ".security-7",
        "shard": 0,
        "node": "your_node_name",
        "allow_primary": true
      }
    }
  ]
}'

 还是失败。

4、最后,删除了所有节点data目录下的内容,重新启动ES后,问题解决了。

(.security-7存放在data目录下,强制删除数据后会重新分配索引)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值