pt-kill 是属于percona-toolkit中的一个工具,作用是kill mysql的连接,pt-kill连接mysql,通过show processlist获得查询.


参数:

--kill

#kill mysql的连接

--busy-time=m  

#匹配运行时间超过m的连接,可以指定时间单位,默认单位秒      

--match-command

#匹配当前连接的命令

--victims

#所有匹配的连接


#kill超过60s的连接:

[root@Darren1 ~]# pt-kill --user=root --password=147258 --host=localhost  --busy-time 60 --kill


#输出超过60s的连接:

[root@Darren1 ~]# pt-kill --user=root --password=147258 --host=localhost  --busy-time 60 --print 


#检查休眠进程,并每隔10skill:

[root@Darren1 ~]# pt-kill --user=root --password=147258 --host=localhost  --match-command sleep --kill --victims all --interval 10


#打印所有登陆信息:

[root@Darren1 ~]# pt-kill --user=root --password=147258 --host=localhost  --match-command login --print --victims all             

#指定文件

[root@Darren1 tmp]# mysql -uroot -p147258 -e "show processlist" > processlist.txt

[root@Darren1 ~]# pt-kill --user=root --password=147258 --host=localhost --test-matching /tmp/processlist.txt --busy-time 60 --print