mysql 8.0 使用 XtraBackup增量备份及恢复

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介: 使用 XtraBackup 进行备份,并使用备份数据进行恢复。

1.问题描述

使用 XtraBackup 进行增量备份(仅仅备份自上次备份后变更的数据),并使用备份数据进行恢复。

增量备份原理:
1)每个 InnoDB Page 都包含 LSN,LSN 是整个数据库的系统版本号,每个 InnoDB Page 的 LSN 都展示 InnoDB Page 是如何变化的
2)在增量备份时,对比 InnoDB Page 的 LSN 与 全量备份的 LSN,如果 InnoDB Page 的 LSN 较新,则复制该 InnoDB Page
3)更进一步,如果你知道 LSN,则无需基础的全量备份,可以使用 –incremental-lsn 直接指定(但是恢复的时候依旧需要基础的全量备份)

注意事项:
1)该增量备份只能针对 MySQL 实例,而不能针对特定数据库或者特定数据表;

2.centos 安装XtraBackup

yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm


yum install -y percona-xtrabackup-80.x86_64

3.创建增量备份

3.1 创建全量备份

增量备份是在全量备份的基础之上,因此需要先创建全量备份:

[root@lys-mysql full]#  xtrabackup    --host=10.6.8.238 --user=user0001 --password=User0001! --port=3306 --databases="db01" --backup --target-dir=/data/backups/full  --no-server-version-check


