ES平滑下线节点操作手册

 

检查集群配置

在做节点下线操作之前,建议先检查 master-eligible 节点的数量与 minimum_master_nodes 配置,确认下线节点不会影响集群可用性与稳定性,特别是针对小集群。minimum_master_nodes和具有master资格的node数,一般可以设置为3

discovery.zen.minimum_master_nodes: 3

node.master: true


将节点从集群路由策略中排除

通过以下方式将下线节点从集群路由策略中排除:

# Kibana dev tools

PUT _cluster/settings

{

  "transient" : {

    "cluster.routing.allocation.exclude._ip" "IP_ADDRESS"

  }

}

上面其实会触发分片的 Allocation 机制,涉及的参数为cluster.routing.allocation.exclude.{attribute},其中 {attribute} 表示节点的匹配方式

_name

Match nodes by node name

_host_ip

Match nodes by host IP address (IP associated with hostname)

_publish_ip

Match nodes by publish IP address

_ip

Match either _host_ip or _publish_ip

_host

Match nodes by hostname

_id

Match nodes by node id

执行后将导致该节点上的分片慢慢迁移到其他节点,可能会花几分钟甚至更多的时间,期间不会影响正常业务。

等待所有分区与数据迁移完成

执行下列命令,等待集群分片前已完成,集群变绿

# Kibana dev tools

GET _cluster/health

停掉节点服务进程

Kill {pid}

恢复集群路由策略

PUT _cluster/settings

{

  "transient": {

    "cluster.routing.allocation.exclude._ip"null

  }

}

至此节点下线操作完成。这里的目标是将节点从集群中下线剔除,并没有上线操作,如果要再次上线该节点,只需要启动服务即可,节点会自动加入集群并分配分片。

 


参考资料:

https://cloud.tencent.com/developer/article/1596752

https://www.elastic.co/guide/en/elasticsearch/reference/7.6/allocation-filtering.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值