当前位置:网站首页>使用 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 删掉。
边栏推荐
- Clock in during winter vacation
- 史上最全学习率调整策略lr_scheduler
- Kotlin Android 环境搭建
- 你心目中的数据分析 Top 1 选 Pandas 还是选 SQL?
- MySQL storage engine
- Vernacular high concurrency (2)
- 22. (ArcGIS API for JS) ArcGIS API for JS Circle Collection (sketchviewmodel)
- Confirm the future development route! Digital economy, digital transformation, data This meeting is very important
- Top 50 hit industry in the first half of 2022
- VHDL implementation of arbitrary size matrix multiplication
猜你喜欢
10 ways of interface data security assurance

How to detect whether the MySQL code runs deadlock +binlog view

What is Ba? How about Ba? What is the relationship between Ba and Bi?

Machine learning notes - bird species classification using machine learning

A 股指数成分数据 API 数据接口

Code quality management

qt-线程等01概念

25. (ArcGIS API for JS) ArcGIS API for JS line modification line editing (sketchviewmodel)

Function reentry, function overloading and function rewriting are understood by yourself

史上最全学习率调整策略lr_scheduler
随机推荐
Graphical tools package yolov5 and generate executable files exe
概率论公式
如何检测mysql代码运行是否出现死锁+binlog查看
运算放大器应用汇总1
19. (ArcGIS API for JS) ArcGIS API for JS line acquisition (sketchviewmodel)
web服务性能监控方案
海思3559万能平台搭建:RTSP实时播放的支持
史上最全学习率调整策略lr_scheduler
Clock in during winter vacation
复杂因子计算优化案例:深度不平衡、买卖压力指标、波动率计算
Can the applet run in its own app and realize live broadcast and connection?
R data analysis: how to predict Cox model and reproduce high score articles
23. (ArcGIS API for JS) ArcGIS API for JS ellipse collection (sketchviewmodel)
[leetcode] 450 and 98 (deletion and verification of binary search tree)
SSL证书部署
浅谈网络安全之文件上传
About Confidence Intervals
维护万星开源向量数据库是什么体验
Termux set up the computer to connect to the mobile phone. (knock the command quickly), mobile phone termux port 8022
2022夏每日一题(一)