xtrabackup: recognized server arguments: --datadir=/var/lib/mysql
xtrabackup: recognized client arguments: --host=10.6.8.238 --user=user0001 --password=* --port=3306 --databases=db01 --backup=1 --target-dir=/data/backups/full --no-server-version-check=1
xtrabackup version 8.0.27-19 based on MySQL server 8.0.27 Linux (x86_64) (revision id: 50dbc8dadda)
220419 09:55:01  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;host=10.6.8.238;port=3306' as 'user0001'  (using password: YES).
220419 09:55:01  version_check Connected to MySQL server
220419 09:55:01  version_check Executing a version check against the server...
220419 09:55:01  version_check Done.
220419 09:55:01 Connecting to MySQL server host: 10.6.8.238, user: user0001, password: set, port: 3306, socket: not set
Using server version 8.0.28
220419 09:55:01 Executing LOCK INSTANCE FOR BACKUP...
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql
xtrabackup: open files limit requested 0, set to 1048576
xtrabackup: using the following InnoDB configuration:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = ./
xtrabackup:   innodb_log_files_in_group = 2
xtrabackup:   innodb_log_file_size = 50331648
Number of pools: 1
xtrabackup: inititialize_service_handles suceeded
220419 09:55:02 Connecting to MySQL server host: 10.6.8.238, user: user0001, password: set, port: 3306, socket: not set
xtrabackup: Redo Log Archiving is not set up.
220419 09:55:02 >> log scanned up to (18611669)
xtrabackup: Generating a list of tablespaces
xtrabackup: Generating a list of tablespaces
Scanning './'
Completed space ID check of 2 files.
Allocated tablespace ID 18 for db01/tb_user, old maximum was 0
Using undo tablespace './undo_001'.
Using undo tablespace './undo_002'.
Opened 2 existing undo tablespaces.
220419 09:55:02 [01] Copying ./ibdata1 to /data/backups/full/ibdata1
220419 09:55:02 [01]        ...done
220419 09:55:02 [01] Copying ./db01/tb_user.ibd to /data/backups/full/db01/tb_user.ibd
220419 09:55:02 [01]        ...done
220419 09:55:02 [01] Copying ./db01/tb_user_copy1.ibd to /data/backups/full/db01/tb_user_copy1.ibd
220419 09:55:02 [01]        ...done
220419 09:55:02 [01] Copying ./mysql.ibd to /data/backups/full/mysql.ibd
220419 09:55:02 [01]        ...done
220419 09:55:02 [01] Copying ./undo_002 to /data/backups/full/undo_002
220419 09:55:03 [01]        ...done
220419 09:55:03 [01] Copying ./undo_001 to /data/backups/full/undo_001
220419 09:55:03 [01]        ...done
220419 09:55:03 >> log scanned up to (18611669)
220419 09:55:03 Starting to backup non-InnoDB tables and files
220419 09:55:03 [01] Skipping ./auto.cnf.
220419 09:55:03 [01] Skipping ./ibdata1.
220419 09:55:03 [01] Skipping ./ib_logfile1.
220419 09:55:03 [01] Skipping ./#ib_16384_0.dblwr.
220419 09:55:03 [01] Skipping ./#ib_16384_1.dblwr.
220419 09:55:03 [01] Skipping ./undo_001.
220419 09:55:03 [01] Skipping ./undo_002.
220419 09:55:03 [01] Skipping ./ib_logfile0.
220419 09:55:03 [01] Skipping ./mysql.ibd.
220419 09:55:03 [01] Skipping ./ca-key.pem.
220419 09:55:03 [01] Skipping ./ca.pem.
220419 09:55:03 [01] Skipping ./server-key.pem.
220419 09:55:03 [01] Skipping ./server-cert.pem.
220419 09:55:03 [01] Skipping ./client-key.pem.
220419 09:55:03 [01] Skipping ./client-cert.pem.
220419 09:55:03 [01] Skipping ./private_key.pem.
220419 09:55:03 [01] Skipping ./public_key.pem.
220419 09:55:03 [01] Skipping ./ib_buffer_pool.
220419 09:55:03 [01] Skipping ./ibtmp1.
220419 09:55:03 [01] Skipping ./binlog.000001.
220419 09:55:03 [01] Skipping ./mysql.sock.lock.
220419 09:55:03 [01] Skipping ./lys_bin.txt.
220419 09:55:03 [01] Skipping ./binlog.000002.
220419 09:55:03 [01] Skipping ./binlog.000003.
220419 09:55:03 [01] Skipping ./binlog.000004.
220419 09:55:03 [01] Skipping ./binlog.000005.
220419 09:55:03 [01] Skipping ./binlog.000006.
220419 09:55:03 [01] Skipping ./binlog.000007.
220419 09:55:03 [01] Skipping ./binlog.index.
220419 09:55:03 Finished backing up non-InnoDB tables and files
220419 09:55:03 Executing FLUSH NO_WRITE_TO_BINLOG BINARY LOGS
220419 09:55:03 Selecting LSN and binary log position from p_s.log_status
220419 09:55:03 [00] Copying /var/lib/mysql/binlog.000008 to /data/backups/full/binlog.000008 up to position 157
220419 09:55:03 [00]        ...done
220419 09:55:03 [00] Writing /data/backups/full/binlog.index
220419 09:55:03 [00]        ...done
220419 09:55:03 [00] Writing /data/backups/full/xtrabackup_binlog_info
220419 09:55:03 [00]        ...done
220419 09:55:03 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '18611669'
xtrabackup: Stopping log copying thread at LSN 18611669.
Starting to parse redo log at lsn = 18611226

220419 09:55:03 Executing UNLOCK INSTANCE
220419 09:55:03 All tables unlocked
220419 09:55:03 [00] Copying ib_buffer_pool to /data/backups/full/ib_buffer_pool
220419 09:55:03 [00]        ...done
220419 09:55:03 Backup created in directory '/data/backups/full/'
MySQL binlog position: filename 'binlog.000008', position '157'
220419 09:55:03 [00] Writing /data/backups/full/backup-my.cnf
220419 09:55:03 [00]        ...done
220419 09:55:03 [00] Writing /data/backups/full/xtrabackup_info
220419 09:55:03 [00]        ...done
xtrabackup: Transaction log of lsn (18611669) to (18611679) was copied.
220419 09:55:05 completed OK!

查看 xtrabackup_checkpoints 文件可以获取 LSN 相关信息。

[root@lys-mysql full]# cat xtrabackup_checkpoints
backup_type = full-backuped
from_lsn = 0
to_lsn = 18611669
last_lsn = 18611669
flushed_lsn = 18611669

