etcd静态集群部署(Centos 3节点)

当确定集群的成员个数及其信息,可以使用静态模式(Static)部署集群,具体步骤如下:

一、机器信息

hostname ip 系统版本
infra0 172.17.0.2 CentOS Linux release 7.4.1708 (Core)
infra1 172.17.0.3 CentOS Linux release 7.4.1708 (Core)
infra2 172.17.0.4 CentOS Linux release 7.4.1708 (Core)

二、下载etcd二进制包

wget https://github.com/coreos/etcd/releases/download/v3.2.10/etcd-v3.2.10-linux-amd64.tar.gz
tar -xf etcd-v3.2.10-linux-amd64.tar.gz
sudo mv etcd-v3.2.10-linux-amd64/etcd* /usr/local/bin/
etcd --version 
--------------------------------
etcd Version: 3.2.10
Git SHA: 694728c
Go Version: go1.8.5
Go OS/Arch: linux/amd64
--------------------------------

etcdctl --version
------------------------------
etcdctl version: 3.2.10
API version: 2-
------------------------------

三、启动节点

1.infra0节点执行命令

NODE_INFRA0_IP=172.17.0.2
NODE_INFRA1_IP=172.17.0.3
NODE_INFRA2_IP=172.17.0.4
mkdir -p /data/etcd/data_dir
nohup etcd --name infra0 --data-dir /data/etcd/data_dir \
  --initial-advertise-peer-urls http://${NODE_INFRA0_IP}:2380 \
  --listen-peer-urls http://${NODE_INFRA0_IP}:2380 \
  --listen-client-urls http://${NODE_INFRA0_IP}:2379,http://127.0.0.1:2379 \
  --advertise-client-urls http://${NODE_INFRA0_IP}:2379 \
  --initial-cluster-token etcd-cluster-1 \
  --initial-cluster infra0=http://${NODE_INFRA0_IP}:2380,infra1=http://${NODE_INFRA1_IP}:2380,infra2=http://${NODE_INFRA2_IP}:2380 \
  --initial-cluster-state new >> /data/etcd/etcd.log 2>&1 &

2.infra1节点执行命令

NODE_INFRA0_IP=172.17.0.2
NODE_INFRA1_IP=172.17.0.3
NODE_INFRA2_IP=172.17.0.4
mkdir -p /data/etcd/data_dir
nohup etcd --name infra1 --data-dir /data/etcd/data_dir \
  --initial-advertise-peer-urls http://${NODE_INFRA1_IP}:2380 \
  --listen-peer-urls http://${NODE_INFRA1_IP}:2380 \
  --listen-client-urls http://${NODE_INFRA1_IP}:2379,http://127.0.0.1:2379 \
  --advertise-client-urls http://${NODE_INFRA1_IP}:2379 \
  --initial-cluster-token etcd-cluster-1 \
  --initial-cluster infra0=http://${NODE_INFRA0_IP}:2380,infra1=http://${NODE_INFRA1_IP}:2380,infra2=http://${NODE_INFRA2_IP}:2380 \
  --initial-cluster-state new >> /data/etcd/etcd.log 2>&1 &

3.infra2节点执行命令

NODE_INFRA0_IP=172.17.0.2
NODE_INFRA1_IP=172.17.0.3
NODE_INFRA2_IP=172.17.0.4
mkdir -p /data/etcd/data_dir
nohup etcd --name infra2 --data-dir /data/etcd/data_dir \
  --initial-advertise-peer-urls http://${NODE_INFRA2_IP}:2380 \
  --listen-peer-urls http://${NODE_INFRA2_IP}:2380 \
  --listen-client-urls http://${NODE_INFRA2_IP}:2379,http://127.0.0.1:2379 \
  --advertise-client-urls http://${NODE_INFRA2_IP}:2379 \
  --initial-cluster-token etcd-cluster-1 \
  --initial-cluster infra0=http://${NODE_INFRA0_IP}:2380,infra1=http://${NODE_INFRA1_IP}:2380,infra2=http://${NODE_INFRA2_IP}:2380 \
  --initial-cluster-state new >> /data/etcd/etcd.log 2>&1 &

四、检查集群状态

etcdctl cluster-health #在任意节点执行

member 9198227ac1a2c055 is healthy: got healthy result from http://172.17.0.3:2379
member 983274ac8c0149ec is healthy: got healthy result from http://172.17.0.2:2379
member ab3fbede047aa1ac is healthy: got healthy result from http://172.17.0.4:2379
cluster is healthy


猜你喜欢

转载自blog.csdn.net/u014042372/article/details/80667798