[root@liuan tools]# dbslower mysql -p `pidof mysqld` -m 2
Tracing database queries for pids 3350 slower than 2 ms...
TIME(s) PID MS QUERY
1.765087 3350 2.996 UPDATE sbtest1 SET k=k+1 WHERE id=963
3.187147 3350 2.069 UPDATE sbtest1 SET k=k+1 WHERE id=628
5.945987 3350 2.171 UPDATE sbtest1 SET k=k+1 WHERE id=325
7.771761 3350 3.853 UPDATE sbtest1 SET k=k+1 WHERE id=595
5. 使用限制
bcc 基于 eBPF 开发(需要 Linux 3.15 及更高版本)。bcc 使用的大部分内容都需要 Linux 4.1 及更高版本。
“bcc.usdt.USDTException: failed to enable probe ‘query__start’; a possible cause can be that the probe requires a pid to enable” 需要 MySQL 具备 Dtrace tracepoint。
dbslower man page:https://github.com/iovisor/bcc/blob/master/man/man8/mysqld_qslower.8#L17-L18