当前位置:网站首页>使用 TiDB Lightning 恢复 GCS 上的备份数据
使用 TiDB Lightning 恢复 GCS 上的备份数据
2022-07-06 21:09:00 【添香小铺】
本文档介绍如何将 Kubernetes 上通过 TiDB Operator 备份的数据恢复到 TiDB 集群。
本文使用的恢复方式基于 TiDB Operator v1.1 及以上的 CustomResourceDefinition (CRD) 实现,底层通过使用 TiDB Lightning TiDB-backend 来恢复数据。
TiDB Lightning 是一款将全量数据高速导入到 TiDB 集群的工具,可用于从本地盘、Google Cloud Storage (GCS) 或 Amazon S3 云盘读取数据。目前,TiDB Lightning 支持三种后端:Importer-backend、Local-backend、TiDB-backend。本文介绍的方法使用 TiDB-backend。关于这三种后端的区别和选择,请参阅 TiDB Lightning 文档。如果要使用 Importer-backend 或者 Local-backend 导入数据,请参阅使用 TiDB Lightning 导入集群数据。
以下示例将存储在 GCS 上指定路径上的集群备份数据恢复到 TiDB 集群。
使用场景
如果你需要从 GCS 导出备份数据到 TiDB 集群,并对数据恢复有以下要求,可使用本文介绍的恢复方案:
- 希望以较低资源占用率和较低网络带宽占用进行恢复,并能接受 50 GB/小时的恢复速度
- 要求导入集群时满足 ACID
- 要求备份期间 TiDB 集群仍可对外提供服务
恢复前的准备
在进行数据恢复前,你需要准备恢复环境,并拥有数据库的相关权限。
环境准备
下载文件 backup-rbac.yaml,并执行以下命令在
test2这个 namespace 中创建恢复所需的 RBAC 相关资源:kubectl apply -f backup-rbac.yaml -n test2远程存储访问授权。
参考 GCS 账号授权授权访问 GCS 远程存储。
创建
restore-demo2-tidb-secretsecret,该 secret 存放用来访问 TiDB 集群的 root 账号和密钥:kubectl create secret generic restore-demo2-tidb-secret --from-literal=user=root --from-literal=password=${password} --namespace=test2
所需的数据库权限
使用 TiDB Lightning 将 GCS 上的备份数据恢复至 TiDB 集群前,确保你拥有备份数据库的以下权限:
| 权限 | 作用域 |
|---|---|
| SELECT | Tables |
| INSERT | Tables |
| UPDATE | Tables |
| DELETE | Tables |
| CREATE | Databases, tables |
| DROP | Databases, tables |
| ALTER | Tables |
将指定备份数据恢复到 TiDB 集群
创建 restore custom resource (CR),将指定的备份数据恢复至 TiDB 集群:
kubectl apply -f restore.yamlrestore.yaml文件内容如下:--- apiVersion: pingcap.com/v1alpha1 kind: Restore metadata: name: demo2-restore namespace: test2 spec: to: host: ${tidb_host} port: ${tidb_port} user: ${tidb_user} secretName: restore-demo2-tidb-secret gcs: projectId: ${project_id} secretName: gcs-secret path: gcs://${backup_path} # storageClassName: local-storage storageSize: 1Gi以上示例将存储在 GCS 上指定路径
spec.gcs.path的备份数据恢复到 TiDB 集群spec.to.host。关于 GCS 的配置项可以参考 GCS 字段介绍。更多
RestoreCR 字段的详细解释参考 Restore CR 字段介绍。创建好
RestoreCR 后可通过以下命令查看恢复的状态:kubectl get rt -n test2 -owide
注意
TiDB Operator 会创建一个 PVC,用于数据恢复,备份数据会先从远端存储下载到 PV,然后再进行恢复。如果恢复完成后想要删掉这个 PVC,可以参考删除资源先把恢复 Pod 删掉,然后再把 PVC 删掉。
边栏推荐
- 机器学习笔记 - 使用机器学习进行鸟类物种分类
- Optimization cases of complex factor calculation: deep imbalance, buying and selling pressure index, volatility calculation
- Free PHP online decryption tool source code v1.2
- 自适应非欧表征广告检索系统AMCAD
- 运算放大器应用汇总1
- 未来发展路线确认!数字经济、数字化转型、数据...这次会议很重要
- On file uploading of network security
- 二叉搜索树的实现
- 哈夫曼树基本概念
- A 股指数成分数据 API 数据接口
猜你喜欢

海思3559万能平台搭建:RTSP实时播放的支持

About Confidence Intervals

codeforces每日5题(均1700)-第七天
10 ways of interface data security assurance
![[security attack and Defense] how much do you know about serialization and deserialization?](/img/1c/e5ae74e65bacf688d7f61cc1b71d3e.png)
[security attack and Defense] how much do you know about serialization and deserialization?

Restcloud ETL Community Edition June featured Q & A
Docker部署Mysql8的实现步骤

About Tolerance Intervals

Graphical tools package yolov5 and generate executable files exe

Kotlin Android 环境搭建
随机推荐
About Confidence Intervals
map和set的实现
Adaptive non European advertising retrieval system amcad
When QT uses qtooltip mouse to display text, the picture of the button will also be displayed and the prompt text style will be modified
21. (article ArcGIS API for JS) ArcGIS API for JS rectangular acquisition (sketchviewmodel)
Force buckle ----- path sum III
A 股指数成分数据 API 数据接口
Machine learning notes - bird species classification using machine learning
Set static IP for raspberry pie
Confirm the future development route! Digital economy, digital transformation, data This meeting is very important
Graphical tools package yolov5 and generate executable files exe
华为小米互“抄作业”
ggplot 分面的细节调整汇总
Termux set up the computer to connect to the mobile phone. (knock the command quickly), mobile phone termux port 8022
Can the applet run in its own app and realize live broadcast and connection?
小程序能运行在自有App中,且实现直播和连麦?
Kotlin Android environment construction
Principle of attention mechanism
[dpdk] dpdk sample source code analysis III: dpdk-l3fwd_ 001
Create commonly used shortcut icons at the top of the ad interface (menu bar)