单节点Elasticsearch健康状态为 yellow

项目环境中,有一个不重要的辅助功能用到了 Elasticsearch,给的服务器资源有限,只能部署一个单机 Elasticsearch。刚部署完成时,health 状态为正常的 green,但是过了几天后,在查看 Elasticsearch 的 health,已经变为 yellow :
es集群状态说明:

green:最健康得状态,说明所有的分片包括备份都可用
yellow:基本的分片可用,但是备份不可用(或者是没有备份)
red:部分的分片可用,表明分片有一部分损坏。此时执行查询部分数据仍然可以查到,但是要尽快解决

[root@web-01 ~]# curl -X GET "192.168.0.229:9200/_cluster/health?pretty"
{
  "cluster_name" : "yxfes",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 2,
  "active_shards" : 2,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 2,
  "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" : 50.0
}

根据上面的返回信息,集群的 unassigned_shards 为 2

由于我们是单节点部署elasticsearch,而默认的分片副本数目配置为1,而相同的分片不能在一个节点上,所以就存在副本分片指定不明确的问题,所以显示为yellow
解决方法:
1、可以通过在elasticsearch集群上添加一个节点来解决问题(推荐)
2、你可以删除那些指定不明确的副本分片(当然这不是一个好办法)

[root@web-01 ~]# curl -X PUT "10.88.0.92:9200/_settings" -H 'Content-Type: application/json' -d'
{"number_of_replicas":0}'
# 返回
{"acknowledged":true}

再次查看 Elasticsearch health,已经转为 green:

[root@web-01 ~]# curl -X GET "10.88.0.92:9200/_cluster/health?pretty"
{
  "cluster_name" : "yxfes",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 2,
  "active_shards" : 2,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "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" : 100.0
}
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值