目的:es架构:5台master,9台data 服务器资源太多,计划收缩4台data,2台master
一、data节点收缩,命令以下:node
#排除:data-1,data-2,data-3,data-4 4台data节点 curl -H "Content-Type: application/json" -XPUT http://10.10.1.24:9200/_cluster/settings -d' { "persistent" : { "cluster.routing.allocation.exclude._name" : "data-1,data-2,data-3,data-4" } }'
require表示必须分配到指定node,include表示能够分配到指定node,exclude表示不容许分配到指定Node,cluster的配置会覆盖index级别的配置,好比index include某个node,cluster exclude某个node,最后的结果是exclude某个node,上面{attribute}表示node的匹配方式有:
_name 匹配node名称,多个node名称用逗号隔开
_ip 匹配node ip,多个ip用逗号隔开
_host 匹配node的host name 多个host name用逗号隔开
让_name匹配到对应的node便可 也能够使用_ip _host
persistent表示永久生效,transient表示暂时生效,重启后无效json
从新加入节点,清空_name变量:服务器
curl -H "Content-Type: application/json" -XPUT http://10.10.1.24:9200/_cluster/settings -d' { "persistent" : { "cluster.routing.allocation.exclude._name" : "" } }'
二、经过kibana监控观察分片是否所有迁移到其余node节点,迁移后中止es。架构