关于 ES集群 优雅重启

关于 ES集群 优雅重启

如何正确的关闭ES或者ES集群

第一步,禁止分片自动分布

PUT _cluster/settings

{
  "persistent": {
    "cluster.routing.allocation.enable": "none"
  }
}

第二步,执行同步刷新

POST _flush/synced

第三步,各节点逐个关闭

# 通过服务关闭
sudo systemctl stop elasticsearch.service
#杀进程关闭
kill $(cat pid.txt)

如何启动ES集群

第一步,执行完操作后逐个启动节点

cd $ES_HOME/bin
./elasticsearch -d -p $ES_HOME/pid.txt

第二步,等待所有节点加入集群

查看集群状态是否为"green"

GET _cat/health

GET _cat/nodes

第三步,启用分片自动分布

PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.enable": null
  }
}

第四步,等待集群可用

通过集群的状态和恢复进程监控集群是否可用

GET _cat/health

GET _cat/recovery

原文地址:https://www.cnblogs.com/carry00/p/14021616.html