CentOS8利用xtrabackup8.0 完全备份和还原MySQL8.0
Posted 白-胖-子
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS8利用xtrabackup8.0 完全备份和还原MySQL8.0相关的知识,希望对你有一定的参考价值。
使用percona-xtrabackup备份和还原数据库
xtrabackup工具备份和还原
- 需要三步实现
- 备份:对数据库做完全或增量备份
- 预准备: 还原前,先对备份的数据,整理至一个临时目录
- 还原:将整理好的数据,复制回数据库目录中
还原注意事项:
- datadir 目录必须为空。除非指定innobackupex --force-non-empty-directorires选项指定,否则–copy-back选项不会覆盖
- 在restore之前,必须shutdown mysql实例,不能将一个运行中的实例restore到datadir目录中
- 由于文件属性会被保留,大部分情况下需要在启动实例之前将文件的属主改为mysql,这些文件将属于创建备份的用户,
执行chown -R mysql:mysql /data/mysql,以上需要在用户调用innobackupex之前完成
利用 xtrabackup 实现完全备份及还原
备份准备
- 源主机 CentOS8 10.0.0.186 MySQL8.0.25 percona-xtrabackup-80-8.0.23
[root@C8-186 ~]# cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)
[root@C8-186 ~]# mysql -V
mysql Ver 8.0.25 for Linux on x86_64 (MySQL Community Server - GPL)
[root@C8-186 ~]# xtrabackup -v
xtrabackup: recognized server arguments: --server-id=186 --log_bin=/data/mysql/mysql-bin --datadir=/data/mysql
xtrabackup version 8.0.23-16 based on MySQL server 8.0.23 Linux (x86_64) (revision id: 934bc8f)
- 目标主机 CentOS7 10.0.0.199 MySQL8.0.25 percona-xtrabackup-80-8.0.23
[root@c7-199 ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@c7-199 ~]# mysql -V
mysql Ver 8.0.25 for Linux on x86_64 (MySQL Community Server - GPL)
[root@c7-199 ~]# xtrabackup -v
xtrabackup: recognized server arguments: --server-id=199 --log_bin=/data/mysql/mysql-bin --datadir=/data/mysql
xtrabackup version 8.0.23-16 based on MySQL server 8.0.23 Linux (x86_64) (revision id: 934bc8f)
源主机备份数据库
创建文件夹并备份
xtrabackup -uroot -paaaaaaaa --backup --target-dir=/mysqlBak/base
[root@C8-186 ~]# mkdir /mysqlBak/
[root@C8-186 ~]# xtrabackup -uroot -paaaaaaaa --backup --target-dir=/mysqlBak/base
直接备份报错
- xtrabackup 8.0.23 会做版本检查,默认不支持不同版本的数据区
xtrabackup version 8.0.23-16 based on MySQL server 8.0.23 Linux (x86_64) (revision id: 934bc8f)
……
Error: Unsupported server version 8.0.25.
Please upgrade PXB, if a new version is available. To continue with risk, use the option --no-server-version-check.
- 按提示使用–no-server-version-check 参数后备份成功
xtrabackup -uroot -paaaaaaaa --backup --target-dir=/mysqlBak/base --no-server-version-check
[root@C8-186 ~]# xtrabackup -uroot -paaaaaaaa --backup --target-dir=/mysqlBak/base --no-server-version-check
xtrabackup: recognized server arguments: --server-id=186 --log_bin=/data/mysql/mysql-bin --datadir=/data/mysql
xtrabackup: recognized client arguments: --socket=/data/mysql/mysql.sock --user=root --password=* --backup=1 --target-dir=/mysqlBak/base --no-server-version-check=1
xtrabackup version 8.0.23-16 based on MySQL server 8.0.23 Linux (x86_64) (revision id: 934bc8f)
210520 20:00:11 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/data/mysql/mysql.sock' as 'root' (using password: YES).
210520 20:00:11 version_check Connected to MySQL server
210520 20:00:11 version_check Executing a version check against the server...
210520 20:00:11 version_check Done.
210520 20:00:11 Connecting to MySQL server host: localhost, user: root, password: set, port: not set, socket: /data/mysql/mysql.sock
Using server version 8.0.25
210520 20:00:11 Executing LOCK INSTANCE FOR BACKUP...
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /data/mysql
xtrabackup: open files limit requested 0, set to 1024
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
210520 20:00:11 Connecting to MySQL server host: localhost, user: root, password: set, port: not set, socket: /data/mysql/mysql.sock
xtrabackup: Redo Log Archiving is not set up.
210520 20:00:11 >> log scanned up to (18259542)
xtrabackup: Generating a list of tablespaces
xtrabackup: Generating a list of tablespaces
Scanning './'
Completed space ID check of 2 files.
Allocated tablespace ID 2 for hellodb/classes, old maximum was 0
Using undo tablespace './undo_001'.
Using undo tablespace './undo_002'.
Opened 2 existing undo tablespaces.
210520 20:00:12 [01] Copying ./ibdata1 to /mysqlBak/base/ibdata1
210520 20:00:12 [01] ...done
210520 20:00:12 [01] Copying ./undo_001 to /mysqlBak/base/undo_001
210520 20:00:12 [01] ...done
210520 20:00:12 >> log scanned up to (18259542)
210520 20:00:13 Starting to backup non-InnoDB tables and files
210520 20:00:13 [01] Copying mysql/general_log_213.sdi to /mysqlBak/base/mysql/general_log_213.sdi
210520 20:00:13 [01] ...done
……
210520 20:00:13 [00] Writing /mysqlBak/base/xtrabackup_binlog_info
210520 20:00:13 [00] ...done
210520 20:00:13 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '18259542'
xtrabackup: Stopping log copying thread at LSN 18259542.
Starting to parse redo log at lsn = 18259504
210520 20:00:13 Executing UNLOCK INSTANCE
210520 20:00:13 All tables unlocked
210520 20:00:13 [00] Copying ib_buffer_pool to /mysqlBak/base/ib_buffer_pool
210520 20:00:13 [00] ...done
210520 20:00:13 Backup created in directory '/mysqlBak/base/'
MySQL binlog position: filename 'mysql-bin.000005', position '156'
210520 20:00:13 [00] Writing /mysqlBak/base/backup-my.cnf
210520 20:00:13 [00] ...done
210520 20:00:13 [00] Writing /mysqlBak/base/xtrabackup_info
210520 20:00:13 [00] ...done
xtrabackup: Transaction log of lsn (18259542) to (18259562) was copied.
210520 20:00:14 completed OK!
将备份文件夹直接拷贝至目标主机根目录
rsync -avz /mysqlBak 10.0.0.199:/
目标主机还原数据
确保数据一致性
- 源主机本分的数据
[root@C8-186 ~]# du -sh /mysqlBak/base/
71M /mysqlBak/base/
[root@C8-186 ~]# ll /mysqlBak/base/
total 69680
-rw-r----- 1 root root 477 May 20 20:00 backup-my.cnf
drwxr-x--- 2 root root 132 May 20 20:00 hellodb
-rw-r----- 1 root root 3493 May 20 20:00 ib_buffer_pool
-rw-r----- 1 root root 12582912 May 20 20:00 ibdata1
drwxr-x--- 2 root root 143 May 20 20:00 mysql
-rw-r----- 1 root root 156 May 20 20:00 mysql-bin.000005
-rw-r----- 1 root root 29 May 20 20:00 mysql-bin.index
-rw-r----- 1 root root 25165824 May 20 20:00 mysql.ibd
drwxr-x--- 2 root root 8192 May 20 20:00 performance_schema
drwxr-x--- 2 root root 28 May 20 20:00 sys
-rw-r----- 1 root root 16777216 May 20 20:00 undo_001
-rw-r----- 1 root root 16777216 May 20 20:00 undo_002
-rw-r----- 1 root root 21 May 20 20:00 xtrabackup_binlog_info
-rw-r----- 1 root root 102 May 20 20:00 xtrabackup_checkpoints
-rw-r----- 1 root root 500 May 20 20:00 xtrabackup_info
-rw-r----- 1 root root 2560 May 20 20:00 xtrabackup_logfile
-rw-r----- 1 root root 39 May 20 20:00 xtrabackup_tablespaces
- 目标主机备份的数据
[root@c7-199 ~]# du -sh /base/
71M /base/
[root@c7-199 ~]# ll /base/
total 69680
-rw-r----- 1 root root 477 May 20 2021 backup-my.cnf
drwxr-x--- 2 root root 132 May 20 2021 hellodb
-rw-r----- 1 root root 3493 May 20 2021 ib_buffer_pool
-rw-r----- 1 root root 12582912 May 20 2021 ibdata1
drwxr-x--- 2 root root 143 May 20 2021 mysql
-rw-r----- 1 root root 156 May 20 2021 mysql-bin.000005
-rw-r----- 1 root root 29 May 20 2021 mysql-bin.index
-rw-r----- 1 root root 25165824 May 20 2021 mysql.ibd
drwxr-x--- 2 root root 8192 May 20 2021 performance_schema
drwxr-x--- 2 root root 28 May 20 2021 sys
-rw-r----- 1 root root 16777216 May 20 2021 undo_001
-rw-r----- 1 root root 16777216 May 20 2021 undo_002
-rw-r----- 1 root root 21 May 20 2021 xtrabackup_binlog_info
-rw-r----- 1 root root 102 May 20 2021 xtrabackup_checkpoints
-rw-r----- 1 root root 500 May 20 2021 xtrabackup_info
-rw-r----- 1 root root 2560 May 20 2021 xtrabackup_logfile
-rw-r----- 1 root root 39 May 20 2021 xtrabackup_tablespaces
确保目标主机处MySQL于停服状态
[root@c7-199 ~]# systemctl stop mysql.service
[root@c7-199 ~]# /etc/init.d/mysqld stop
Shutting down MySQL. SUCCESS!
[root@c7-199 ~]# ss -nl | grep 3306
[root@c7-199 ~]# systemctl status mysql.service
● mysqld.service - LSB: start and stop MySQL
Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
准备还原数据
[root@c7-199 ~]# xtrabackup --prepare --target-dir=/mysqlBak/base --no-server-version-check
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=186 --innodb_log_checksums=ON --innodb_redo_log_encrypt=0 --innodb_undo_log_encrypt=0
xtrabackup: recognized client arguments: --prepare=1 --target-dir=/mysqlBak/base --no-server-version-check=1
xtrabackup version 8.0.23-16 based on MySQL server 8.0.23 Linux (x86_64) (revision id: 934bc8f)
xtrabackup: cd to /mysqlBak/base/
xtrabackup: This target seems to be not prepared yet.
Number of pools: 1
Operating system error number 2 in a file operation.
The error means the system cannot find the path specified.
xtrabackup: Warning: cannot open ./xtrabackup_logfile. will try to find.
xtrabackup: 'ib_logfile0' seems to be 'xtrabackup_logfile'. will retry.
xtrabackup: xtrabackup_logfile detected: size=9437184, start_lsn=(18259542)
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 = 9437184
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 = 9437184
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 CPU crc32 instructions
Directories to scan './'
Scanning './'
Completed space ID check of 11 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 18092085 in the system tablespace does not match the log sequence number 18259542 in the ib_logfiles!
Database was not shutdown normally!
Starting crash recovery.
Starting to parse redo log at lsn = 18259504, whereas checkpoint_lsn = 18259542 and start_lsn = 18259456
Doing recovery: scanned up to log sequence number 18259542
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: 2148
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.23 started; log sequence number 18259542
Allocated tablespace ID 8 for hellodb/toc, old maximum was 0
xtrabackup: Unknown error 3611
xtrabackup: Unknown error 3611
xtrabackup: Unknown error 3611
xtrabackup: Unknown error 3611
xtrabackup: Unknown error 3611
xtrabackup: Unknown error 3611
xtrabackup: Unknown error 3611
xtrabackup: Unknown error 3611
xtrabackup: Unknown error 3611
05:01:13 UTC - mysqld got signal 11 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x46000
xtrabackup(my_print_stacktrace(unsigned char const*, unsigned long)+0x2e) [0x23cb75e]
xtrabackup(handle_fatal_signal+0x2eb) [0x120155b]
/lib64/libpthread.so.0(+0xf630) [0x7f2a3f69a630]
xtrabackup(dd::get_dd_client(THD*)+0x1) [0x1731d91]
xtrabackup(dd_table_open_on_name(THD*, MDL_ticket**, char const*, bool, unsigned long, int*)+0x322) [0x13cf052]
xtrabackup() [0xceb144]
xtrabackup() [0xcec35c]
xtrabackup(main+0xca9) [0xca9979]
/lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2a3d505555]
xtrabackup() [0xcd87c7]
Please report a bug at https://jira.percona.com/projects/PXB
执行还原命令
xtrabackup --copy-back --target-dir=/base
[root@c7-199 ~]# xtrabackup --copy-back --target-dir=/mysqlBak/base --no-server-version-check
xtrabackup: recognized server arguments: --server-id=199 --log_bin=/data/mysql/mysql-bin --datadir=/data/mysql
xtrabackup: recognized client arguments: --socket=/data/mysql/mysql.sock --copy-back=1 --target-dir=/mysqlBak/base --no-server-version-check=1
xtrabackup version 8.0.23-16 based on MySQL server 8.0.23 Linux (x86_64) (revision id: 934bc8f)
210520 13:04:10 [01] Copying undo_001 to /data/mysql/undo_001
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying undo_002 to /data/mysql/undo_002
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ib_logfile0 to /data/mysql/ib_logfile0
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ibdata1 to /data/mysql/ibdata1
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying mysql-bin.000005 to /data/mysql/mysql-bin.000005
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying mysql-bin.index to /data/mysql/mysql-bin.index
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./hellodb/classes.ibd to /data/mysql/hellodb/classes.ibd
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./hellodb/coc.ibd to /data/mysql/hellodb/coc.ibd
……
210520 13:04:10 [01] Copying ./ib_buffer_pool to /data/mysql/ib_buffer_pool
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./mysql.ibd to /data/mysql/mysql.ibd
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./xtrabackup_info to /data/mysql/xtrabackup_info
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./#innodb_temp/temp_1.ibt to /data/mysql/#innodb_temp/temp_1.ibt
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./#innodb_temp/temp_2.ibt to /data/mysql/#innodb_temp/temp_2.ibt
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./#innodb_temp/temp_3.ibt to /data/mysql/#innodb_temp/temp_3.ibt
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./#innodb_temp/temp_4.ibt to /data/mysql/#innodb_temp/temp_4.ibt
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./#innodb_temp/temp_5.ibt to /data/mysql/#innodb_temp/temp_5.ibt
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./#innodb_temp/temp_6.ibt to /data/mysql/#innodb_temp/temp_6.ibt
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./#innodb_temp/temp_7.ibt to /data/mysql/#innodb_temp/temp_7.ibt
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./#innodb_temp/temp_8.ibt to /data/mysql/#innodb_temp/temp_8.ibt
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./#innodb_temp/temp_9.ibt to /data/mysql/#innodb_temp/temp_9.ibt
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./#innodb_temp/temp_10.ibt to /data/mysql/#innodb_temp/temp_10.ibt
210520 13:04:10 [01] ...done
210520 13:04:10 [01] Copying ./ibtmp1 to /data/mysql/ibtmp1
210520 13:04:10 [01] ...done
210520 13:04:10 completed OK!
[root@c7-199 ~]# ll /data
total 0
drwxr-x--- 7 root root 280 May 20 13:04 mysql
检查还原结果
启动数据库
[root@c7-199 ~]# chown mysql.mysql /data/mysql
[root@c7-199 ~]# chmod 755 /data/mysql
[root@c7-199 ~]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/data/mysql/mysql.log'.
ERROR! The server quit without updating PID file (/data/mysql/mysql.pid).
检查数据库和表
[root@c7-199 ~]# mysql -uroot -paaaaaaaa
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/data/mysql/mysql.sock' (2)
所以使用percona-xtrabackup-80-8.0.23来备份还原来备份和还原MySQL8.0.25是有问题的
数据库重装过MySQL8.0.23后使用percona-xtrabackup-80-8.0.23备份和还原就没问题了
[root@c7-199 ~]# ll /data/mysql/
total 20
drwxr-xr-x 6 mysql mysql 4096 May 20 15:59 base
-rw-r----- 1 mysql mysql 179 May 20 15:57 mysql-bin.000001
-rw-r----- 1 mysql mysql 514 May 20 15:59 mysql-bin.000002
-rw-r----- 1 mysql mysql 58 May 20 15:57 mysql-bin.index
-rw-r----- 1 mysql mysql 1743 May 20 15:59 mysql.log
[root@c7-199 ~]# rm -rf /data/mysql/*
[root@c7-199 ~]# ll /data/mysql/
total 0
[root@c7-199 ~]# xtrabackup --prepare --target-dir=/mysqlBak/base
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=194 --innodb_log_checksums=ON --innodb_redo_log_encrypt=0 --innodb_undo_log_encrypt=0
xtrabackup: recognized client arguments: --prepare=1 --target-dir=/mysqlBak/base
xtrabackup version 8.0.23-16 based on MySQL server 8.0.23 Linux (x86_64) (revision id: 934bc8f)
xtrabackup: cd to /mysqlBak/base/
xtrabackup: This target seems to be not prepared yet.
Number of pools: 1
xtrabackup: xtrabackup_logfile detected: size=8388608, start_lsn=(18042475)
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: 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 CPU crc32 instructions
Directories to scan './'
Scanning './'
Completed space ID check of 4 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 17684135 in the system tablespace does not match the log sequence number 18042475 in the ib_logfiles!
Database was not shutdown normally!
Starting crash recovery.
Starting to parse redo log at lsn = 18042437, whereas checkpoint_lsn = 18042475 and start_lsn = 18042368
Doing recovery: scanned up to log sequence number 18042475
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: 1547
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.23 started; log sequence number 18042475
Allocated tablespace ID 1 for sys/sys_config, 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 18042475
Number of pools: 1
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 = 2
xtrabackup: innodb_log_file_size = 50331648
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 CPU crc32 instructions
Directories to scan './'
Scanning './'
Completed space ID check of 4 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
Creating log file ./ib_logfile101
Creating log file ./ib_logfile1
page_cleaner worker priority: -20
page_cleaner worker priority: -20
Renaming log file ./ib_logfile101 to ./ib_logfile0
New log files created, LSN=18042892
Starting to parse redo log at lsn = 18042892, whereas checkpoint_lsn = 18042892 and start_lsn = 18042880
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: 1547
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.23 started; log sequence number 18042892
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
FTS optimize thread exiting.
Trying to access missing tablespace 4294967294
Starting shutdown...
Log background threads are being closed...
Shutdown completed; log sequence number 18042892
210520 16:00:50 completed OK!
[root@c7-199 ~]# xtrabackup --copy-back --target-dir=/mysqlBak/base
xtrabackup: recognized server arguments: --server-id=199 --log_bin=/data/mysql/mysql-bin --datadir=/data/mysql/base
xtrabackup: recognized client arguments: --socket=/data/mysql/mysql.sock --copy-back=1 --target-dir=/mysqlBak/base
xtrabackup version 8.0.23-16 based on MySQL server 8.0.23 Linux (x86_64) (revision id: 934bc8f)
210520 16:01:20 [01] Copying undo_001 to /data/mysql/base/undo_001
210520 16:01:20 [01] ...done
210520 16:01:20 [01] Copying undo_002 to /data/mysql/base/undo_002
210520 16:01:20 [01] ...done
……
210520 16:01:20 [01] ...done
210520 16:01:20 [01] Copying ./mysql.ibd to /data/mysql/base/mysql.ibd
210520 16:01:20 [01] ...done
210520 16:01:20 [01] Copying ./xtrabackup_info to /data/mysql/base/xtrabackup_info
210520 16:01:20 [01] ...done
210520 16:01:20 [01] Copying ./xtrabackup_master_key_id to /data/mysql/base/xtrabackup_master_key_id
210520 16:01:20 [01] ...done
210520 16:01:20 [01] Copying ./ibtmp1 to /data/mysql/base/ibtmp1
210520 16:01:20 [01] ...done
210520 16:01:20 [01] Creating directory ./#innodb_temp
210520 16:01:20 [01] ...done.
210520 16:01:20 completed OK!
[root@c7-199 ~]# service mysqld start
Starting MySQL.2021-05-20T08:01:29.104452Z mysqld_safe error: log-error set to '/data/mysql/mysql.log', however file don't exists. Create writable for user 'mysql'.
ERROR! The server quit without updating PID file (/data/mysql/mysql.pid).
[root@c7-199 ~]# chown -R mysql.mysql /data/mysql/
[root@c7-199 ~]# service mysqld start
Starting MySQL.2021-05-20T08:02:36.771192Z mysqld_safe error: log-error set to '/data/mysql/mysql.log', however file don't exists. Create writable for user 'mysql'.
ERROR! The server quit without updating PID file (/data/mysql/mysql.pid).
[root@c7-199 ~]# ll /data
total 0
drwxr-xr-x 3 mysql mysql 65 May 20 16:01 mysql
[root@c7-199 ~]# ll /data/mysql/
total 8
drwxr-x--- 5 mysql mysql 249 May 20 16:01 base
-rw-r----- 1 mysql mysql 156 May 20 16:01 mysql-bin.000003
-rw-r----- 1 mysql mysql 29 May 20 16:01 mysql-bin.index
[root@c7-199 ~]# chmod 755 /data/mysql/
[root@c7-199 ~]# service mysqld start
Starting MySQL.2021-05-20T08:04:49.686972Z mysqld_safe error: log-error set to '/data/mysql/mysql.log', however file don't exists. Create writable for user 'mysql'.
ERROR! The server quit without updating PID file (/data/mysql/mysql.pid).
[root@c7-199 ~]# ll /data/
total 0
drwxr-xr-x 3 mysql mysql 65 May 20 16:01 mysql
[root@c7-199 ~]# ll /data/ -d
drwxr-xr-x 3 root root 19 May 20 15:57 /data/
[root@c7-199 ~]# touch /data/mysql/mysql.log
[root@c7-199 ~]# ll /data/mysql/
total 8
drwxr-x--- 5 mysql mysql 249 May 20 16:01 base
-rw-r----- 1 mysql mysql 156 May 20 16:01 mysql-bin.000003
-rw-r----- 1 mysql mysql 29 May 20 16:01 mysql-bin.index
-rw-r--r-- 1 root root 0 May 20 16:06 mysql.log
[root@c7-199 ~]# chown -R mysql.mysql /data/mysql/
[root@c7-199 ~]# service mysqld start
Starting MySQL. SUCCESS!
以上是关于CentOS8利用xtrabackup8.0 完全备份和还原MySQL8.0的主要内容,如果未能解决你的问题,请参考以下文章