多主机搭建etcd集群

下载https://github.com/etcd-io/etcd/releases/download/v3.4.10/etcd-v3.4.10-linux-amd64.tar.gz分别放到两台主机上,因为wget太慢了。

HOST1:101.200.243.176(公网)172.17.229.160(内网)
HOST2:110.43.50.186(公网)10.0.0.254(内网)

HOST1

[root@peiqi test]# tar xzvf etcd-v3.4.10-linux-amd64.tar.gz
[root@peiqi test]# mv etcd-v3.4.10-linux-amd64 etcd && cd etcd
[root@peiqi etcd]# ./etcd --name docker01 --listen-peer-urls http://172.17.229.160:2380 --listen-client-urls http://172.17.229.160:2379,http://127.0.0.1:2379 --initial-advertise-peer-urls http://101.200.243.176:2380 --advertise-client-urls http://127.0.0.1:2379,http://101.200.243.176:2379 --initial-cluster docker01=http://101.200.243.176:2380,docker02=http://110.43.50.186:2380 --initial-cluster-token etcd-cluster --initial-cluster-state new

HOST2

[root@qiaozhi test]# tar xzvf etcd-v3.4.10-linux-amd64.tar.gz
[root@qiaozhi test]# mv etcd-v3.4.10-linux-amd64 etcd && cd etcd
[root@qiaozhi etcd]# ./etcd --name docker02 --listen-peer-urls http://10.0.0.254:2380 --listen-client-urls http://10.0.0.254:2379,http://127.0.0.1:2379 --initial-advertise-peer-urls http://110.43.50.186:2380 --advertise-client-urls http://127.0.0.1:2379,http://110.43.50.186:2379 --initial-cluster docker01=http://101.200.243.176:2380,docker02=http://110.43.50.186:2380 --initial-cluster-token etcd-cluster --initial-cluster-state new

检查cluster状态

[root@peiqi etcd]# ./etcdctl member list
23311ae1cecb97ad, started, docker01, http://101.200.243.176:2380, http://101.200.243.176:2379,http://127.0.0.1:2379, false
d95dada82a934bb0, started, docker02, http://110.43.50.186:2380, http://110.43.50.186:2379,http://127.0.0.1:2379, false

 

posted @ 2020-08-04 19:34  就俗人一个  阅读(387)  评论(0编辑  收藏  举报