3.2 创建增量备份

[root@lys-mysql inc1]#  xtrabackup  --no-server-version-check  --backup --host=10.6.8.238 --user=user0001 --password=User0001! --port=3306 --databases="db01" --target-dir=/data/backups/inc1  --incremental-basedir=/data/backups/full

xtrabackup: recognized server arguments: --datadir=/var/lib/mysql
xtrabackup: recognized client arguments: --no-server-version-check=1 --backup=1 --host=10.6.8.238 --user=user0001 --password=* --port=3306 --databases=db01 --target-dir=/data/backups/inc1 --incremental-basedir=/data/backups/full
xtrabackup version 8.0.27-19 based on MySQL server 8.0.27 Linux (x86_64) (revision id: 50dbc8dadda)
220419 10:00:44  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;host=10.6.8.238;port=3306' as 'user0001'  (using password: YES).
220419 10:00:44  version_check Connected to MySQL server
220419 10:00:44  version_check Executing a version check against the server...
220419 10:00:44  version_check Done.
220419 10:00:44 Connecting to MySQL server host: 10.6.8.238, user: user0001, password: set, port: 3306, socket: not set
Using server version 8.0.28
220419 10:00:44 Executing LOCK INSTANCE FOR BACKUP...
incremental backup from 18611669 is enabled.
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql
xtrabackup: open files limit requested 0, set to 1048576
xtrabackup: using the following InnoDB configuration:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = ./
xtrabackup:   innodb_log_files_in_group = 2
xtrabackup:   innodb_log_file_size = 50331648
Number of pools: 1
xtrabackup: inititialize_service_handles suceeded
220419 10:00:44 Connecting to MySQL server host: 10.6.8.238, user: user0001, password: set, port: 3306, socket: not set
xtrabackup: Redo Log Archiving is not set up.
220419 10:00:45 >> log scanned up to (18612011)
xtrabackup: Generating a list of tablespaces
xtrabackup: Generating a list of tablespaces
Scanning './'
Completed space ID check of 2 files.
Allocated tablespace ID 18 for db01/tb_user, old maximum was 0
Using undo tablespace './undo_001'.
Using undo tablespace './undo_002'.
Opened 2 existing undo tablespaces.
xtrabackup: using the full scan for incremental backup
220419 10:00:45 [01] Copying ./ibdata1 to /data/backups/inc1/ibdata1.delta
220419 10:00:45 [01]        ...done
220419 10:00:45 [01] Copying ./db01/tb_user.ibd to /data/backups/inc1/db01/tb_user.ibd.delta
220419 10:00:45 [01]        ...done
220419 10:00:45 [01] Copying ./db01/tb_user_copy1.ibd to /data/backups/inc1/db01/tb_user_copy1.ibd.delta
220419 10:00:45 [01]        ...done
220419 10:00:45 [01] Copying ./mysql.ibd to /data/backups/inc1/mysql.ibd.delta
220419 10:00:46 [01]        ...done
220419 10:00:46 >> log scanned up to (18612011)
220419 10:00:46 [01] Copying ./undo_002 to /data/backups/inc1/undo_002.delta
220419 10:00:46 [01]        ...done
220419 10:00:46 [01] Copying ./undo_001 to /data/backups/inc1/undo_001.delta
220419 10:00:46 [01]        ...done
220419 10:00:47 >> log scanned up to (18612011)
220419 10:00:47 Starting to backup non-InnoDB tables and files
220419 10:00:47 [01] Skipping ./auto.cnf.
220419 10:00:47 [01] Skipping ./ibdata1.
220419 10:00:47 [01] Skipping ./ib_logfile1.
220419 10:00:47 [01] Skipping ./#ib_16384_0.dblwr.
220419 10:00:47 [01] Skipping ./#ib_16384_1.dblwr.
220419 10:00:47 [01] Skipping ./undo_001.
220419 10:00:47 [01] Skipping ./undo_002.
220419 10:00:47 [01] Skipping ./ib_logfile0.
220419 10:00:47 [01] Skipping ./mysql.ibd.
220419 10:00:47 [01] Skipping ./ca-key.pem.
220419 10:00:47 [01] Skipping ./ca.pem.
220419 10:00:47 [01] Skipping ./server-key.pem.
220419 10:00:47 [01] Skipping ./server-cert.pem.
220419 10:00:47 [01] Skipping ./client-key.pem.
220419 10:00:47 [01] Skipping ./client-cert.pem.
220419 10:00:47 [01] Skipping ./private_key.pem.
220419 10:00:47 [01] Skipping ./public_key.pem.
220419 10:00:47 [01] Skipping ./ib_buffer_pool.
220419 10:00:47 [01] Skipping ./ibtmp1.
220419 10:00:47 [01] Skipping ./binlog.000001.
220419 10:00:47 [01] Skipping ./mysql.sock.lock.
220419 10:00:47 [01] Skipping ./lys_bin.txt.
220419 10:00:47 [01] Skipping ./binlog.000002.
220419 10:00:47 [01] Skipping ./binlog.000003.
220419 10:00:47 [01] Skipping ./binlog.000004.
220419 10:00:47 [01] Skipping ./binlog.000005.
220419 10:00:47 [01] Skipping ./binlog.000006.
220419 10:00:47 [01] Skipping ./binlog.000007.
220419 10:00:47 [01] Skipping ./binlog.000008.
220419 10:00:47 [01] Skipping ./binlog.000009.
220419 10:00:47 [01] Skipping ./binlog.index.
220419 10:00:47 Finished backing up non-InnoDB tables and files
220419 10:00:47 Executing FLUSH NO_WRITE_TO_BINLOG BINARY LOGS
220419 10:00:47 Selecting LSN and binary log position from p_s.log_status
220419 10:00:47 [00] Copying /var/lib/mysql/binlog.000010 to /data/backups/inc1/binlog.000010 up to position 157
220419 10:00:47 [00]        ...done
220419 10:00:47 [00] Writing /data/backups/inc1/binlog.index
220419 10:00:47 [00]        ...done
220419 10:00:47 [00] Writing /data/backups/inc1/xtrabackup_binlog_info
220419 10:00:47 [00]        ...done
220419 10:00:47 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '18612011'
xtrabackup: Stopping log copying thread at LSN 18612011.
Starting to parse redo log at lsn = 18611725

