验证版本:5.5.3
- 停止节点分片
curl -XPUT http://192.168.10.247:9200/_cluster/settings -H 'Content-Type: application/json' -d ' { "transient": { "cluster.routing.allocation.exclude._ip": "192.168.10.249" #多个IP用逗号隔开 } }'
- 停止后观察状态
理论上ES会自动把192.168.10.249上面的分片迁走,剩余可用节点少于2则不会触发迁移
curl -s http://192.168.10.247:9200/_cat/shards curl -s http://192.168.10.247:9200/_cluster/health?pretty
- 关闭ES进程
注意关闭前客户端仍然可以通过此节点查询数据
su - <ES_USER> kill <ES_PID>
- 清除分片设置
curl -XPUT http://192.168.10.247:9200/_cluster/settings -H 'Content-Type: application/json' -d ' { "transient": { "cluster.routing.allocation.exclude._ip": null } }'
- 更新配置
剩余节点修改elasticsearch.yml删除已经下线的机器(非必要,可以留着以后方便扩容)
discovery.zen.ping.unicast.hosts: ["192.168.10.247", "192.168.10.248", "192.168.10.249"] -> discovery.zen.ping.unicast.hosts: ["192.168.10.247", "192.168.10.248"]