1.查看etcd的版本bash
[root@etcd01 ssl]# curl -L http://127.0.0.1:2379/version {"etcdserver":"3.3.10","etcdcluster":"3.3.0"}
2.查看etcd暴露出來的prometheus指標;在prometheus對其監控時使用curl
curl -L http://127.0.0.1:2379/metrics 注:prometheus採集指標時,是經過https方式採集的
3.查看etcd集羣的成員ide
[root@etcd01 ssl]# etcdctl --ca-file=ca.pem --cert-file=etcd.pem --key-file=etcd-key.pem member list a03dc3532588a426: name=etcd2 peerURLs=https://10.10.5.183:2380 clientURLs=https://10.10.5.183:2379 isLeader=true e5760d44b75c8a8f: name=etcd1 peerURLs=https://10.10.5.169:2380 clientURLs=https://10.10.5.169:2379 isLeader=false f6569926ef77ab79: name=etcd3 peerURLs=https://10.10.5.184:2380 clientURLs=https://10.10.5.184:2379 isLeader=false 注:member命令同時支持添加、刪除一個節點 peerURLs:表示此節點對其它的節點開放的通訊地址 clientURLs:表示向客戶端提供的通訊地址 isLeader:表示當前節點是不是leader
4.查看etcd集羣的健康狀態url
[root@etcd01 ssl]# etcdctl --ca-file=ca.pem --cert-file=etcd.pem --key-file=etcd-key.pem cluster-health member a03dc3532588a426 is healthy: got healthy result from https://10.10.5.183:2379 member e5760d44b75c8a8f is healthy: got healthy result from https://10.10.5.169:2379 member f6569926ef77ab79 is healthy: got healthy result from https://10.10.5.184:2379
5.備份etcd的整個數據目錄;默認的數據目錄爲/var/lib/etcd/
3d
etcdctl --ca-file=ca.pem --cert-file=etcd.pem --key-file=etcd-key.pem backup --data-dir /var/lib/etcd --backup-dir /tmp/etcd --data-dir:指明數據目錄的位置 --backup-dir:指明備份的位置
6.對etcd進行快照備份
rest
[root@etcd01 k8s]# ETCDCTL_API=3 /etc/kubernetes/bin/etcdctl snapshot save snapshot.db Snapshot saved at snapshot.db ETCDCTL_API=3:表示使用etcd的v3版本的API接口 注:必定要添加ETCDCTL_API=3才能正常備份;若是不添加將沒法備份
7.經過快照恢復etcd集羣;(每一個節點都要執行)server
ETCDCTL_API=3 etcdctl snapshot restore snapshot.db \ --name {{ NODE_NAME }} \ --initial-cluster {{ ETCD_NODES }} \ --initial-cluster-token etcd-cluster-0 \ --initial-advertise-peer-urls https://{{ inventory_hostname }}:2380 --name:表示當前etcd節點的名字(非主機名) --initial-cluster:集羣中全部節點的peer訪問地址;例:etcd01=https://10.10.5.217:2380 ,etcd02=https://10.10.5.219:2380,etcd03=https://10.10.5.220:2380 --initial-cluster-token:集羣中各節點通訊的token --initial-advertise-peer-urls:當前節點對其它節點的通訊地址