220419 10:00:47 Executing UNLOCK INSTANCE
220419 10:00:47 All tables unlocked
220419 10:00:47 [00] Copying ib_buffer_pool to /data/backups/inc1/ib_buffer_pool
220419 10:00:47 [00]        ...done
220419 10:00:47 Backup created in directory '/data/backups/inc1/'
MySQL binlog position: filename 'binlog.000010', position '157'
220419 10:00:47 [00] Writing /data/backups/inc1/backup-my.cnf
220419 10:00:47 [00]        ...done
220419 10:00:47 [00] Writing /data/backups/inc1/xtrabackup_info
220419 10:00:47 [00]        ...done
xtrabackup: Transaction log of lsn (18612011) to (18612021) was copied.
220419 10:00:48 completed OK!

查看 xtrabackup_checkpoints 文件可以获取 LSN 相关信息。

[root@lys-mysql inc1]# cat xtrabackup_checkpoints
backup_type = incremental
from_lsn = 18611669
to_lsn = 18612011
last_lsn = 18612011
flushed_lsn = 18612011

4. 准备增量备份

增量备份的准备阶段不同与全量备份的准备阶段:

  • 对于全量备份,在准备阶段中,需要:将已提交事务从日志文件写入数据文件;回滚未提交的事务;
  • 对于增量备份,在准备阶段中,不能回滚未提交的事务,因为事务可能在下次备份中提价;

因此对全量备份使用 xtrabackup –apply-log-only 应用日志,防止发生回滚,否则全量备份无法用于增量备份。

4.1全量备份准备

