How to stop/shut down an elasticsearch node?

前端 未结 11 1829
忘掉有多难
忘掉有多难 2021-01-29 22:34

I want to restart an elasticsearch node with a new configuration. What is the best way to gracefully shut down an node?

Is killing the process the best way of shutting t

11条回答
  •  走了就别回头了
    2021-01-29 22:55

    Considering you have 3 nodes.

    Prepare your cluster

    export ES_HOST=localhost:9200
    
    # Disable shard allocation
    curl -X PUT "$ES_HOST/_cluster/settings" -H 'Content-Type: application/json' -d'
    {
      "persistent": {
        "cluster.routing.allocation.enable": "none"
      }
    }
    '
    
    # Stop non-essential indexing and perform a synced flush
    curl -X POST "$ES_HOST/_flush/synced"
    

    Stop elasticsearch service in each node

    # check nodes
    export ES_HOST=localhost:9200
    curl -X GET "$ES_HOST/_cat/nodes"
    
    # node 1
    systemctl stop elasticsearch.service
    
    # node 2
    systemctl stop elasticsearch.service
    
    # node 3
    systemctl stop elasticsearch.service
    

    Restarting cluster again

    # start
    systemctl start elasticsearch.service
    
    # Reenable shard allocation once the node has joined the cluster
    curl -X PUT "$ES_HOST/_cluster/settings" -H 'Content-Type: application/json' -d'
    {
      "persistent": {
        "cluster.routing.allocation.enable": null
      }
    }
    '
    

    Tested on Elasticseach 6.5

    Source:

    1. https://www.elastic.co/guide/en/elasticsearch/reference/6.5/stopping-elasticsearch.html
    2. https://www.elastic.co/guide/en/elasticsearch/reference/6.5/rolling-upgrades.html

提交回复
热议问题