mysql xtrabackup use backup tool

Tool description:
. 1, xtrabackup: hot backup for InnoDB, xtradb tool data in the table, the table can not be other types of backup can not backup data table structure;
2, innobackupex: perl script xtrabackup is encapsulated, there is provided myisam ability to back up the table.
3, xtrabackup 2.3 version starts innobackupex all integrated into xtrabackup, innobackupex has been abandoned.

1. Check and install Perl modules associated with
xtrabackup tool is written in Perl language and execution, so the system needs to have Perl environment.
Dependencies check command:
RPM -qa the DBI Perl-Perl-the DBD-Time-HiRes the MySQL Perl-Perl the IO-the Socket-the SSL-
if indeed dependencies can be installed using the following command:
yum -Y-Perl the install the DBI
yum the install the DBD-Perl--Y the MySQL
yum the install Perl-Time-HiRes
yum the install the IO-Perl-the Socket-the SSL


2、安装过程
Warning: Make sure that you have the libev package installed before installing Percona XtraBackup. The libev package is available from the EPEL repositories.

Download libev-4.03-3.el6.x86_64.rpm installation package from the http://rpmfind.net/linux/rpm2html/search.php, and then install it, as shown below


[root@oracle12c /]# rpm -ivh libev-4.03-3.el6.x86_64.rpm

[root@oracle12c /]# rpm -ivh mysql-community-libs-compat-5.7.19-1.el6.x86_64.rpm

[root@oracle12c /]# rpm -ivh perl-DBD-MySQL-4.022-1.el6.rfx.x86_64.rpm

[root@oracle12c /]# rpm -ivh percona-xtrabackup-80-8.0.6-1.el6.x86_64.rpm
检查安装
[root@oracle12c /]# rpm -qa |grep xtrabackup
percona-xtrabackup-80-8.0.6-1.el6.x86_64

 

3、备份过程:
全备:
xtrabackup --backup --password=123456 --target-dir=/mysql/backups/base/
增量:
xtrabackup --backup --password=123456 --target-dir=/mysql/backups/inc1 --incremental-basedir=/mysql/backups/base
xtrabackup --backup --password=123456 --target-dir=/mysql/backups/inc2 --incremental-basedir=/mysql/backups/inc1

4, the recovery process:

Prerequisite
1, the before Backup Needs to the Prepared BE IT CAN BE restored.
2, MySQL service datadir directory is empty.
3, mysql service stops running.
4, there binlog log time range need to recover.


Based on the point in time recovery, recovery to determine which incremental backup
CAT / path / to / Backup / xtrabackup_binlog_info
MySQL-bin.000003 57

数据增量恢复
xtrabackup --prepare --apply-log-only --target-dir=/mysql/backups/base
xtrabackup --prepare --apply-log-only --target-dir=/mysql/backups/base --incremental-dir=/mysql/backups/inc1
xtrabackup --prepare --apply-log-only --target-dir=/mysql/backups/base --incremental-dir=/mysql/backups/inc2

My.cnf recover data files to the specified DATADIR
xtrabackup --copy-Back---target the dir = / MySQL / Backups / Base
OR:
the rsync -avrP / MySQL / Backups / / MySQL / Data /

Modify permissions
chown -R mysql: mysql / mysql / data /

Start the database
service mysqld start

binlog log mining and recovering data
mysqlbinlog /path/to/datadir/mysql-bin.000003 /path/to/datadir/mysql-bin.000004 --start-position = 57 --stop-datetime = "11-12-25 01:00:00 "| mysql -u root -p

 

Guess you like

Origin www.cnblogs.com/JcLevy/p/11420111.html