当前位置:网站首页>Backup kubernetes backup etcd data
Backup kubernetes backup etcd data
2022-07-19 03:16:00 【Lao Duan studio】
1. Practice goals
First prepare one in the environment pod1, Then back up etcd data , Then delete pod1. The backup data contains pod1 Of , So by restoring etcd After the data , You can still see pod1.
2. Practice environment
This experiment consists of 2 Taiwan machine , Namely vms71 and vms72.
[[email protected] ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
vms71.rhce.cc Ready control-plane,master 2d6h v1.23.2
vms72.rhce.cc Ready <none> 2d6h v1.23.2
[[email protected] ~]#
3. stay vms71 Installation on etcd software package
[[email protected] ~]# yum install etcd -y
... Output ...
complete !
[[email protected] ~]#
4. Preparation before experiment
Now in the current environment, there is a name called pod1 Of pod Running .
[[email protected] ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
pod1 1/1 Running 0 42h
[[email protected] ~]#
In order to reduce the length of commands during backup and recovery , Here we first define some variables .
[[email protected] ~]# export ETCDCTL_API=3
[[email protected] ~]# cert=/etc/kubernetes/pki/etcd/server.crt
[[email protected] ~]# key=/etc/kubernetes/pki/etcd/server.key
[[email protected] ~]# cacert=/etc/kubernetes/pki/etcd/ca.crt
[[email protected] ~]#
5. The backup data
Back up the data according to the following command .
[[email protected] ~]# etcdctl --endpoints=https://192.168.26.71:2379 --cacert=$cacert --cert=$cert --key=$key snapshot save snap1.data
*Snapshot saved at snap1.data*
[[email protected] ~]#
At this time, the backup data includes pod1 This pod Of .
Delete after backup pod1.
[[email protected] ~]# kubectl delete pod pod1
pod "pod1" deleted
[[email protected] ~]# kubectl get pods
No resources found in default namespace.
[[email protected] ~]#
The current namespace does not exist pod 了 , But there are in the backup data .
6. Restore data
1. close kubernetes Its core components include etcd.
Because they are static pod The way it works , And the static directory is /etc/kubernetes/manifests/, So just cut this directory to another location , Cut here to / Next .
[[email protected] ~]# mv /etc/kubernetes/manifests/ /
[[email protected] ~]#
2. Delete the original data .
[[email protected] ~]# rm -rf /var/lib/etcd/
[[email protected] ~]#
3. Restore data .
[[email protected] ~]# etcdctl --endpoints=https://192.168.26.71:2379 --cacert=$cacert --cert=$cert --key=$key snapshot restore snap1.data --data-dir=/var/lib/etcd/ --name=vms71.rhce.cc --initial-cluster=vms71.rhce.cc=https://192.168.26.71:2380 --initial-advertise-peer-urls https://192.168.26.71:2380
*2022-02-28 16:58:25.518748 I | mvcc: restore compact to 67960
2022-02-28 16:58:25.526988 I | etcdserver/membership: added member ec884fe58e76ba1a [https://192.168.26.71:2380] to cluster 6ba0775b22f7fb90*
[[email protected] ~]#
In this way, the data recovery is completed , Most of the parameters of this command can be changed to the original /etc/kubernetes/manifests/etcd.yaml current /manifests/etcd.yaml Found in .
Modify owner and group
[[email protected] ~]# chown -R etcd.etcd /var/lib/etcd/
[[email protected] ~]#
4. restart kubelet.
[[email protected] ~]# systemctl restart kubelet
[[email protected] ~]#
5. verification pod Whether it has been restored .
[[email protected] ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
pod1 0/1 ContainerCreating 1 42h
[[email protected] ~]#
[[email protected] ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
pod1 1/1 Running 0 42h
[[email protected] ~]#
边栏推荐
- [MCU simulation] (IX) instruction system - add, ADDC, sub, Inc, Dec, Da of arithmetic operation instructions
- CorelDRAW cannot be installed. Solution
- After 4 years of developing two-sided meituan, we finally lost: the interview question of volatile keyword function and principle
- ubuntu清除cuda缓存
- 深入理解机器学习——类别不平衡学习(Imbalanced Learning):样本采样技术-[人工采样技术之ADASYN采样法]
- 仿射变换实现
- Tools and methods - Excel plug-in xltools
- 【剑指Offer】31-35题(判断一个序列是否是栈的出栈序列之一,层序打印二叉树以及分行打印、每行逆着打印),判断序列是否是二叉搜索树的后序遍历路径,二叉树找一条权值为K的路径,复制复杂链表
- 【单片机仿真】(四)寻址方式 — 寄存器寻址与直接寻址
- Is there really no way out for functional testing? 10K capping is never a joke
猜你喜欢

无线用的鉴权代码

C语言基础Day4-数组

RESNET learning notes

ES6学习笔记——B站小马哥

Is there really no way out for functional testing? 10K capping is never a joke
![[regression prediction] lithium ion battery life prediction based on particle filter with matlab code](/img/1d/5562934499edfb4781b1118d0c4f9c.png)
[regression prediction] lithium ion battery life prediction based on particle filter with matlab code

【人脸识别】基于直方图Histogram实现人脸识别附matlab代码

2002 - Can‘t connect to server on ‘127.0.0.1‘ (36)

Visual analysis of ncnn param file and bin model
![[PHP] tp6 multi table connection query](/img/f8/a3803f01820082792901bff98bb96c.png)
[PHP] tp6 multi table connection query
随机推荐
【单片机仿真】(六)寻址方式 — 变址寻址与相对寻址
Systick timer basic learning and hand tearing code
My most productive easypypi once again has been updated! V1.4.0 release
Redis和其他数据库的比较
[face recognition] face recognition based on histogram histogram with matlab code
乐视还有400多位员工?过着没有老板的神仙日子 官方出来回应了...
Go language realizes sending SMS verification code and logging in
JDBC连接Mysql数据库
【单片机仿真】(一)Proteus8.9 安装教程
05_ Service call ribbon
zsh: command not found: mysql
Automatic assembly & set injection
CorelDRAW 安装不了解决方法
Flutter development: running the flutter upgrade command reports an error exception:flutter failed to create a directory at... Solution
GraphQL初识
mysql复制表
C language foundation day4 array
A Youku VIP member account can be used by several people to log in at the same time. How to share multiple people using Youku member accounts?
[MCU simulation] (XIII) instruction system logic operation instruction shift instruction
【单片机仿真】(八)指令系统 — 数据传送指令