MySql8.0.20+percona-xtrabackup-80-8.0.13备份与恢复

一、软件:

 MySql8.0.20

 percona-xtrabackup-80-8.0.13-1.el7.x86_64
安装:

1、安装percona依赖库:

yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm

2、测试依赖库是否安装成功:

yum list | grep percona

3、安装percona

yum install percona-xtrabackup-24

MySql8.0.20+percona-xtrabackup-80-8.0.13备份与恢复_第1张图片

解决方法:

yum update percona-release -y

yum update -y

4、安装完成。

 rpm -ql percona-xtrabackup-24

Xtrabackup 2.4.已经不支持MySQL 8.0的备份恢复,使用会报如下错误!

Error: MySQL 8.0 and Percona Server 8.0 are not supported by Percona Xtrabackup 2.4.x series. Please use Percona Xtrabackup 8.0.x for backups and restores.

 

在percona官方下载centos版本的rpm包,使用yum安装(示例):

yum -y localinstall percona-xtrabackup-80-8.0.1-2.alpha2.el7.x86_64.rpm

  yum install https://repo.percona.com/centos/7/RPMS/noarch/percona-release-0.1-8.noarch.rpm

xtrabackup --version  查看版本

安装percona-xtrabackup-80

yum -y install percona-xtrabackup-80-8.0.7-1.el7.x86_64.rpm

查看安装后结果,发现已经没有innobackupex命令

  rpm -ql percona-xtrabackup-80-8.0.7-1.el7.x86_64

 
二、使用:
1.权限

    CREATE USER 'xtrabk'@'127.0.0.1' IDENTIFIED BY 'Xtrabk#123';
    GRANT BACKUP_ADMIN, PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'xtrabk'@'127.0.0.1';
    GRANT SELECT ON performance_schema.log_status TO 'xtrabk'@'127.0.0.1';
    FLUSH PRIVILEGES;

mysql_config_editor set --login-path=xtrlogin -uxtrabk -h127.0.0.1 -P3306 -pXtrabk#123

2.全备+增备
全备xbstream:

xtrabackup --login-path=xtrlogin  --parallel=2 --stream=xbstream --extra-lsndir=/mysqlbackup/node2/checkpoint  --tmpdir=/mysqlbackup/node2/tmp   --backup  --target-dir=/mysqlbackup/node2

增备:

xtrabackup --login-path=xtrlogin  --parallel=2 --stream=xbstream --extra-lsndir=/mysqlbackup/node2/checkpoint  --backup --incremental-basedir=/mysqlbackup/node2/checkpoint --backup  --target-dir=/mysqlbackup/node2

或者

 more /home/op/shell/xtrabackuphot-mysql8.sh

#!/bin/sh

# xtrabackup的相关配置
INNOBACKUPEX="xtrabackup"
MY_CNF="/home/pubsrv/mysql-8.0.12-3306/etc/my.cnf"
MY_USER="PWD"
MY_PASSWORD="PWD"
MY_SOCKET="/home/pubsrv/mysql-8.0.12-3306/run/mysql.sock"
MY_HOST=192.168.1.11
MY_PORT=3306
# 远程备份机 文件名配置
REMOTE_HOST="192.168.6.10"
REMOTE_DIR="/home/20200401backupmysql"
#LOCAL_LSN_FILE="~/.to_lsn_important"
#LOCAL_LSN_FILE="/home/backup/mysql/test/.to_lsn_important"
DATE_NAME=`date +%Y-%m-%d-%H-%M-%S`
REMOTE_FILE=$DATE_NAME.xbstream.gz
#REMOTE_FILE_STREAM=$DATE_NAME.xbstream
#LOCK_FILE="~/.mysql.backup.lock"
#LOCK_FILE="/home/backup/mysql/test/.mysql.backup.lock"
#LOCAL_BACKUP_DIR="/home/backup/mysql/test/$DATE_NAME"

    # 全量备份
    echo '1' > $LOCK_FILE
     $INNOBACKUPEX  --defaults-file=$MY_CNF --user=$MY_USER --password=$MY_PASSWORD --port=$MY_PORT  --socket=$MY_SOCKET --host=$MY_HOST --no-timestamp --parallel=4 --throttl
e=2000 --compress-threads=8 --backup --stream=xbstream|gzip |ssh $REMOTE_HOST   "cat - > $REMOTE_DIR/FULL-131database-$REMOTE_FILE"

 

3.恢复
全备恢复:

xtrabackup  --prepare --parallel=2 --use-memory=1g   --apply-log-only   --target-dir=/mysqlbackup/node2

增备恢复:

xtrabackup --prepare --use-memory=1g  --parallel=2 --apply-log-only  --target-dir=/mysqlbackup/node2 --incremental-dir=/mysqlbackup/node2/checkpoint

应用事务日志+回滚未提交:

   xtrabackup   --prepare --use-memory=1g  --parallel=2  --target-dir=/mysqlbackup/node2

最后一步copy把备份复制到datadir目录下:

xtrabackup --copy-back --target-dir=/mysqlbackup/node2
 

你可能感兴趣的:(备份与恢复)