etcd集群部署文档
1.部署的服务器ip地址 172.16.0.151 172.16.0.173 172.16.0.220 2.etcd版本 wget https://github.com/etcd-io/etcd/releases/download/v3.5.0/etcd-v3.5.0-linux-amd64.tar.gz 3.三台服务器安装目录 /data/ 4.启动脚本 cd /data/etcd-v3.5.0 [root@im-03 etcd-v3.5.0]cat etcd.sh #For each machine TOKEN=my-etcd-token-1 CLUSTER_STATE=new NAME_1=etcd_1 NAME_2=etcd_2 NAME_3=etcd_3 HOST_1=172.16.0.151 HOST_2=172.16.0.173 HOST_3=172.16.0.220 CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_3}=http://${HOST_3}:2380 # For node 1 THIS_NAME=${NAME_1} THIS_IP=${HOST_1} /data/etcd-v3.5.0/etcd --data-dir=/data/etcd-v3.5.0/data.etcd --name ${THIS_NAME} \ --initial-advertise-peer-urls http://${THIS_IP}:2380 \ --listen-peer-urls http://${THIS_IP}:2380 \ --advertise-client-urls http://${THIS_IP}:2379,http://127.0.0.1:2379 \ --listen-client-urls http://${THIS_IP}:2379,http://127.0.0.1:2379 \ --initial-cluster ${CLUSTER} \ --initial-cluster-state ${CLUSTER_STATE} \ --initial-cluster-token ${TOKEN} > /data/etcd-v3.5.0/etcd.out 2>&1 & [root@im-04 etcd-v3.5.0]cat etcd.sh #for each machine TOKEN=my-etcd-token-1 CLUSTER_STATE=new NAME_1=etcd_1 NAME_2=etcd_2 NAME_3=etcd_3 HOST_1=172.16.0.151 HOST_2=172.16.0.173 HOST_3=172.16.0.220 CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_3}=http://${HOST_3}:2380 # For node 2 THIS_NAME=${NAME_2} THIS_IP=${HOST_2} /data/etcd-v3.5.0/etcd --data-dir=/data/etcd-v3.5.0/data.etcd --name ${THIS_NAME} \ --initial-advertise-peer-urls http://${THIS_IP}:2380 \ --listen-peer-urls http://${THIS_IP}:2380 \ --advertise-client-urls http://${THIS_IP}:2379,http://127.0.0.1:2379 \ --listen-client-urls http://${THIS_IP}:2379,http://127.0.0.1:2379 \ --initial-cluster ${CLUSTER} \ --initial-cluster-state ${CLUSTER_STATE} \ --initial-cluster-token ${TOKEN} > /data/etcd-v3.5.0/etcd.out 2>&1 & [root@im-05 etcd-v3.5.0]cat etcd.sh # For each machine TOKEN=my-etcd-token-1 CLUSTER_STATE=new NAME_1=etcd_1 NAME_2=etcd_2 NAME_3=etcd_3 HOST_1=172.16.0.151 HOST_2=172.16.0.173 HOST_3=172.16.0.220 CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_3}=http://${HOST_3}:2380 # For node 3 THIS_NAME=${NAME_3} THIS_IP=${HOST_3} /data/etcd-v3.5.0/etcd --data-dir=/data/etcd-v3.5.0/data.etcd --name ${THIS_NAME} \ --initial-advertise-peer-urls http://${THIS_IP}:2380 \ --listen-peer-urls http://${THIS_IP}:2380 \ --advertise-client-urls http://${THIS_IP}:2379,http://127.0.0.1:2379 \ --listen-client-urls http://${THIS_IP}:2379,http://127.0.0.1:2379 \ --initial-cluster ${CLUSTER} \ --initial-cluster-state ${CLUSTER_STATE} \ --initial-cluster-token ${TOKEN} > /data/etcd-v3.5.0/etcd.out 2>&1 & 5.三台服务器分别执行etcd.sh赋予执行权限并启动 chmod +x /data/etcd-v3.5.0/etcd.sh /data/etcd-v3.5.0/etcd.sh 6.三台服务器分别执行建立软连接 [root@im-05 etcd-v3.5.0]# ln -s /data/etcd-v3.5.0/etcd /usr/local/bin/etcd [root@im-05 etcd-v3.5.0]# ln -s /data/etcd-v3.5.0/etcdctl /usr/local/bin/etcdctl [root@im-05 etcd-v3.5.0]# ln -s /data/etcd-v3.5.0/etcdutl /usr/local/bin/etcdutl 7./usr/local/bin/加入环境变量 vim /etc/profile export PATH=/usr/local/bin/:$PATH 8. 执行命令 source /etc/profile 9. (1)查看集群成员健康情况: [root@im-05 etcd-v3.5.0]# etcdctl endpoint health --endpoints="http://172.16.0.151:2380,http://172.16.0.173:2380,http://172.16.0.220:2380" http://172.16.0.173:2380 is healthy: successfully committed proposal: took = 4.430984ms http://172.16.0.151:2380 is healthy: successfully committed proposal: took = 4.378476ms http://172.16.0.220:2380 is healthy: successfully committed proposal: took = 4.759539ms (2)查看集群成员列表: [root@im-05 etcd-v3.5.0]# etcdctl member list 88ba7d086f91dc5e, started, etcd_3, http://172.16.0.220:2380, http://127.0.0.1:2379,http://172.16.0.220:2379, false 932d1a5425ec0f72, started, etcd_2, http://172.16.0.173:2380, http://127.0.0.1:2379,http://172.16.0.173:2379, false f0ac2546d16a17f4, started, etcd_1, http://172.16.0.151:2380, http://127.0.0.1:2379,http://172.16.0.151:2379, false 10.参考文档 https://www.cnblogs.com/hanease/p/16332130.html https://cloud.tencent.com/developer/article/1890434 https://www.cnblogs.com/wujuntian/p/15121004.html
posted on 2022-09-07 14:03 running-fly 阅读(35) 评论(0) 编辑 收藏 举报