手动恢复方法:
通过以下脚本生成恢复unassigned分片的脚本
#!/bin/sh
for index in $(curl -s 'http://localhost:9200/_cat/shards' | grep UNASSIGNED | awk '{print $1}' | sort | uniq); do
for shard in $(curl -s 'http://localhost:9200/_cat/shards' | grep UNASSIGNED | grep $index | awk '{print $2}' | sort | uniq); do
cat <<EOF
curl -XPOST 'localhost:9200/_cluster/reroute?v' -d '{
"commands" : [ {
"allocate" : {
"index" : "$index",
"shard" : $shard,
"node" : "es1-hot",
"allow_primary" : true
}
}
]
}'
EOF
done
done