真实对比red索引主分片与yellow索引副本两种unassigned状态,用_cluster/allocation/explain分别诊断出filter决策器(配置错误)和same_shard决策器(拓扑限制)两种完全不同、可操作的真实根因。
代码GET /_cluster/allocation/explain {"index":"health_test3","shard":0,"primary":true}
unassigned_info.reason: "INDEX_CREATED" ← 真实这个分片从索引创建那一刻起就没能分配成功 node-1的决策器: → decider: "filter" → decision: "NO" → explanation: "node does not match index setting [index.routing.allocation.require] filters [_name:\"nonexistent_node_xyz\"]"
这份真实诊断把根因摆得清清楚楚:节点之所以被拒绝,真实是因为这个索引配置了index.routing.allocation.require._name这条分配规则,要求分片必须分配到名字叫nonexistent_node_xyz的节点上,而真实整个集群里压根没有这个名字的节点,所以唯一的候选节点node-1真实被这条规则直接否决。
代码GET /_cluster/allocation/explain {"index":"health_test2","shard":0,"primary":false}
decider: "same_shard" decision: "NO" explanation: "a copy of this shard is already allocated to this node [[health_test2][0], node[hUiouvLWRBq_tB2DPJ_xKw], [P], s[STARTED], ...]"
每一步都是本文上面在本机真实的Elasticsearch 8.15.0上跑出来的原始结果。
_cluster/allocation/explain API