博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL5.6下使用xtrabackup部分备份恢复到MySQL5.7
阅读量:6418 次
发布时间:2019-06-23

本文共 8286 字,大约阅读时间需要 27 分钟。

现有需求:需要备份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

转载于:https://www.cnblogs.com/Bccd/p/5939729.html

你可能感兴趣的文章
PANDAS 数据合并与重塑(join/merge篇)
查看>>
文件时间信息在测试中的应用
查看>>
Exception loading sessions from persistent storage (tomcat异常)
查看>>
直播疑难杂症排查(8)— 播放杂音、噪音、回声问题
查看>>
安装乌班图系统,并且演示有趣的linux命令,你还怕对linux无兴趣吗
查看>>
IBM存储部门换了新老板:还是6年前那个
查看>>
IBM公司公布三层单元PCM-MLC,向3DX堆栈方案发起挑战
查看>>
《2040大预言:高科技引擎与社会新秩序》—— 导读
查看>>
数据库操作:添加、插入、更新语句
查看>>
降低数据中心能源消耗
查看>>
《Python Cookbook(第3版)中文版》——1.8 与字典有关的计算问题
查看>>
《提高转化率!网页A/B测试与多变量测试实战指南》一2.5 勇气与责任心
查看>>
深入实践Spring Boot3.2 控制器设计
查看>>
《微信小程序:开发入门及案例详解》—— 导读
查看>>
降低JRuby的内存占用的可能方法
查看>>
如何创建和使用Python CGI脚本
查看>>
RHCSA 系列(九): 安装、配置及加固一个 Web 和 FTP 服务器
查看>>
《jQuery、jQuery UI及jQuery Mobile技巧与示例》——3.7 示例:添加函数的返回结果...
查看>>
并发集合(一)引言
查看>>
如何写gdb命令脚本
查看>>