一.安装MyFlash
1.安装条件
binlog_f
ORMat=ROW
binlog_row_image=FULL
仅支持5.6与5.7,并且只能回滚DML
2.安装
unzip MyFlash.zip
yum -y install glib2*
cd /data/MyFlash/MyFlash-master
GCc -w `pkg-config --cflags --libs glib-2.0` source/binlogParseGlib.c -o binary/flashback
*没有报错,证明安装成功
二.恢复场景
1.回滚整个文件
./flashback --binlogFileNames=haha.000041
Mysqlbinlog binlog_output_base.flashback |
mysql -h -u -p
2.回滚某个表的DML语句
-删除数据
my
sql> show tables;
+---------------+
| Tables_in_wwj |
+---------------+
| t1 |
+---------------+
1 row in set (0.00 sec)
mysql> select * from t1;
+----+------+
| id | name |
+----+------+
| 5 | haha |
| 6 | mxt3 |
| 7 | mxt4 |
+----+------+
3 rows in set (0.00 sec)
mysql> delete from t1;
Query OK, 3 rows affected (0.02 sec)
mysql> select * from t1;
Empty set (0.00 sec)
-生成恢复文件(回滚t1表的delete操作)
cd /data/MyFlash/MyFlash-master/binary
# ./flashback --databaseNames='wwj' --tableNames='t1' --sqlTypes='DELETE' --binlogFileNames=/home/mysql3307/mysql3307/mysql-bin.000001
-查看文件
# /usr/local/mysql/bin/mysqlbinlog -vv binlog_output_base.flashback
-恢复
# /usr/local/mysql/bin/mysqlbinlog binlog_output_base.flashback|/usr/local/mysql/bin/mysql -S /tmp/mysql3307.sock -p
恢复完成
mysql> select * from t1;
+----+------+
| id | name |
+----+------+
| 5 | haha |
| 6 | mxt3 |
| 7 | mxt4 |
+----+------+
3 rows in set (0.00 sec)
0