码迷,mamicode.com
首页 > Web开发 > 详细

linux运维、架构之路-kubernetes集群维护

时间:2020-09-17 19:39:33      阅读:41      评论:0      收藏:0      [点我收藏+]

标签:ber   server   clu   http   res   暂停   var   ken   cert   

一、Etcd数据库备份与恢复

       Kubernetes 使用Etcd 数据库实时存储集群中的数据,安全起见,一定要备份!

1、kubeadm部署方式备份

①备份

ETCDCTL_API=3 etcdctl snapshot save snap.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

②恢复

暂停kube-apiserver和etcd容器

mv /etc/kubernetes/manifests /etc/kubernetes/manifests.bak
mv /var/lib/etcd/ /var/lib/etcd.bak

执行恢复命令

ETCDCTL_API=3 etcdctl snapshot restore snap.db --data-dir=/var/lib/etcd

启动kube-apiserver和etcd容器

mv /etc/kubernetes/manifests.bak /etc/kubernetes/manifests

2、二进制部署方式备份

①备份

ETCDCTL_API=3 etcdctl snapshot save snap.db --endpoints=https://192.168.56.61:2379 \
--cacert=/opt/etcd/ssl/ca.pem --cert=/opt/etcd/ssl/server.pem --key=/opt/etcd/ssl/server-key.pem

②恢复

暂停kube-apiserver和etcd

systemctl stop kube-apiserver
systemctl stop etcd
mv /var/lib/etcd/default.etcd /var/lib/etcd/default.etcd.bak

在每个节点上恢复

ETCDCTL_API=3 etcdctl snapshot restore snap.db --name etcd-1 --initial-cluster="etcd-1=https://192.168.56.61:2380,etcd-2=https://192.168.56.62:2380,etcd-3=https://192.168.56.63:2380" --initial-cluster-token=etcd-cluster --initial-advertise-peer-urls=https://192.168.56.61:2380 \
--data-dir=/var/lib/etcd/default.etcd

启动kube-apiserver和etcd服务

systemctl start kube-apiserver
systemctl start etcd

 

linux运维、架构之路-kubernetes集群维护

标签:ber   server   clu   http   res   暂停   var   ken   cert   

原文地址:https://www.cnblogs.com/yanxinjiang/p/13638772.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!