环境:
master1:192.168.0.122
master2:192.168.0.86
master3:192.168.0.144
1、备份etcd数据快照(不需要停止etcd服务)
ETCDCTL_API=3 etcdctl snapshot save /opt/etcd-back/snap-20220219-2359.db
–endpoints=https://127.0.0.1:2379
–cacert=/etc/kubernetes/pki/etcd/ca.crt
–cert=/etc/kubernetes/pki/etcd/peer.crt
–key=/etc/kubernetes/pki/etcd/peer.key
2、恢复etcd数据,恢复数据必须使用同一份数据快照
恢复数据前必须停止etcd运行(所有master节点执行)
mv /etc/kubernetes/manifests/etcd.yaml /opt/
master1节点操作
ETCDCTL_API=3 etcdctl snapshot restore /opt/etcd-back/snap-20220219-2359.db
–endpoints=127.0.0.1:2379
–data-dir=/var/lib/etcd
–initial-cluster=k8s-master1=https://192.168.0.122:2380,k8s-master2=https://192.168.0.86:2380,k8s-master3=https://192.168.0.144:2380
–name=k8s-master1
–initial-advertise-peer-urls=https://192.168.0.122:2380
mv /opt/etcd.yaml /etc/kubernetes/manifests/
master2节点操作
ETCDCTL_API=3 etcdctl snapshot restore /opt/etcd-back/snap-20220219-2359.db
–endpoints=127.0.0.1:2379
–data-dir=/var/lib/etcd
–initial-cluster=k8s-master1=https://192.168.0.122:2380,k8s-master2=https://192.168.0.86:2380,k8s-master3=https://192.168.0.144:2380
–name=k8s-master2
–initial-advertise-peer-urls=https://192.168.0.86:2380
mv /opt/etcd.yaml /etc/kubernetes/manifests/
master3节点操作
ETCDCTL_API=3 etcdctl snapshot restore /opt/etcd-back/snap-20220219-2359.db
–endpoints=127.0.0.1:2379
–data-dir=/var/lib/etcd
–initial-cluster=k8s-master1=https://192.168.0.122:2380,k8s-master2=https://192.168.0.86:2380,k8s-master3=https://192.168.0.144:2380
–name=k8s-master3
–initial-advertise-peer-urls=https://192.168.0.144:2380
mv /opt/etcd.yaml /etc/kubernetes/manifests/
kubeadm搭建的多节点k8s中etcd多节点数据备份及恢复
最新推荐文章于 2024-08-22 12:47:47 发布