Elasticsearch 索引修复
作者:互联网
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
标签:index,http,9200,shard,索引,Elasticsearch,172.17,curl,修复 来源: https://www.cnblogs.com/ArchitecTang/p/16613247.html