xtrabackup8安装和使用

----------centos 7安装xtrabackup8.0.7---------------------------
1.下载
#8.0版本
$ wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-8.0.4/binary/redhat/7/x86_64/percona-xtrabackup-80-8.0.7-1.el7.x86_64.rpm

或是下载二进制版本进行安装

percona-xtrabackup-8.0.7-Linux-x86_64.libgcrypt145.tar


2.安装
yum localinstall percona-xtrabackup-80-8.0.7-1.el7.x86_64.rpm
卸载命令如下:
yum remove percona-xtrabackup

3.使用备份
rpm的安装方式默认安装路径为:/usr/bin/xtrabackup
/usr/bin/xtrabackup --defaults-file=/opt/mha/mysql8/conf/my.cnf --host=localhost --user=root --password=mysql --port=13306 --socket=/opt/mha/mysql8/mysql.sock --backup --target-dir=/opt/mha/xbackup/


-------------异地恢复----------------------
1.将备份文件拷贝到目的机器
[root@localhost mha]# tar -cvf xbackup.tar ./xbackup/
[root@localhost mha]# scp xbackup.tar [email protected]:/opt/mha/

2.解压到指定目录
[root@localhost bin]# mkdir -p /opt/mha/xbackup/
[root@localhost xbackup]# tar -xvf xbackup.tar

3.停掉需要恢复的数据库
/opt/mha/mysql8/bin/mysqladmin -h 127.0.0.1 -uroot -P13306 -S /opt/mha/mysql8/mysql.sock shutdown


4.备份之前的数据文件目录,并创建一个空目录
[root@localhost mysql8]# cd /opt/mha/mysql8
[root@host02 mysql5718]# mv data bakdata
[root@host02 mysql5718]# mkdir data

6.准备
xtrabackup --host=localhost --user=root --password=mysql --port=13306 --prepare --target-dir=/opt/mha/xbackup/xbackup/
xtrabackup --defaults-file=/opt/mha/mysql8/conf/my.cnf --user=root --prepare --target-dir=/opt/mha/xbackup/xbackup/


7.拷回数据:
xtrabackup --defaults-file=/opt/mha/mysql8/conf/my.cnf --user=root --copy-back --target-dir=/opt/mha/xbackup/xbackup/

8.修改目录属性启动数据库:
/opt/mha/mysql8
chown -R mysql:mysql ./data ##数据文件
chown -R mysql:mysql ./mysqllog ##binlog存储路径

su - mysql
/opt/mha/mysql8/bin/mysqld_safe --defaults-file=/opt/mha/mysql8/conf/my.cnf --user=mysql &

登陆查看
/opt/mha/mysql8/bin/mysql -h localhost -uroot -P13306 -S /opt/mha/mysql8/mysql.sock -pmysql

-----------------------------
问题1:遇到的问题:
Populating InnoDB table cache.
Allocated tablespace ID 1 for sys/sys_config, old maximum was 0
xtrabackup: Unknown error 3613
xtrabackup: Unknown error 3613
xtrabackup: Unknown error 3613

该问题是在8.0.4版本出现的,后来安装了8.0.7版本问题解决

你可能感兴趣的:(xtrabackup8安装和使用)