Use pt-kill to kill the connection method based on certain rules _ MySQL

Source: Internet
Author: User
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 )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.