日期:2014-05-16 浏览次数:20675 次
依赖包
yum install libaio libaio-devel perl-Time-HiRes curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel perl-ExtUtils-MakeMaker perl-DBD-MySQL.* package -y
简单实例
备份
$ innobackupex --user=root --password=oracle /home/mysql/backup
模拟故障
$ mysqladmin -uroot -poracle shutdown
$ rm -rf /home/mysql/mysql/data/*
恢复
$ innobackupex --user=root --password=oracle --apply-log /home/mysql/backup/2013-10-08_14-32-27
$ innobackupex --user=root --password=oracle --copy-back /home/mysql/backup/2013-10-08_14-32-27
xtrabackup备份原理大概有如下3个过程:
① 记录LSN(log sequence number)
② 复制文件
③ 启动后台进程,不停地记录变化的redo
这个流程可以从xtrabackup备份输出结果看出来
简单测试
备份
$ xtrabackup --backup --target-dir=/home/mysql/backup
[mysql@even backup]$ ls
employees ibdata1 xtrabackup_checkpoints xtrabackup_logfile
模拟故障
关闭MySQL,把整个datadir目录清空,不过仅保留mysql和performance_schema这两个库
恢复
--恢复ibdata1,让数据文件自身保持一致
$ xtrabackup --prepare --target-dir=/home/mysql/backup/
--恢复ib_logfile0 ib_logfile1,减少恢复时间
$ xtrabackup --prepare --target-dir=/home/mysql/backup/
$ rsync -avrP /home/mysql/backup/ /home/mysql/mysql/data/
$ chown -R mysql:dba /home/mysql/mysql/data
参考文章:
http://www.percona.com/doc/percona-xtrabackup/2.1/xtrabackup_bin/xtrabackup_binary.html
http://www.baidu-ops.com/2013/05/26/xtrabackup/
http://www.banping.com/2011/07/01/xtrabackup-process-backgroud/
http://www.orczhou.com/index.php/2009/10/xtrabackup-2/
By 迦夜
2013-10-9
Early start makes easy stages