当前位置:网站首页>使用 BR 恢复 S3 兼容存储上的备份数据
使用 BR 恢复 S3 兼容存储上的备份数据
2022-07-06 07:58:00 【添香小铺】
本文介绍如何将 S3 兼容存储上的 SST 备份数据恢复到 AWS Kubernetes 环境中的 TiDB 集群。
本文使用的恢复方式基于 TiDB Operator 的 Custom Resource Definition (CRD) 实现,底层使用 BR 进行数据恢复。BR 全称为 Backup & Restore,是 TiDB 分布式备份恢复的命令行工具,用于对 TiDB 集群进行数据备份和恢复。
使用场景
当使用 BR 将 TiDB 集群数据备份到 Amazon S3 后,如果需要从 Amazon S3 将备份的 SST(键值对)文件恢复到 TiDB 集群,请参考本文使用 BR 进行恢复。
注意
- BR 只支持 TiDB v3.1 及以上版本。
- BR 恢复的数据无法被同步到下游,因为 BR 直接导入 SST 文件,而下游集群目前没有办法获得上游的 SST 文件。
本文假设将存储在 Amazon S3 上指定路径 spec.s3.bucket 存储桶中 spec.s3.prefix 文件夹下的备份数据恢复到 namespace test2 中的 TiDB 集群 demo2。下面是具体的操作过程。
第 1 步:准备恢复环境
使用 BR 将 S3 兼容存储上的备份数据恢复到 TiDB 前,请按照以下步骤准备恢复环境。
下载文件 backup-rbac.yaml,并执行以下命令在
test2这个 namespace 中创建恢复需要的 RBAC 相关资源:kubectl apply -f backup-rbac.yaml -n test2授予远程存储访问权限。
- 如果要恢复的数据在 Amazon S3 上,可以使用三种权限授予方式授予权限,可参考文档 AWS 账号授权。
- 如果要恢复的数据在其他兼容 S3 的存储上,例如 Ceph、MinIO,可以使用 AccessKey 和 SecretKey 模式授权,可参考文档通过 AccessKey 和 SecretKey 授权。
如果你使用的 TiDB 版本低于 v4.0.8,你还需要进行以下操作。如果你使用的 TiDB 为 v4.0.8 及以上版本,请跳过此步骤。
确保你拥有恢复数据库
mysql.tidb表的SELECT和UPDATE权限,用于恢复前后调整 GC 时间。创建
restore-demo2-tidb-secretsecret 用于存放访问 TiDB 集群的 root 账号和密钥。kubectl create secret generic restore-demo2-tidb-secret --from-literal=password=${password} --namespace=test2
第 2 步:将指定备份数据恢复到 TiDB 集群
根据上一步选择的远程存储访问授权方式,你需要使用下面对应的方法将备份数据恢复到 TiDB:
方法 1: 如果通过了 accessKey 和 secretKey 的方式授权,你可以按照以下说明创建
RestoreCR 恢复集群数据:kubectl apply -f resotre-aws-s3.yamlrestore-aws-s3.yaml文件内容如下:--- apiVersion: pingcap.com/v1alpha1 kind: Restore metadata: name: demo2-restore-s3 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 s3: provider: aws secretName: s3-secret region: us-west-1 bucket: my-bucket prefix: my-folder方法 2: 如果通过了 IAM 绑定 Pod 的方式授权,你可以按照以下说明创建
RestoreCR 恢复集群数据:kubectl apply -f restore-aws-s3.yamlrestore-aws-s3.yaml文件内容如下:--- apiVersion: pingcap.com/v1alpha1 kind: Restore metadata: name: demo2-restore-s3 namespace: test2 annotations: iam.amazonaws.com/role: arn:aws:iam::123456789012:role/user spec: 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 s3: provider: aws region: us-west-1 bucket: my-bucket prefix: my-folder方法 3: 如果通过了 IAM 绑定 ServiceAccount 的方式授权,你可以按照以下说明创建
RestoreCR 恢复集群数据:kubectl apply -f restore-aws-s3.yamlrestore-aws-s3.yaml文件内容如下:--- apiVersion: pingcap.com/v1alpha1 kind: Restore metadata: name: demo2-restore-s3 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 s3: provider: aws region: us-west-1 bucket: my-bucket prefix: my-folder
在配置 restore-aws-s3.yaml 文件时,请参考以下信息:
- 关于兼容 S3 的存储相关配置,请参考 S3 存储字段介绍。
.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 -o wide
边栏推荐
- octomap averageNodeColor函数说明
- Data governance: data quality
- http缓存,强制缓存,协商缓存
- Pangolin Library: control panel, control components, shortcut key settings
- Epoll and IO multiplexing of redis
- 08- [istio] istio gateway, virtual service and the relationship between them
- Wireshark grabs packets to understand its word TCP segment
- Asia Pacific Financial Media | designer universe | Guangdong responds to the opinions of the national development and Reform Commission. Primary school students incarnate as small community designers
- Nc204382 medium sequence
- 数据治理:元数据管理篇
猜你喜欢

National economic information center "APEC industry +": economic data released at the night of the Spring Festival | observation of stable strategy industry fund

链表面试题(图文详解)

The Vice Minister of the Ministry of industry and information technology of "APEC industry +" of the national economic and information technology center led a team to Sichuan to investigate the operat
![08- [istio] istio gateway, virtual service and the relationship between them](/img/fb/09793f5fd12c2906b73cc42722165f.jpg)
08- [istio] istio gateway, virtual service and the relationship between them

Document 2 Feb 12 16:54

It's hard to find a job when the industry is in recession

Description of octomap averagenodecolor function

opencv学习笔记九--背景建模+光流估计

Go learning notes (3) basic types and statements (2)
![[非线性控制理论]9_非线性控制理论串讲](/img/a8/03ed363659a0a067c2f1934457c106.png)
[非线性控制理论]9_非线性控制理论串讲
随机推荐
Onie supports pice hard disk
Solution: intelligent site intelligent inspection scheme video monitoring system
Asia Pacific Financial Media | female pattern ladyvision: forced the hotel to upgrade security. The drunk woman died in the guest room, and the hotel was sentenced not to pay compensation | APEC secur
使用 TiUP 升级 TiDB
NFT smart contract release, blind box, public offering technology practice -- jigsaw puzzle
Comparison of usage scenarios and implementations of extensions, equal, and like in TS type Gymnastics
Pre knowledge reserve of TS type gymnastics to become an excellent TS gymnastics master
Esrally domestic installation and use pit avoidance Guide - the latest in the whole network
649. Dota2 Senate
24. Query table data (basic)
[1. Delphi foundation] 1 Introduction to Delphi Programming
MFC sends left click, double click, and right click messages to list controls
Document 2 Feb 12 16:54
Position() function in XPath uses
实现精细化生产, MES、APS、ERP必不可少
Generator Foundation
08- [istio] istio gateway, virtual service and the relationship between them
DataX self check error /datax/plugin/reader/_ drdsreader/plugin. Json] does not exist
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
MES, APS and ERP are essential to realize fine production