ES集群状态yellow修复
查看集群状态
GET /_cluster/health
{
"cluster_name" : "yzt-es-cluster",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 20,
"number_of_data_nodes" : 17,
"active_primary_shards" : 1576,
"active_shards" : 3044,
"relocating_shards" : 5, #正在重定位的分片的数量。
"initializing_shards" : 2, #正在初始化的分片数。
"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" : 99.93434011818779
}
查看问题索引
GET _cat/indices
yellow open comunication-iot-2022.06.08 9bSOiO0-TbWTUzJmaiMihw 7 1 146014958 0 154.7gb 90.3gb
查看详细的异常信息
GET /_cluster/allocation/explain
"deciders" : [
{
"decider" : "shards_limit",
"decision" : "NO",
"explanation" : "too many shards [1] allocated to this node for index [comunication-iot-2022.06.08], index setting [index.routing.allocation.total_shards_per_node=1]"
}
]
GET /comunication-iot-2022.06.08/_settings?pretty
"routing" : {
"allocation" : {
"exclude" : {
"box_type" : "cool"
},
"require" : {
"box_type" : "large"
},
"total_shards_per_node" : "1"
}
},
Note:我们发现服务器集群配置了total_shards_per_node这个属性,并且该值的值为1,也就验证了上面的错误,该配置没配置在elasticsearch.yml配置文件中,elasticsearch可以通过settings动态修改索引的分片和副本数等一些配置,我们发现集群中total_shards_per_node配置了每个节点上允许的最多分片是2,然而我们在移动分片的时候需要某个节点在一段时间内允许同时存在三个分片,因此,我们需要修改该配置,修改此配置不需要重新启动集群,风险较小。
解决方案
PUT /comunication-iot-2022.06.08/_settings
{
"index.routing.allocation.total_shards_per_node":2
}
如对您有帮助,支持下呗!
微信
![](https://files.cnblogs.com/files/Dev0ps/WeChat.gif)
支付宝
![](https://files.cnblogs.com/files/Dev0ps/Alipay.gif)