etcd节点替换

完全新实例替换

从集群中删除节点

$ etcdctl member remove a8266ecf031671f3

删除的即使是leader,也是安全的,但在选举新leader期间,集群会处于非活跃状态。此持续时间通常是选举超时时间加上投票过程的时间

添加新节点

$ etcdctl member add infra3 --peer-urls=http://10.0.1.13:2380

执行此命令会并打印出成功启动新实例所需的环境变量

在使用新成员的相关标志启动新的 etcd 进程,新实例会立刻开始同步追赶集群

!!!如果添加多个成员,需要逐一添加,在添加更多新成员之前验证其是否正确启动

迁移异常member的数据目录

如果集群的v2 data大小超过50MB,建议执行此操作

当计划进行机器维护或退役时,可以将 etcd 成员迁移到另一台机器,而不会丢失数据和更改成员 ID

1.停止etcd进程

2.拷贝etcd data数据

3.更新peer URL

3.1)查看确认集群信息

$ export ETCDCTL_ENDPOINT=http://10.0.1.10:2379,http://10.0.1.11:2379,http://10.0.1.12:2379
$ etcdctl member list
84194f7c5edd8b37: name=infra0 peerURLs=http://10.0.1.10:2380 clientURLs=http://127.0.0.1:2379,http://10.0.1.10:2379
b4db3bf5e495e255: name=infra1 peerURLs=http://10.0.1.11:2380 clientURLs=http://127.0.0.1:2379,http://10.0.1.11:2379
bc1083c870280d44: name=infra2 peerURLs=http://10.0.1.12:2380 clientURLs=http://127.0.0.1:2379,http://10.0.1.12:2379

 

3.2)执行更新 

$ curl http://10.0.1.10:2379/v2/members/b4db3bf5e495e255 -XPUT \
-H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.1.13:2380"]}'

或者

$ etcdctl member update b4db3bf5e495e255 http://10.0.1.13:2380

4.使用相同的配置和数据目录的副本启动新实例

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值