当前位置:网站首页>Use br to back up tidb cluster data to azure blob storage
Use br to back up tidb cluster data to azure blob storage
2022-07-07 21:25:00 【Tianxiang shop】
This article describes how to run on Kubernetes In the environment TiDB The cluster data is backed up to Azure Blob Storage On .
The backup method used in this article is based on TiDB Operator Of Custom Resource Definition(CRD) Realization , Bottom use BR Get cluster data , Then upload the data to Azure Blob Storage On .BR Its full name is Backup & Restore, yes TiDB Command line tools for distributed backup and recovery , Used to deal with TiDB Cluster for data backup and recovery .
Use scenarios
If you have the following requirements for data backup , Consider using BR take TiDB Cluster data in Ad-hoc Backup or Scheduled full backup Backup to Azure Blob Storage On :
- The amount of data that needs to be backed up is large ( Greater than 1 TB), And it requires faster backup
- Need to backup data directly SST file ( Key value pair )
If there are other backup requirements , Please refer to Introduction to backup and recovery Choose the right backup method .
Be careful
- BR Only support TiDB v3.1 And above .
- Use BR The data backed up can only be restored to TiDB In the database , Cannot recover to other databases .
Ad-hoc Backup
Ad-hoc Backup supports full backup and incremental backup .
To carry out Ad-hoc Backup , You need to create a custom Backup custom resource (CR) Object to describe this backup . Create good Backup After the object ,TiDB Operator Automatically complete the specific backup process according to this object . If an error occurs during the backup , The program will not automatically retry , At this time, it needs to be handled manually .
This article assumes that for deployment in Kubernetes test1 This namespace Medium TiDB colony demo1 Data backup . The following is the specific operation process .
The first 1 Step : Get ready Ad-hoc Backup environment
Download the file backup-rbac.yaml, And execute the following command in
test1This namespace To create a backup RBAC Related resources :kubectl apply -f backup-rbac.yaml -n test1Grant remote storage access , There are two ways to grant permissions , Refer to the documentation Azure Account Authorization .
If you use it TiDB Version below v4.0.8, You also need to complete the following steps . If you use it TiDB by v4.0.8 And above , Please skip these steps .
Make sure you have a backup database
mysql.tidbTabularSELECTandUPDATEjurisdiction , Used to adjust before and after backup GC Time .establish
backup-demo1-tidb-secretsecret For storing access TiDB Password corresponding to the user of the cluster .kubectl create secret generic backup-demo1-tidb-secret --from-literal=password=${password} --namespace=test1
The first 2 Step : Backup data to Azure Blob Storage
According to the remote storage access authorization method selected in the previous step , You need to use the corresponding method below to export the data to Azure Blob Storage On :
Method 1: If you authorize by accessing the key , You can create
BackupCR Backup cluster data :kubectl apply -f backup-azblob.yamlbackup-azblob.yamlThe contents of the document are as follows :--- apiVersion: pingcap.com/v1alpha1 kind: Backup metadata: name: demo1-backup-azblob namespace: test1 spec: backupType: full br: cluster: demo1 clusterNamespace: test1 # logLevel: info # statusAddr: ${status_addr} # concurrency: 4 # rateLimit: 0 # timeAgo: ${time} # checksum: true # sendCredToTikv: true # options: # - --lastbackupts=420134118382108673 # Only needed for TiDB Operator < v1.1.10 or TiDB < v4.0.8 from: host: ${tidb_host} port: ${tidb_port} user: ${tidb_user} secretName: backup-demo1-tidb-secret azblob: secretName: azblob-secret container: my-container prefix: my-folderMethod 2: If it passes Azure AD Method of authorization , You can create
BackupCR Backup cluster data :kubectl apply -f backup-azblob.yamlbackup-azblob.yamlThe contents of the document are as follows :--- apiVersion: pingcap.com/v1alpha1 kind: Backup metadata: name: demo1-backup-azblob namespace: test1 spec: backupType: full serviceAccount: tidb-backup-manager br: cluster: demo1 sendCredToTikv: false clusterNamespace: test1 # logLevel: info # statusAddr: ${status_addr} # concurrency: 4 # rateLimit: 0 # timeAgo: ${time} # checksum: true # options: # - --lastbackupts=420134118382108673 # Only needed for TiDB Operator < v1.1.10 or TiDB < v4.0.8 from: host: ${tidb_host} port: ${tidb_port} user: ${tidb_user} secretName: backup-demo1-tidb-secret azblob: secretName: azblob-secret-ad container: my-container prefix: my-folder
In the configuration backup-azblob.yaml When you file , Please refer to the following information :
- since TiDB Operator v1.1.6 Since version , If you need incremental backup , Only need
spec.br.optionsSpecifies the last backup timestamp--lastbackuptsthat will do . Restrictions on incremental backups , May refer to Use BR Back up and restore . - About Azure Blob Storage Related configuration , Please refer to Azure Blob Storage Storage field introduction .
.spec.brSome parameters in are optional , for examplelogLevel、statusAddretc. . complete.spec.brDetailed explanation of fields , Please refer to BR Field is introduced .- If you use it TiDB by v4.0.8 And above , BR Will automatically adjust
tikv_gc_life_timeParameters , No configuration requiredspec.tikvGCLifeTimeandspec.fromField . - more
BackupCR For detailed explanation of fields, please refer to Backup CR Field is introduced .
Create good Backup CR after ,TiDB Operator Will be based on Backup CR Automatically start backup . You can check the backup status through the following commands :
kubectl get bk -n test1 -o wide
Backup example
Back up all cluster data
Backing up data from a single database
Back up the data of a single table
Use the table library filtering function to back up the data of multiple tables
Scheduled full backup
You can set the backup policy to TiDB The cluster performs scheduled backup , At the same time, set the retention policy of backup to avoid too many backups . Scheduled full backup through customized BackupSchedule CR Object to describe . A full backup will be triggered every time the backup time point , The bottom layer of scheduled full backup passes Ad-hoc Full backup .
The first 1 Step : Prepare a scheduled full backup environment
Same as Get ready Ad-hoc Backup environment .
The first 2 Step : Regularly back up data to Azure Blob Storage
Basis preparation Ad-hoc The remote storage access authorization method selected when backing up the environment , You need to use the corresponding method below to regularly back up data to Azure Blob Storage On :
Method 1: If you authorize by accessing the key , You can create
BackupScheduleCR, Turn on TiDB Cluster regular full backup :kubectl apply -f backup-scheduler-azblob.yamlbackup-scheduler-azblob.yamlThe contents of the document are as follows :--- apiVersion: pingcap.com/v1alpha1 kind: BackupSchedule metadata: name: demo1-backup-schedule-azblob namespace: test1 spec: #maxBackups: 5 #pause: true maxReservedTime: "3h" schedule: "*/2 * * * *" backupTemplate: backupType: full br: cluster: demo1 clusterNamespace: test1 # 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 from: host: ${tidb_host} port: ${tidb_port} user: ${tidb_user} secretName: backup-demo1-tidb-secret azblob: secretName: azblob-secret-ad container: my-container prefix: my-folderMethod 2: If it passes Azure AD Method of authorization , You can create
BackupScheduleCR, Turn on TiDB Cluster regular full backup :kubectl apply -f backup-scheduler-azblob.yamlbackup-scheduler-azblob.yamlThe contents of the document are as follows :--- apiVersion: pingcap.com/v1alpha1 kind: BackupSchedule metadata: name: demo1-backup-schedule-azblob namespace: test1 spec: #maxBackups: 5 #pause: true maxReservedTime: "3h" schedule: "*/2 * * * *" backupTemplate: backupType: full br: cluster: demo1 sendCredToTikv: false clusterNamespace: test1 # 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 from: host: ${tidb_host} port: ${tidb_port} user: ${tidb_user} secretName: backup-demo1-tidb-secret azblob: secretName: azblob-secret-ad container: my-container prefix: my-folder
From above backup-scheduler-azblob.yaml The file configuration example shows ,backupSchedule The configuration of consists of two parts . Part of it is backupSchedule Unique configuration , The other part is backupTemplate.
- About
backupScheduleSpecific introduction to unique configuration items , Please refer to BackupSchedule CR Field is introduced . backupTemplateUsed to specify the configuration related to cluster and remote storage , Fields and Backup CR Mediumspecequally , Please refer to Backup CR Field is introduced .
After the scheduled full backup is created , You can view the status of scheduled full backup through the following commands :
kubectl get bks -n test1 -o wide
Check all the backup pieces below the scheduled full backup :
kubectl get bk -l tidb.pingcap.com/backup-schedule=demo1-backup-schedule-azblob -n test1
边栏推荐
- Problems encountered in installing mysql8 for Ubuntu and the detailed installation process
- 万字总结数据存储,三大知识点
- FTP steps for downloading files from Huawei CE switches
- 恶魔奶爸 指南帖——简易版
- npm uninstall和rm直接删除的区别
- H3C s7000/s7500e/10500 series post stack BFD detection configuration method
- 程序猿赚的那点钱算个P啊!
- 智能交通焕发勃勃生机,未来会呈现哪些巨变?[通俗易懂]
- 【OpenCV 例程200篇】223. 特征提取之多边形拟合(cv.approxPolyDP)
- uva 12230 – Crossing Rivers(概率)「建议收藏」
猜你喜欢

