美文网首页DBA
Elasticsearch unassigned shard

Elasticsearch unassigned shard

作者: mysia | 来源:发表于2019-03-27 14:45 被阅读14次

1.产生原因

ES的data节点异常关闭,会导致副本出现unassigned shard,致使索引状态变为yellow,甚至是red。

2.处理方式

2.1查看集群状态

curl -XGET http://localhost:9200/_cluster/health\?pretty

结果中,unassigned_shards对应的数字就是当前集群中异常分片的数量。

2.2查看所有分片状态

curl -s "http://localhost:9200/_cat/shards" | grep UNASSIGNED | awk '{print $1 $2}'

结果中,第一列为索引名,第二列为分片号

2.3调整分片

已kibana为例(ES版本为6.3.0):
假设索引test的1号分片是unassigned shard,由192.168.1.1_9200节点调整到192.168.1.2_9200

POST /_cluster/reroute
{
    "commands" : [
        {
            "move" : {
                "index" : "test", "shard" : 1,
                "from_node" : "192.168.1.1_9200", "to_node" : "192.168.1.2_9200"
            }
        }
    ]
}

调整完成后,集群状态将调整为Green

相关文章

网友评论

    本文标题:Elasticsearch unassigned shard

    本文链接:https://www.haomeiwen.com/subject/azrzvqtx.html