elasticsearch-yellow-red

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'

常见根因

  1. 节点下线或磁盘满,分片无法分配。
  2. 副本数大于可用节点数(yellow 常见)。
  3. 磁盘 watermark 触发只读/迁移。
  4. allocation 过滤/感知配置限制了节点。
  5. 分片数过多或单节点分片上限。
  6. 索引 mapping 错误导致主分片失败。

修复

相关命令