Elasticsearch 7.X
点击查看代码
#!/bin/bash
master=$(curl -s 'http://172.17.89.243:9200/_cat/master?v' | grep -v ' ip ' | awk '{print $1}')
for index in $(curl -s 'http://172.17.89.243:9200/_cat/shards' | grep UNASSIGNED | awk '{print $1}' | sort | uniq); do
for shard in $(curl -s 'http://172.17.89.243:9200/_cat/shards' | grep UNASSIGNED | grep $index | awk '{print $2}' | sort | uniq); do
echo $index $shard
curl -XPOST -H 'Content-Type: application/json' 'http://172.17.89.243:9200/_cluster/reroute' -d '{
"commands" : [ {
"allocate_empty_primary" : {
"index" : "'$index'",
"shard" : "'$shard'",
"node" : "'$master'",
"accept_data_loss" : true
}
}
]
}'
sleep 1
done
done
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。