elasticsearch safe restart

安全重启elasticsearch节点

  1. 刷新到磁盘

    1
    2
    [root@ip-172-31-90-193 ~]# curl -XGET http://172.31.90.193:9200/_flush
    {"_shards":{"total":152,"successful":152,"failed":0}}
  2. 先暂停集群的shard自动均衡

    1
    2
    3
    4
    5
    6
    7
    [root@ip-172-31-90-193 ~]# curl -XPUT http://172.31.90.193:9200/_cluster/settings -d '
    > {
    > "transient" : {
    > "cluster.routing.allocation.enable" : "none"
    > }
    > }'
    {"acknowledged":true,"persistent":{},"transient":{"cluster":{"routing":{"allocation":{"enable":"none"}}}}}
  3. 停止node节点

    1
    2
    3
    4
    5
    6
    [root@ip-172-31-90-193 ~]# curl -XGET http://172.31.90.193:9200/_cat/nodes?v
    host ip heap.percent ram.percent load node.role master name
    172.31.90.193 172.31.90.193 34 99 2.07 d * Molten Man
    172.31.90.45 172.31.90.45 43 99 0.75 d m node-2

    [root@ip-172-31-90-193 ~]# curl -XPOST http://192.168.1.3:9200/_cluster/nodes/_local/_shutdown
  4. 启动node节点

  5. 开启集群的shard自动均衡

    1
    2
    3
    4
    5
    6
    7
    [root@ip-172-31-90-193 ~]# curl -XPUT http://172.31.90.193:9200/_cluster/settings -d'
    > {
    > "transient" : {
    > "cluster.routing.allocation.enable" : "all"
    > }
    > }'
    {"acknowledged":true,"persistent":{},"transient":{"cluster":{"routing":{"allocation":{"enable":"all"}}}}}