xtrabackupインクリメンタルバックアップとリカバリテスト

53572 ワード

テストバージョン:xtrabackup version 2.2.3 based on MySQL server 5.6.17 Linux(x 86_64)(revision id:)
xtrabackupインクリメンタルバックアップとリカバリテスト
一、増分バックアップの作成
1、全備を作成する

   
   
   
   
  1. innobackupex --defaults-file=/opt/mariadb-10.0.12-linux-x86_64/my.cnf --user=backup --password=backup@123 /data/backup/physical/full/

2、新しいデータベースとテーブルの作成

    
    
    
    
  1. root@[test] 11:49:19>create database test2 default charset utf8; 
  2. Query OK, 1 row affected (0.00 sec)
  3. root@[test] 11:49:24>use test
  4. Database changed
  5. root@[test] 11:49:36>create table t6 (id int,name varchar(4));
  6. Query OK, 0 rows affected (0.01 sec)

3、 1

    
    
    
    
  1. innobackupex --defaults-file=/opt/mariadb-10.0.12-linux-x86_64/my.cnf --user=backup --password=backup@123 --incremental /data/backup/physical/inc/ --incremental-basedir=/data/backup/physical/full/2014-08-10_11-47-14/

4、

    
    
    
    
  1. root@[test] 11:49:54>alter table t5 add column (b2 int);
  2. Query OK, 1 row affected (0.01 sec)
  3. Records: 1  Duplicates: 0  Warnings: 0
  4. root@[test] 11:53:08>alter table t6 drop column name;
  5. Query OK, 0 rows affected (0.00 sec)
  6. Records: 0  Duplicates: 0  Warnings: 0

5、 2

    
    
    
    
  1. innobackupex --defaults-file=/opt/mariadb-10.0.12-linux-x86_64/my.cnf --user=backup --password=backup@123 --incremental /data/backup/physical/inc/ --incremental-basedir=/data/backup/physical/inc/2014-08-10_11-51-50/

6、

    
    
    
    
  1. root@[test] 11:55:44>insert into t6 values (1),(2);
  2. Query OK, 2 rows affected (0.00 sec)
  3. Records: 2  Duplicates: 0  Warnings: 0
  4. root@[test] 11:55:50>select * from t5;
  5. +------+------+------+
  6. | id   | b1   | b2   |
  7. +------+------+------+
  8. |    1 |    1 | NULL |
  9. +------+------+------+
  10. 1 row in set (0.00 sec)
  11. root@[test] 11:56:03>insert into t5 values (2,2,2),(3,3,3);
  12. Query OK, 2 rows affected (0.00 sec)
  13. Records: 2  Duplicates: 0  Warnings: 0
  14. root@[test] 11:56:17>select * from t5;                     
  15. +------+------+------+
  16. | id   | b1   | b2   |
  17. +------+------+------+
  18. |    1 |    1 | NULL |
  19. |    2 |    2 |    2 |
  20. |    3 |    3 |    3 |
  21. +------+------+------+
  22. 3 rows in set (0.00 sec)

7、 3

    
    
    
    
  1. innobackupex --defaults-file=/opt/mariadb-10.0.12-linux-x86_64/my.cnf --user=backup --password=backup@123 --incremental /data/backup/physical/inc/ --incremental-basedir=/data/backup/physical/inc/2014-08-10_11-54-06/

1、 test2, t6, t5 , , 3

    
    
    
    
  1. root@[test] 12:02:11>drop database test2; 
  2. root@[test] 12:02:33>drop table t6;
  3. Query OK, 0 rows affected (0.00 sec)
  4. root@[test] 12:02:41>show tables;  
  5. +----------------+
  6. | Tables_in_test |
  7. +----------------+
  8. | sbtest1        |
  9. | t1             |
  10. | t2             |
  11. | t3             |
  12. | t4             |
  13. | t5             |
  14. +----------------+
  15. 6 rows in set (0.00 sec)
  16. root@[test] 12:02:45>delete from t5 where id=2 or id =3;
  17. Query OK, 2 rows affected (0.00 sec)
  18. root@[test] 12:03:02>select * from t5;
  19. +------+------+------+
  20. | id   | b1   | b2   |
  21. +------+------+------+
  22. |    1 |    1 | NULL |
  23. +------+------+------+
  24. 1 row in set (0.00 sec)

2、

    
    
    
    
  1. innobackupex --apply-log -redo-only /data/backup/physical/full/2014-08-10_11-47-14/

1, :

    
    
    
    
  1. innobackupex --apply-log -redo-only /data/backup/physical/full/2014-08-10_11-47-14/ --incremental-dir=/data/backup/physical/inc/2014-08-10_11-51-50/

2, :

    
    
    
    
  1. innobackupex --apply-log -redo-only /data/backup/physical/full/2014-08-10_11-47-14/ --incremental-dir=/data/backup/physical/inc/2014-08-10_11-54-06/

