MySQL-使用tcpdump排查MySQLl数据库tps飙升的问题

可以直接输出

tcpdump -i eth1 -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
    if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL)/i)
    {
        if (defined $q) { print "$q
"; }
        $q=$_;
    } else {
        $_ =~ s/^[ 	]+//; $q.=" $_";
    }
}'

也可以保存到文件,使用grep、awk等分析

#执行一分钟
tcpdump -i eth0 -A -s 3000 port 3306 > ~/sql.log

#上步结束后分析
grep 'update' ./sql.log | head
原文地址:https://www.cnblogs.com/JohnABC/p/5944592.html