千家信息网

centos7.6下部署ETCD3.4.7 集群的详细步骤

发表于:2025-01-25 作者:千家信息网编辑
千家信息网最后更新 2025年01月25日,这篇文章主要讲解了"centos7.6下部署ETCD3.4.7 集群的详细步骤",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"centos7.6下部署E
千家信息网最后更新 2025年01月25日centos7.6下部署ETCD3.4.7 集群的详细步骤

这篇文章主要讲解了"centos7.6下部署ETCD3.4.7 集群的详细步骤",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"centos7.6下部署ETCD3.4.7 集群的详细步骤"吧!

安装包地址:

https://github.com/etcd-io/etcd/releases

解压安装文件
tar -xvf etcd-v3.4.7-linux-amd64.tar.gzcd etcd-v3.4.7-linux-amd64cp etcd etcdctl /k8s/etcd/bin/
设置etcd的配置文件

cat /k8s/etcd/cfg/etcd #[Member] ETCD_NAME="etcd01" ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_PEER_URLS="https://192.168.2.88:2380" ETCD_LISTEN_CLIENT_URLS="https://192.168.2.88:2379" #[Clustering] ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.2.88:2380" ETCD_ADVERTISE_CLIENT_URLS="https://192.168.2.88:2379" ETCD_INITIAL_CLUSTER="etcd01=https://192.168.2.88:2380,etcd02=https://192.168.2.81:2380,etcd03=https://192.168.2.82:2380" ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"

创建 etcd的 systemd unit 文件

cat /usr/lib/systemd/system/etcd.service

[Unit]Description=Etcd ServerAfter=network.targetAfter=network-online.targetWants=network-online.target [Service]Type=notifyEnvironmentFile=/k8s/etcd/cfg/etcdExecStart=/k8s/etcd/bin/etcd \--initial-cluster-state=new \--cert-file=/k8s/etcd/ssl/server.pem \--key-file=/k8s/etcd/ssl/server-key.pem \--peer-cert-file=/k8s/etcd/ssl/server.pem \--peer-key-file=/k8s/etcd/ssl/server-key.pem \--trusted-ca-file=/k8s/etcd/ssl/ca.pem \--peer-trusted-ca-file=/k8s/etcd/ssl/ca.pemRestart=on-failureLimitNOFILE=65536 [Install]WantedBy=multi-user.target
启动ETCD服务
systemctl daemon-reloadsystemctl enable etcdsystemctl start etcd
查看etcd状态
systemctl status etcd● etcd.service - Etcd Server   Loaded: loaded (/usr/lib/systemd/system/etcd.service; enabled; vendor preset: disabled)   Active: active (running) since Tue 2019-07-09 15:55:58 CST; 1h 12min ago Main PID: 29830 (etcd)    Tasks: 12   Memory: 66.7M   CGroup: /system.slice/etcd.service           └─29830 /k8s/etcd/bin/etcd --name=etcd01 --data-dir=/var/lib/etcd/default.etcd --listen-peer-urls=https://192.168.1.10... Jul 09 17:07:39 qas-k8s-master01 etcd[29830]: the clock difference against peer 2369b1ebd5f356e7 is too high [1.340843978s ...SAGE")Jul 09 17:07:39 qas-k8s-master01 etcd[29830]: the clock difference against peer 2369b1ebd5f356e7 is too high [1.343013157s ...SHOT")Jul 09 17:08:04 qas-k8s-master01 etcd[29830]: the clock difference against peer 67ad1178efd89256 is too high [1.287315582s ...SHOT")Jul 09 17:08:04 qas-k8s-master01 etcd[29830]: the clock difference against peer 67ad1178efd89256 is too high [1.285244104s ...SAGE")Jul 09 17:08:09 qas-k8s-master01 etcd[29830]: the clock difference against peer 2369b1ebd5f356e7 is too high [1.340602239s ...SAGE")Jul 09 17:08:09 qas-k8s-master01 etcd[29830]: the clock difference against peer 2369b1ebd5f356e7 is too high [1.342891162s ...SHOT")Jul 09 17:08:34 qas-k8s-master01 etcd[29830]: the clock difference against peer 67ad1178efd89256 is too high [1.285259365s ...SAGE")Jul 09 17:08:34 qas-k8s-master01 etcd[29830]: the clock difference against peer 67ad1178efd89256 is too high [1.287337806s ...SHOT")Jul 09 17:08:39 qas-k8s-master01 etcd[29830]: the clock difference against peer 2369b1ebd5f356e7 is too high [1.342999378s ...SHOT")Jul 09 17:08:39 qas-k8s-master01 etcd[29830]: the clock difference against peer 2369b1ebd5f356e7 is too high [1.339802949s ...SAGE")Hint: Some lines were ellipsized, use -l to show in full.
将启动文件、配置文件拷贝到 节点1、节点2
cd /k8s/ scp -r etcd 192.168.2.81:/k8s/scp -r etcd 192.168.2.82:/k8s/scp /usr/lib/systemd/system/etcd.service  192.168.2.81:/usr/lib/systemd/system/etcd.servicescp /usr/lib/systemd/system/etcd.service  192.168.2.82:/usr/lib/systemd/system/etcd.service
node01节点修改

cat /k8s/etcd/cfg/etcd

#[Member]ETCD_NAME="etcd02"ETCD_DATA_DIR="/var/lib/etcd/default.etcd"ETCD_LISTEN_PEER_URLS="https://192.168.2.81:2380"ETCD_LISTEN_CLIENT_URLS="https://192.168.2.81:2379" #[Clustering]ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.2.81:2380"ETCD_ADVERTISE_CLIENT_URLS="https://192.168.2.81:2379"ETCD_INITIAL_CLUSTER="etcd01=https://192.168.2.88:2380,etcd02=https://192.168.2.81:2380,etcd03=https://192.168.2.82:2380"ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
node02节点修改

cat /k8s/etcd/cfg/etcd

#[Member]ETCD_NAME="etcd03"ETCD_DATA_DIR="/var/lib/etcd/default.etcd"ETCD_LISTEN_PEER_URLS="https://192.168.2.82:2380"ETCD_LISTEN_CLIENT_URLS="https://192.168.2.82:2379" #[Clustering]ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.2.82:2380"ETCD_ADVERTISE_CLIENT_URLS="https://192.168.2.82:2379"ETCD_INITIAL_CLUSTER="etcd01=https://192.168.2.88:2380,etcd02=https://192.168.2.81:2380,etcd03=https://192.168.2.82:2380"ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
验证集群是否正常运行
./etcdctl --cacert=/k8s/etcd/ssl/ca.pem --cert=/k8s/etcd/ssl/server.pem --key=/k8s/etcd/ssl/server-key.pem --endpoints="https://192.168.2.88:2379,https://192.168.2.81:2379,https://192.168.2.82:2379" endpoint health

注意: 启动ETCD集群同时启动二个节点,启动一个节点集群是无法正常启动的; 返回以下表示ok

https://192.168.2.82:2379 is healthy: successfully committed proposal: took = 15.675731mshttps://192.168.2.88:2379 is healthy: successfully committed proposal: took = 15.764248mshttps://192.168.2.81:2379 is healthy: successfully committed proposal: took = 14.121678ms

感谢各位的阅读,以上就是"centos7.6下部署ETCD3.4.7 集群的详细步骤"的内容了,经过本文的学习后,相信大家对centos7.6下部署ETCD3.4.7 集群的详细步骤这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!

0