天天看點

Xtrabackup 8.0.x關于MySQL的版本支援的淺析

​ 

我們知道從MySQL 8.0.x開始,我們必須用Percona Xtrabackup 8.0.x來備份,之前的Percona XtraBackup 2.4已經不支援MySQL 8.x的備份了。而且Percona Xtrabackup 8.0.x也不支援備份之前的MySQL 5.6/MySQL 5.7了。但是我們對Percona Xtrabackup的具體版本支援哪一些MySQL版本了解甚少,而且官方文檔也沒有很詳細的介紹資料。

下面來看一個案例,最近安裝了一個MySQL環境,MySQL版本為最新的MySQL 8.0.28版本,Percona XtraBackup版本也是下載下傳最新的8.0.27-19版本。

MySQL版本:8.0.28 MySQL Community Server - GPL

Xtrabackup版本:8.0.27-19

mysql> select version();      
+-----------+      
| version() |      
+-----------+      
| 8.0.28    |      
+-----------+      
1 row in set (0.00 sec)      
mysql>      
$ xtrabackup --version      
xtrabackup: recognized server arguments: --datadir=/var/lib/mysql      
xtrabackup version 8.0.27-19 based on MySQL server 8.0.27 Linux (x86_64) (revision id: 50dbc8dadda)      

使用Percona Xtrabackup 8.0.27備份MySQL 8.0.28的時報錯,如下所示:

xtrabackup: recognized server arguments: --datadir=/data/mysql/data --tmpdir=/data/mysql/mysql_temp --innodb_buffer_pool_size=8G  --server-id=1 --log_bin=/data/mysql/bin_logs/mysql_binlog      
xtrabackup: recognized client arguments: --port=3306 --socket=/tmp/mysql.sock --user=bkuser --password=* --host=127.0.0.1 --port=3306 --backup=1 --target-dir=/mysql_backup/db_backup/backup_cycle_2022_02_06/full_backup_2022_02_12_08_57_02      
/usr/bin/xtrabackup version 8.0.27-19 based on MySQL server 8.0.27 Linux (x86_64) (revision id: 50dbc8dadda)      
220212 08:58:02  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;host=127.0.0.1;port=3306;mysql_socket=/tmp/mysql.sock' as 'bkuser'  (using password: YES).      
220212 08:58:02  version_check Connected to MySQL server      
220212 08:58:02  version_check Executing a version check against the server...      
220212 08:58:02  version_check Done.      
220212 08:58:02 Connecting to MySQL server host: 127.0.0.1, user: bkuser, password: set, port: 3306, socket: /tmp/mysql.sock      
Error: Unsupported server version 8.0.28.      
Please upgrade PXB, if a new version is available. To continue with risk, use the option --no-server-version-check.      

提示目前的Percona Xtrabackup(8.0.27-19)不支援MySQL 8.0.28. 但是目前時間節點(2022-02-11),Percona官方網址,Xtrabackup最新版本為percona-xtrabackup-80-8.0.27-19.1.el7.x86_64.rpm。而MySQL的官方最新版本為MySQL 8.0.28。看了一下釋出日期,MySQL 8.0.28是Sep 28, 2021釋出的。 而percona-xtrabackup 8.0.27是February 2, 2022才釋出的。也就是說目前官方還沒有釋出percona-xtrabackup 8.0.28

不過,根據官方文檔,Percona XtraBackup 8.0.21 開始,新增了--no-server-version-check 參數。此參數控制是否将源系統版本與 Percona XtraBackup 版本進行比較。

--no-server-version-check      
This option allows backup to proceed when the server      
version is greater (newer) than the PXB supported version      

關于這個參數,搜尋了一下官方資料,具體介紹如下所示

Percona XtraBackup 8.0.21 adds the --no-server-version-check parameter. This parameter compares the source system version to the Percona XtraBackup version.

The parameter checks for the following scenarios:

·         The source system and the PXB version are the same, the backup proceeds

·         The source system is less than the PXB version, the backup proceeds

·         The source system is greater than the PXB version, and the parameter is not overridden, the backup is stopped and returns an error message

·         The source system is greater than the PXB version, and the parameter is overridden, the backup proceeds

Explicitly adding the --no-server-version-check parameter, like the example, overrides the parameter and the backup proceeds.

$ xtrabackup --backup --no-server-version-check --target-dir=$mysql/backup1

When you override the parameter, the following events can happen:

·         Backup fails

·         Creates a corrupted backup

·         Backup successful

該參數檢查以下場景:

·         源系統和PXB版本一樣,備份繼續

·         源系統低于PXB版本,備份繼續

·         源系統大于PXB版本,且參數未被覆寫,停止備份并傳回錯誤資訊

·         源系統大于PXB版本,參數被覆寫,備份繼續

是以我們如果使用參數--no-server-version-check備份的話,可能可以備份成功。也可能備份失敗,還有可能建立了一個損壞的備份。

xtrabackup --defaults-file=/data/mysql/my.cnf --login-path=dbbackup --backup --no-server-version-check --target-dir=/mysql_backup/db_backup      

後面在搜尋相關資料時,也看到了其他人遇到了類似問題,詳見參考資料連結。 

關于Percona Xtrabackup 8.0.x的版本支援與限制,其實之前也是很少去了解這方面的内容,而Percona官方也沒有詳細的資料介紹,那麼Xtrabackup 8.0.x是否能向下相容支援呢 ?

例如 Xtrabackup 8.0.27-19 是否支援備份 MySQL 8.0.26 或MySQL 8.0.26之下的MySQL 8.*.*的版本呢,簡單測試了一下,我安裝了一個MySQL 8.0.26,然後安裝Xtrabackup 8.0.27-19, 測試驗證它能否備份成功,看來Xtrabackup 8.0.x應該是向下相容(當然Xtrabackup 8.0.x隻能向下相容 MySQL8.0.x的版本)

後面我搜尋相關資料時,也看到了官方一則部落格,它也隻是簡單介紹了一下,Percona XtraBackup 8.0.12之前的版本不支援MySQL 8.0.20或以上版本的備份。因為此版本包含對 InnoDB 重做日志格式的更改,這破壞了與所有目前釋出的 Percona XtraBackup 8.x 系列版本的相容性。

https://www.percona.com/blog/2020/04/28/percona-xtrabackup-8-x-and-mysql-8-0-20/

​ 

Update: Percona XtraBackup 8.0.12 now supports backup and restore processing for versions of MySQL 8.x; previous versions of Percona XtraBackup will not work with MySQL 8.0.20 and higher. More information

On Monday, April 27, 2020, Oracle released the highly anticipated 8.0.20 version of the MySQL database server. This release contains changes to the InnoDB redo log format which breaks compatibility with all currently released versions of the Percona XtraBackup 8.x series.

At this time, there are no known workarounds that will allow any version of Percona XtraBackup 8.x to function properly with MySQL 8.0.20.

We have identified the specific cause of the issue and diligently working towards a new release that will safely solve this issue as soon as possible.

Thank you for your patience.

看來MySQL 8.0.*的變更太快,Percona Xtrabackup 8.0.*的版本開發有點跟不上節奏了。開源免費的産品,在版本的更新釋出上肯定不如商業軟體那麼高效,這也是開源軟體的一些缺陷,沒辦法的事情。