etcd v3 ssl 集群添加新节点

集群搭建

下面只用同一台服务器进行三个成员节点的开启

节点1

./etcd --name cd0 --initial-advertise-peer-urls http://127.0.0.1:2380 --listen-peer-urls http://127.0.0.1:2380 --listen-client-urls http://127.0.0.1:2379 --advertise-client-urls http://127.0.0.1:2379 --initial-cluster-token etcd-cluster-1 --initial-cluster cd0=http://127.0.0.1:2380,cd1=http://127.0.0.1:2480,cd2=http://127.0.0.1:2580 --initial-cluster-state new

节点2

./etcd --name cd1 --initial-advertise-peer-urls http://127.0.0.1:2480 --listen-peer-urls http://127.0.0.1:2480 --listen-client-urls http://127.0.0.1:2479 --advertise-client-urls http://127.0.0.1:2479 --initial-cluster-token etcd-cluster-1 --initial-cluster cd0=http://127.0.0.1:2380,cd1=http://127.0.0.1:2480,cd2=http://127.0.0.1:2580 --initial-cluster-state new

节点3

./etcd --name cd2 --initial-advertise-peer-urls http://127.0.0.1:2580 --listen-peer-urls http://127.0.0.1:2580 --listen-client-urls http://127.0.0.1:2579 --advertise-client-urls http://127.0.0.1:2579 --initial-cluster-token etcd-cluster-1 --initial-cluster cd0=http://127.0.0.1:2380,cd1=http://127.0.0.1:2480,cd2=http://127.0.0.1:2580 --initial-cluster-state new

查询 member 列表

export ETCDCTL_API=3
ENDPOINTS=127.0.0.1:2379,127.0.0.1:2479,127.0.0.1:2579

./etcdctl --endpoints=$ENDPOINTS member list

运行结果:

98f0c6bf64240842, started, cd2, http://127.0.0.1:2580, http://127.0.0.1:2579
bf9071f4639c75cc, started, cd0, http://127.0.0.1:2380, http://127.0.0.1:2379
e3ba87c3b4858ef1, started, cd1, http://127.0.0.1:2480, http://127.0.0.1:2479

添加 member 节点

member add 添加节点

./etcdctl --endpoints=$ENDPOINTS member add cd3 --peer-urls=http://127.0.0.1:2180
Member b9057cfdc8ff17ce added to cluster 9da8cd75487bd6dc

运行结果:

ETCD_NAME="cd3"
ETCD_INITIAL_CLUSTER="cd2=http://127.0.0.1:2580,cd3=http://127.0.0.1:2180,cd0=http://127.0.0.1:2380,cd1=http://127.0.0.1:2480"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://127.0.0.1:2180"
ETCD_INITIAL_CLUSTER_STATE="existing"

查询 member 节点列表信息

./etcdctl --endpoints=$ENDPOINTS member list

运行结果:

98f0c6bf64240842, started, cd2, http://127.0.0.1:2580, http://127.0.0.1:2579
b9057cfdc8ff17ce, unstarted, , http://127.0.0.1:2180, 
bf9071f4639c75cc, started, cd0, http://127.0.0.1:2380, http://127.0.0.1:2379
e3ba87c3b4858ef1, started, cd1, http://127.0.0.1:2480, http://127.0.0.1:2479

通过查询结果可以发现:http://127.0.0.1:2180 显示状态为:unstarted

启动新节点

./etcd --name cd3 --listen-client-urls http://127.0.0.1:2179 --advertise-client-urls http://127.0.0.1:2179 --listen-peer-urls http://127.0.0.1:2180 --initial-advertise-peer-urls http://127.0.0.1:2180 --initial-cluster-state existing --initial-cluster cd2=http://127.0.0.1:2580,cd0=http://127.0.0.1:2380,cd3=http://127.0.0.1:2180,cd1=http://127.0.0.1:2480 --initial-cluster-token etcd-cluster-1

查询 member 节点列表信息

./etcdctl --endpoints=$ENDPOINTS member list

运行结果:

98f0c6bf64240842, started, cd2, http://127.0.0.1:2580, http://127.0.0.1:2579
b9057cfdc8ff17ce, started, cd3, http://127.0.0.1:2180, http://127.0.0.1:2179
bf9071f4639c75cc, started, cd0, http://127.0.0.1:2380, http://127.0.0.1:2379
e3ba87c3b4858ef1, started, cd1, http://127.0.0.1:2480, http://127.0.0.1:2479

删除 member

./etcdctl --endpoints=$ENDPOINTS member remove b9057cfdc8ff17ce

运行结果:

Member b9057cfdc8ff17ce removed from cluster 9da8cd75487bd6dc

查询 member 节点列表信息

./etcdctl --endpoints=$ENDPOINTS member list

运行结果:

98f0c6bf64240842, started, cd2, http://127.0.0.1:2580, http://127.0.0.1:2579
bf9071f4639c75cc, started, cd0, http://127.0.0.1:2380, http://127.0.0.1:2379
e3ba87c3b4858ef1, started, cd1, http://127.0.0.1:2480, http://127.0.0.1:2479


作者:RickJay
链接:https://www.jianshu.com/p/00185e3eb579
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
原文地址:https://www.cnblogs.com/lvcisco/p/11884154.html