Percona XtraBackup 8.0翻译学习
  Xs9g92thGIdj 2023年11月02日 29 0

https://docs.percona.com/percona-xtrabackup/8.0/

1.Percona XtraBackup 介绍

1.1 开源、热备

Percona XtraBackup (PXB) is an open source hot backup utility, for MySQL - based servers, that keeps your database fully available during planned maintenance windows.

Percona XtraBackup (PXB)是适用于MySQL 的一款开源热备工具。

1.2 支持存储引擎

Percona XtraBackup can back up data from InnoDB, XtraDB, MyISAM, and MyRocks tables on MySQL 8.0 servers as well as Percona Server for MySQL with XtraDB, Percona Server for MySQL 8.0, and Percona XtraDB Cluster 8.0.

支持对MySQL 8.0 servers、Percona Server for MySQL with XtraDB、Percona Server for MySQL 8.0 以及 Percona XtraDB Cluster 8.0下的InnoDB、XtraDB、MyISAM 以及 MyRocks存储引擎做备份。

1.3 版本支持

Percona XtraBackup 2.4 supports MySQL and Percona Server for MySQL 5.6 and 5.7 databases. Due to changes in the MySQL redo log and data dictionary formats, the Percona XtraBackup 8.0.x versions are only compatible with MySQL 8.0.x, Percona Server for MySQL 8.0.x, and compatible versions.

2.Percona XtraBackup 工作原理


Percona XtraBackup is based on InnoDB’s crash-recovery functionality. It copies your InnoDB data files, which results in data that is internally inconsistent; but then it performs crash recovery on the files to make them a consistent, usable database again.

Percona XtraBackup基于InnoDB的崩溃恢复原理。

2.1 备份过程锁机制

Percona XtraBackup uses Backup locks where available as a lightweight alternative to FLUSH TABLES WITH READ LOCK. This feature is available in Percona Server for MySQL 5.6+. MySQL 8.0 allows acquiring an instance level backup lock via the LOCK INSTANCE FOR BACKUP statement.

Locking is only done for MyISAM and other non-InnoDB tables after Percona XtraBackup finishes backing up all InnoDB/XtraDB data and logs. Percona XtraBackup uses this automatically to copy non-InnoDB data to avoid blocking DML queries that modify InnoDB tables.

备份过程的锁类似MySQL 5.6+的FLUSH TABLES WITH READ LOCK

MySQL 8.0允许使用LOCK INSTANCE FOR BACKUP语句持有实例级别备份锁。

在完成全部的InnoDB/XtraDB数据和日志的备份后,继续备份MyISAM和non-InnoDB表时才会有锁。

当实例仅包含InnoDB表,xtrabackup不会产生备份锁和 FLUSH TABLES WITH READ LOCK

2.2 需要的权限

The BACKUP_ADMIN privilege is required to query the performance_schema.log_status for either LOCK INSTANCE FOR BACKUP or LOCK TABLES FOR BACKUP.

2.3 备份过程

2.3.1 copy 阶段

When backup locks are supported by the server, xtrabackup first copies InnoDB data, runs the LOCK TABLES FOR BACKUP and then copies the MyISAM tables. Once this is done, the backup of the files will begin. It will backup .frm, .MRG, .MYD, .MYI, .CSM, .CSV, .sdi and .par files.

After that xtrabackup will use LOCK BINLOG FOR BACKUP to block all operations that might change either binary log position or Exec_Master_Log_Pos or Exec_Gtid_Set (i.e. source binary log coordinates corresponding to the current SQL thread state on a replication replica) as reported by SHOW MASTER/SLAVE STATUS. xtrabackup will then finish copying the REDO log files and fetch the binary log coordinates. After this is completed xtrabackup will unlock the binary log and tables.

Finally, the binary log position will be printed to STDERR and xtrabackup will exit returning 0 if all went OK.

1.首先复制InnoDB数据。

2.执行LOCK TABLES FOR BACKUP 并复制MyISAM表。

3.备份文件:.frm、.MRG、.MYD、.MYI、.CSM、.CSV、.sdi和.par文件

4.执行LOCK BINLOG FOR BACKUP 阻塞可能改变二进制坐标或Exec_Gtid_Set的操作,复制REDO log(transaction log)文件,完成后释放锁。

5.最后,二进制日志坐标将会输出到标准错误中(注意:标准错误需要重定向到文件中,如xtrabackup OPTIONS 2> backupout.log)。如果运行成功,xtrabackup将会返回0退出。

2.3.2 prepare(recovery) 阶段

Percona XtraBackup performs crash recovery against the copied data files, using the copied transaction log file. After this is done, the database is ready to restore and use.

Percona XtraBackup使用复制的transaction log文件,对数据文件进行恢复。完成后,所有数据都达到备份完成时间点的数据状态。

2.3.3 restoring a backup

xtrabackup使用--copy-back--move-back选项还原备份。

--move-back选项:move备份文件至目标目录,空间不够时使用。

--copy-back选项:copy备份文件至目标目录

xtrabackup will read from the my.cnf the variables datadir, innodb_data_home_dir, innodb_data_file_path, innodb_log_group_home_dir and check that the directories exist.


It will copy the MyISAM tables, indexes, etc. (.MRG, .MYD, .MYI, .CSM, .CSV, .sdi, and par files) first, InnoDB tables and indexes next and the log files at last. It will preserve file’s attributes when copying them, you may have to change the files’ ownership to mysql before starting the database server, as they will be owned by the user who created the backup.

1.读取my.cnf配置文件中的datadirinnodb_data_home_dirinnodb_data_file_pathinnodb_log_group_home_dir参数,确认相关目录是否存在

2.首先复制MyISAM的表、索引等(如.MRG、.MYD、.MYI、.CSM、.CSV、.sdi、par文件),然后复制InnoDB表和索引,最后复制日志文件。复制会保留文件的属性,故属主可能需要修改成mysql。



【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  xaeiTka4h8LY   2024年05月31日   37   0   0 MySQL索引
  xaeiTka4h8LY   2024年05月31日   53   0   0 MySQLSQL
  xaeiTka4h8LY   2024年05月31日   36   0   0 字段MySQL
  xaeiTka4h8LY   2024年05月31日   47   0   0 MySQL数据库
  xaeiTka4h8LY   2024年05月17日   53   0   0 MySQLgithub
  xaeiTka4h8LY   2024年05月17日   38   0   0 MySQL数据库
Xs9g92thGIdj
作者其他文章 更多