当前位置:网站首页>恢复持久卷上的备份数据
恢复持久卷上的备份数据
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
边栏推荐
- Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
- 第二十章 使用工作队列管理器(三)
- vulnhub之tre1
- LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
- Force buckle 1790 Can two strings be equal by performing string exchange only once
- Opencv学习笔记 高动态范围 (HDR) 成像
- 毕业季|遗憾而又幸运的毕业季
- 831. KMP字符串
- openEuler 有奖捉虫活动,来参与一下?
- Gorilla official: sample code for golang to open websocket client
猜你喜欢

vulnhub之school 1
![[philosophy and practice] the way of program design](/img/c8/93f2ac7c5beb95f64b7883ad63c74c.jpg)
[philosophy and practice] the way of program design

mock.js从对象数组中任选数据返回一个数组

Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記

PHP method of obtaining image information

Data island is the first danger encountered by enterprises in their digital transformation

Splicing and splitting of integer ints

力扣 599. 两个列表的最小索引总和

关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】

CSDN语法说明
随机推荐
The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared
机器学习笔记 - 使用Streamlit探索对象检测数据集
Chapter 9 Yunji datacanvas company won the highest honor of the "fifth digital finance innovation competition"!
841. String hash
使用高斯Redis实现二级索引
Force buckle 1037 Effective boomerang
openEuler 有奖捉虫活动,来参与一下?
如何在软件研发阶段落地安全实践
力扣 1790. 仅执行一次字符串交换能否使两个字符串相等
【哲思与实战】程序设计之道
LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
毕业季|遗憾而又幸运的毕业季
PHP method of obtaining image information
Cuda版本不一致,编译apex报错
力扣 1232.缀点成线
Opencv learning notes high dynamic range (HDR) imaging
MSE API学习
深度学习模型压缩与加速技术(七):混合方式
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
Force buckle 459 Duplicate substring