#安装etcd3.4
wget https://github.com/etcd-io/etcd/releases/download/v3.4.18/etcd-v3.4.18-linux-amd64.tar.gz
tar xf etcd-v3.4.18-linux-amd64.tar.gz
cp etcd-v3.4.18-linux-amd64/etcd /usr/bin/
#创建三个不同的数据目录
mkdir -p /usr/local/etcd/node1
mkdir -p /usr/local/etcd/node2
mkdir -p /usr/local/etcd/node3
#创建配置文件的目录
mkdir –p /usr/local/etcd/conf
cd /usr/local/etcd/conf
#在 /usr/local/etcd/conf下创建三个配置文件
node1.yml
name: node1
data-dir: /usr/local/etcd/node1
listen-client-urls: 'http://10.1.60.32:9002'
advertise-client-urls: 'http://10.1.60.32:9002'
listen-peer-urls: 'http://10.1.60.32:9001'
initial-advertise-peer-urls: 'http://10.1.60.32:9001'
initial-cluster: node1=http://10.1.60.32:9001,node2=http://10.1.60.32:9003,node3=http://10.1.60.32:9005
initial-cluster-token: etcd-cluster-1
initial-cluster-state: new
node2.yml
name: node2
data-dir: /usr/local/etcd/node2
listen-client-urls: 'http://10.1.60.32:9004'
advertise-client-urls: 'http://10.1.60.32:9004'
listen-peer-urls: 'http://10.1.60.32:9003'
initial-advertise-peer-urls: 'http://10.1.60.32:9003'
initial-cluster: node1=http://10.1.60.32:9001,node2=http://10.1.60.32:9003,node3=http://10.1.60.32:9005
initial-cluster-token: etcd-cluster-1
initial-cluster-state: new
node3.yml
name: node3
data-dir: /usr/local/etcd/node3
listen-client-urls: 'http://10.1.60.32:9006'
advertise-client-urls: 'http://10.1.60.32:9006'
listen-peer-urls: 'http://10.1.60.32:9005'
initial-advertise-peer-urls: 'http://10.1.60.32:9005'
initial-cluster: node1=http://10.1.60.32:9001,node2=http://10.1.60.32:9003,node3=http://10.1.60.32:9005
initial-cluster-token: etcd-cluster-1
initial-cluster-state: new
#分别启动3个节点
etcd --config-file=/usr/local/etcd/conf/node1.yml &
etcd --config-file=/usr/local/etcd/conf/node2.yml &
etcd --config-file=/usr/local/etcd/conf/node3.yml &
#查看集群成员列表
[root@VM-60-32-centos ~]# etcdctl --endpoints http://10.1.60.32:9002,http://10.1.60.32:9004,http://10.1.60.32:9006 member list
564f2f648823b8d, started, node1, http://10.1.60.32:9001, http://10.1.60.32:9002, false
4d1b97662f8941f2, started, node2, http://10.1.60.32:9003, http://10.1.60.32:9004, false
7648a8047d2489ee, started, node3, http://10.1.60.32:9005, http://10.1.60.32:9006, false
#在这里插入代码片查看集群成员健康情况
[root@VM-60-32-centos ~]# etcdctl --endpoints http://10.1.60.32:9002,http://10.1.60.32:9004,http://10.1.60.32:9006 endpoint health
http://10.1.60.32:9004 is healthy: successfully committed proposal: took = 1.286839ms
http://10.1.60.32:9002 is healthy: successfully committed proposal: took = 1.328996ms
http://10.1.60.32:9006 is healthy: successfully committed proposal: took = 1.359183ms