1. 获取需要的binlog 日志:
[root@zjzc01 binlog]# mysqlbinlog --start-datetime='2016-08-01 00:00:00' --stop-datetime='2016-08-11 12:00:00' mysql-bin.00006* >a.txt
2.获取对应行的记录 匹配 update ProductAccess
[root@zjzc01 binlog]# cat get_num.pl
open (A,"<","a.txt");
open (B,">","b.txt");
$a=$ARGV[0];
$b=$ARGV[1];
while (<A>) {
$num++;
if (( $_ =~/$as+$bs+/i ) or ($_ =~/$as+`zjzc`.`$b`s+/i) ) { $c = $num;print B ("$c
"); };
}
}
[root@zjzc01 binlog]# perl get_num.pl update ProductAccess
3.
[root@zjzc01 binlog]# cat sed.sh
cat b.txt | while read A
do
#num1=`expr $A - 5`
num1=`expr $A - 5`
num2=`expr $A + 5`
#num2=`expr $A + 30`
sed -n ''$num1','$num2'p' a.txt
done
取上下5行
4.
[root@zjzc01 binlog]# sh ./get_sql.sh update ProductAccess >aa.sql
[root@zjzc01 binlog]# cat aa.sql | grep 551 | grep ProductAccess
UPDATE `zjzc`.`ProductAccess` SET `yieldForFirst`='0.0120000000' WHERE `productSn`='551'
/****************
zjtest7-frontend:/root# cat a.txt
UPDATE `zjzc`.`ProductAccess` SET `yieldForFirst`='0.0120000000' WHERE `productSn`='551'
xyj
update `zjzc`.`ProduCtAccess` SET `yieldForFirst`='0.0120000000' WHERE `productSn`='551'
update ProduCtAccess set
update ProduCtAcCess set
zjtest7-frontend:/root# perl a1.pl update productaccess
zjtest7-frontend:/root# cat b.txt
1
3
4
5