当前位置:网站首页>使用 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
边栏推荐
- 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
- Oracle time display adjustment
- wincc7.5下载安装教程(Win10系统)
- Inspiration from the recruitment of bioinformatics analysts in the Department of laboratory medicine, Zhujiang Hospital, Southern Medical University
- Nc204382 medium sequence
- Circuit breaker: use of hystrix
- 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
- Data governance: data quality
- opencv学习笔记九--背景建模+光流估计
- 数据治理:数据质量篇
猜你喜欢

A Closer Look at How Fine-tuning Changes BERT

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

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

23. Update data
![07- [istio] istio destinationrule (purpose rule)](/img/be/fa0ad746a79ec3a0d4dacd2896235f.jpg)
07- [istio] istio destinationrule (purpose rule)
![[cf gym101196-i] waif until dark network maximum flow](/img/66/6b339fc23146b5fbdcd2a1fa0a2349.png)
[cf gym101196-i] waif until dark network maximum flow

Qualitative risk analysis of Oracle project management system

Sanzi chess (C language)

链表面试题(图文详解)

File upload of DVWA range
随机推荐
远程存储访问授权
MFC sends left click, double click, and right click messages to list controls
Position() function in XPath uses
Data governance: Data Governance under microservice architecture
Entity class design for calculating age based on birthday
Luogu p4127 [ahoi2009] similar distribution problem solution
A Closer Look at How Fine-tuning Changes BERT
[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
P3047 [USACO12FEB]Nearby Cows G(树形dp)
Epoll and IO multiplexing of redis
实现精细化生产, MES、APS、ERP必不可少
21. Delete data
上线APS系统,破除物料采购计划与生产实际脱钩的难题
Document 2 Feb 12 16:54
File upload of DVWA range
Secure captcha (unsafe verification code) of DVWA range
A Closer Look at How Fine-tuning Changes BERT
Linked list interview questions (Graphic explanation)
Step by step guide to setting NFT as an ens profile Avatar
onie支持pice硬盘