此时的全量备份可以用于数据恢复,因为未提交的事务会在启动时被 MySQL 处理。首先对全量备份应用日志,以作为增量的基础:

[root@lys-mysql full]# xtrabackup  --no-server-version-check --prepare --apply-log-only --host=10.6.8.238 --user=user0001 --password=User0001! --port=3306 --databases="db01" --target-dir=/data/backups/full


xtrabackup: recognized server arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksums=1 --innodb_data_file_path=ibdata1:12M:autoextend --innodb_log_files_in_group=2 --innodb_log_file_size=50331648 --innodb_page_size=16384 --innodb_undo_directory=./ --innodb_undo_tablespaces=2 --server-id=0 --innodb_log_checksums=ON --innodb_redo_log_encrypt=0 --innodb_undo_log_encrypt=0
xtrabackup: recognized client arguments: --no-server-version-check=1 --prepare=1 --apply-log-only=1 --host=10.6.8.238 --user=user0001 --password=* --port=3306 --databases=db01 --target-dir=/data/backups/full
xtrabackup version 8.0.27-19 based on MySQL server 8.0.27 Linux (x86_64) (revision id: 50dbc8dadda)
xtrabackup: cd to /data/backups/full/
xtrabackup: This target seems to be not prepared yet.
Number of pools: 1
xtrabackup: xtrabackup_logfile detected: size=8388608, start_lsn=(18611669)
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = .
xtrabackup:   innodb_log_files_in_group = 1
xtrabackup:   innodb_log_file_size = 8388608
xtrabackup: inititialize_service_handles suceeded
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = .
xtrabackup:   innodb_log_files_in_group = 1
xtrabackup:   innodb_log_file_size = 8388608
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
PUNCH HOLE support available
Uses event mutexes
GCC builtin __atomic_thread_fence() is used for memory barrier
Compressed tables use zlib 1.2.11
Number of pools: 1
Using hardware accelerated crc32 and polynomial multiplication.
Directories to scan './'
Scanning './'
Completed space ID check of 5 files.
Initializing buffer pool, total size = 128.000000M, instances = 1, chunk size =128.000000M
Completed initialization of buffer pool
page_cleaner coordinator priority: -20
page_cleaner worker priority: -20
page_cleaner worker priority: -20
page_cleaner worker priority: -20
The log sequence number 17790438 in the system tablespace does not match the log sequence number 18611669 in the ib_logfiles!
Database was not shutdown normally!
Starting crash recovery.
Starting to parse redo log at lsn = 18611226, whereas checkpoint_lsn = 18611669 and start_lsn = 18611200
Doing recovery: scanned up to log sequence number 18611669
Log background threads are being started...
Applying a batch of 0 redo log records ...
Apply batch completed!
Using undo tablespace './undo_001'.
Using undo tablespace './undo_002'.
Opened 2 existing undo tablespaces.
GTID recovery trx_no: 1695
Parallel initialization of rseg complete
Time taken to initialize rseg using 2 thread: 648843 ms.
Creating shared tablespace for temporary tables
Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
File './ibtmp1' size is now 12 MB.
Scanning temp tablespace dir:'./#innodb_temp/'
Created 128 and tracked 128 new rollback segment(s) in the temporary tablespace. 128 are now active.
8.0.27 started; log sequence number 18611679
Allocated tablespace ID 18 for db01/tb_user, old maximum was 0
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
FTS optimize thread exiting.
Starting shutdown...
Log background threads are being closed...
Shutdown completed; log sequence number 18611679
Number of pools: 1
220420 01:18:44 completed OK!

4.2 应用首个增量备份准备

最后新的备份数据位于/data/backups/full 目录,即该目录数据已经被修改,不再是原先的全量备份。

注意事项,增量备份目录(/data/backups/inc1)只能使用一次,如果以后会再次使用,需要先将其备份。

[root@lys-mysql full]# xtrabackup  --no-server-version-check --prepare --apply-log-only --host=10.6.8.238 --user=user0001 --password=User0001! --port=3306 --databases="db01" --target-dir=/data/backups/full  --incremental-dir=/data/backups/inc1


