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

相关文章

文章浏览阅读774次,点赞24次,收藏16次。typescript项目中我...
文章浏览阅读784次。react router redux antd eslint pretti...
文章浏览阅读3.9k次,点赞5次,收藏11次。需要删除.security...
文章浏览阅读1.2k次,点赞23次,收藏24次。Centos 8 安装es_...
文章浏览阅读3.2k次。设置完之后,数据会⾃动同步到其他节点...
文章浏览阅读1.9k次,点赞2次,收藏7次。针对多数据源写入的...