删除一个节点
删除节点相对简单
代码语言: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
84099faad6d56427: name=h102 peerURLs=http://192.168.100.102:2380 clientURLs=http://192.168.100.102: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]# ./etcdctl member remove 84099faad6d56427
Removed member 84099faad6d56427 from cluster
[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]# curl http://localhost:2379/v2/members
{"members":[{"id":"1b80a88a471eb4b8","name":"h104","peerURLs":["http://192.168.100.104:2380"],"clientURLs":["http://192.168.100.104:2379"]},{"id":"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]#
同时 h102 的日志中出现如下信息,最后退出
代码语言:javascript复制...
...
...
2016-02-16 17:42:21.320955 I | rafthttp: the connection with 1b80a88a471eb4b8 became inactive
2016-02-16 17:42:21.321053 E | rafthttp: failed to dial 1b80a88a471eb4b8 on stream MsgApp v2 (the member has been permanently removed from the cluster)
2016-02-16 17:42:21.321402 E | etcdserver: the member has been permanently removed from the cluster
2016-02-16 17:42:21.321452 I | etcdserver: the data-dir used by this member must be removed.
2016-02-16 17:42:21.341262 I | rafthttp: the connection with 940f6e83e019a03f became inactive
2016-02-16 17:42:21.341313 E | rafthttp: failed to dial 940f6e83e019a03f on stream MsgApp v2 (the member has been permanently removed from the cluster)
2016-02-16 17:42:21.342089 E | rafthttp: failed to dial 940f6e83e019a03f on stream Message (net/http: request canceled)
2016-02-16 17:42:21.342314 E | etcdhttp: error removing member 84099faad6d56427 (etcdserver: server stopped)
2016-02-16 17:42:21.342338 E | etcdhttp: got unexpected response error (etcdserver: server stopped)
[root@h102 etcd-v2.2.4-linux-amd64]#
Tip: 直接删除leader也是安全的,只是在选举出新的leader前集群是不可用状态,时长相当于一个选举timeout周期加上投票过程耗费的总时间