---
title: "elasticsearch 重启节点"
author: "leichenlei"
date: "2017-07-19T09:48:48Z"
tags: []
categories: ["互联网"]
slug: "elasticsearch"
draft: false
lastmod: "2017-07-19T09:48:48Z"
id: 2384967
url: "https://leichenlei.iteye.com/blog/2384967"
---

由于修改配置等原因，elasticsearch需要重启节点，如果操作不当会造成整个集群崩溃，主要是因为elasticsearch有再平衡策略，就是当一个节点停机，整个集群就开始执行再平衡策略，集群开始移动分片，elasticsearch的健康状态不再是绿色。

 

可以通过集群API  关闭再平衡策略，再进行节点重启：

 

```
1，put  http://localhost:9092/_cluster/settings
   {
        "transient" : {
            "cluster.routing.allocation.enable" : "none"
        }
    }

2，重启一个节点


3，put  http://localhost:9092/_cluster/settings
{
    "transient" : {
        "cluster.routing.allocation.enable" : "all"
    }
}


重复上面的步骤，全部重启所有节点
```