ES 5.2 版本安全重启
官方文档 https://www.elastic.co/guide/en/elasticsearch/reference/5.2/rolling-upgrades.html
# 1. 关闭shard自动均衡
PUT /_cluster/settings?pretty
{
"transient": {
"cluster.routing.allocation.enable": "none"
}
}
# 2. 停止非必要的索引并执行同步刷新(可选)
POST /_flush/synced?pretty
# 3. 停止并升级单个节点
# 4. 升级节点
# 5. 启动升级后的节点
#启动现在升级的节点,通过检查日志文件或检查此请求的输出来确认它加入了集群
GET _cat/nodes
## 6.打开shard重新分配
PUT /_cluster/settings?pretty
{
"transient": {
"cluster.routing.allocation.enable": "all"
}
}
# 7. 等待节点恢复
GET /_cat/health?pretty
#没有同步刷新的碎片可能需要一些时间来恢复。单个分片的恢复状态可以通过_cat/recovery请求监控
GET /_cat/recovery?pretty
# 8. 重复
#当集群稳定且节点恢复后,对所有剩余节点重复上述步骤