1.1 使用脚本下载与服务端相同版本的 etcdctl
软件包
[shutang@centos03.com etcd]$ pwd
/home/shutang/k8s/etcd
[shutang@centos03.com etcd]$ ls
download.sh
[shutang@centos03.com etcd]$ cat download.sh
#!/bin/bash
ETCD_VER=v3.4.3
ETCD_DIR=etcd-download
DOWNLOAD_URL=https://github.com/coreos/etcd/releases/download
# Download
mkdir ${ETCD_DIR}
cd ${ETCD_DIR}
wget ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz
tar -xzvf etcd-${ETCD_VER}-linux-amd64.tar.gz
# install
cd etcd-${ETCD_VER}-linux-amd64
cp etcdctl /usr/local/bin/
1.2 执行脚本,然后配置环境变量和别名
[shutang@centos03.com etcd] bash download.sh
# 创建该文件
[shutang@centos03.com profile.d]$ cat etcd.sh
export ETCDCTL_API=3
alias etcdctl='etcdctl --endpoints=https://centos01.com:2379,https://centos02.com:2379,https://centos03.com:2379 --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key'
[shutang@centos03.com profile.d]$ source etcd.sh
# 这里需要注意要保证两个证书文件和一个私钥文件具有可读权限,以便普通用户可以使用 etcdctl 命令
2 普通用户可以使用 etcdctl
命令
2.1 查看 etcd
集群成员列表
[shutang@centos03.com profile.d]$ etcdctl member list fw57bbcfbe9bc95, started, centos03.com, https://192.168.0.100:2380, https://192.168.0.100:2379, false ds8968b39130b7a, started, centos02.com, https://192.168.0.101:2380, https://192.168.0.101:2379, false fs663af9b5wfr85, started, centos01.com, https://192.168.0.102:2380, https://192.168.0.102:2379, false
2.2 查看 endpoints
状态
[shutang@centos03.com profile.d]$ etcdctl endpoint status --write-out=table +------------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | +------------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | https://centos03.com:2379 | fw57bbcfbe9bc95 | 3.4.3 | 36 MB | true | false | 4 | 8387884 | 8387884 | | | https://centos03.com:2379 | ds8968b39130b7a | 3.4.3 | 36 MB | false | false | 4 | 8387884 | 8387884 | | | https://centos03.com:2379 | fs663af9b5wfr85 | 3.4.3 | 36 MB | false | false | 4 | 8387884 | 8387884 | | +------------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
2.3 查看 etcd endpoints
的健康
[shutang@centos03.com profile.d]$ etcdctl endpoint health https://centos03.com:2379 is healthy: successfully committed proposal: took = 12.253777ms https://centos02.com:2379 is healthy: successfully committed proposal: took = 13.902653ms https://centos01.com:2379 is healthy: successfully committed proposal: took = 15.32191ms
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南