一、备份
生成快照
1
2
| # etcdctl snapshot save <FILENAME>
etcdctl snapshot save etcd-snapshot.db
|
二、恢复
2.1 停止所有节点的 ETCD 服务,并删除数据目录
1
2
3
| systemctl stop etcd
rm -rf /data/etcd/*
|
2.2 在所有节点上恢复数据
1
2
3
4
5
| etcdctl snapshot restore etcd-snapshot.db --name etcd01 --data-dir=/data/etcd initial-cluster=etcd01=http://172.20.10.129:2380,etcd02=http://172.20.10.132:2380,etcd03=http://172.20.10.134:2380 initial-advertise-peer-urls=http://172.20.10.129:2380
etcdctl snapshot restore etcd-snapshot.db --name etcd02 --data-dir=/data/etcd initial-cluster=etcd01=http://172.20.10.129:2380,etcd02=http://172.20.10.132:2380,etcd03=http://172.20.10.134:2380 initial-advertise-peer-urls=http://172.20.10.132:2380
etcdctl snapshot restore etcd-snapshot.db --name etcd03 --data-dir=/data/etcd initial-cluster=etcd01=http://172.20.10.129:2380,etcd02=http://172.20.10.132:2380,etcd03=http://172.20.10.134:2380 initial-advertise-peer-urls=http://172.20.10.134:2380
|
2.3 重启所有节点的 ETCD 服务