添加一个节点
添加节点相对麻烦一点,分作两步:
- 使用
etcdctl member add
或 members API 添加节点 - 使用新的集群配置启动新加入的节点,包含一份所有当前成员的列表
[root@h104 etcd-v2.2.4-linux-amd64]# ./etcdctl member list
1b80a88a471eb4b8: name=h104 peerURLs=http://192.168.100.104:2380 clientURLs=http://192.168.100.104:2379
940f6e83e019a03f: name=docker peerURLs=http://192.168.100.103:2380 clientURLs=http://192.168.100.103:2379
[root@h104 etcd-v2.2.4-linux-amd64]#
[root@h104 etcd-v2.2.4-linux-amd64]# ./etcdctl member add new-h102 http://192.168.100.102:2380
Added member named new-h102 with ID cdc1e5e338e27adc to cluster
ETCD_NAME="new-h102"
ETCD_INITIAL_CLUSTER="h104=http://192.168.100.104:2380,docker=http://192.168.100.103:2380,new-h102=http://192.168.100.102:2380"
ETCD_INITIAL_CLUSTER_STATE="existing"
[root@h104 etcd-v2.2.4-linux-amd64]#
执行完后,终端反馈出几个关键的环境变量
要使用这些环境变量来运行新加入的节点,当前情况下新节点还没运行
代码语言:javascript复制[root@h104 etcd-v2.2.4-linux-amd64]# ./etcdctl member list
1b80a88a471eb4b8: name=h104 peerURLs=http://192.168.100.104:2380 clientURLs=http://192.168.100.104:2379
940f6e83e019a03f: name=docker peerURLs=http://192.168.100.103:2380 clientURLs=http://192.168.100.103:2379
cdc1e5e338e27adc[unstarted]: peerURLs=http://192.168.100.102:2380
[root@h104 etcd-v2.2.4-linux-amd64]#