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
}
如对您有帮助,支持下呗!
微信

支付宝

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类