1. Check the version of etcd

[root@etcd01 ssl]# curl -L http://127.0.0.1:2379/version
{"etcdserver":"3.3.10","etcdcluster":"3.3.0"}
 

2. Check prometheus indicators etcd exposed; the monitoring of its use in prometheus

curl -L http://127.0.0.1:2379/metrics

注:prometheus采集指标时,是通过https方式采集的
 

3. Check the cluster members etcd

[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. Review the health status of the cluster etcd

[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
 

The backup the entire data directory ETCD; the default directory for data / var / lib / etcd /

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 snapshot backup

[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. snapshot recovery etcd clusters; (each node needs to perform)

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:当前节点对其它节点的通信地址