xtrabackup8安装和使用

环境:

OS:Centos 7

 

----------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.4-1.el7.x86_64.rpm

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

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


2.安装

rpm方式安装,将系统盘做为本地yum

 

[root@rac02 soft]# yum install rsync
[root@rac02 soft]# rpm -ivh libev-4.15-7.el7.x86_64.rpm ##需要单独下载
[root@rac02 soft]# rpm -ivh percona-xtrabackup-80-8.0.7-1.el7.x86_64.rpm 

 

安装目录

 

[root@rac02 soft]# which xtrabackup
/usr/bin/xtrabackup

 

安装完成后需要检查下当前xtrabackup支持的mysql版本

[root@rac02 xtrabackup_file]# /usr/bin/xtrabackup -v
xtrabackup: recognized server arguments: --datadir=/var/lib/mysql
/usr/bin/xtrabackup version 8.0.7 based on MySQL server 8.0.16 Linux (x86_64) (revision id: 069e0e6)

 

可以看到当前的xtrabackup只支持 MySQL server 8.0.16

 

 

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 root@192.168.1.135:/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版本问题解决

posted @ 2019-09-23 17:59  slnngk  阅读(3372)  评论(0编辑  收藏  举报