1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| # 备份etcd数据 # docker run --rm -it --net host -v /etc/kubernetes:/etc/kubernetes \ registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.7-0 etcdctl --cert \ /etc/kubernetes/pki/etcd/peer.crt --key /etc/kubernetes/pki/etcd/peer.key --cacert \ /etc/kubernetes/pki/etcd/ca.crt member list # docker run --rm -it --net host -v /etc/kubernetes:/etc/kubernetes \ registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.7-0 etcdctl --cert \ /etc/kubernetes/pki/etcd/peer.crt --key /etc/kubernetes/pki/etcd/peer.key --cacert \ /etc/kubernetes/pki/etcd/ca.crt member remove b8434eb7a3474524
# mkdir /opt/etcd-bak cd /opt/etcd-bak
etcdctl --cert \ /etc/kubernetes/pki/etcd/peer.crt --key /etc/kubernetes/pki/etcd/peer.key --cacert \ /etc/kubernetes/pki/etcd/ca.crt \ --endpoints=https://192.168.64.52:2379 \ snapshot save snapshot-20240531.db
# docker run --rm -it --net host -v /etc/kubernetes:/etc/kubernetes registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.7-0 etcdctl --cert /etc/kubernetes/pki/etcd/peer.crt --key /etc/kubernetes/pki/etcd/peer.key --cacert /etc/kubernetes/pki/etcd/ca.crt member list
docker cp 73912616f41d:/usr/local/bin/etcdctl /usr/local/bin chmod 777 /usr/local/bin/etcdctl
# ETCDCTL_API=3 etcdctl snapshot restore --data-dir /var/lib/etcd/ /opt/etcd.bak/snapshot-20240531.db
|