【OpenCV 例程200篇】223. 特征提取之多边形拟合(cv.approxPolyDP)

Cantata9.0 | new features
Mysql子查询关键字的使用方式(exists)

95年专注安全这一件事 沃尔沃未来聚焦智能驾驶与电气化领域安全

Solve the problem of using uni app mediaerror mediaerror errorcode -5

Problems encountered in installing mysql8 for Ubuntu and the detailed installation process

使用枚举实现英文转盲文

Helix QAC 2020.2 new static test tool maximizes the coverage of standard compliance

恶魔奶爸 B3 少量泛读,完成两万词汇量+

H3C s7000/s7500e/10500 series post stack BFD detection configuration method
随机推荐
Deployment, recall and deletion solutions - stsadm and PowerShell "suggestions collection"
easyui 日期控件清空值
FatMouse&#39; Trade (Hangdian 1009)
margin 等高布局
Postgresql数据库character varying和character的区别说明
现在网上开户安全么?想知道我现在在南宁,到哪里开户比较好?
使用高斯Redis实现二级索引
【C语言】指针进阶---指针你真的学懂了吗?
Numerical method for solving optimal control problem (0) -- Definition
[paper reading] maps: Multi-Agent Reinforcement Learning Based Portfolio Management System
How to choose financial products? Novice doesn't know anything
国家正规的股票交易app有哪些?使用安不安全
Implement secondary index with Gaussian redis
How to meet the dual needs of security and confidentiality of medical devices?
Demon daddy A3 stage near normal speed speech flow initial contact
Goal: do not exclude yaml syntax. Try to get started quickly
Object-C programming tips timer "suggestions collection"
openGl超级宝典学习笔记 (1)第一个三角形「建议收藏」
How to choose fund products? What fund is suitable to buy in July 2022?
FatMouse&#39; Trade(杭电1009)