ElasticSearch: Unassigned Shards, how to fix?

前端 未结 24 1180
悲&欢浪女
悲&欢浪女 2020-12-04 05:03

I have an ES cluster with 4 nodes:

number_of_replicas: 1
search01 - master: false, data: false
search02 - master: true, data: true
search03 - master: false,          


        
24条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 05:45

    This little bash script will brute force reassign, you may lose data.

    NODE="YOUR NODE NAME"
    IFS=$'\n'
    for line in $(curl -s 'localhost:9200/_cat/shards' | fgrep UNASSIGNED); do
      INDEX=$(echo $line | (awk '{print $1}'))
      SHARD=$(echo $line | (awk '{print $2}'))
    
      curl -XPOST 'localhost:9200/_cluster/reroute' -d '{
         "commands": [
            {
                "allocate": {
                    "index": "'$INDEX'",
                    "shard": '$SHARD',
                    "node": "'$NODE'",
                    "allow_primary": true
              }
            }
        ]
      }'
    done
    

提交回复
热议问题