2021-04-30 14:30:05
浏览数 (1)
下载工具包
代码语言:javascript
复制wget https://github.com/etcd-io/etcd/releases/download/v3.4.14/etcd-v3.4.14-linux-amd64.tar.gz
解压并加入环境变量
代码语言:javascript
复制tar -zxf etcd-v3.4.14-linux-amd64.tar.gz
mv etcd-v3.4.14-linux-amd64/etcdctl /usr/local/bin
chmod x /usr/local/bin/
验证etcdctl是否能用,出现以下结果代表已经成功了
代码语言:javascript
复制[root@k8s-master1 ~]#etcdctl version
etcdctl version: 3.4.14
API version: 3.4
etcd的地址是各master节点的IP
查看etcd高可用集群健康状态
代码语言:javascript
复制[root@k8s-master1 ~]#ETCDCTL_API=3 etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/peer.crt --key=/etc/kubernetes/pki/etcd/peer.key --write-out=table --endpoints=42.51.80.221:2379,42.51.80.222:2379,42.51.80.223:2379 endpoint health
------------------- -------- ------------- -------
| ENDPOINT | HEALTH | TOOK | ERROR |
------------------- -------- ------------- -------
| 42.51.80.221:2379 | true | 29.23678ms | |
| 42.51.80.222:2379 | true | 30.169546ms | |
| 42.51.80.223:2379 | true | 30.654512ms | |
------------------- -------- ------------- -------
查看etcd高可用集群列表
代码语言:javascript
复制[root@k8s-master1 ~]#ETCDCTL_API=3 etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/peer.crt --key=/etc/kubernetes/pki/etcd/peer.key --write-out=table --endpoints=42.51.80.221:2379,42.51.80.222:2379,42.51.80.223:2379 member list
------------------ --------- ------------- --------------------------- --------------------------- ------------
| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER |
------------------ --------- ------------- --------------------------- --------------------------- ------------
| 4a22b8f319402aba | started | k8s-master2 | https://42.51.80.222:2380 | https://42.51.80.222:2379 | false |
| b0e52dad330ab3ee | started | k8s-master3 | https://42.51.80.223:2380 | https://42.51.80.223:2379 | false |
| efe5d6122ccb1c7e | started | k8s-master1 | https://42.51.80.221:2380 | https://42.51.80.221:2379 | false |
------------------ --------- ------------- --------------------------- --------------------------- ------------
查看etcd高可用集群leader
代码语言:javascript
复制[root@k8s-master1 ~]#ETCDCTL_API=3 etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/peer.crt --key=/etc/kubernetes/pki/etcd/peer.key --write-out=table --endpoints=42.51.80.221:2379,42.51.80.222:2379,42.51.80.223:2379 endpoint status
------------------- ------------------ --------- --------- ----------- ------------ ----------- ------------ -------------------- --------
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
------------------- ------------------ --------- --------- ----------- ------------ ----------- ------------ -------------------- --------
| 42.51.80.221:2379 | efe5d6122ccb1c7e | 3.4.13 | 3.7 MB | false | false | 9 | 16535 | 16535 | |
| 42.51.80.222:2379 | 4a22b8f319402aba | 3.4.13 | 3.7 MB | false | false | 9 | 16535 | 16535 | |
| 42.51.80.223:2379 | b0e52dad330ab3ee | 3.4.13 | 3.7 MB | true | false | 9 | 16535 | 16535 | |
------------------- ------------------ --------- --------- ----------- ------------ ----------- ------------ -------------------- --------