概述
介绍: 本章内容为阿里云RDS Mysql 将物理备份文件.xb恢复到自建数据库的过程、环境搭建
准备环境
● Mysql
● XtraBackup2.4.4
● qpress
● 相关依赖
恢复代码如下
# 安装依赖
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-devel-0.3.107-10.el6.x86_64.rpm
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libgpg-error-devel-1.7-4.el6.x86_64.rpm
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libgcrypt-devel-1.4.5-12.el6_8.x86_64.rpm
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libidn-devel-1.18-2.el6.x86_64.rpm
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libcurl-devel-7.19.7-53.el6_9.x86_64.rpm
wget http://download-ib01.fedoraproject.org/pub/epel/6/x86_64/Packages/l/libev-4.03-3.el6.x86_64.rpm
wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.4/binary/redhat/6/x86_64/percona-xtrabackup-24-2.4.4-1.el6.x86_64.rpm
rpm -ivh libaio-devel-0.3.107-10.el6.x86_64.rpm --force --nodeps
rpm -ivh libgpg-error-devel-1.7-4.el6.x86_64.rpm --force --nodeps
rpm -ivh libgcrypt-devel-1.4.5-12.el6_8.x86_64.rpm --force --nodeps
rpm -ivh libidn-devel-1.18-2.el6.x86_64.rpm --force --nodeps
rpm -ivh libcurl-devel-7.19.7-53.el6_9.x86_64.rpm --force --nodeps
rpm -ivh libev-4.03-3.el6.x86_64.rpm --force --nodeps
# 安装XtraBackUp
wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.11/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.11-1.el7.x86_64.rpm
yum localinstall percona-xtrabackup-24-2.4.11-1.el7.x86_64.rpm
# 安装qpress
wget http://www.quicklz.com/qpress-11-linux-x64.tar
tar xvf qpress-11-linux-x64.tar
cp qpress /usr/bin
# 创建目录
mkdir -p /home/mysql/data
# 解包
cat *_qp.xb |xbstream -x -v -C /home/mysql/data
# 解压
innobackupex --decompress --remove-original /home/mysql/data
编辑backup-my.cnf
vim /home/mysql/data/backup-my.cnf
注释下面内容(不存在忽略)
#innodb_log_checksum_algorithm
#innodb_fast_checksum
#innodb_log_block_size
#innodb_doublewrite_file
#rds_encrypt_data
#innodb_encrypt_algorithm
#redo_log_version
#master_key_id
# 授权mysql用户
chown -R mysql:mysql /home/mysql/data
# 验证启动
mysqld_safe --defaults-file=/home/mysql/data/backup-my.cnf --user=mysql --datadir=home/mysql/data &
# 验证数据库是否启动成功
mysql -u root -p
# 直接替换整个data文件夹即可
\cp -rf /home/mysql/data/ /usr/local/mysql/
# 启动mysql
service mysql start
安装完成 通过工具即可连接