1、安装innobackupex
wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.9/binary/redhat/7/x86_64/Percona-XtraBackup-2.4.9-ra467167cdd4-el7-x86_64-bundle.tar
wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/libev-4.15-7.el7.x86_64.rpm
rpm -ivh percona-xtrabackup-24-2.4.9-1.el7.x86_64.rpm
rpm -ivh percona-xtrabackup-24-debuginfo-2.4.9-1.el7.x86_64.rpm
rpm -ivh percona-xtrabackup-test-24-2.4.9-1.el7.x86_64.rpm
rpm包安装过程中缺什么依赖就装什么
2、安装好后进行首次进行全量备份
数据库登录信息参数
innobackupex --user=root --password=password /root/mysql/backup/
备份过程如出现错误,解决后继续,比如常见的open_files值过小,备份完成后会生成一个新的目录
/root/mysql/backup/2019-12-02_14-55-24
3、增量备份
innobackupex --user=root --password=password --host=192.168.1.170 --incremental /root/mysql/backup/ --incremental-basedir=/root/mysql/backup/2019-12-02_14-55-24/
4、合并增量备份和全量备份
innobackupex --apply-log --redo-only --incremental /root/mysql/backup/2019-12-02_14-55-24/ --incremental-dir=/root/mysql/backup/2019-12-02_15-04-32
5、还原,如还原2019-12-02_14-55-24该备份
关闭数据库,删除/var/lib/mysql目录
innobackupex --datadir=/var/lib/mysql --copy-back /root/mysql/backup/2019-12-02_14-55-24/
chown -R mysql:mysql /var/lib/mysql
开启数据库