Application _innobackupex database backup and recovery

1.Percona Software; 2.innobackupex backup and recovery

A, Percona software

Before learning percona software, we look at the physical backup and backup mysqldump what defects.

Physical backup disadvantage: the cross-platform performance is poor, a long time backup, redundancy, waste of storage space;

Mysqldump backup disadvantages: low efficiency, slow backup and restore, but also the lock table; backup process, data inserted or updated can not be achieved.

Therefore, percona came into being.

1.percona Advantage software

  Enables online hot backup , the backup process does not lock the library , do not lock the table , more suitable for our actual production environment .

2.Percona software of two components

  Xtrabackup: C program , supports InnoDB / XtraDB 

  Innobackupex:  with Perl scripting package xtrabackup, also supports MyISAM.

3. Common Options

Two, innobackupex backup and recovery

Content Outline : 1. full backup and restore ; 2. Incremental backup and recovery ; 3. restore single table .

1. Data full backup and recovery

   Backup format: innobackupex --user  username  --password  password backup directory name  --no-timestamp

   Format recovery: i nnobackupex --apply-log  directory name  // ready to resume data

                  innobackupex --copy-bak  directory name   // restore data

                  innobackupex --copy-bak  directory name  // restore data

Example :

In 192.168.4.50 backup data , at 192.168.4.51 recover data .

Topology:

Host 192.168.4.50 backup data :

50]# innobackupex -uroot -p123qqq...A /root/allbak --no-timestamp    //备份

50] # scp -r / root / allbak  [email protected]: / root /     // upload backup data to the host 4.51

Host 192.168.4.51 recover data on :

51] #rpm -ivh libev-4.15 // mounting percona of dependencies

51]#yum -y install percona    //安装percona

51]#systemctl stop mysqld

51] #ls / var / lib / mysql // view the document content

51] #rm -rf / var / lib / mysql / * // empty the content of the document

51 is] #Innobackupex --apply-log / the root / allbak    // preparing to resume data

51] #Innobackupex --copy-back / root / allbak // restore data

51] #ls / var / lib / mysql // see if the data recovery

51] #ls / var / lib / mysql -l // view the file directory permissions belongs to root

51] #chown -R mysql: mysql / var / lib / mysql // modify directory permissions belongs mysql

51]#systemctl restart mysqld   

mysql -uroot -p123qqq ... A // enter mysql

mysql> show databases; select * from db3.user // View data recovery situation

2. Incremental backup and recovery of data

Backup format: innobackupex --user  username --password  password --incremental  incremental directories --incremental-basedir = directory name --no-timestamp

Resume format: innobackupex --apply-log --redo-only  directory name --incremental-dir = directory name

Example :

Host 192.168.4.50 on the backup the host 192.168.4.51 recovery on .

Topology:

Host 192.168.4.50 on the backup :

50] #innobackupex --user root --password 123qqq ... A / fullbak --no-timestamp // full backup data

50] #ls / fullbak / // Check the backup status

mysql> insert into db3.user2 values ( " tom"); // increase the data

mysql> insert into db3.user2 values ( " jack"); // increase the data

50] #innobackupex --user the root --password 123qqq ... A --incremental  / new1dir  --incremental-the basedir = / fullbak // incremental backup timestamp --no- 1 , stored in the directory / new1dir

50] #ls / new1dir // Check the backup folder

50] #innobackupex --user the root --password 123qqq ... A --incremental  / new new 2 the dir  --incremental-the basedir = / fullbak --no-incremental backup timestamp // 2 , stored in the directory / new2dir

50] #ls / new2dir // Check the backup folder

Host 192.168.4.51 recover data on :

51]#systemctl stop mysqld

51] Contents / * // at #rm -rf / var / lib / mysql empty directory

51] # innobackupex --apply-log --redo -only / root / fullbak / // restore the full backup and

51 is] #innobackupex --apply --redo-log-only / the root / fullbak / --incremental-the dir = / the root / new1dir // Restoration an incremental backup data

51] #rm -rf / root / new1dir / // After recovery is complete , clear the data, so as not to affect other

51 is] #innobackupex --apply --redo-log-only / the root / fullbak / --incremental-the dir = / the root / new2dir // Restoration 2 data incremental backups

51] After #rm -rf / root / new2dir / // recovery is complete , clear the data, so as not to affect other

51] #innobackupex --copy-back / root / fullbak / // copy the file to the database , to complete the data recovery

51] #chown -R mysql: mysql / var / lib / mysql // modify your permission to mysql

51]#systemctl restart mysqld

51]# mysql -uroot -p123qqq...A    

        mysql> show databases; select * from db3.user2; // access to the database to view the status of data recovery

3. single form of recovery

With db3 at the library user2 table, for example :

mysql> alter table db3.user2 discard tablespace; // Delete table space

#innobackupex --apply-log --export / allbak; ( after export / allbak / db3 / directory will be more than two files user2.cfg and use2.exp )      // export table information

# Cp -r /allbak/db3/user2.{cfg.exp,ibd} / var / lib / mysql / db3 /; // copy information file to the database catalog

#chown mysql: mysql /var/lib/mysql/db3/user2.* // ownership rights to modify the information file for mysql

mysql> alter table db3.user2 import tablespace; // Import tablespace

#rm -rf /var/lib/mysql/db3/user2.cfg // delete files in the database table information .cfg

#rm -rf /var/lib/mysql/db3/user2.exp // delete files in the database table information .exp

Mysql> select * from db3.user2; // Display Record

End.

 

Guess you like

Origin www.cnblogs.com/liusingbon/p/11028783.html