xtrabackup: recognized server arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksums=1 --innodb_data_file_path=ibdata1:12M:autoextend --innodb_log_files_in_group=2 --innodb_log_file_size=50331648 --innodb_page_size=16384 --innodb_undo_directory=./ --innodb_undo_tablespaces=2 --server-id=0 --innodb_log_checksums=ON --innodb_redo_log_encrypt=0 --innodb_undo_log_encrypt=0
xtrabackup: recognized client arguments: --no-server-version-check=1 --prepare=1 --apply-log-only=1 --host=10.6.8.238 --user=user0001 --password=* --port=3306 --databases=db01 --target-dir=/data/backups/full --incremental-dir=/data/backups/inc1
xtrabackup version 8.0.27-19 based on MySQL server 8.0.27 Linux (x86_64) (revision id: 50dbc8dadda)
incremental backup from 18611669 is enabled.
xtrabackup: cd to /data/backups/full/
xtrabackup: This target seems to be already prepared with --apply-log-only.
Number of pools: 1
xtrabackup: xtrabackup_logfile detected: size=8388608, start_lsn=(18612011)
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = /data/backups/inc1/
xtrabackup:   innodb_log_files_in_group = 1
xtrabackup:   innodb_log_file_size = 8388608
xtrabackup: inititialize_service_handles suceeded
xtrabackup: Generating a list of tablespaces
xtrabackup: Generating a list of tablespaces
Scanning './'
Completed space ID check of 2 files.
Allocated tablespace ID 18 for db01/tb_user, old maximum was 0
Using undo tablespace './undo_001'.
Using undo tablespace './undo_002'.
Opened 2 existing undo tablespaces.
xtrabackup: page size for /data/backups/inc1//ibdata1.delta is 16384 bytes
Applying /data/backups/inc1//ibdata1.delta to ./ibdata1...
xtrabackup: page size for /data/backups/inc1//db01/tb_user.ibd.delta is 16384 bytes
Applying /data/backups/inc1//db01/tb_user.ibd.delta to ./db01/tb_user.ibd...
xtrabackup: page size for /data/backups/inc1//db01/tb_user_copy1.ibd.delta is 16384 bytes
Applying /data/backups/inc1//db01/tb_user_copy1.ibd.delta to ./db01/tb_user_copy1.ibd...
xtrabackup: page size for /data/backups/inc1//mysql.ibd.delta is 16384 bytes
Applying /data/backups/inc1//mysql.ibd.delta to ./mysql.ibd...
xtrabackup: page size for /data/backups/inc1//undo_002.delta is 16384 bytes
Applying /data/backups/inc1//undo_002.delta to ./undo_002...
xtrabackup: page size for /data/backups/inc1//undo_001.delta is 16384 bytes
Applying /data/backups/inc1//undo_001.delta to ./undo_001...
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = /data/backups/inc1/
xtrabackup:   innodb_log_files_in_group = 1
xtrabackup:   innodb_log_file_size = 8388608
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
PUNCH HOLE support available
Uses event mutexes
GCC builtin __atomic_thread_fence() is used for memory barrier
Compressed tables use zlib 1.2.11
Number of pools: 1
Using hardware accelerated crc32 and polynomial multiplication.
Directories to scan './'
Scanning './'
Completed space ID check of 5 files.
Initializing buffer pool, total size = 128.000000M, instances = 1, chunk size =128.000000M
Completed initialization of buffer pool
page_cleaner coordinator priority: -20
page_cleaner worker priority: -20
page_cleaner worker priority: -20
page_cleaner worker priority: -20
The log sequence number 18611679 in the system tablespace does not match the log sequence number 18612011 in the ib_logfiles!
Database was not shutdown normally!
Starting crash recovery.
Starting to parse redo log at lsn = 18611725, whereas checkpoint_lsn = 18612011 and start_lsn = 18611712
Doing recovery: scanned up to log sequence number 18612011
Log background threads are being started...
Applying a batch of 0 redo log records ...
Apply batch completed!
Using undo tablespace './undo_001'.
Using undo tablespace './undo_002'.
Opened 2 existing undo tablespaces.
GTID recovery trx_no: 1700
Parallel initialization of rseg complete
Time taken to initialize rseg using 2 thread: 491856 ms.
Removed temporary tablespace data file: "ibtmp1"
Creating shared tablespace for temporary tables
Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
File './ibtmp1' size is now 12 MB.
Scanning temp tablespace dir:'./#innodb_temp/'
Created 128 and tracked 128 new rollback segment(s) in the temporary tablespace. 128 are now active.
8.0.27 started; log sequence number 18612021
Allocated tablespace ID 18 for db01/tb_user, old maximum was 0
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
FTS optimize thread exiting.
Starting shutdown...
Log background threads are being closed...
Shutdown completed; log sequence number 18612021
Number of pools: 1
220420 01:22:49 [00] Copying /data/backups/inc1//xtrabackup_binlog_info to ./xtrabackup_binlog_info
220420 01:22:49 [00]        ...done
220420 01:22:49 [00] Copying /data/backups/inc1//xtrabackup_info to ./xtrabackup_info
220420 01:22:49 [00]        ...done
220420 01:22:49 [00] Copying /data/backups/inc1//xtrabackup_tablespaces to ./xtrabackup_tablespaces
220420 01:22:49 [00]        ...done
220420 01:22:49 [00] Copying /data/backups/inc1/binlog.000010 to ./binlog.000010
220420 01:22:49 [00]        ...done
220420 01:22:49 [00] Copying /data/backups/inc1/binlog.index to ./binlog.index
220420 01:22:49 [00]        ...done
220420 01:22:49 completed OK!