3, , --redo-only:

    
    
    
    
  1. innobackupex --apply-log /data/backup/physical/full/2014-08-10_11-47-14/ --incremental-dir=/data/backup/physical/inc/2014-08-10_11-56-44/


    
    
    
    
  1. innobackupex --apply-log /data/backup/physical/full/2014-08-10_11-47-14/

xtrabackup mysql , : xtrabackup version 2.2.3 based on MySQL server 5.6.17 Linux (x86_64) (revision id: ) mysql 5.5.38
2014-08-10 12:10:37 7f00603a8700 InnoDB: Error: page 7561 log sequence number 2875887409
InnoDB: is in the future! Current system log sequence number 2395543093.
InnoDB: Your database may be corrupt or you may have copied the InnoDB
InnoDB: tablespace but not the InnoDB log files. See
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/forcing-innodb-recovery.html
InnoDB: for more information.

3、 ( ), ,

    
    
    
    
  1. rm -rf /data/mysql55/*
  2. innobackupex --defaults-file=/opt/mariadb-10.0.12-linux-x86_64/my.cnf --copy-back /data/backup/physical/full/2014-08-10_11-47-14/
  3. cd /data/mysql55/
  4. chown mysql.mysql -R *
  5. chmod 770 -R *

4、

    
    
    
    
  1. root@[(none)] 12:16:14>show databases;
  2. +--------------------+
  3. | Database           |
  4. +--------------------+
  5. | information_schema |
  6. | employees          |
  7. | mysql              |
  8. | percona            |
  9. | performance_schema |
  10. | sakila             |
  11. | test               |
  12. | test2              |
  13. +--------------------+
  14. 8 rows in set (0.00 sec)
  15. root@[(none)] 12:16:18>use test 
  16. Database changed
  17. root@[test] 12:16:50>select * from t5;
  18. +------+------+------+
  19. | id   | b1   | b2   |
  20. +------+------+------+
  21. |    1 |    1 | NULL |
  22. |    2 |    2 |    2 |
  23. |    3 |    3 |    3 |
  24. +------+------+------+
  25. 3 rows in set (0.01 sec)
  26. root@[test] 12:16:59>select * from t6;
  27. +------+
  28. | id   |
  29. +------+
  30. |    1 |
  31. |    2 |
  32. +------+
  33. 2 rows in set (0.02 sec)

2 , --redo-only, 3 , : , 3

     
     
     
     
  1. innobackupex --apply-log -redo-only /data/backup/physical/full/2014-08-10_14-25-17/
  2. innobackupex --apply-log -redo-only /data/backup/physical/full/2014-08-10_14-25-17/ --incremental-dir=/data/backup/physical/inc/2014-08-10_14-30-19/
  3. # 2 --redo-only ,
  4. innobackupex --apply-log /data/backup/physical/full/2014-08-10_14-25-17/ --incremental-dir=/data/backup/physical/inc/2014-08-10_14-31-21/
  5. innobackupex --apply-log /data/backup/physical/full/2014-08-10_14-25-17/
  6. # 3 , , lsn
  7. innobackupex --apply-log /data/backup/physical/full/2014-08-10_14-25-17/ --incremental-dir=/data/backup/physical/inc/2014-08-10_14-32-19/
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013.  All Rights Reserved.

This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p

IMPORTANT: Please check that the apply-log run completes successfully.
           At the end of a successful apply-log run innobackupex
           prints "completed OK!".



140810 14:46:21  innobackupex: Starting ibbackup with command: xtrabackup  --defaults-file="/data/backup/physical/full/2014-08-10_14-25-17/backup-my.cnf"  --defaults-group="mysqld" --prepare --target-dir=/data/backup/physical/full/2014-08-10_14-25-17 --incremental-dir=/data/backup/physical/inc/2014-08-10_14-32-19/ --tmpdir=/tmp

xtrabackup version 2.2.3 based on MySQL server 5.6.17 Linux (x86_64) (revision id: )
incremental backup from 2875985858 is enabled.
xtrabackup: cd to /data/backup/physical/full/2014-08-10_14-25-17
xtrabackup: This target seems to be already prepared.
xtrabackup: error: This incremental backup seems not to be proper for the target.
xtrabackup:  Check 'to_lsn' of the target and 'from_lsn' of the incremental.
innobackupex: Error: 
innobackupex: ibbackup failed at /usr/bin/innobackupex line 2610.



1、 , master , slave , master , ,slave master , slave ;
2、 xtrabackup mysql ( xtrabackup), , --ibbackup=IBBACKUP-BINARY xtrabackup ;
3、 , , , , ;
4、 --redo-only , ;
5、 , 。

1、 http://www.percona.com/doc/percona-xtrabackup/2.2/innobackupex/incremental_backups_innobackupex.html




(Wiz)