if ( $#ARGV < 2 ){
print "please input like binglog-0001 '2013-07-01 00:00:00' '2013-07-02 00:00:00'!\n";
exit(-1);
}
$file= $ARGV[0];
$start_dt = $ARGV[1];
$end_dt = $ARGV[2];
@bin=`mysqlbinlog --start-datetime='$start_dt' --stop-datetime='$end_dt' $file`;
foreach (@bin){
$_ =~ s/`//g;
#\s+匹配一个或者多个空格
if ($_ =~/^update\s+(.*?)\s+/i)
{#print "\$1 is $1\n";
$act='update';
$table=$1;
$var=$act.-$table;
$hash1{$var}++;
}
if ($_ =~/^delete\s+from\s+(.*?)\s+/i)
{#print "\$1 is $1\n";
$act='delete';
$table=$1;
$var=$act.-$table;
$hash2{$var}++;
}
if ($
perl 分析binlog
最新推荐文章于 2017-01-16 17:42:15 发布