Pt-kill is an excellent tool for connecting to killMySQL. it is part of perconatoolkit. when many idle connections cause the maximum number of connections to be exceeded and a problematic SQL statement causes high mysql load, all of them need to kill some connections. This tool is mainly because pt-kill is an excellent tool for kill MySQL connections and is part of percona toolkit, when the maximum number of connections is exceeded due to a large number of idle connections and a problematic SQL statement causes a high mysql load, you must kill some connections. This tool is mainly used for this purpose.
Parameters
-Busy-time
Running time
-Idle-time
Idle Time
-Victims
All matched connections should have the longest connection
-Interval
Interval. the default value is 30 s. It is a bit long and can be adjusted according to the actual situation.
-Print
Print the kill connection.
-Match-command
Match the current connection command
QuerySleepBinlog DumpConnectDelayed insertExecuteFetchInit DBKillPrepareProcesslistQuitReset stmtTable Dump–match-state
Match the current connection status
Lockedlogincopy to tmp tableCopying to tmp tableCopying to tmp table on diskCreating tmp tableexecutingReading from netSending dataSorting for orderSorting resultTable lockUpdating–match-info
Use a regular expression to match the correct SQL statement
–match-db –match-user –match-host
Mingzhiyi
Common usage
Kill idle links
pt-kill –match-command Sleep –idle-time 5 –host –port –interval –print –kill –victims all
Kill the link that has been running for more than 5s
pt-kill –match-command Query –busy-time 5 –host –port –interval –print –kill –victims all
Kill running SQL statements that match a rule.
pt-kill –match-command Query –busy-time 5 –host –port –interval –print –kill –victims all –match-info
Kill the SQL statement that is executing filesort
pt-kill –match-command Query –match-state “Sorting result” busy-time 5 –host –port –interval –print –kill –victims all
Kill the SQL statement that is being Copying to tmp table
pt-kill –match-command Query –match-state “Copying to tmp table” busy-time 5 –host –port –interval –print –kill –victims all
The above section uses pt-kill to kill the connection method _ MySQL based on certain rules. For more information, see PHP Chinese network (www.php1.cn )!