[root@mysql tools]# wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.4/binary/redhat/6/x86_64/percona-xtrabackup-24-2.4.4-1.el6.x86_64.rpm
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-MySQL
yum install -y percona-xtrabackup-24-2.4.4-1.el6.x86_64.rpm
yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-MySQL
yum install -y percona-xtrabackup-24-2.4.4-1.el6.x86_64.rpm
全量备份:
[root@mysql test]# innobackupex --user=root --password=oldboy /data/backup/full --slave-info --safe-slave-backup --parallel=4 --safe-slave-backup-timeout=7200 --socket=/data/3306/mysql.sock
指定文件目录增量备份:
[root@mysql ~]# innobackupex --user=root --password=oldboy --incremental --incremental-basedir=/data/backup/full/2016-09-04_14-33-56 /data/backup/inc --slave-info --safe-slave-backup --parallel=4 --safe-slave-backup-timeout=7200 --socket=/data/3306/mysql.sock
指定POS位置的增量备份:
[root@mysql data]# innobackupex --user=root --password=oldboy --incremental --incremental-lsn=1615344 /data/backup/inc --slave-info --safe-slave-backup --parallel=4 --safe-slave-backup-timeout=7200 --socket=/data/3306/mysql.sock
查看参数配置
show variables like "log_bin";
show variables like "%binlog_format%";
set global binlog_format='row';
show variables like "%binlog_format%";
set global binlog_format='row';
将以下参数加入my.cnf内
binlog_format = 'ROW'
binlog_format = 'ROW'
重启3306实例
innobackupex --user=root --password=oldboy --apply-log --redo-only /data/backup/full/2016-09-04_14-33-56 --socket=/data/3306/mysql.sock
innobackupex --user=root --password=oldboy --apply-log --redo-only /data/backup/full/2016-09-04_14-33-56 --incremental-dir=/data/backup/inc/2016-09-04_15-03-48 --socket=/data/3306/mysql.sock
innobackupex --user=root --password=oldboy --apply-log --redo-only /data/backup/full/2016-09-04_14-33-56 --incremental-dir=/data/backup/inc/2016-09-04_15-03-48 --socket=/data/3306/mysql.sock
innobackupex --user=root --password=oldboy --apply-log --redo-only /data/backup/full/2016-09-04_14-33-56 --incremental-dir=/data/backup/inc/2016-09-04_15-30-32 --socket=/data/3306/mysql.sock
innobackupex --user=root --password=oldboy --apply-log --redo-only /data/backup/full/2016-09-04_14-33-56 --incremental-dir=/data/backup/inc/2016-09-04_15-56-37 --socket=/data/3306/mysql.sock
innobackupex --user=root --password=oldboy --apply-log /data/backup/full/2016-09-04_14-33-56 --socket=/data/3306/mysql.sock
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2016-09-04 16:05:30 |
+---------------------+
1 row in set (0.00 sec)
327 545
mysqlbinlog --start-position=327 --stop-position=1048 mysql-bin.000268 |mysql -uroot -p -S /data/3306/mysql.sock
[root@db01 3306]# iptables -I INPUT -s 172.16.1.0/24 -p tcp --dport 3306 -j DROP
[root@db01 3306]# iptables -D INPUT -s 172.16.1.0/24 -p tcp --dport 3306 -j DROP
[root@db01 3306]# mysqlbinlog mysql-bin.000001 --start-position=4 --stop-position=1470|grep trunc
[root@db01 3306]# mysqlbinlog mysql-bin.000001 --start-position=1471 --stop-position=1472|grep trunc
truncate table backupstep
[root@db01 3306]# mysqlbinlog mysql-bin.000001 --start-position=1471 --stop-position=1472|grep trunc
truncate table backupstep