Etcd 是一个可靠的分布式键值存储, 常用于分布式系统关键数据的存储;而 etcdadm 是一个用于操作 etcd 集群的命令行工具,它可以轻松创建集群、向现有集群添加成员、从现有集群中删除成员等操作;其使用方式类似 kubeadm, 即主要操作流程为: 先启动第一个集群节点 , 后续节点直接 join 即可
建议通过 PC 端 , 访问 运维技术帮 (https://ywjsbang.com) 以获取更好阅读体验,由于精力有限,该文章的后续更新、完善仅限此处,望理解 !!
测试环境节点主机名节点 IP 地址系统版本etcd 版本etcdadm 版本c7192.168.31.37CentOS 7.9.2009 ( 5.4.180-1.el7 )V3.5.5V0.1.5c8192.168.31.38同上同上同上c9192.168.31.39同上同上同上安装 etcdadm1、预编译二进制安装
wget https://github.com/kubernetes-sigs/etcdadm/releases/download/v0.1.5/etcdadm-linux-amd64mv etcdadm-linux-amd64 /usr/local/bin/etcdadmchmod +x /usr/local/bin/etcdadmscp /usr/local/bin/etcdadm 192.168.31.{38,39}:/usr/local/bin/
2、各节点系统防火墙放行端口 2379,2380
firewall-cmd --add-port=2379/tcpfirewall-cmd --add-port=2380/tcp
初始化 etcd 节点1、初始化第一个 etcd 集群节点
etcdadm init \--version "3.5.5" \--init-system "systemd" \--install-dir "/opt/bin/" \--certs-dir "/etc/etcd/pki" \--data-dir "/var/lib/etcd" \--release-url "https://github.com/etcd-io/etcd/releases/download"# 主要选项解析--version# 指定部署的 etcd 版本--init-system# 设置 etcd 进程管理方式,默认 systemd,取值 kubelet 时 , 则以容器方法运行 etcd 进程--install-dir# etcd 二进制程序安装目录
2、etcdadm init 初始化过程解析
# 下载解压、安装二进制文件 etcd、etcdctl2022-10-20 14:26:12.781166 I | [install] Artifact not found in cache. Trying to fetch from upstream: https://github.com/etcd-io/etcd/releases/downloadINFO[0000] [install] Downloading & installing etcd https://github.com/etcd-io/etcd/releases/download from 3.5.5 to /var/cache/etcdadm/etcd/v3.5.5INFO[0000] [install] downloading etcd from https://github.com/etcd-io/etcd/releases/download/v3.5.5/etcd-v3.5.5-linux-amd64.tar.gz to /var/cache/etcdadm/etcd/v3.5.5/etcd-v3.5.5-linux-amd64.tar.gzINFO[0009] [install] extracting etcd archive /var/cache/etcdadm/etcd/v3.5.5/etcd-v3.5.5-linux-amd64.tar.gz to /tmp/etcd641204404INFO[0009] [install] verifying etcd 3.5.5 is installed in /opt/bin/# 生成一个自签名的 CA 证书及私钥INFO[0001] [certificates] creating PKI assetsINFO[0001] creating a self signed etcd CA certificate and key files[certificates] Generated ca certificate and key.> /etc/etcd/pki/ca.crt> /etc/etcd/pki/ca.key# 生成一个 server 证书及私钥INFO[0001] creating a new server certificate and key files for etcd[certificates] Generated server certificate and key.[certificates] server serving cert is signed for DNS names [c7] and IPs [192.168.31.37 127.0.0.1]# > /etc/etcd/pki/server.crt# > /etc/etcd/pki/server.key# 生成一个 peer 证书及私钥INFO[0001] creating a new certificate and key files for etcd peering[certificates] Generated peer certificate and key.[certificates] peer serving cert is signed for DNS names [c7] and IPs [192.168.31.37]# > /etc/etcd/pki/peer.crt# > /etc/etcd/pki/peer.key# 生成一个用于 etcdctl 的 client 证书及私钥INFO[0001] creating a new client certificate for the etcdctl[certificates] Generated etcdctl-etcd-client certificate and key.# > /etc/etcd/pki/etcdctl-etcd-client.crt# > /etc/etcd/pki/etcdctl-etcd-client.key# 生成一个用于 k8s apiserver 调用 etcd 时的 client 证书及私钥INFO[0002] creating a new client certificate for the apiserver calling etcd[certificates] Generated apiserver-etcd-client certificate and key.[certificates] valid certificates and keys now exist in "/etc/etcd/pki"# > /etc/etcd/pki/apiserver-etcd-client.crt# > /etc/etcd/pki/apiserver-etcd-client.key# 检查本地 etcd 端点是否健康INFO[0003] [health] Checking local etcd endpoint healthINFO[0003] [health] Local etcd endpoint is healthy# 复制 CA cert/key 到其它 etcd 节点,并在其它 etcd 节点运行 etcdadm join 命令, 将其它 etcd 节点加入集群INFO[0003] To add another member to the cluster, copy the CA cert/key to its certificate dir and run:INFO[0003]etcdadm join https://192.168.31.37:2379
3、向其它节点分发 CA 根证书及私钥
ssh root@192.168.31.38 "mkdir /etc/etcd/pki/"scp -r /etc/etcd/pki/{ca.crt,ca.key} 192.168.31.38:/etc/etcd/pki/ssh root@192.168.31.39 "mkdir /etc/etcd/pki/"scp -r /etc/etcd/pki/{ca.crt,ca.key} 192.168.31.39:/etc/etcd/pki/
添加 etcd 节点若当前主机无法下载 , 可提前将 etcd 二进制程序包存放在如下路径: /var/cache/etcdadm/etcd/v3.5.5/etcd-v3.5.5-linux-amd64.tar.gz
1、添加节点 192.168.31.38
etcdadm join https://192.168.31.38:2379 \--version "3.5.5" \--init-system "systemd" \--install-dir "/opt/bin/"\--certs-dir"/etc/etcd/pki" \--data-dir "/var/lib/etcd"\--release-url "https://github.com/etcd-io/etcd/releases/download"
推荐阅读
- Android RecyclerView使用ListAdapter高效刷新数据
- 使用 Windows Core Audio APs 进行 Loopback Recording 并生成 WAV 文件
- 4 .NET 6学习笔记——如何在.NET 6的Desktop App中使用Windows Runtime API
- 使用react+redux实现弹出框案例
- 你真的会使用Typora吗?
- vue3中$attrs的变化与inheritAttrs的使用
- win10本地python第三方库安装成功,但是pycharm项目无法使用解决方案
- 华为快充66w和40w有什么区别-使用对比
- 了解 Flutter 开发者们的 IDE 使用情况
- iqoo5实际使用感受_iqoo5实际用机体验