kubeadm搭建的多节点k8s中etcd多节点数据备份及恢复

环境:
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/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值