当前位置:网站首页>使用 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
边栏推荐
- CIS芯片测试到底怎么测?
- Force buckle 459 Duplicate substring
- Machine learning notes - explore object detection datasets using streamlit
- Vulnhub tre1
- 力扣 1790. 仅执行一次字符串交换能否使两个字符串相等
- [philosophy and practice] the way of program design
- Kubernetes -- detailed usage of kubectl command line tool
- Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
- Force buckle 88 Merge two ordered arrays
- 九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
猜你喜欢
有了ST7008, 蓝牙测试完全拿捏住了
Mongodb由浅入深学习
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
使用高斯Redis实现二级索引
With st7008, the Bluetooth test is completely grasped
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
Simulate the implementation of string class
Vulnhub tre1
Cloud component development and upgrading
Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
随机推荐
Solve the problem of incomplete display around LCD display of rk3128 projector
vulnhub之tre1
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
[sword finger offer] sword finger offer II 012 The sum of left and right subarrays is equal
Cloud component development and upgrading
Compiler optimization (4): inductive variables
PHP method of obtaining image information
编译器优化那些事儿(4):归纳变量
Try the tuiroom of Tencent cloud (there is an appointment in the evening, which will be continued...)
Implement secondary index with Gaussian redis
【STL】vector
CSDN语法说明
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
【解决】package ‘xxxx‘ is not in GOROOT
Force buckle 674 Longest continuous increasing sequence
力扣599. 两个列表的最小索引总和
c语言如何判定是32位系统还是64位系统
力扣 459. 重复的子字符串
Boot 和 Cloud 的版本选型
微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