centos下安装etcd集群

环境准备
172.16.50.30(centos7.x)
172.16.50.31(centos7.x)

  • 在172.16.50.30这台机器上面运行
#!/bin/bash
yum install wget -y
cd /opt && wget https://github.com/etcd-io/etcd/releases/download/v3.3.10/etcd-v3.3.10-linux-amd64.tar.gz
tar zxvf etcd-v3.3.10-linux-amd64.tar.gz && cd etcd-v3.3.10-linux-amd64
nohup ./etcd --name docker-node1 \
--initial-advertise-peer-urls http://172.16.50.30:2380 \
--listen-peer-urls http://172.16.50.30:2380 \
--listen-client-urls http://172.16.50.30:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://172.16.50.30:2379 \
--initial-cluster-token etcd-cluster \
--initial-cluster docker-node1=http://172.16.50.30:2380,docker-node2=http://172.16.50.31:2380 \
--initial-cluster-state new&
  • 在172.16.50.31这台机器上面运行
#!/bin/bash
yum install wget -y
cd /opt && wget https://github.com/etcd-io/etcd/releases/download/v3.3.10/etcd-v3.3.10-linux-amd64.tar.gz
tar zxvf etcd-v3.3.10-linux-amd64.tar.gz && cd etcd-v3.3.10-linux-amd64
nohup ./etcd --name docker-node2 \
--initial-advertise-peer-urls http://172.16.50.31:2380 \
--listen-peer-urls http://172.16.50.31:2380 \
--listen-client-urls http://172.16.50.31:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://172.16.50.31:2379 \
--initial-cluster-token etcd-cluster \
--initial-cluster docker-node1=http://172.16.50.30:2380,docker-node2=http://172.16.50.31:2380 \
--initial-cluster-state new&
  • 查看集群状态
./etcdctl cluster-health