binlog2sql数据恢复

牛叉的工具有好几个,包括MyFlash、binlog2Sql、mysqlbinlog_flashback,还有一些收费的等等,各有优劣,具体使用可自行百度

1、安装binlog2sql

shell> git clone https://gitee.com/qweff/binlog2sql && cd binlog2sql
shell> pip install -r requirements.txt

git安装方法:https://www.cnblogs.com/cjh-notes/p/10354532.html

pip在系统7以上的都是自带的,6应该也有

2、设置MySql Server参数

配置文件默认路径一般是:/etc/my.cnf

或 find -name / my.cnf 看看在哪里

[mysqld]
server_id = 1
log_bin = /var/log/mysql/mysql-bin.log
max_binlog_size = 1G
binlog_format = row
binlog_row_image = full

3、测试恢复

这个官方已经写得很详细了,相当简单,https://github.com/danfengcao/binlog2sql

需要注意的一点就是,当需要回滚的是DROP操作的时候,执行解析时会发现出来的效果不是我们想要的

这是因为表删除后information_schema对应的元数据没有了,所以CRUD的语句解析不出来,我们只需要把表(包括表结构)重新建立就可以了。

附上常用命令:

//查看目前的
show master status;

//查看所有
show master logs;

官方项目GIT:https://github.com/danfengcao/binlog2sql

转载请注明博客出处:http://www.cnblogs.com/cjh-notes/

猜你喜欢

转载自www.cnblogs.com/cjh-notes/p/10354630.html