perl 分析mysql binlog

binlog 日志格式:

use `zjzc`/*!*/;
SET TIMESTAMP=1476326343/*!*/;
UPDATE `ProductAccess` pa SET pa.accessType =1 WHERE pa.productSn IN( SET TIMESTAMP=1476326807/*!*/;
update ClientActionTrack set SET TIMESTAMP=1476327571/*!*/;
UPDATE `zjzc`.`scan` SET `sn`='200' WHERE `sn`='100' [root@zjzc01 binlog]# cat binlog.pl
if ( $#ARGV < 2 ){
print "please input file update|insert table_namee!\n";
exit(-1); };
my $a=$ARGV[0];
my $b=$ARGV[1];
my $c=$ARGV[2];
local $/='/*!*/;';
open (A,"<","$a");
while (<A>){
if (( $_ =~/$b\s+$c/i ) or ($_ =~/$b\s+`$c`/i) ){
print $_;
};
}; [root@zjzc01 binlog]# perl binlog.pl aa UPDATE scan
[root@zjzc01 binlog]#
[root@zjzc01 binlog]# /*!*/;[root@zjzc01 binlog]# cat binlog.pl
if ( $#ARGV < 2 ){
print "please input file update|insert table_namee!\n";
exit(-1); };
my $a=$ARGV[0];
my $b=$ARGV[1];
my $c=$ARGV[2];
local $/='/*!*/;';
open (A,"<","$a");
while (<A>){
if (( $_ =~/$b\s+$c/i ) or ($_ =~/$b\s+`$c`/i) or ($_ =~/$b\s+`zjzc`.`$c`/i) ){
print $_;
};
}; [root@zjzc01 binlog]# perl binlog.pl aa UPDATE scan UPDATE `zjzc`.`scan` SET `sn`='200' WHERE `sn`='100' [root@zjzc01 binlog]# perl binlog.pl aa UPDATE scan UPDATE `zjzc`.`scan` SET `sn`='200' WHERE `sn`='100'
/*!*/;
UPDATE `scan` SET `sn`='300' WHERE `sn`='200' [root@zjzc01 binlog]# perl binlog.pl aa UPDATE scan UPDATE `zjzc`.`scan` SET `sn`='200' WHERE `sn`='100'
/*!*/;
UPDATE `scan` SET `sn`='300' WHERE `sn`='200'
/*!*/;
UPDATE scan SET `sn`='400' WHERE `sn`='300' /*!*/;[root@zjzc01 binlog]# cat binlog.pl
if ( $#ARGV < 2 ){
print "please input file update|insert table_namee!\n";
exit(-1); };
my $a=$ARGV[0];
my $b=$ARGV[1];
my $c=$ARGV[2];
local $/='/*!*/;';
open (A,"<","$a");
while (<A>){
if (( $_ =~/$b\s+$c/i ) or ($_ =~/$b\s+`$c`/i) or ($_ =~/$b\s+`zjzc`.`$c`/i) or ($_ =~/$b\s+zjzc.$c/i )){
print $_;
};
}; [root@zjzc01 binlog]# perl binlog.pl aa UPDATE scan UPDATE `zjzc`.`scan` SET `sn`='200' WHERE `sn`='100'
/*!*/;
UPDATE `scan` SET `sn`='300' WHERE `sn`='200'
/*!*/;
UPDATE scan SET `sn`='400' WHERE `sn`='300'
/*!*/;
UPDATE zjzc.scan SET `sn`='500' WHERE `sn`='400' /*!*/;[root@zjzc01 binlog]# cat binlog.pl
if ( $#ARGV < 2 ){
print "please input file update|insert table_namee!\n";
exit(-1); };
my $a=$ARGV[0];
my $b=$ARGV[1];
my $c=$ARGV[2];
local $/='/*!*/;';
open (A,"<","$a");
while (<A>){
if (( $_ =~/$b\s+$c/i ) or ($_ =~/$b\s+`$c`/i) or ($_ =~/$b\s+`zjzc`.`$c`/i) or ($_ =~/$b\s+zjzc.$c/i )){
print $_;
};
};
上一篇:Linux 安装Xampp以后,Apache服务器无法启动,以及启动后,连接sql数据库遇到的问题的解决方法


下一篇:设置MySQL数据表主键