5.使用数据恢复

1)最后可将 /data/backups/base/ 内容复制到数据库目录;
2)修改数据库文件权限及所有者/组;
3)启动数据库服务,并检查数据库服务是否正常;

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
3月前
|
存储 关系型数据库 MySQL
mysql数据库备份与恢复
MySQL数据库的备份与恢复是确保数据安全性和业务连续性的关键操作。
117 4
|
1月前
|
关系型数据库 MySQL Linux
Linux环境下MySQL数据库自动定时备份实践
数据库备份是确保数据安全的重要措施。在Linux环境下,实现MySQL数据库的自动定时备份可以通过多种方式完成。本文将介绍如何使用`cron`定时任务和`mysqldump`工具来实现MySQL数据库的每日自动备份。
97 3
|
1月前
|
监控 关系型数据库 MySQL
Linux环境下MySQL数据库自动定时备份策略
在Linux环境下,MySQL数据库的自动定时备份是确保数据安全和可靠性的重要措施。通过设置定时任务,我们可以每天自动执行数据库备份,从而减少人为错误和提高数据恢复的效率。本文将详细介绍如何在Linux下实现MySQL数据库的自动定时备份。
45 3
|
6月前
|
存储 SQL 关系型数据库
|
2月前
|
安全 关系型数据库 MySQL
MySQL用户备份
【10月更文挑战第2天】MySQL用户备份
64 3
|
2月前
|
存储 关系型数据库 MySQL
MySQL如何备份?
【10月更文挑战第2天】MySQL如何备份?
153 3
|
4月前
|
关系型数据库 MySQL Linux
mysql 主从同步 实现增量备份
【8月更文挑战第28天】mysql 主从同步 实现增量备份
58 3
|
4月前
|
SQL 关系型数据库 MySQL
在Linux中,如何备份和恢复MySQL数据库?
在Linux中,如何备份和恢复MySQL数据库?
|
4月前
|
SQL 数据可视化 关系型数据库
MySQL 备份可视化巡检系统
MySQL 备份可视化巡检系统
|
4月前
|
SQL 存储 关系型数据库
MySQL备份:mydumper 备份恢复工具生产实战
MySQL备份:mydumper 备份恢复工具生产实战