在上一篇里,演示了使用xtrabackup对InnoDB进行在线物理热备,使用innobackupex脚本,可以很简单的一条命令行搞定InnoDB和MyISAM的物理备份。
本文则演示如何从xtrabackup的备份中进行恢复。本次恢复的是一个600GB大小的InnoDB数据库,备份的时候没有使用gzip压缩。
首先将备份好的tar文件解开到目标数据库的数据路径下,这一步类似oracle的restore database:
tar xvf mysqlbak.tar /opt/mysqldata
注意解出来的文件和目录的属主以及权限是否正确。如果是将备份恢复到一台全新的环境,则需要修改/etc/my.cnf,将innodb_data_file_path等参数设置和原备份的库一致。然后执行:
$innobackupex-1.5.1 --apply-log /opt/mysqldata
这一步类似于oracle的recover database,从日志来看,差不多一个小时执行完毕,该InnoDB数据库分配空间600GB,实际使用空间约590GB,并且数据的更新量还是比较大的,大约一个小时apply-log完成。运行的日志简单记录如下:
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy. All Rights Reserved. This software is published under the GNU GENERAL PUBLIC LICENSE Version 2, June 1991. IMPORTANT: Please check that the apply-log run completes successfully. At the end of a successful apply-log run innobackup prints "innobackup completed OK!". 090708 09:50:44 innobackupex: Starting ibbackup with command: xtrabackup --prepare --target-dir=/opt/mysqldata xtrabackup Ver rc-0.7 for 5.0.77 unknown-linux-gnu (x86_64) xtrabackup: cd to /opt/mysqldata xtrabackup: This target seems to be not prepared yet. xtrabackup: xtrabackup_logfile detected: size=2882535424, start_lsn=(514 2288109039) xtrabackup: Temporary instance for recovery is set as followings. xtrabackup: innodb_data_home_dir = ./ xtrabackup: innodb_data_file_path = ibdata1:10000M;ibdata2:10000M;ibdata3:10000M...;ibdata60:10000M xtrabackup: innodb_log_group_home_dir = ./ xtrabackup: innodb_log_files_in_group = 1 xtrabackup: innodb_log_file_size = 2882535424 xtrabackup: Starting InnoDB instance for recovery. xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter) InnoDB: Log scan progressed past the checkpoint lsn 514 2288109039 090708 9:50:45 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Doing recovery: scanned up to log sequence number 514 2293351424 (0 %) InnoDB: Doing recovery: scanned up to log sequence number 514 2298594304 (0 %) InnoDB: Doing recovery: scanned up to log sequence number 514 2303837184 (0 %) InnoDB: Doing recovery: scanned up to log sequence number 514 2309080064 (0 %) 090708 9:50:47 InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percents: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 InnoDB: Apply batch completed InnoDB: Doing recovery: scanned up to log sequence number 514 2314322944 (1 %) InnoDB: Doing recovery: scanned up to log sequence number 514 2319565824 (1 %) InnoDB: Doing recovery: scanned up to log sequence number 514 2324808704 (1 %) InnoDB: Doing recovery: scanned up to log sequence number 514 2330051584 (1 %) InnoDB: Doing recovery: scanned up to log sequence number 514 2335294464 (1 %) ...这里省略若干行 InnoDB: Doing recovery: scanned up to log sequence number 514 3881944064 (62 %) InnoDB: Doing recovery: scanned up to log sequence number 514 3887186944 (62 %) InnoDB: Doing recovery: scanned up to log sequence number 514 3887732530 (62 %) 090708 10:52:00 InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percents: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 InnoDB: Apply batch completed InnoDB: In a MySQL replication slave the last master binlog file InnoDB: position 0 350504077, file name mysql-bin.000748 InnoDB: Last MySQL binlog file position 0 36434864, file name /opt/mysqllog/mysql-bin.003015 090708 10:52:17 InnoDB: Started; log sequence number 514 3887732530 [notice (again)] If you use binary log and don't use any hack of group commit, the binary log position seems to be: InnoDB: Last MySQL binlog file position 0 36434864, file name /opt/mysqllog/mysql-bin.003015 xtrabackup: starting shutdown with innodb_fast_shutdown = 1 090708 10:52:17 InnoDB: Starting shutdown... 090708 10:52:24 InnoDB: Shutdown completed; log sequence number 514 3887732530 090708 10:52:24 innobackupex: Restarting xtrabackup with command: xtrabackup --prepare --target-dir=/opt/mysqldata for creating ib_logfile* xtrabackup Ver rc-0.7 for 5.0.77 unknown-linux-gnu (x86_64) xtrabackup: cd to /opt/mysqldata xtrabackup: This target seems to be already prepared. xtrabackup: notice: xtrabackup_logfile was already used to '--prepare'. xtrabackup: Temporary instance for recovery is set as followings. xtrabackup: innodb_data_home_dir = ./ xtrabackup: innodb_data_file_path = ibdata1:10000M;ibdata2:10000M;ibdata3:10000M;...;ibdata60:10000M xtrabackup: innodb_log_group_home_dir = ./ xtrabackup: innodb_log_files_in_group = 4 xtrabackup: innodb_log_file_size = 104857600 xtrabackup: Starting InnoDB instance for recovery. xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter) 090708 10:52:25 InnoDB: Log file ./ib_logfile0 did not exist: new to be created InnoDB: Setting log file ./ib_logfile0 size to 100 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 090708 10:52:25 InnoDB: Log file ./ib_logfile1 did not exist: new to be created InnoDB: Setting log file ./ib_logfile1 size to 100 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 090708 10:52:26 InnoDB: Log file ./ib_logfile2 did not exist: new to be created InnoDB: Setting log file ./ib_logfile2 size to 100 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 090708 10:52:26 InnoDB: Log file ./ib_logfile3 did not exist: new to be created InnoDB: Setting log file ./ib_logfile3 size to 100 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 InnoDB: The log sequence number in ibdata files does not match InnoDB: the log sequence number in the ib_logfiles! 090708 10:52:27 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: In a MySQL replication slave the last master binlog file InnoDB: position 0 350504077, file name mysql-bin.000748 InnoDB: Last MySQL binlog file position 0 36434864, file name /opt/mysqllog/mysql-bin.003015 090708 10:52:27 InnoDB: Started; log sequence number 514 3887732748 [notice (again)] If you use binary log and don't use any hack of group commit, the binary log position seems to be: InnoDB: Last MySQL binlog file position 0 36434864, file name /opt/mysqllog/mysql-bin.003015 xtrabackup: starting shutdown with innodb_fast_shutdown = 1 090708 10:52:27 InnoDB: Starting shutdown... 090708 10:52:29 InnoDB: Shutdown completed; log sequence number 514 3887732748 090708 10:52:29 innobackupex: innobackup completed OK!
运行完毕后,启动mysql即可。
相关推荐
本教程将详细介绍如何使用`xtrabackup`结合Shell脚本来实现MySQL数据库的备份与还原。 首先,我们需要理解`xtrabackup`的工作原理。`xtrabackup`通过读取InnoDB的数据文件和Redo日志,生成一个完整的物理备份。由于...
该脚本资源是使用xtrabackup对mysql做定时备份使用的,方便大家下载学习,如果过有是问题可以私信我,关于xtrabackup我也是没有太深入的了解,还有很多需要学习的地方,作为开发人员,也需要了解一些简单的运维知识
总的来说,Xtrabackup是MySQL数据库备份的理想选择,特别是在大型数据库和高可用性环境中。其高效、无锁的备份机制,灵活的增量备份,以及易于集成到自动化流程中的特性,都使其成为管理MySQL数据库不可或缺的工具。
MySQL数据库的自动定时备份是数据库管理中的重要环节,它确保了数据的安全性和可恢复性,尤其是在发生意外情况如系统故障、硬件损坏或人为错误时。本教程将详细讲解如何设置MySQL数据库的自动定时备份,包括步骤、所...
定时备份MySQL数据库是一项必不可少的任务,确保在出现意外情况如硬件故障、软件错误或人为操作失误时,能够快速恢复到正常状态。本篇文章将详细介绍如何配置定时备份MySQL数据库,包括每日、每周和每月的备份策略。...
下面将详细介绍如何通过CMD(命令提示符)和Java来使用mysqldump进行MySQL数据库的备份。 ### CMD备份 在Windows系统中,我们通常使用CMD(命令提示符)来执行mysqldump命令。首先,确保MySQL服务器已运行,并且...
MySQL数据库的备份与恢复是确保数据安全性的重要环节。在本测试报告中,主要涉及了全量备份和增量备份的恢复过程,并对恢复后的数据进行了验证。以下是对这些知识点的详细说明: 1. **全量备份**:全量备份是数据库...
《使用Xtrabackup备份还原MySQL数据库的详解》 MySQL数据库在企业级应用中扮演着至关重要的角色,为了确保数据的安全性和可恢复性,定期备份是必不可少的。本文将详细探讨如何使用Xtrabackup工具进行MySQL数据库的...
本文将详细介绍 MySQL 实时增量备份和 XtraBackup 备份技术,并结合实际案例,演示如何使用 binlog 日志恢复删除的表记录。 MySQL 实时增量备份 MySQL 实时增量备份是指在 MySQL 服务器上实时记录所有的数据库...
在MySQL数据库管理中,数据安全至关重要,而定期备份和有效的恢复策略是保障数据安全的关键环节。Xtrabackup是一款开源的、针对InnoDB存储引擎的热备份工具,它能够在不锁定数据库的情况下进行完整备份。本文将详细...
基于xtrabackup8.0的数据库备份脚本,支持全库压缩备份、排除指定数据库压缩备份以及指定数据库压缩备份。备份规则:周一至周六增量备份,周日全库备份,自动管理备份和备份日志。如果有格式问题,应该是windows的...
7.Xtrabackup备份Mysql数据库一.mp4 8.Xtrabackup备份Mysql数据库二.mp4 9.MySQL数据库主从原理讲解.mp4 10.MySQL高效架构读写分离配置.mp4 11.MySQL主从集群构建及故障切换.mp4 12.使用Binlog日志快速恢复MySQL数据...
XtraBackup 备份与恢复实例讲解 XtraBackup 是 Percona 公司开发的一款开源的 MySQL ...通过对 XtraBackup 的参数选项的了解,我们可以更好地使用 XtraBackup 来备份和恢复 MySQL 数据库,确保数据的安全和可靠性。
《使用Xtrabackup 2.4.4恢复MySQL数据库》 在MySQL数据库管理中,数据的安全性和可恢复性是至关重要的。Percona Xtrabackup是一款强大的开源工具,专为InnoDB和XtraDB存储引擎提供热备份解决方案。本文将详细阐述...
NBU备份恢复Mysql+Mysql安装部署
**Xtrabackup**是Percona公司提供的一款开源、高效的数据备份工具,它主要用于MySQL数据库,特别是InnoDB存储引擎的备份与恢复。Xtrabackup的主要特点是能够在不锁定数据库的情况下进行热备份,这意味着在备份过程中...
Xtrabackup是Percona公司开发的一款高效、可靠的MySQL数据库备份工具,特别适用于InnoDB和XtraDB存储引擎的物理热备份。它在备份过程中具有以下显著特点: 1. **备份过程快速且可靠**:Xtrabackup能够在不影响...
Percona XtraBackup是MySQL数据库管理系统的一个重要工具,专门用于高效、无损的数据备份。它在MySQL社区中广受欢迎,特别是在需要对InnoDB存储引擎进行热备份的场景下。这款工具的独特之处在于它可以在不中断服务的...