elasticsearch 报错 NoShardAvailableActionException: No shard available for routing [null]]

1. 检查健康状态

curl --user 用户名:密码  -XGET http://本机ip:端口/_cluster/health\?pretty

我不加–user 用户名:密码 会报错,还有如果使用127.0.0.1或者localhost,可能会报错not route to host,反正我是遇到了。

{
  "cluster_name" : "elasticsearch",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 1201,
  "active_shards" : 1201,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 50,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 96.00319744204636
}

green为健康状态,red为不健康,yellow在两者之间,但仍不健康。

2. 查看unassigned类型的索引名字

可以看到有很多unssigned,就是此类导致的报错。

authentication-2021.02.20    3 p STARTED         72  169.1kb 96.0.193.57 LasG0MY
authentication-2021.02.20    1 p STARTED         65  104.8kb 96.0.193.57 LasG0MY
authentication-2021.02.20    2 p STARTED         58  124.9kb 96.0.193.57 LasG0MY
authentication-2021.02.20    4 p STARTED         64  141.1kb 96.0.193.57 LasG0MY
authentication-2021.02.20    0 p STARTED         81  149.8kb 96.0.193.57 LasG0MY
mobile01-2021.03.02 3 p STARTED          3     33kb 96.0.193.57 LasG0MY
mobile01-2021.03.02 3 r UNASSIGNED                              
mobile01-2021.03.02 1 p STARTED          5   46.6kb 96.0.193.57 LasG0MY
mobile01-2021.03.02 1 r UNASSIGNED                              
mobile01-2021.03.02 2 p STARTED          7   96.6kb 96.0.193.57 LasG0MY

由于我的是单机环境,没有启用副本分片,可以将副本设置为0 。

 curl --user 用户名:密码  -XGET http://本机ip:端口/_settings' -H 'content-Type:application/json' -d' {"number_of_replicas":0}'

3. 删除unassigned状态的索引

curl --user 用户名:密码  -XGET http://本机ip:端口/authentication-2021.02.20
等等。。。

其中,authentication-2021.02.20 为unassigned 状态的名字。

参考

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值