问题描述:
索引label的0分区的主分区和复制分区全部丢失,集群状态是红色,并且新的数据无法写入
如下
curl 192.168.0.11:9200/_cat/shards
label 0 p UNASSIGNED
label 0 r UNASSIGNED
解决思路:
将现有的数据备份出来,然后重新导入
具体步骤:
1.先备份数据和mapping:
# 备份mapping
elasticdump --ignore-errors=true --scrollTime=120m --bulk=true --input=http://192.168.0.11:9200/label --output=label_mapping.json --type=mapping
# 备份数据
elasticdump --ignore-errors=true --scrollTime=120m --bulk=true --input=http://192.168.0.11:9200/label --output=label_data.json --type=data
2.删除现有的voice:live:logout索引
curl -X DELETE http://192.168.0.11:9200/label
3.再次导入刚才备份的数据
# 导入mapping
elasticdump --input=label_mapping.json --output=http://192.168.0.11:9200/label --type=mapping
# 导入数据
elasticdump --input=label_data.json --output=http://192.168.0.11:9200/label --type=data
可以看到集群恢复了
$ curl 192.168.0.11:9200/_cluster/health?pretty
{
"cluster_name" : "chinasoft_es",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 11,
"number_of_data_nodes" : 10,
"active_primary_shards" : 91,
"active_shards" : 182,
"relocating_shards" : 2,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}