xtrabackup

Posted chinaops

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xtrabackup相关的知识,希望对你有一定的参考价值。

1.记录备份开始时,InnoDB存储引擎重做日志文件检查点的LSN

2.复制共享表空间文件以及独立共享表空间文件。

3.记录复制完表空间文件后,InnoDB存储引擎重做日志文件检查点的LSN。

4.复制在备份时产生的重做日志。

优点:

1.在线备份,不阻塞任何的SQL语句。

2.备份性能好,备份的实质是复制数据库文件和重做日志文件。

3.支持压缩备份,通过选项,可以支持不同级别的压缩。

下载地址:

https://www.percona.com/downloads/XtraBackup/LATEST/

[[email protected] bin]# ./xtrabackup --version
xtrabackup: recognized server arguments:
./xtrabackup version 2.4.12 based on mysql server 5.7.19 Linux (x86_64) (revision id: 170eb8c)
[[email protected] bin]# ./xtrabackup --backup -S /tmp/mysql3306.sock  -uroot -p 完全备份

xtrabackup: recognized server arguments:
xtrabackup: recognized client arguments: --backup=1 --socket=/tmp/mysql3306.sock --user=root --password
Enter password:
180708 21:30:53  version_check Connecting to MySQL server with DSN ‘dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/tmp/mysql3306.sock‘ as ‘root‘  (using password: YES).
180708 21:30:53  version_check Connected to MySQL server
180708 21:30:53  version_check Executing a version check against the server...
180708 21:30:53  version_check Done.
180708 21:30:53 Connecting to MySQL server host: localhost, user: root, password: set, port: not set, socket: /tmp/mysql3306.sock
Using server version 5.7.22-log
./xtrabackup version 2.4.12 based on MySQL server 5.7.19 Linux (x86_64) (revision id: 170eb8c)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /data/mysql/mysql3306/data/
xtrabackup: open files limit requested 0, set to 1024
xtrabackup: using the following InnoDB configuration:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:100M:autoextend
xtrabackup:   innodb_log_group_home_dir = ./
xtrabackup:   innodb_log_files_in_group = 3
xtrabackup:   innodb_log_file_size = 104857600
InnoDB: Number of pools: 1
180708 21:30:53 >> log scanned up to (3466946626)
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 62 for mysql/time_zone_transition, old maximum was 0
180708 21:30:54 [01] Copying ./ibdata1 to /data/soft/percona-xtrabackup-2.4.12-Linux-x86_64/bin/xtrabackup_backupfiles/ibdata1
180708 21:30:54 >> log scanned up to (3466946626) 记录了重做日志的位置,然后对备份的InnoDB存储引擎表的物理文件,即共享表空间和独立表空间进行copy操作
180708 21:30:55 >> log scanned up to (3466946626)
180708 21:30:56 >> log scanned up to (3466946626)
180708 21:30:57 >> log scanned up to (3466946626)
180708 21:30:59 >> log scanned up to (3466946626)
180708 21:31:00 >> log scanned up to (3466946626)

。。。。。。。。。。。。。。。。。。。。。。。。。

180708 21:35:13 [01] Copying ./cacti/version.frm to /data/backup/cacti/version.frm 180708 21:35:13 [01]        ...done

180708 21:35:13 [01] Copying ./cacti/version.MYI to /data/backup/cacti/version.MYI 180708 21:35:13 [01]        ...done

180708 21:35:13 [01] Copying ./cacti/version.MYD to /data/backup/cacti/version.MYD 180708 21:35:13 [01]        ...done

180708 21:35:13 Finished backing up non-InnoDB tables and files 180708 21:35:13 [00] Writing /data/backup/xtrabackup_binlog_info

180708 21:35:13 [00]        ...done

180708 21:35:13 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS... xtrabackup: The latest check point (for incremental): ‘3466946617‘ xtrabackup: Stopping log copying thread. .

180708 21:35:13 >> log scanned up to (3466946626)

180708 21:35:13 Executing UNLOCK TABLES

180708 21:35:13 All tables unlocked

180708 21:35:13 [00] Copying ib_buffer_pool to /data/backup/ib_buffer_pool

180708 21:35:13 [00]        ...done

180708 21:35:13 Backup created in directory ‘/data/backup/‘ MySQL binlog position: filename ‘mysql-bin.000059‘, position ‘408474790‘, GTID of the last change ‘7f308b50-7701-11e8-8ee3-000c2923f3c9:1-31190‘ 180708 21:35:13 [00] Writing /data/backup/backup-my.cnf 180708 21:35:13 [00]        ...done

180708 21:35:13 [00] Writing /data/backup/xtrabackup_info 180708 21:35:13 [00]        ...done xtrabackup: Transaction log of lsn (3466946617) to (3466946626) was copied. 180708 21:35:13 completed OK!

 

=========================================增量备份=========================================================================

(1)完全备份,指定备份目录:

[[email protected] bin]# ./xtrabackup --backup -S /tmp/mysql3306.sock  -uroot -p --target-dir=/data/backup

(2)增量备份:

[[email protected] bin]# ./xtrabackup --backup -S /tmp/mysql3306.sock  -uroot -p --target-dir=/data/backup/1 --incremental-basedir=/data/backup

180708 21:38:21 [01] Copying ./cacti/version.frm to /data/backup/1/cacti/version.frm 180708 21:38:21 [01]        ...done

180708 21:38:21 [01] Copying ./cacti/version.MYI to /data/backup/1/cacti/version.MYI 180708 21:38:21 [01]        ...done

180708 21:38:21 [01] Copying ./cacti/version.MYD to /data/backup/1/cacti/version.MYD 180708 21:38:21 [01]        ...done

180708 21:38:21 Finished backing up non-InnoDB tables and files 180708 21:38:21 [00] Writing /data/backup/1/xtrabackup_binlog_info

180708 21:38:21 [00]        ...done 180708 21:38:21 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS... xtrabackup: The latest check point (for incremental): ‘3466946617‘ xtrabackup: Stopping log copying thread. .180708 21:38:21 >> log scanned up to (3466946626)

180708 21:38:21 Executing UNLOCK TABLES

180708 21:38:21 All tables unlocked

180708 21:38:21 [00] Copying ib_buffer_pool to /data/backup/1/ib_buffer_pool

180708 21:38:21 [00]        ...done

180708 21:38:21 Backup created in directory ‘/data/backup/1/‘ MySQL binlog position: filename ‘mysql-bin.000059‘, position ‘408474790‘, GTID of the last change ‘7f308b50-7701-11e8-8ee3-000c2923f3c9:1-31190‘ 180708 21:38:21 [00] Writing /data/backup/1/backup-my.cnf 180708 21:38:21 [00]        ...done

180708 21:38:21 [00] Writing /data/backup/1/xtrabackup_info

180708 21:38:21 [00]        ...done xtrabackup: Transaction log of lsn (3466946617) to (3466946626) was copied.

(3)prepare

[[email protected] bin]# ./xtrabackup --backup -S /tmp/mysql3306.sock  -uroot -p --prepare --target-dir=/data/backup/1

(4)apply incremental backup:

[[email protected] bin]# ./xtrabackup --backup -S /tmp/mysql3306.sock  -uroot -p --prepare  --target-dir=/data/backup/1 --incremental-basedir=/data/backup

 

































以上是关于xtrabackup的主要内容,如果未能解决你的问题,请参考以下文章