使用pt-kill根據(jù)一定的規(guī)則來kill連接的方法
pt-kill 是一個優(yōu)秀的kill MySQL連接的一個工具,是percona toolkit的一部分,在因為空閑連接較多導(dǎo)致超過最大連接數(shù)、某個有問題的sql導(dǎo)致mysql負載很高時,都需要將一些連接kill掉,這個工具主要就是這個用途。
參數(shù)
–busy-time
運行時間
–idle-time
空閑時間
–victims
所有匹配的連接,對應(yīng)有最久的連接
–interval
間隔時間,默認30s,有點長,可以根據(jù)實際情況來調(diào)節(jié)
打印出來kill掉的連接
–match-command
匹配當前連接的命令
Query
Sleep
Binlog Dump
Connect
Delayed insert
Execute
Fetch
Init DB
Kill
Prepare
Processlist
Quit
Reset stmt
Table Dump
–match-state
匹配當前連接的狀態(tài)
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
殺掉匹配某個規(guī)則的正在運行的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
相關(guān)文章
Mysql5.7及以上版本 ONLY_FULL_GROUP_BY報錯的解決方法
這篇文章主要介紹了Mysql5.7及以上版本 ONLY_FULL_GROUP_BY報錯的解決方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03my.cnf參數(shù)配置實現(xiàn)InnoDB引擎性能優(yōu)化
目前來說:InnoDB是為Mysql處理巨大數(shù)據(jù)量時的最大性能設(shè)計。它的CPU效率可能是任何其它基于磁盤的關(guān)系數(shù)據(jù)庫引擎所不能匹敵的。在數(shù)據(jù)量大的網(wǎng)站或是應(yīng)用中Innodb是倍受青睞的。另一方面,在數(shù)據(jù)庫的復(fù)制操作中Innodb也是能保證master和slave數(shù)據(jù)一致有一定的作用。2017-05-05一次非法關(guān)機導(dǎo)致mysql數(shù)據(jù)表損壞的實例解決
本文介紹由于非法硬件關(guān)機,造成了mysql的數(shù)據(jù)表損壞,數(shù)據(jù)庫不能正常運行的一個實例,接下來是作者排查錯誤的過程,希望對大家能有所幫助2013-01-01mysql中int(3)和int(10)的數(shù)值范圍是否相同
依稀還記得有次面試,有面試官問我int(10)與int(11)有什么區(qū)別,當時覺得就是長度的區(qū)別吧,后來發(fā)現(xiàn)事情不是這么簡單,這篇文章主要給大家介紹了關(guān)于mysql中int(3)和int(10)的數(shù)值范圍是否相同的相關(guān)資料2021-10-10