1.1 使用脚本下载与服务端相同版本的 etcdctl
软件包
[[email protected] etcd]$ pwd /home/shutang/k8s/etcd [[email protected] etcd]$ ls download.sh [[email protected] 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 执行脚本,然后配置环境变量和别名
[[email protected] etcd] bash download.sh # 创建该文件 [[email protected] 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' [[email protected] profile.d]$ source etcd.sh # 这里需要注意要保证两个证书文件和一个私钥文件具有可读权限,以便普通用户可以使用 etcdctl 命令
2 普通用户可以使用 etcdctl
命令
2.1 查看 etcd
集群成员列表
[[email protected] 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
状态
[[email protected] 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
的健康
[[email protected] 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标签:etcd,centos03,集群,2379,https,k8s,com,shutang From: https://www.cnblogs.com/libruce/p/18095990