Xtrabackup 8.0.x關(guān)于MySQL的版本支持淺析
本文轉(zhuǎn)載自微信公眾號「DBA閑思雜想錄」,作者瀟湘隱者 。轉(zhuǎn)載本文請聯(lián)系DBA閑思雜想錄公眾號。
我們知道從MySQL 8.0.x開始,我們必須用Percona Xtrabackup 8.0.x來備份,之前的Percona XtraBackup 2.4已經(jīng)不支持MySQL 8.x的備份了。而且Percona Xtrabackup 8.0.x也不支持備份之前的MySQL 5.6/MySQL 5.7了。但是我們對Percona Xtrabackup的具體版本支持哪一些MySQL版本了解甚少,而且官方文檔也沒有很詳細(xì)的介紹資料。
下面來看一個案例,最近安裝了一個MySQL環(huán)境,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.
提示當(dāng)前的Percona Xtrabackup(8.0.27-19)不支持MySQL 8.0.28. 但是當(dāng)前時間節(jié)點(diǎn)(2022-02-11),Percona官方網(wǎng)址,Xtrabackup最新版本為percona-xtrabackup-80-8.0.27-19.1.el7.x86_64.rpm。而MySQL的官方最新版本為MySQL 8.0.28??戳艘幌掳l(fā)布日期,MySQL 8.0.28是Sep 28, 2021發(fā)布的。而percona-xtrabackup 8.0.27是February 2, 2022才發(fā)布的。也就是說目前官方還沒有發(fā)布percona-xtrabackup 8.0.28
不過,根據(jù)官方文檔,Percona XtraBackup 8.0.21 開始,新增了--no-server-version-check 參數(shù)。此參數(shù)控制是否將源系統(tǒng)版本與 Percona XtraBackup 版本進(jìn)行比較。
--no-server-version-check
This option allows backup to proceed when the server
version is greater (newer) than the PXB supported version
關(guān)于這個參數(shù),搜索了一下官方資料,具體介紹如下所示
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
該參數(shù)檢查以下場景:
- 源系統(tǒng)和PXB版本一樣,備份繼續(xù)
- 源系統(tǒng)低于PXB版本,備份繼續(xù)
- 源系統(tǒng)大于PXB版本,且參數(shù)未被覆蓋,停止備份并返回錯誤信息
- 源系統(tǒng)大于PXB版本,參數(shù)被覆蓋,備份繼續(xù)
所以我們?nèi)绻褂脜?shù)--no-server-version-check備份的話,可能可以備份成功。也可能備份失敗,還有可能創(chuàng)建了一個損壞的備份。
xtrabackup --defaults-file=/data/mysql/my.cnf --login-path=dbbackup --backup --no-server-version-check --target-dir=/mysql_backup/db_backup
后面在搜索相關(guān)資料時,也看到了其他人遇到了類似問題,詳見鏈接:When will xtrabackup-8.0.26-18 release[1]
關(guān)于Percona Xtrabackup 8.0.x的版本支持與限制,其實(shí)之前也是很少去了解這方面的內(nèi)容,而Percona官方也沒有詳細(xì)的資料介紹,那么Xtrabackup 8.0.x是否能向下兼容支持呢 ?
例如 Xtrabackup 8.0.27-19 是否支持備份 MySQL 8.0.26 或MySQL 8.0.26之下的MySQL 8.x.x的版本呢,簡單測試了一下,我安裝了一個MySQL 8.0.26,然后安裝Xtrabackup 8.0.27-19, 測試驗(yàn)證它能否備份成功,看來Xtrabackup 8.0.x應(yīng)該是向下兼容(當(dāng)然Xtrabackup 8.0.x只能向下兼容 MySQL 8.0.x的版本)
后面我搜索相關(guān)資料時,也看到了官方一則博客,它也只是簡單介紹了一下,Percona XtraBackup 8.0.12之前的版本不支持MySQL 8.0.20或以上版本的備份。因?yàn)榇税姹景瑢?InnoDB 重做日志格式的更改,這破壞了與所有當(dāng)前發(fā)布的 Percona XtraBackup 8.x 系列版本的兼容性。詳見Percona XtraBackup 8.x and MySQL 8.0.20[2]
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.x的變更太快,Percona Xtrabackup 8.0.x的版本開發(fā)有點(diǎn)跟不上節(jié)奏了。開源免費(fèi)的產(chǎn)品,在版本的更新發(fā)布上肯定不如商業(yè)軟件那么高效,這也是開源軟件的一些缺陷,沒辦法的事情。
參考資料
[1]When will xtrabackup-8.0.26-18 release: https://forums.percona.com/t/when-will-xtrabackup-8-0-26-18-release/11944
[2]Percona XtraBackup 8.x and MySQL 8.0.20: https://www.percona.com/blog/2020/04/28/percona-xtrabackup-8-x-and-mysql-8-0-20/