ES中分片强制上线

Administrator
发布于 2020-05-21 / 386 阅读 / 0 评论 / 1 点赞

ES中分片强制上线

Nodes=$(curl -s -XGET 'http://'$(hostname)':9200/_nodes/process?pretty=true' |grep nodes -A 1 |grep -v nodes |cut -d \" -f2 )
for Index in $(curl  -s  -XGET 'http://'$(hostname)':9200/_cat/shards' | grep UNASSIGNED |awk '{print $1}'|sort |uniq)
do 
	for Shards in $(curl  -s -XGET 'http://'$(hostname)':9200/_cat/shards' | grep UNASSIGNED | grep $Index | awk '{print $2}'|sort|uniq)
	do  
        curl -s -XPOST 'http://'$(hostname)':9200/_cluster/reroute'  -d '{"commands":[{"allocate":{"index":"'$Index'","shard":'$Shards',"node":"'$Nodes'","allow_primary":"true"}}]}' 
	done
done 



评论