Introduction to common killing process parameters of pt-kill and parameters of pt-kill
Pt-kill is an excellent tool for kill MySQL connection 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.
1. Press user kill
/Usr/bin/pt-kill -- busy-time 15 -- match-user = "dbUSER1 | dbUSER2 ,... "-- victim all -- interval 1 -- kill -- daemonize -- pid =/tmp/ptkill. pid -- print -- log =/home/pt-kill.log
Note: The test uses user-based thread killing. Note that multiple users of -- match-user are separated by |.
2. Run the query source host kill command.
/Usr/bin/pt-kill -- busy-time 15 -- 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: In the test, the thread is killed by the source host. Note that multiple hosts in match-host are separated by |.
3. Press command kill
/Usr/bin/pt-kill -- busy-time 15 -- 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 15 -- ignore-command = "sleep | binlogdump" -- victim all -- interval 1 -- kill -- daemonize -- pid =/tmp/ptkill. pid -- print -- log =/home/pt-kill.log
Note: In the test, the thread is killed by pressing command. Note that the command content must be case-sensitive. Otherwise, the thread cannot be killed. Note: -- match-command multiple commands are separated by |; otherwise, they will become invalid.
(Commands include Query, Sleep, Binlog Dump, Connect, Delayed insert, Execute, Fetch, Init DB, Kill, Prepare, Processlist, Quit, Reset stmt, and Table Dump)
4. Press state kill
/Usr/bin/pt-kill -- busy-time 15 -- match-state = "Locked | Sending data" -- victim all -- interval 1 -- kill -- daemonize -- pid =/tmp/ ptkill. pid -- print -- log =/home/pt-kill.log
Note: In the test, the thread is killed by pressing state. Note that the state content must strictly match the case. Otherwise, the thread cannot be killed. Note: -- match-state multiple states are separated by |; otherwise, it will become invalid.
(The state types include: 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)
5. Press the info keyword kill.
/Usr/bin/pt-kill -- busy-time 15 -- match-info = "SELECT | DELETE" -- victim all -- interval 1 -- kill -- daemonize -- pid =/tmp/ptkill. pid -- print -- log =/home/pt-kill.log
Note: In the test, the thread is killed by pressing info. Note that the info content must be case-sensitive. Otherwise, the thread cannot be killed. Note: -- match-info multiple info are separated by |; otherwise, it will become invalid.
-- Ignore-info/-- match-info
(Info can be matched using select, update, insert, and delete, and multiple matches can be performed using "|", for example, "select | SELECT | delete | DELETE | update | UPDATE"
6. kill by the accessed dbname
/Usr/bin/pt-kill -- busy-time 15 -- 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: In the test, the thread is killed by db. Note that the content of the db must be case-sensitive. Otherwise, the thread cannot be killed. Note: -- match-db multiple DBs are separated by |; otherwise, it will become invalid.
Also: Action:
-- Kill the connection and exit
-- Kill-query: only the statement executed by the connection is killed, but the thread is not terminated.