pt-kill是一个优秀的kill MySQL连接的一个工具,是percona toolkit的一部分,在因为空闲连接较多导致超过最大连接数、某个有问题的sql导致mysql负载很高时,都需要将一些连接kill掉,这个工具主要就是这个用途。
运行时间
空闲时间
所有匹配的连接,对应有最久的连接
间隔时间,默认30s,有点长,可以根据实际情况来调节
打印出来kill掉的连接
匹配当前连接的命令
Query Sleep Binlog Dump Connect Delayed insert Execute Fetch Init DB Kill Prepare Processlist Quit Reset stmt Table Dump
匹配当前连接的状态
Locked login copy to tmp table Copying to tmp table Copying to tmp table on disk Creating tmp table executing Reading from net Sending data Sorting for order Sorting result Table lock Updating
使用正则表达式匹配符合的sql
见名知意
pt-kill –match-command Sleep –idle-time 5 –host –port –interval –print –kill –victims all
pt-kill –match-command Query –busy-time 5 –host –port –interval –print –kill –victims all
pt-kill –match-command Query –busy-time 5 –host –port –interval –print –kill –victims all –match-info
pt-kill –match-command Query –match-state “Sorting result” busy-time 5 –host –port –interval –print –kill –victims all
pt-kill –match-command Query –match-state “Copying to tmp table” busy-time 5 –host –port –interval –print –kill –victims all