ElasticSearch单机健康状况为黄色的解决方法

在学习过程中,我安装了Elasticsearch单机,配置过程具体不说,启动也没问题,但是在查看健康状况的时候出现了问题,健康状况为黄色,先说下E的健康状况的三种情况
green
最健康得状态,说明所有的分片包括备份都可用
yellow
基本的分片可用,但是备份不可用(或者是没有备份)
red
部分的分片可用,表明分片有一部分损坏。此时执行查询部分数据仍然可以查到,但是要尽快解决
问题 :curl -X GET http://192.168.8.36:9200/_cat/health?v
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1572420364 15:26:04 ymq yellow 1 1 1 1 0 0 1 0 - 50.0%
这里可以看到我们的健康状况为黄色。

过程:首先查看启动日志

[2019-10-30T15:24:46,579][INFO ][o.e.c.r.a.AllocationService] [ELK-node1] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[.kibana][0]] …]).
这里有一个说明,集群从红色变为黄色,因为【kibana】这个碎片启动了
,和我们要解决的问题貌似无关,但是给了我一点想法,是不是因为节点的原因呢,我查找了下资料,确实如此。
原因:这里解释一下为什么集群状态为yellow
由于我们是单节点部署elasticsearch,而默认的分片副本数目配置为1,而相同的分片不能在一个节点上,所以就存在副本分片指定不明确的问题,所以显示为yellow,我们可以通过在elasticsearch集群上添加一个节点来解决问题,如果你不想这么做,你可以删除那些指定不明确的副本分片(当然这不是一个好办法)但是作为测试和解决办法还是可以尝试的,下面我们试一下删除副本分片的办法 (这里我引用了博主落尘曦的文章再此感谢,
原文链接:https://blog.csdn.net/qq_23994787/article/details/79389048

解决方法 :以下两种
1.
curl -XPUT “http://localhost:9200/_settings” -d’ { “number_of_replicas” : 0 } ’ #删除那些指定不明确的副本分片
2.
将E做成集群,不做单机,完成后,健康状态将变成绿色

结果
url -X GET 'http://localhosh?pretty’luster/healt
{
“cluster_name” : “ymq”,
“status” : “green”,
“timed_out” : false,
“number_of_nodes” : 1,
“number_of_data_nodes” : 1,
“active_primary_shards” : 1,
“active_shards” : 1,
“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


版权声明:本文为ROI_kun原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。