How to stop/shut down an elasticsearch node?

前端 未结 11 1828
忘掉有多难
忘掉有多难 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:43

    use the following command to know the pid of the node already running.

    curl -XGET 'http://localhost:9200/_nodes/process'

    It took me an hour to find out the way to kill the node and could finally do it after using this command in the terminal window.

    0 讨论(0)
  • 2021-01-29 22:46

    This works for me on OSX.

    pkill -f elasticsearch
    
    0 讨论(0)
  • 2021-01-29 22:49

    Answer for Elasticsearch inside Docker:

    Just stop the docker container. It seems to stop gracefully because it logs:

    [INFO ][o.e.n.Node               ] [elastic] stopping ...
    
    0 讨论(0)
  • 2021-01-29 22:54

    The Head plugin for Elasticsearch provides a great web based front end for Elasticsearch administration, including shutting down nodes. It can run any Elasticsearch commands as well.

    0 讨论(0)
  • 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
    0 讨论(0)
  • 2021-01-29 22:58

    If you're running a node on localhost, try to use brew service stop elasticsearch

    I run elasticsearch on iOS localhost.

    0 讨论(0)
提交回复
热议问题