xtrabackup是第三方的mysql热备工具
下载xtrabackup
网址:
http://www.percona.com/downloads/ ,这里能找到你想要的xtrabackup版本
安装xtrabackup
tar zxvf p
ercona-xtrabackup-2.0.1-446.tar.gz
cd percona-xtrabackup-2.0.1
Value | Alias | Server |
---|
innodb51_builtin | 5.1 | build against built-in InnoDB in MySQL 5.1 |
innodb51 | plugin | build agsinst InnoDB plugin in MySQL 5.1 |
innodb55 | 5.5 | build against InnoDB in MySQL 5.5 |
xtradb51 | xtradb | build against Percona Server with XtraDB 5.1 |
xtradb55 | xtradb55 | build against Percona Server with XtraDB 5.5 |
AUTO_DOWNLOAD="yes" ./utils/build.sh 5.5(后面的名字,是跟着alias走,看上图,这里会产生一个与之匹配的mysql版本,对应的这里是5.5.17版本)
安装完之后,建立软链接
# ln -s /usr/local/script/percona-xtrabackup-2.0.1/innobackupex /usr/local/mysql55/bin/innobackupex
# ln -s /usr/local/script/percona-xtrabackup-2.0.1/src/xtrabackup_innodb55 /usr/local/mysql55/bin/xtrabackup_55
# ln -s /usr/local/script/percona-xtrabackup-2.0.1/src/xtrabackup_innodb55 /usr/local/mysql55/bin/xtrabackup
然后添加环境变量
export PATH=$PATH:/usr/local/mysql55/bin
现在就可以使用
xtrabackup的备份:
/usr/local/mysql55/bin/innobackupex --defaults-file=/data/mysqldata/3306/my.cnf --user=root /data/backup/full
备份完之后,要使用--apply-log,使一系列的在备份过程中,未写入到磁盘的日志。写入到磁盘中。
/usr/local/mysql55/bin/innobackupex --defaults-file=/data/mysqldata/3306/my.cnf --apply-log --user=root
/data/backup/full/
2012-07-04_13-44-40
这个时候,你就可以移空数据目录文件。执行恢复
/usr/local/mysql55/bin/innobackupex --defaults-file=/data/mysqldata/3306/my.cnf --copy-back /data/backup/full/2012-07-04_13-44-40
这样,就算是执行了一遍简单的xtrabackup的备份和恢复