索引状态为yellow
yellow表示存在副本分片未分配。
curl -H "Content-Type: application/json" -XPUT 'http://localhost:9200/_settings' -d '
{
"index" : {
"number_of_replicas" : 0
}
}'
再次查看状态
curl http://localhost:9200/_cat/indices?v
索引状态为red
red状态表示存在主分片未分配到任一节点通过以下命令分配节点。
curl -H "Content-Type: application/json" -XPOST 'http://localhost:9200//_cluster/reroute' -d '
{
"commands":[
{
"allocate_stale_primary":{
"index":"索引名称".
"shard":0,
"node":"targetn_node",
"accept_data_loss":true
}
}
]
}'
使用此命令后仍然报错,表示分配失败。
随后通过以下命令找寻索引分配失败原因
curl -XGET http://localhost:9200/_cluster/allocation/explain -d '
{
"index":"索引名称",
"shard":0,
"primary":true
}'
最终找到原因磁盘已满,节点分配失败。