第26章 SQL语句执行慢真假难辨 - xiaoboluo768/qianjinliangfang GitHub Wiki

26.3.1 采集应用服务器数据包

[root@localhost~]# tcpdump -s 0 -w /tmp/client_3306.pcap --host 10.10.30.161\ 
and port 3306

[root@localhost ~]# mysql -uqbench -pqbench -h10.10.30.161
……
mysql> show processlist;
......
1 row in set (0.01 sec)

mysql> quit
Bye

26.3.2 采集数据库服务器数据包

[root@localhost ~]# tcpdump -s 0 -w /tmp/server_3306.pcap --host 10.10.30.165 \
and port 3306

26.4.2 使用tcpdump解析数据包

  • 1.采集MySQL数据包
[root@localhost ~]# tcpdump -s 65535 -xx -XX -nn -q -tttt host 10.10.30.165 and port\ 3306 >/tmp/server_3306.txt

[root@localhost ~]# cat /tmp/server_3306.txt
......
  • 2.解析MySQL数据包
[root@localhost ~]# pt-query-digest --type tcpdump /tmp/server_3306.txt
......

上一篇:第21章 SQL优化 | 下一篇:第27章 如何避免三天两头换硬盘、内存、主板