perl 分析mysql binlog

时间:2022-11-27 15:33:52
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 $_;
};
};