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

发布时间:2021-09-08 17:13:30 作者:chen
来源:亿速云 阅读:161

这篇文章主要讲解了“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.gz
cd etcd-v3.4.7-linux-amd64
cp 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 Server
After=network.target
After=network-online.target
Wants=network-online.target
 
[Service]
Type=notify
EnvironmentFile=/k8s/etcd/cfg/etcd
ExecStart=/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.pem
Restart=on-failure
LimitNOFILE=65536
 
[Install]
WantedBy=multi-user.target
启动ETCD服务
systemctl daemon-reload
systemctl enable etcd
systemctl 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.service
scp /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.675731ms
https://192.168.2.88:2379 is healthy: successfully committed proposal: took = 15.764248ms
https://192.168.2.81:2379 is healthy: successfully committed proposal: took = 14.121678ms

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

推荐阅读:
  1. Taishan服务器装centos7.6系统部署ceph服务出现的慢请求
  2. Kubeadm部署Kubernetes集群的步骤

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

centos

上一篇:Node.js丢失上下文this的实例说明

下一篇:vmware workstation怎么搭建本地虚拟机centOS7 mini环境

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》