centos 7 安装 percona-xtrabackup-24-2.4.24-1.el7.x86_64
rpm -ivh libaio-devel-0.3.109-13.el7.x86_64.rpm
rpm -ivh libev-4.15-3.el7.x86_64.rpm
yum -y install libaio*
yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-MySQL
yum -y install rsync perl l perl-Digest-MD5
yum install https://downloads.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.24/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.24-1.el7.x86_64.rpm
# 查看版本:
xtrabackup --version
xtrabackup: recognized server arguments: --datadir=/data/mysql/data --log_bin=mysql-bin --server-id=1
xtrabackup version 2.4.24 based on MySQL server 5.7.35 Linux (x86_64) (revision id: b4ee263)
####### 全库备份
#!/bin/bash
datename=$(date +%Y%m%d-%H%M%S)
mkdir /data_140_backups/backups/143_mysql_5807/$datename
xtrabackup --defaults-file=/data/server/mysql/my.cnf --user=root --password=密码 --compress --backup --target-dir=/data_140_backups/backups/143_mysql_5807/$datename >> /data_140_backups/backups/logs/143_mysql_5807_backup.$(date +%F).log 2>&1
###################
######## 恢复备份
1) 先解压备份:
xtrabackup --decompress --parallel=4 --target-dir=/data/20221229-150710
2)确保/data/mysql/data,数据目录没有内容,否则会提示不为空而失败:
mv /data/mysql/data /opt/
mkdir /data/mysql/data -p && chown -R mysql.mysql /data/mysql/data
3) 还原数据库,还原前需确认数据库目录为空:
innobackupex --apply-log /data/20221229-150710 # 对备份进行整理
innobackupex --copy-back /data/20221229-150710 # 还原数据库,还原前需确认数据库目录为空
4) 赋予权限:
chown -R /data/mysql/data
5) 启动mysql:
/etc/init.d/mysqld start
6) 用old库的密码登录:
mysql -u root -p -P 5807
三、单表导出和导入
注:需MySQL 5.6及以上版本才支持此功能
1、单表备份
innobackupex --user=root --password=密码 --include='reset_gq.wp_users' /backups
2、导出表结构
mysql -uroot -p -e 'show create table reset_gq.wp_users'
3、删除表
mysql -uroot -p -e 'drop table reset_gq.wp_users'
4、单表恢复
innobackupex --apply-log --export /backups/2018-03-09_12-26-33/
错误解决
# xtrabackup --decompress --parallel=4 --target-dir=/mysqldatabak/xtrabak/full_20220821
...
sh: qpress: command not found
cat: write error: Broken pipe
Error: thread 0 failed.
#解决办法:
wget https://repo.percona.com/yum/release/7/RPMS/x86_64/qpress-11-1.el7.x86_64.rpm
rpm -ivh qpress-11-1.el7.x86_64.rpm
标签:24,--,data,xtrabackup,64,mysql,C7
From: https://www.cnblogs.com/zhenxing06/p/17016245.html