当前位置:网站首页>使用 BR 恢复 Azure Blob Storage 上的备份数据
使用 BR 恢复 Azure Blob Storage 上的备份数据
2022-07-07 18:11:00 【添香小铺】
本文介绍如何将 Azure Blob Storage 上的 SST 备份数据恢复到 Kubernetes 环境中的 TiDB 集群。
本文使用的恢复方式基于 TiDB Operator 的 Custom Resource Definition (CRD) 实现,底层使用 BR 进行数据恢复。BR 全称为 Backup & Restore,是 TiDB 分布式备份恢复的命令行工具,用于对 TiDB 集群进行数据备份和恢复。
使用场景
当使用 BR 将 TiDB 集群数据备份到 Azure Blob Storage 后,如果需要从 Azure Blob Storage 将备份的 SST(键值对)文件恢复到 TiDB 集群,请参考本文使用 BR 进行恢复。
注意
- BR 只支持 TiDB v3.1 及以上版本。
- BR 恢复的数据无法被同步到下游,因为 BR 直接导入 SST 文件,而下游集群目前没有办法获得上游的 SST 文件。
本文假设将存储在 Azure Blob Storage 上指定路径 spec.azblob.container
存储桶中 spec.azblob.prefix
文件夹下的备份数据恢复到 namespace test2
中的 TiDB 集群 demo2
。下面是具体的操作过程。
第 1 步:准备恢复环境
使用 BR 将 Azure Blob Storage 上的备份数据恢复到 TiDB 前,请按照以下步骤准备恢复环境。
下载文件 backup-rbac.yaml,并执行以下命令在
test2
这个 namespace 中创建恢复需要的 RBAC 相关资源:kubectl apply -f backup-rbac.yaml -n test2
授予远程存储访问权限,可以使用两种方式授予权限,可参考文档 Azure 账号授权。
如果你使用的 TiDB 版本低于 v4.0.8,你还需要进行以下操作。如果你使用的 TiDB 为 v4.0.8 及以上版本,请跳过此步骤。
确保你拥有恢复数据库
mysql.tidb
表的SELECT
和UPDATE
权限,用于恢复前后调整 GC 时间。创建
restore-demo2-tidb-secret
secret 用于存放访问 TiDB 集群的 root 账号和密钥。kubectl create secret generic restore-demo2-tidb-secret --from-literal=password=${password} --namespace=test2
第 2 步:将指定备份数据恢复到 TiDB 集群
根据上一步选择的远程存储访问授权方式,你需要使用下面对应的方法将备份数据恢复到 TiDB:
方法 1: 如果通过了访问密钥的方式授权,你可以按照以下说明创建
Restore
CR 恢复集群数据:kubectl apply -f resotre-azblob.yaml
restore-azblob.yaml
文件内容如下:--- apiVersion: pingcap.com/v1alpha1 kind: Restore metadata: name: demo2-restore-azblob namespace: test2 spec: br: cluster: demo2 clusterNamespace: test2 # logLevel: info # statusAddr: ${status_addr} # concurrency: 4 # rateLimit: 0 # timeAgo: ${time} # checksum: true # sendCredToTikv: 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 azblob: secretName: azblob-secret container: my-container prefix: my-folder
方法 2: 如果通过了 Azure AD 的方式授权,你可以按照以下说明创建
Restore
CR 恢复集群数据:kubectl apply -f restore-azblob.yaml
restore-azblob.yaml
文件内容如下:--- apiVersion: pingcap.com/v1alpha1 kind: Restore metadata: name: demo2-restore-azblob namespace: test2 spec: serviceAccount: tidb-backup-manager br: cluster: demo2 sendCredToTikv: false clusterNamespace: test2 # logLevel: info # statusAddr: ${status_addr} # concurrency: 4 # rateLimit: 0 # timeAgo: ${time} # 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 azblob: secretName: azblob-secret-ad container: my-container prefix: my-folder
在配置 restore-azblob.yaml
文件时,请参考以下信息:
- 关于 Azure Blob Storage 相关配置,请参考 Azure Blob Storage 存储字段介绍。
.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
字段。 - 更多
Restore
CR 字段的详细解释,请参考 Restore CR 字段介绍。
创建好 Restore
CR 后,可通过以下命令查看恢复的状态:
kubectl get rt -n test2 -o wide
边栏推荐
- equals 方法
- Data island is the first danger encountered by enterprises in their digital transformation
- 剑指 Offer II 013. 二维子矩阵的和
- School 1 of vulnhub
- 831. KMP字符串
- 力扣674. 最长连续递增序列
- One click deployment of any version of redis
- Force buckle 989 Integer addition in array form
- Kubernetes -- detailed usage of kubectl command line tool
- 力扣 459. 重复的子字符串
猜你喜欢
About cv2 dnn. Readnetfromonnx (path) reports error during processing node with 3 inputs and 1 outputs [exclusive release]
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
LeetCode_7_5
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
PHP method of obtaining image information
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
【mysql篇-基础篇】事务
Flink并行度和Slot详解
一. 基础概念
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
随机推荐
【哲思与实战】程序设计之道
力扣 1037.有效的回旋镖
剑指 Offer II 013. 二维子矩阵的和
Semantic slam source code analysis
MIT science and technology review article: AgI hype around Gato and other models may make people ignore the really important issues
一键部署Redis任意版本
pom. Brief introduction of XML configuration file label function
841. 字符串哈希
一文读懂数仓中的pg_stat
JVM class loading mechanism
【Auto.js】自动化脚本
[résolution] le paquet « xxxx» n'est pas dans goroot
[auto.js] automatic script
多个线程之间如何协同
Oracle 存储过程之遍历
毕业季|遗憾而又幸运的毕业季
Some important knowledge of MySQL
AIRIOT助力城市管廊工程,智慧物联守护城市生命线
力扣 2319. 判断矩阵是否是一个 X 矩阵
Cuda版本不一致,编译apex报错