elasticsearch进入red状态,修复方法

#!/bin/bash

for index in $(curl  -s 'http://192.168.0.234:9200/_cat/shards' | grep UNASSIGNED | awk '{print $1}' | sort | uniq); do
    for shard in $(curl  -s 'http://192.168.0.234:9200/_cat/shards' | grep UNASSIGNED | grep $index | awk '{print $2}' | sort | uniq); do
        echo  $index $shard

        curl -XPOST '192.168.0.234:9200/_cluster/reroute' -d "{
            'commands' : [ {
                  'allocate' : {
                      'index' : $index,
                      'shard' : $shard,
                      'node' : '7p7qvMcqTKux54dYmflEyg',
                      'allow_primary' : true
                  }
                }
            ]
        }"

        sleep 5
    done
done

 

posted on 2018-12-18 18:04  Copernicus  阅读(2602)  评论(0)    收藏  举报

导航