es分片迁移

集群节点临时重启
当修改配置时可能需要重启集群才生效,或者集群发生严重错误无法恢复时都可能需要重启集群
一个集群节点重启前要先临时禁用自动分配,设置cluster.routing.allocation.enable为none,否则节点停止后,当前节点的分片会自动分配到其他节点上,本节点启动后需要等其他节点RECOVERING后才会RELOCATING,也就是分片在其他节点恢复后又转移回来,浪费大量时间
首先禁用自动分配
curl -XPUT http://192.168.1.83:9200/_cluster/settings -d '{
    "transient" : {
        "cluster.routing.allocation.enable" : "none"
    }
}'

#################################################

curl -XPUT 192.168.1.83:9200/_cluster/settings -d'{
    "transient": {
        "cluster.routing.allocation.enable": "none"
    }
}'
然后再重启集群
集群启动后再改回配置
curl -XPUT http://127.0.0.1:9200/_cluster/settings -d '{
    "transient" : {
        "cluster.routing.allocation.enable" : "all"
    }
}'

迁移具体的分片到其他节点上去

curl -XPOST '192.168.1.83:9200/_cluster/reroute' -d  '{
    "commands" : [
        {
            "move" : {
                "index" : "info-test", "shard" : 3,
                "from_node" : "192.168.1.81", "to_node" : "192.168.1.82"
            }
        }
    ]
}'

手动分配分片

curl -XPOST ‘192.168.1.83:9200/_cluster/reroute?retry_failed’

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章