mysql之 percona-xtrabackup 2.4.7安装(热备工具)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql之 percona-xtrabackup 2.4.7安装(热备工具)相关的知识,希望对你有一定的参考价值。

1.安装依赖包
 
#yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-mysql
2. 安装percona-xtrabackup工具
 
# rpm -ivh percona-xtrabackup-24-2.4.7-1.el5.x86_64.rpm
提示缺少依赖:
 
warning: percona-xtrabackup-24-2.4.7-2.el6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY
error: Failed dependencies:
    libev.so.4()(64bit) is needed by percona-xtrabackup-24-2.4.7-2.el6.x86_64
    libnuma.so.1()(64bit) is needed by percona-xtrabackup-24-2.4.7-2.el6.x86_64
    rsync is needed by percona-xtrabackup-24-2.4.7-2.el6.x86_64
安装libnuma依赖包命令:
 
#yum -y install numactl
3.查看安装目录
 
# rpm -ql percona-xtrabackup-24
/usr/bin/innobackupex
/usr/bin/xbcloud
/usr/bin/xbcloud_osenv
/usr/bin/xbcrypt
/usr/bin/xbstream
/usr/bin/xtrabackup
/usr/share/doc/percona-xtrabackup-24-2.4.7
/usr/share/doc/percona-xtrabackup-24-2.4.7/COPYING
/usr/share/man/man1/innobackupex.1.gz
/usr/share/man/man1/xbcrypt.1.gz
/usr/share/man/man1/xbstream.1.gz
/usr/share/man/man1/xtrabackup.1.gz
4.创建专用备份账户
 
mysql> create user [email protected]‘localhost‘ identified by ‘123456‘;
mysql> grant reload,PROCESS,lock tables,Replication client,super on *.* to [email protected]‘localhost‘;
5.全备、增备及恢复
 
全备:
#innobackupex --defaults-file=/etc/my.cnf  --user=root --password=123456 /home/backup/full
 
全备恢复:
innobackupex --apply-log /home/backup/full/2017-06-14_21-26-56
 
innobackupex --copy-back /home/backup/full/2017-06-14_21-26-56
 
增备:
#innobackupex --defaults-file=/etc/my.cnf --user=root --password=123456 --incremental-basedir=/home/backup/full/2017-06-14_21-26-56 --incremental /home/backup/incremental
 
增备恢复:
第一步是在所有备份目录下重做已提交的日志:
innobackupex --apply-log --redo-only /home/backup/full/2017-06-14_21-26-56
innobackupex --apply-log --redo-only /home/backup/full/2017-06-14_21-26-56 --incremental-dir=/home/backup/incremental/2017-06-14_21-35-43
第二步回滚未完成的日志:
innobackupex --apply-log /home/backup/full/2017-06-14_21-26-56
第三步拷贝:
service mysql stop
执行copy-back之前需要清空mysql的data目录
innobackupex --copy-back /home/backup/full/2017-06-14_21-26-56
启动之前注意data目录的权限问题
service mysql start

以上是关于mysql之 percona-xtrabackup 2.4.7安装(热备工具)的主要内容,如果未能解决你的问题,请参考以下文章

MySQL备份之xtrabackup

mysql Percona-XtraBackup

mysql备份还原工具percona-xtrabackup

mysql增量备份 percona-xtrabackup

使用percona-xtrabackup工具对mysql数据库的备份方案

Percona-Xtrabackup 2.3.3 不再堵塞备份