Elasticsearch 集群 yellow/red 的定位与修复
_cluster/health 返回 yellow 或 red。yellow 表示主分片可用但副本未分配;red 表示至少一个主分片未分配,部分索引不可用。
curl -s 'http://es:9200/_cluster/health?pretty'
curl -s 'http://es:9200/_cat/shards?v'
curl -s 'http://es:9200/_cat/nodes?v'
curl -s 'http://es:9200/_cluster/allocation/explain?pretty'
curl -s 'http://es:9200/_cat/allocation?v'
allocation/explain 的具体原因,不要盲目 reroute。cluster.routing.allocation.* 和分片上限。POST /_cluster/reroute,但确认不会丢数据。合上页面,先回答,再展开对照。
yellow 和 red 的差别是什么?_cluster/reroute?yellow 表示主分片可用但副本未分配;red 表示至少一个主分片未分配,部分索引不可用。_cluster/allocation/explain 的具体原因,盲目 reroute 可能丢数据;red 索引应优先恢复主分片,再处理副本。yellow;应增加节点或降低副本数,并检查分配过滤和分片上限。
小程序版
微信扫码,随时查命令