Innobackupex Physical BACKUP Database + recovery using Xtrabackup

Source: Internet
Author: User
Tags percona

1. Prepare two servers to install the mysql5.7 version separately (previously installed)
db1 11.0.0.51db2 11.0.0.52数据目录均为/data/mysql_data备份目录均为/db_all_backup
2. Backing up the database using DB1
#db1和db2安装以下备份软件:yum install  perl-DBD-MySQL perl-devel -ycd /usr/local/src/wget ftp://rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/libev-4.15-1.el6.rf.x86_64.rpm rpm -ivh libev-4.15-1.el6.rf.x86_64.rpm  wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.5/binary/redhat/6/x86_64/percona-xtrabackup-24-2.4.5-1.el6.x86_64.rpm rpm -ivh percona-xtrabackup-24-2.4.5-1.el6.x86_64.rpm #全备指令 innobackupex --user=root --password=123456  --stream=tar /db_all_backup | gzip > /db_all_backup/mysql_all_`date +%F`.tar.gz 2>/db_all_backup/xtrabackup_`date +%F`.log #在/db_all_backup目录中会生成全备tar包,以及备份日志
3. Recovering DB1 Data on DB2
 #db1上将tar包scp到db2上 scp /all_db_backup/mysql_all_2018-04-18.tar.gz [email protected]:/db_all_backup/ #解压该tar包,然后移走该tar包 3.1 该目录下会出现几个重要文件 xtrabackup_binlog_info xtrabackup_checkpoints xtrabackup_info 注意:xtrabackup_info文件,这个文件是按照db1数据库备份的,一般db2和db1环境配置都会保持一致,所以我们可以直接进行恢复,如果db2中的目录与db1不一样,要注意修改xtrabackup_info文件。 #db2恢复前需要将db2库stop,然后移走数据目录备份 /etc/init.d/mysqld stop mv /data/mysql_data /data/mysql_data.bak #创建mysql的数据目录 mkdir /data/mysql_data -p #db2恢复开始执行(以下是恢复指令,这条指令会将db_all_backup中的解压后的数据,同步到我们的db数据目录) innobackupex  --defaults-file=/etc/my.cnf --copy-back --rsync /db_all_backup/ #上一步如果执行成功,就可以将数据目录改为mysql用户管理 chown -R mysql:mysql /data/mysql_data #启动db2数据库,就可以看到和db1一样的数据了 /etc/init.d/mysqld start

Innobackupex Physical BACKUP Database + recovery using Xtrabackup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.