Pt-kill common Kill process parameter introduction _mysql

Source: Internet
Author: User

Pt-kill is a good kill MySQL connection tool, is a part of Percona Toolkit, in the due to more idle connections cause more than the maximum number of connections, a problem of SQL causes MySQL load is high, you need to kill some connections, This tool is mainly used for this purpose.

1. Kill by user
/usr/bin/pt-kill--busy-time--match-user= "dbUSER1 | DbUSER2,... "--victim all--interval 1--kill--daemonize--pid=/tmp/ptkill.pid--print--log=/home/pt-kill.log
Note: Test by user to kill the thread, pay attention to--match-user between multiple users with | Separated.


2. Press query source host kill
/usr/bin/pt-kill--busy-time--match-host= "192.168.10.10 | 192.168.10.11 "--victim all--interval 1--kill--daemonize--pid=/tmp/ptkill.pid--print--log=/home/pt-kill.log
--ignore-host/--match-host

Note: Test by the source host to kill the thread, note--match-host between multiple host with | Separated.


3. Press Command Kill
/usr/bin/pt-kill--busy-time--match-command= "Query | Execute "--victim all--interval 1--kill--daemonize--pid=/tmp/ptkill.pid--print--log=/home/pt-kill.log
/usr/bin/pt-kill--busy-time--ignore-command= "Sleep | Binlogdump "--victim all--interval 1--kill--daemonize--pid=/tmp/ptkill.pid--print--log=/home/pt-kill.log

Note: Test by pressing command to kill the thread, note that the command must be strictly match the contents of the case, otherwise it will not kill. Note--match-command multiple command with | Separate, otherwise it will fail.
(Command: Query, sleep, Binlog Dump, Connect, delayed Insert, Execute, Fetch, Init DB, Kill, Prepare, Processlist, Quit, Reset stmt, Table Dump)


4. Kill by State
/usr/bin/pt-kill--busy-time--match-state= "Locked | Sending data "--victim all--interval 1--kill--daemonize--pid=/tmp/ptkill.pid--print--log=/home/pt-kill.log
Note: Test by state to kill the thread, note that the contents of the State must be strictly match the case, otherwise it will not kill. Note--match-state multiple state with | Separate, otherwise it will fail.
(State types are: Locked, login, copy to TMP table, copying to TMP table, copying to TMP table on disk, creating TMP table, executing, Re Ading from net, sending data, sorting for order, sorting result, Table lock, updating)


5. Click the info keyword kill
/usr/bin/pt-kill--busy-time--match-info= "SELECT | DELETE "--victim all--interval 1--kill--daemonize--pid=/tmp/ptkill.pid--print--log=/home/pt-kill.log
Note: The test by the info to kill the thread, pay attention to the contents of the info must be strictly match the case, otherwise it will not kill off. Note--match-info with multiple info | Separate, otherwise it will fail.
--ignore-info/--match-info
(info can be matched with SELECT, UPDATE, INSERT, delete, and you can use the ' | ' Perform multiple matches, such as "select| select|delete| delete|update| UPDATE "


6. By visiting dbname Kill
/usr/bin/pt-kill--busy-time--match-db= "DB1 | DB2 "--victim all--interval 1--kill--daemonize--pid=/tmp/ptkill.pid--print--log=/home/pt-kill.log
--IGNORE-DB/--match-db
Note: Test by db to kill the thread, note that the contents of the DB must be strictly match the case, otherwise it will not kill. Note--match-db between multiple db | Separate, otherwise it will fail.


Another: Action:
--kill Kill the connection and exit.
--kill-query only kills the statement that the connection executes, but the thread is not terminated

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.