安装依赖包 # yum install autoconf libtool cmake yum install libgcrypt-devel wget http://www.percona.com/redir/downloads/XtraBackup/XtraBackup-2.0.4/source/percona-xtrabackup-2.0.4.tar.gz tar -xf percona-xtrabackup-2.0.4.tar.gz [root@RS1 soft]# cd percona-xtrabackup-2.0.4 [root@RS1 percona-xtrabackup-2.0.4]# ./utils/build.sh 报错 ./utils/build.sh: line 159: cmake: command not found 安装cmake文件即可 [root@RS1 percona-xtrabackup-2.0.7]# yum install cmake Build an xtrabackup binary against the specified InnoDB flavor. Usage: build.sh CODEBASE where CODEBASE can be one of the following values or aliases: innodb50 | 5.0 build against innodb 5.1 builtin, but should be compatible with MySQL 5.0 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 [root@RS1 percona-xtrabackup-2.0.4]# ./utils/build.sh innodb51_builtin 复制相应文件和建立软链到/usr/bin下,这么做的原因是满足innobackupex脚本的需要 [root@RS1 src]# cp xtrabackup_51 /usr/bin/xtrabackup_51 [root@RS1 percona-xtrabackup-2.0.4]# cp innobackupex /usr/bin/innobackupex cp:是否覆盖"/usr/bin/innobackupex"? yes [root@RS1 percona-xtrabackup-2.0.4]# ls -sf /usr/local/mysql/bin/mysql /usr/bin/mysql /usr/local/mysql/bin/mysql /usr/bin/mysql
使用innobackupex备份测试
[root@RS1 xtrabak]# innobackupex --user=root --password=123456 --no-lock --defaults-file=/etc/my.cnf /data/xtrabak/ 2>/data/xtrabak/xtarbackup.log
错误提示及其解决方法
[root@linux-212 upload]# cat activity.log Can't locate Time/HiRes.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./innobackupex line 23. BEGIN failed--compilation aborted at ./innobackupex line 23. [root@linux-212 upload]# yum install perl-Time-HiRes innobackupex: Error: Failed to connect to MySQL server as DBD::mysql module is not installed at ./innobackupex line 2956. [root@linux-212 upload]# [root@linux-212 upload]# yum install perl-DBD-MySQL
测试
[root@linux-212 bin]# ./innobackupex --user=root -password=123456 --defaults-file=/etc/my.cnf --database=xy_db_activity_s1 --stream=tar /data/upload/tmp/ 2>/data/upload/tmp/activity.log|gzip 1>/data/upload/tmp/activity.tar.gz
[root@linux-212 bin]# ./innobackupex --host=192.168.1.213 --user=root -password=123 --defaults-file=/etc/my.cnf --database=xy_db_activity_cehua --stream=tar /data/upload/ 2>/data/upload/activity.log|gzip 1>/data/upload/activity.tar.gz
xtrabackup的最新版不支持mysql5.1
下载旧版的
1、首先从http://www.percona.com/下载
wget http://www.percona.com/downloads/XtraBackup/XtraBackup-1.6/Linux/binary/i686/xtrabackup-1.6.tar.gz
开始安装xtrabackup
1)解压
cd /qeedoodb/setup
tar zxvf xtrabackup-1.6.tar.gz
2)拷贝innobackupex、xtrabackup、xtrabackup_51 工具到/usr/bin
cp /data/soft/bac/bin/innobackupex /usr/bin/innobackupex
cp /data/soft/bac/bin/xtrabackup /usr/bin/xtrabackup
cp /data/soft/bac/bin/xtrabackup_51 /usr/bin/xtrabackup_51
做一个mysql的软连接
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
否则会报innobackupex: Error: mysql child process has died: sh: mysql: command not found错误信息
PS:删除链接
有创建就有删除
cd /usr/bin/
rm -rf mysql 注意不是rm -rf mysql/