1、下载安装xtrabackup
下载地址:https://www.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.19/binary/tarball/percona-xtrabackup-2.4.19-Linux-x86_64.el7.tar.gz
上传到/usr/src 下
cd /usr/src
tar -zxvf percona-xtrabackup-2.4.19-Linux-x86_64.el7.tar.gz -C /usr/local
mv /usr/local/percona-xtrabackup-2.4.19-Linux-x86_64.el7 /usr/local/xtrabackup
echo "export PATH=\$PATH:/usr/local/xtrabackup/bin" >> /etc/profile
source /etc/profile
2、mysql创建用户,全量备份
[root@localhost ~]# mysql -uroot -p mysql> create user 'backup'@'%' identified by '123456'; #创建用户backup,密码123456 mysql> grant reload, lock tables, process, replication client on *.* to 'backup'@'%'; mysql> flush privileges;
全量备份:
[root@localhost ~]# innobackupex --default-file=/etc/my.cnf --host=192.168.1.50 --user=backup --password=123456 --port=3306 --socket=/tmp/mysqld.sock /data/backups
显示 200411 10:49:06 completed OK! 时,说明全量备份已完成
恢复全备:
[root@localhost ~]# innobackupex --apply-log /data/backups/2020-04-11_09-59-07/record/