1. 确定内容更新时间节点

抽查 uuid: 25a896451efdc7de5b60df4b4294c1d8 的文章,查询文章在topic表入库时间(2019-03-07 17:56:04),最后更新时间(2019-03-29 14:07:05)
确定相关时间节点binlog文件:
image.png
image.png

2.检查起始状态值

查询入库时效性状态:

  1. /usr/bin/mysqlbinlog --no-defaults --base64-output=decode-rows -v mysql-bin.000157|grep '25a896451efdc7de5b60df4b4294c1d8' -C 20 |grep 'topic' -A 70

显示时效性为 1, user_id 为 null
image.png
image.png

3.查询文章最终更改记录

  1. /usr/bin/mysqlbinlog --no-defaults --base64-output=decode-rows -v mysql-bin.000258|grep '25a896451efdc7de5b60df4b4294c1d8' -C 20 |grep 'UPDATE `artdb`.`topic`' -A 70

显示时效性为0,文章下架,user_id : revertTimeSens0321
可知之前已有sql 将时效性变为 0, 操作用户 revertTimeSens0321
image.png
image.png

4. 批量查询中间状态

通过通配符批量查询157 - 268 之间相关binlog 日志:

  1. /usr/bin/mysqlbinlog --no-defaults --base64-output=decode-rows -v /usr/bin/mysqlbinlog --no-defaults --base64-output=decode-rows -v mysql-bin.00025*|grep '25a896451efdc7de5b60df4b4294c1d8' -C 20 |grep 'UPDATE `artdb`.`topic`' -A 2

定位到 mysql-bin.00023* 文件,从后往前找,定位到mysql-bin.000239 文件

5. 定位相关语句

  1. /usr/bin/mysqlbinlog --no-defaults --base64-output=decode-rows -v /usr/bin/mysqlbinlog --no-defaults --base64-output=decode-rows -v mysql-bin.000239|grep '25a896451efdc7de5b60df4b4294c1d8' -C 20 |grep 'UPDATE `artdb`.`topic`' -A 70

用户revertTimeSens0321 的 更新时效性的sql语句 如下:
将时效性由 1 改为 0
image.png
image.png