使用pt-kill根据一定的规则来kill连接的方法
pt-kill 是一个优秀的kill MySQL连接的一个工具,是percona toolkit的一部分,在因为空闲连接较多导致超过最大连接数、某个有问题的sql导致mysql负载很高时,都需要将一些连接kill掉,这个工具主要就是这个用途。
参数
–busy-time
运行时间
–idle-time
空闲时间
–victims
所有匹配的连接,对应有最久的连接
–interval
间隔时间,默认30s,有点长,可以根据实际情况来调节
打印出来kill掉的连接
–match-command
匹配当前连接的命令
Query
Sleep
Binlog Dump
Connect
Delayed insert
Execute
Fetch
Init DB
Kill
Prepare
Processlist
Quit
Reset stmt
Table Dump
–match-state
匹配当前连接的状态
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
–match-info
使用正则表达式匹配符合的sql
–match-db –match-user –match-host
见名知意
常用用法
杀掉空闲链接
pt-kill –match-command Sleep –idle-time 5 –host –port –interval –print –kill –victims all
杀掉运行时间超过5s的链接
pt-kill –match-command Query –busy-time 5 –host –port –interval –print –kill –victims all
杀掉匹配某个规则的正在运行的sql
pt-kill –match-command Query –busy-time 5 –host –port –interval –print –kill –victims all –match-info
杀掉正在进行filesort的sql
pt-kill –match-command Query –match-state “Sorting result” busy-time 5 –host –port –interval –print –kill –victims all
杀掉正在Copying to tmp table的sql
pt-kill –match-command Query –match-state “Copying to tmp table” busy-time 5 –host –port –interval –print –kill –victims all
编程语言
- ThinkPad 笔记本如何调节LCD屏幕亮度
- Dreamweaver制作网页打开特效教程
- Win10 Mobile 10586升级后无限重启怎么办 硬重启帮您
- Win8系统提示音频设备有问题有一个或多个音频服
- Xbox One版Win10首个预览版9月份发布
- 如何在textarea文本输入区内实现换行
- Win10 Build 9901系统更新 预览版新版本下载
- McAfee Framework存在远程格式串处理漏洞
- Win10家庭版今日(7月30)正式在中国官方商城开卖
- Win10 Mobile预览版更新完10536.1000后才收到10536.100
- Win10 RS2更新了什么-Win10 RS2最终版本号1704首曝
- Windows7如何查看回收站对应的文件夹有哪些方法
- Win10让Charms栏回归桌面的方法教程
- 取消Windows XP系统开机启动画面的小技巧
- win8系统怎么下载安装USB百兆网卡?
- XP系统下磁盘空间变少了怎么办?XP系统磁盘空间