搭建Etcd集群
docker pull quay.io/coreos/etcd:v3.3.1
docker run -d --name etcd1 quay.io/coreos/etcd:v3.3.1 etcd -name etcd1 -advertise-client-urls http://172.17.0.2:2379 -initial-advertise-peer-urls http://172.17.0.2:2380 -listen-client-urls http://0.0.0.0:2379 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster-token etcd-cluster -initial-cluster "etcd1=http://172.17.0.2:2380,etcd2=http://172.17.0.3:2380,etcd3=http://172.17.0.4:2380" -initial-cluster-state new
docker run -d --name etcd2 quay.io/coreos/etcd:v3.3.1 etcd -name etcd2 -advertise-client-urls http://172.17.0.3:2379 -initial-advertise-peer-urls http://172.17.0.3:2380 -listen-client-urls http://0.0.0.0:2379 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster-token etcd-cluster -initial-cluster "etcd1=http://172.17.0.2:2380,etcd2=http://172.17.0.3:2380,etcd3=http://172.17.0.4:2380" -initial-cluster-state new
docker run -d --name etcd3 quay.io/coreos/etcd:v3.3.1 etcd -name etcd3 -advertise-client-urls http://172.17.0.4:2379 -initial-advertise-peer-urls http://172.17.0.4:2380 -listen-client-urls http://0.0.0.0:2379 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster-token etcd-cluster -initial-cluster "etcd1=http://172.17.0.2:2380,etcd2=http://172.17.0.3:2380,etcd3=http://172.17.0.4:2380" -initial-cluster-state new
查看集群健康状态
export ETCDCTL_API=3
etcdctl --endpoints="http://172.17.0.2:2379,http://172.17.0.3:2379,http://172.17.0.4:2379" endpoint health
参数名 |
含义 |
-name |
设置成员节点的别名 |
-advertise-client-urls |
广播到集群中本成员的监听客户端请求的地址 |
-initial-advertise-peer-urls |
广播到集群中本成员的Peer监听通信地址 |
-listen-client-urls |
客户端请求的监听地址列表 |
-listen-peer-urls |
Peer消息的监听服务地址列表 |
-initial-cluster-token |
启动集群的时候指定集群口令,拥有相同token才能加入同一集群 |
-initial-cluster |
所有集群节点的地址列表 |
-initial-cluster-state |
初始化集群状态,默认为new,existing表示加入到已有集群 |
--quota-backend-bytes=8589934592 --auto-compaction-mode=revision --auto-compaction-retention=1000000 |
配额从默认2G改成8G |
参考资料