1. 安装
1.1 下载
https://github.com/etcd-io/etcd/releases
找到对应的版本下载下来 解压到指定目录下
这里我创建 /home/etcd目录 文件解压在这里
1.2 创建目录
mkdir node1 node2 node3
1.3 创建shell脚本
vim node1/start.sh
/home/etcd/etcd-v3.5.0-linux-amd64/etcd --name infra1 --initial-advertise-peer-urls http://127.0.0.1:2381 \
--listen-peer-urls http://127.0.0.1:2381 \
--listen-client-urls http://127.0.0.1:2379 \
--advertise-client-urls http://127.0.0.1:2379 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra1=http://127.0.0.1:2381,infra2=http://127.0.0.1:2382,infra3=http://127.0.0.1:2383 \
--initial-cluster-state newvim node2/start.sh
/home/etcd/etcd-v3.5.0-linux-amd64/etcd --name infra2 --initial-advertise-peer-urls http://127.0.0.1:2382 \
--listen-peer-urls http://127.0.0.1:2382 \
--listen-client-urls http://127.0.0.1:2378 \
--advertise-client-urls http://127.0.0.1:2378 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra1=http://127.0.0.1:2381,infra2=http://127.0.0.1:2382,infra3=http://127.0.0.1:2383 \
--initial-cluster-state newvim node3/start.sh
/home/etcd/etcd-v3.5.0-linux-amd64/etcd --name infra3 --initial-advertise-peer-urls http://127.0.0.1:2383 \
--listen-peer-urls http://127.0.0.1:2383 \
--listen-client-urls http://127.0.0.1:2377 \
--advertise-client-urls http://127.0.0.1:2377 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra1=http://127.0.0.1:2381,infra2=http://127.0.0.1:2382,infra3=http://127.0.0.1:2383 \
--initial-cluster-state new
1.4 启动
我这里使用的nohup 启动 有时间的话可以安装supervisor管理
nohup sh /home/etcd/node1/start.sh &
nohup sh /home/etcd/node2/start.sh &
nohup sh /home/etcd/node3/start.sh &
1.5 检查集群是否启动成功
/home/etcd/etcd-v3.5.0-linux-amd64/etcdctl member list