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’

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