当前位置:网站首页>使用 BR 恢复 GCS 上的备份数据
使用 BR 恢复 GCS 上的备份数据
2022-07-06 21:09:00 【添香小铺】
本文介绍如何将存储在 Google Cloud Storage (GCS) 上的 SST 备份数据恢复到 Kubernetes 环境中的 TiDB 集群。
本文使用的恢复方式基于 TiDB Operator 新版(v1.1 及以上)的 CustomResourceDefinition (CRD) 实现,底层通过使用 BR 来进行集群恢复。BR 全称为 Backup & Restore,是 TiDB 分布式备份恢复的命令行工具,用于对 TiDB 集群进行数据备份和恢复。
使用场景
当使用 BR 将 TiDB 集群数据备份到 GCS 后,如果需要从 GCS 将备份的 SST(键值对)文件恢复到 TiDB 集群,请参考本文使用 BR 进行恢复。
注意
- BR 只支持 TiDB v3.1 及以上版本。
- BR 恢复的数据无法被同步到下游,因为 BR 直接导入 SST 文件,而下游集群目前没有办法获得上游的 SST 文件。
本文假设将存储在 GCS 上指定路径 spec.gcs.bucket
存储桶中 spec.gcs.prefix
文件夹下的备份数据恢复到 namespace test2
中的 TiDB 集群 demo2
。
第 1 步:准备恢复环境
使用 BR 将 GCS 上的备份数据恢复到 TiDB 前,你需要准备恢复环境,并拥有数据库的相关权限。
下载文件 backup-rbac.yaml,并执行以下命令在
test2
这个 namespace 中创建恢复所需的 RBAC 相关资源:kubectl apply -f backup-rbac.yaml -n test2
授予远程存储访问权限。
参考 GCS 账号授权,授权访问 GCS 远程存储。
如果你使用的 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=user=root --from-literal=password=<password> --namespace=test2
第 2 步:将指定备份数据恢复到 TiDB 集群
创建 restore custom resource (CR),将指定的备份数据恢复至 TiDB 集群:
kubectl apply -f restore.yaml
restore.yaml
文件内容如下:--- apiVersion: pingcap.com/v1alpha1 kind: Restore metadata: name: demo2-restore-gcs namespace: test2 spec: # backupType: full br: cluster: demo2 clusterNamespace: test2 # logLevel: info # statusAddr: ${status-addr} # concurrency: 4 # rateLimit: 0 # 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 gcs: projectId: ${project_id} secretName: gcs-secret bucket: ${bucket} prefix: ${prefix} # location: us-east1 # storageClass: STANDARD_IA # objectAcl: private
在配置
restore.yaml
文件时,请参考以下信息:- 关于 GCS 存储相关配置,请参考 GCS 存储字段介绍。
.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 -owide
边栏推荐
- ubuntu20安装redisjson记录
- A 股指数成分数据 API 数据接口
- 20.(arcgis api for js篇)arcgis api for js面采集(SketchViewModel)
- 25. (ArcGIS API for JS) ArcGIS API for JS line modification line editing (sketchviewmodel)
- [leetcode] 700 and 701 (search and insert of binary search tree)
- Force buckle ----- path sum III
- CMB's written test - quantitative relationship
- 机器学习笔记 - 使用机器学习进行鸟类物种分类
- Cryptography series: detailed explanation of online certificate status protocol OCSP
- ERROR: Could not build wheels for pycocotools which use PEP 517 and cannot be installed directly
猜你喜欢
What is Ba? How about Ba? What is the relationship between Ba and Bi?
Basic concepts of Huffman tree
1200.Minimum Absolute Difference
QT 打开文件 使用 QFileDialog 获取文件名称、内容等
23. (ArcGIS API for JS) ArcGIS API for JS ellipse collection (sketchviewmodel)
2022夏每日一题(一)
20.(arcgis api for js篇)arcgis api for js面采集(SketchViewModel)
Arduino droplet detection
List interview common questions
Ggplot facet detail adjustment summary
随机推荐
NoSQL之Redis配置与优化
qt-线程等01概念
Class常量池与运行时常量池
Cryptography series: detailed explanation of online certificate status protocol OCSP
预处理——插值
[leetcode] 700 and 701 (search and insert of binary search tree)
Enumeration general interface & enumeration usage specification
20.(arcgis api for js篇)arcgis api for js面采集(SketchViewModel)
19.(arcgis api for js篇)arcgis api for js线采集(SketchViewModel)
VHDL implementation of single cycle CPU design
List interview common questions
Que savez - vous de la sérialisation et de l'anti - séquence?
MySQL的索引
C# Task拓展方法
Flutter3.0, the applet is not only run across mobile applications
Code quality management
海思万能平台搭建:颜色空间转换YUV2RGB
你心目中的数据分析 Top 1 选 Pandas 还是选 SQL?
[dpdk] dpdk sample source code analysis III: dpdk-l3fwd_ 001
Can the applet run in its own app and realize live broadcast and connection?