当前位置:网站首页>恢复持久卷上的备份数据
恢复持久卷上的备份数据
2022-07-07 18:11:00 【添香小铺】
本文档介绍如何将存储在持久卷上的备份数据恢复到 Kubernetes 环境中的 TiDB 集群。本文描述的持久卷指任何 Kubernetes 支持的持久卷类型。本文以从网络文件系统 (NFS) 存储恢复数据到 TiDB 为例。
本文档介绍的恢复方法基于 TiDB Operator 的 CustomResourceDefinition (CRD) 实现,底层使用 BR 工具来恢复数据。BR 全称为 Backup & Restore,是 TiDB 分布式备份恢复的命令行工具,用于对 TiDB 集群进行数据备份和恢复。
使用场景
当使用 BR 将 TiDB 集群数据备份到持久卷后,如果需要从持久卷将备份的 SST (键值对) 文件恢复到 TiDB 集群,请参考本文使用 BR 进行恢复。
注意
- BR 只支持 TiDB v3.1 及以上版本。
- BR 恢复的数据无法被同步到下游,因为 BR 直接导入 SST 文件,而下游集群目前没有办法获得上游的 SST 文件。
第 1 步:准备恢复环境
使用 BR 将 PV 上的备份数据恢复到 TiDB 前,请按照以下步骤准备恢复环境。
下载文件 backup-rbac.yaml 到执行恢复的服务器。
执行以下命令在
test2这个命名空间中创建恢复所需的 RBAC 相关资源:kubectl apply -f backup-rbac.yaml -n test2确认可以从 Kubernetes 集群中访问用于存储备份数据的 NFS 服务器。
如果你使用的 TiDB 版本低于 v4.0.8,你还需要进行以下操作。如果你使用的 TiDB 为 v4.0.8 及以上版本,你可以跳过此步骤。
确保你拥有恢复数据库
mysql.tidb表的SELECT和UPDATE权限,用于恢复前后调整 GC 时间。创建
restore-demo2-tidb-secretsecret:kubectl create secret generic restore-demo2-tidb-secret --from-literal=user=root --from-literal=password=<password> --namespace=test2
第 2 步:从持久卷恢复数据
创建 Restore custom resource (CR),将指定的备份数据恢复至 TiDB 集群:
kubectl apply -f restore.yamlrestore.yaml文件内容如下:--- apiVersion: pingcap.com/v1alpha1 kind: Restore metadata: name: demo2-restore-nfs namespace: test2 spec: # backupType: full br: cluster: demo2 clusterNamespace: test2 # logLevel: info # statusAddr: ${status-addr} # concurrency: 4 # rateLimit: 0 # checksum: true # # Only needed for TiDB Operator < v1.1.10 or TiDB < v4.0.8 # to: # host: ${tidb_host} # port: ${tidb_port} # user: ${tidb_user} # secretName: restore-demo2-tidb-secret local: prefix: backup-nfs volume: name: nfs nfs: server: ${nfs_server_if} path: /nfs volumeMount: name: nfs mountPath: /nfs在配置
restore.yaml文件时,请参考以下信息:以上示例中,存储在 NFS 上
local://${.spec.local.volume.nfs.path}/${.spec.local.prefix}/文件夹下的备份数据,被恢复到test2命名空间中的 TiDB 集群demo2。更多持久卷存储相关配置,参考 Local 存储字段介绍。.spec.br中的一些参数项均可省略,如logLevel、statusAddr、concurrency、rateLimit、checksum、timeAgo、sendCredToTikv。更多.spec.br字段的详细解释,参考 BR 字段介绍。如果使用 TiDB >= v4.0.8, BR 会自动调整
tikv_gc_life_time参数,不需要在 Restore CR 中配置spec.to字段。更多
RestoreCR 字段的详细解释,参考 Restore CR 字段介绍。
创建好 Restore CR 后,通过以下命令查看恢复的状态:
kubectl get rt -n test2 -owide
边栏推荐
- Solve the problem of incomplete display around LCD display of rk3128 projector
- mock. JS returns an array from the optional data in the object array
- Sword finger offer II 013 Sum of two-dimensional submatrix
- Force buckle 2315 Statistical asterisk
- Detailed explanation of Flink parallelism and slot
- About cv2 dnn. Readnetfromonnx (path) reports error during processing node with 3 inputs and 1 outputs [exclusive release]
- Compiler optimization (4): inductive variables
- Boot 和 Cloud 的版本选型
- Force buckle 88 Merge two ordered arrays
- MRS离线数据分析:通过Flink作业处理OBS数据
猜你喜欢

Some important knowledge of MySQL

Mrs offline data analysis: process OBS data through Flink job

有了ST7008, 蓝牙测试完全拿捏住了

LeetCode_7_5

Vulnhub's funfox2

LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字

vulnhub之Funfox2

Sword finger offer II 013 Sum of two-dimensional submatrix

编译器优化那些事儿(4):归纳变量

Cloud component development and upgrading
随机推荐
开源重器!九章云极DataCanvas公司YLearn因果学习开源项目即将发布!
Traversal of Oracle stored procedures
[auto.js] automatic script
Traversée des procédures stockées Oracle
c语言如何判定是32位系统还是64位系统
ASP.NET学习& asp‘s one word
One click deployment of any version of redis
一键部署Redis任意版本
Oracle 存储过程之遍历
线性基
Vulnhub's funfox2
CUDA versions are inconsistent, and errors are reported when compiling apex
Mongodb由浅入深学习
YoloV6:YoloV6+Win10---训练自己得数据集
pom.xml 配置文件标签作用简述
Precautions for cjson memory leakage
Force buckle 1232 Dotted line
TS快速入门-泛型
About cv2 dnn. Readnetfromonnx (path) reports error during processing node with 3 inputs and 1 outputs [exclusive release]
编译器优化那些事儿(4):归纳变量