首页 > 代码库 > MySQL5.6下使用xtrabackup部分备份恢复到MySQL5.7
MySQL5.6下使用xtrabackup部分备份恢复到MySQL5.7
现有需求:需要备份MySQL5.6环境下的部分表到MySQL5.7环境下并进行恢复
通过xtrabackup 实现部分备份有三种方式:
参考链接:http://blog.csdn.net/zhu19774279/article/details/49681767
我这里测试了两种方法:
way1
/usr/bin/innobackupex --defaults-file=/etc/mysql/3306.cnf /data0/sql --include=‘test.t1|mysql.*|performance_schema.*‘ --user=root --socket=/tmp/mysql_3306.sock
way2
/usr/bin/innobackupex --defaults-file=/etc/mysql/3306.cnf /data0/sql --databases=‘test.t1 mysql performance_schema‘ --user=root --socket=/tmp/mysql_3306.sock
但在应用日志时都会出现同样的问题,报备份单个表所在的库的其他表的表空间不存在
[root@mysql-bcc01 sql]# innobackupex --apply-log --export 2016-10-08_17-53-09161008 17:53:50 innobackupex: Starting the apply-log operationIMPORTANT: Please check that the apply-log run completes successfully. At the end of a successful apply-log run innobackupex prints "completed OK!".innobackupex version 2.4.4 based on MySQL server 5.7.13 Linux (x86_64) (revision id: df58cf2)xtrabackup: auto-enabling --innodb-file-per-table due to the --export optionxtrabackup: cd to /data0/sql/2016-10-08_17-53-09xtrabackup: This target seems to be not prepared yet.InnoDB: Number of pools: 1xtrabackup: xtrabackup_logfile detected: size=8388608, start_lsn=(802528374)xtrabackup: using the following InnoDB configuration for recovery:xtrabackup: innodb_data_home_dir = .xtrabackup: innodb_data_file_path = ibdata1:512M:autoextendxtrabackup: innodb_log_group_home_dir = .xtrabackup: innodb_log_files_in_group = 1xtrabackup: innodb_log_file_size = 8388608xtrabackup: using the following InnoDB configuration for recovery:xtrabackup: innodb_data_home_dir = .xtrabackup: innodb_data_file_path = ibdata1:512M:autoextendxtrabackup: innodb_log_group_home_dir = .xtrabackup: innodb_log_files_in_group = 1xtrabackup: innodb_log_file_size = 8388608xtrabackup: Starting InnoDB instance for recovery.xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)InnoDB: PUNCH HOLE support not availableInnoDB: Mutexes and rw_locks use GCC atomic builtinsInnoDB: Uses event mutexesInnoDB: GCC builtin __sync_synchronize() is used for memory barrierInnoDB: Compressed tables use zlib 1.2.3InnoDB: Number of pools: 1InnoDB: Using CPU crc32 instructionsInnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100MInnoDB: Completed initialization of buffer poolInnoDB: page_cleaner coordinator priority: -20InnoDB: Highest supported file format is Barracuda.InnoDB: The log sequence number 2342986 in the system tablespace does not match the log sequence number 802528374 in the ib_logfiles!InnoDB: Database was not shutdown normally!InnoDB: Starting crash recovery.InnoDB: Doing recovery: scanned up to log sequence number 802528374 (0%)InnoDB: xtrabackup: Last MySQL binlog file position 2987, file name mysql-bin.000003InnoDB: Creating shared tablespace for temporary tablesInnoDB: Setting file ‘./ibtmp1‘ size to 12 MB. Physically writing the file full; Please wait ...InnoDB: File ‘./ibtmp1‘ size is now 12 MB.InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active.InnoDB: 32 non-redo rollback segment(s) are active.InnoDB: 5.7.13 started; log sequence number 802528374xtrabackup: export option is specified.xtrabackup: export metadata of table ‘test/t1‘ to file `./test/t1.exp` (1 indexes)xtrabackup: name=PRIMARY, id.low=32, page=3xtrabackup: export metadata of table ‘mysql/slave_relay_log_info‘ to file `./mysql/slave_relay_log_info.exp` (1 indexes)xtrabackup: name=PRIMARY, id.low=19, page=3xtrabackup: export metadata of table ‘mysql/innodb_index_stats‘ to file `./mysql/innodb_index_stats.exp` (1 indexes)xtrabackup: name=PRIMARY, id.low=18, page=3xtrabackup: export metadata of table ‘mysql/slave_worker_info‘ to file `./mysql/slave_worker_info.exp` (1 indexes)xtrabackup: name=PRIMARY, id.low=21, page=3xtrabackup: export metadata of table ‘mysql/innodb_table_stats‘ to file `./mysql/innodb_table_stats.exp` (1 indexes)xtrabackup: name=PRIMARY, id.low=17, page=3xtrabackup: export metadata of table ‘mysql/slave_master_info‘ to file `./mysql/slave_master_info.exp` (1 indexes)xtrabackup: name=PRIMARY, id.low=20, page=3InnoDB: xtrabackup: Last MySQL binlog file position 2987, file name mysql-bin.000003xtrabackup: starting shutdown with innodb_fast_shutdown = 0InnoDB: FTS optimize thread exiting.InnoDB: Starting shutdown...InnoDB: Failed to find tablespace for table `test`.`t2` in the cache. Attempting to load the tablespace with space id 113InnoDB: Operating system error number 2 in a file operation.InnoDB: The error means the system cannot find the path specified.InnoDB: Cannot open datafile for read-only: ‘./test/t2.ibd‘ OS error: 71InnoDB: Operating system error number 2 in a file operation.InnoDB: The error means the system cannot find the path specified.InnoDB: Could not find a valid tablespace file for `test/t2`. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting-datadict.html for how to resolve the issue.InnoDB: Shutdown completed; log sequence number 802528393InnoDB: Number of pools: 1xtrabackup: using the following InnoDB configuration for recovery:xtrabackup: innodb_data_home_dir = .xtrabackup: innodb_data_file_path = ibdata1:512M:autoextendxtrabackup: innodb_log_group_home_dir = .xtrabackup: innodb_log_files_in_group = 3xtrabackup: innodb_log_file_size = 104857600InnoDB: PUNCH HOLE support not availableInnoDB: Mutexes and rw_locks use GCC atomic builtinsInnoDB: Uses event mutexesInnoDB: GCC builtin __sync_synchronize() is used for memory barrierInnoDB: Compressed tables use zlib 1.2.3InnoDB: Number of pools: 1InnoDB: Using CPU crc32 instructionsInnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100MInnoDB: Completed initialization of buffer poolInnoDB: page_cleaner coordinator priority: -20InnoDB: Setting log file ./ib_logfile101 size to 100 MBInnoDB: Progress in MB: 100InnoDB: Setting log file ./ib_logfile1 size to 100 MBInnoDB: Progress in MB: 100InnoDB: Setting log file ./ib_logfile2 size to 100 MBInnoDB: Progress in MB: 100InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0InnoDB: New log files created, LSN=802528393InnoDB: Highest supported file format is Barracuda.InnoDB: Log scan progressed past the checkpoint lsn 802528780InnoDB: Doing recovery: scanned up to log sequence number 802528789 (0%)InnoDB: Doing recovery: scanned up to log sequence number 802528789 (0%)InnoDB: Database was not shutdown normally!InnoDB: Starting crash recovery.InnoDB: xtrabackup: Last MySQL binlog file position 2987, file name mysql-bin.000003InnoDB: Removed temporary tablespace data file: "ibtmp1"InnoDB: Creating shared tablespace for temporary tablesInnoDB: Setting file ‘./ibtmp1‘ size to 12 MB. Physically writing the file full; Please wait ...InnoDB: File ‘./ibtmp1‘ size is now 12 MB.InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active.InnoDB: 32 non-redo rollback segment(s) are active.InnoDB: 5.7.13 started; log sequence number 802528789InnoDB: Failed to find tablespace for table `test`.`t2` in the cache. Attempting to load the tablespace with space id 113InnoDB: Operating system error number 2 in a file operation.InnoDB: The error means the system cannot find the path specified.InnoDB: Cannot open datafile for read-only: ‘./test/t2.ibd‘ OS error: 71InnoDB: Operating system error number 2 in a file operation.InnoDB: The error means the system cannot find the path specified.InnoDB: Could not find a valid tablespace file for `test/t2`. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting-datadict.html for how to resolve the issue.xtrabackup: starting shutdown with innodb_fast_shutdown = 0InnoDB: FTS optimize thread exiting.InnoDB: Starting shutdown...InnoDB: Shutdown completed; log sequence number 802528808161008 17:53:57 completed OK!
查找结果是这是一个bug:https://bugs.launchpad.net/percona-xtrabackup/+bug/1532878
直接通过cp备份集到5.7环境下恢复并升级后
[root@mysql-bcc02 mysql]# mysql_upgrade --user=root --socket=/tmp/mysql_6666.sock
重启成功,但错误日志中报和上面相同的错误,既没有复制的表的表空间不存在
这又是一个bug:https://bugs.mysql.com/bug.php?id=82060
恢复部分备份
参考文献:https://www.percona.com/doc/percona-xtrabackup/2.2/innobackupex/restoring_individual_tables_ibk.html
MySQL5.6下使用xtrabackup部分备份恢复到MySQL5.7
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。