基于Innobackupex的全备恢复(2)

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
            ......非重要信息忽略,下同......
xtrabackup: Starting InnoDB instance for recovery.  --开始innodb实例恢复
            ...........
InnoDB: Starting crash recovery.    --开始crash recovery
            ...........
141222 09:13:59  innobackupex: Restarting xtrabackup with command: xtrabackup  --defaults-file="/data/inst3606/data3606/my3606.cnf"
--defaults-group="mysqld" --prepare --target-dir=/data/bak/hotbak/2014-12-22_09-04-05 --tmpdir=/tmp
for creating ib_logfile*          --注意这里,使用了--prepare,并且创建innodb的logfile

xtrabackup: notice: xtrabackup_logfile was already used to '--prepare'.
xtrabackup: using the following InnoDB configuration for recovery:
            ............
-- Author : Leshami
-- Blog  :  
InnoDB: Shutdown completed; log sequence number 391275633
141222 09:14:02  innobackupex: completed OK!        --成功恢复

--查看恢复后文件的相关信息
SHELL>  ll 2014-12-22_09-04-05
total 178404
-rw-r--r-- 1 root root      357 2014/12/22 09:04 backup-my.cnf
drwx------ 2 root root    4096 2014/12/22 09:04 fullbakdb
-rw-r----- 1 root root 79691776 2014/12/22 09:14 ibdata1
-rw-r--r-- 1 root root 50331648 2014/12/22 09:14 ib_logfile0
-rw-r--r-- 1 root root 50331648 2014/12/22 09:13 ib_logfile1
drwx------ 2 root root    4096 2014/12/22 09:04 mysql
drwxr-xr-x 2 root root    4096 2014/12/22 09:04 performance_schema
drwx------ 2 root root    4096 2014/12/22 09:04 recover
drwx------ 2 root root    4096 2014/12/22 09:04 sakila
-rw-r--r-- 1 root root      26 2014/12/22 09:04 xtrabackup_binlog_info
-rw-r--r-- 1 root root      24 2014/12/22 09:14 xtrabackup_binlog_pos_innodb
-rw-r----- 1 root root      93 2014/12/22 09:14 xtrabackup_checkpoints
-rw-r--r-- 1 root root      684 2014/12/22 09:04 xtrabackup_info
-rw-r----- 1 root root  2097152 2014/12/22 09:13 xtrabackup_logfile

--观察上面文件夹内容的变化,可以看到09:14为新增或发生变化的文件,主要是生成了系统表空间数据文件及innodb日志文件
--同时有关Innodb的检查点文件也进行了更新(注,热备只涉及到InnoDB引擎,所有与InnoDB相关的都会在apply-log时发生变化

--将原有文件夹重命名到新位置,并创建原文件夹
SHELL> mv /data/inst3606/data3606 /data/inst3606/data3606bk
SHELL> mkdir -p /data/inst3606/data3606

--将已经恢复好的数据文件复制回原始位置
SHELL> innobackupex --user=robin -password=xxx --port=3606 --defaults-file=/data/inst3606/data3606bk/my3606.cnf \
> --copy-back /data/bak/hotbak/2014-12-22_09-04-05
                    ......非重要信息忽略,下同......
innobackupex: Starting to copy files in '/data/bak/hotbak/2014-12-22_09-04-05' --启动将备份的文件复制回原路径
innobackupex: back to original data directory '/data/inst3606/data3606'        --原路径位置
                    ............复制所有的数据文件,索引文件个,格式文件等............
innobackupex: Starting to copy InnoDB system tablespace  --复制系统表空间
innobackupex: in '/data/bak/hotbak/2014-12-22_09-04-05'
innobackupex: back to original InnoDB data directory '/data/inst3606/data3606'
innobackupex: Copying '/data/bak/hotbak/2014-12-22_09-04-05/ibdata1' to '/data/inst3606/data3606/ibdata1'

innobackupex: Starting to copy InnoDB undo tablespaces  --复制undo表空间
innobackupex: in '/data/bak/hotbak/2014-12-22_09-04-05'
innobackupex: back to '/data/inst3606/data3606'

innobackupex: Starting to copy InnoDB log files          --复制redo表空间
innobackupex: in '/data/bak/hotbak/2014-12-22_09-04-05'
innobackupex: back to original InnoDB log directory '/data/inst3606/data3606'
innobackupex: Copying '/data/bak/hotbak/2014-12-22_09-04-05/ib_logfile1' to '/data/inst3606/data3606/ib_logfile1'
innobackupex: Copying '/data/bak/hotbak/2014-12-22_09-04-05/ib_logfile0' to '/data/inst3606/data3606/ib_logfile0'
innobackupex: Finished copying back files.

141222 09:34:47  innobackupex: completed OK!

--权限修改
SHELL> cp /data/inst3606/data3606bk/my3606.cnf /data/inst3606/data3606/my3606.cnf
SHELL> chown -R mysql:mysql /data/inst3606/data3606

--启动恢复后的实例
SHELL>  mysqld_safe --defaults-file=/data/inst3606/data3606bk/my3606.cnf &

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/783f23050db2ae34514c5909827c401a.html