Consider using `allow_partial_search_results` setting to by
Elasticsearch data node 重啟導致 sharding 找不到家
今天遇到單位同仁重啟 Elasticsearch data node 後發現 Cluster 狀態變成 Red 的狀況,這篇記錄遇到這個問題時該怎麼處理
會遇到這個問題通常是「遺失的 Data node」大於「index.number_of_replicas」,Elasticsearch replication 預設為 1 也就是只有 1 個備份,而 Data node 最大只能消失 1 台,不然就會少掉 index sharing 無法拼湊完整的 index。
在這個案例是不小心操作錯誤將 Data node 下線,但是 index data 仍存在,將 Data node 重新加入 Cluster 後仍然會出現 index shards 缺少的狀況。
Search rejected due to missing shards [[.kibana_task_manager_1][0]]. Consider using `allow_partial_search_results`
從 localhost:9200/_cluster/health
看目前 Cluster 狀況:
{
"cluster_name":"xxx",
"status":"red",
...
"initializing_shards":20,
"unassigned_shards":13983,
"delayed_unassigned_shards":0,
"number_of_pending_tasks":28,
...
}
其中會發現 unassigned_shards
這個數字有點異常,這個參數是代表目前有 13983 個 index shard 找不到家 (data node),意味著
- index shard 資料仍然存在
- 要替這些
unassigned shards
找到適合的 data node 分配
遇到 unassigned_shards 可以透過 Elasticsearch transient update 一次性讓 shard 找到 data node
curl -X PUT "localhost:9200/_cluster/settings?pretty" -H 'Content-Type: application/json' -d'
{
"transient" : {
"cluster.routing.allocation.enable" : "all"
}
}'
再從 localhost:9200/cluster/health
查看 unassigned_shards
應該要陸續下降,狀態也應該會從 red -> yellow -> green 恢復正常
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器