Bootstrap

ES客户端停写,关闭和开启集群shard allocation

客户端停写
1、关闭集群shard allocation
# curl -H "Content-Type: application/json" -XPUT http://`hostname -i`:9100/_cluster/settings -d '{"persistent": {"cluster.routing.allocation.enable": "none"}}'
{"acknowledged":true,"persistent":{"cluster":{"routing":{"allocation":{"enable":"none"}}}},"transient":{}}

2、执行同步刷新
# curl -H "Content-Type: application/json" -XPOST http://`hostname -i`:9100/_flush/synced 
{"_shards":{"total":0,"successful":0,"failed":0}}

3、停es集群进程

4、重新开启集群shard allocation
# curl -H "Content-Type: application/json" -XPUT http://`hostname -i`:9100/_cluster/settings -d '{"persistent": {"cluster.routing.allocation.enable": "all"}}'
{"acknowledged":true,"persistent":{"cluster":{"routing":{"allocation":{"enable":"all"}}}},"transient":{}}
如果有kibana客户端,可以用一下方法:
1 客户端停写
1.1 关闭集群shard allocation
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "none"
}
}
1.2 执行同步刷新
POST _flush/synced
1.3 停es服务
2 启es集群操作
2.1 启动es服务
2.2 重新开启集群shard allocation
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "all"
}
} 
;