Use pt ES1en to connect kill according to certain rules

  • 2021-01-02 22:01:29
  • OfStack

pt-kill is a good kill MySQL connection tool. It is the first part of percona toolkit. When the maximum number of connections is exceeded due to too many idle connections and the load on mysql is high due to some problematic sql, the main purpose of this tool is to drop one of the connections.

parameter

� busy - time

The elapsed time

� idle - time

Free time

� victims

All matched connections should have the longest connection

� interval

Interval time, default 30s, a little long, can be adjusted according to the actual situation

� print

Print out the connection dropped by kill

� match - command

The command that matches the current connection

Query
Sleep
Binlog Dump
Connect
Delayed insert
Execute
Fetch
Init DB
Kill
Prepare
Processlist
Quit
Reset stmt
Table Dump
� match - state

Matches the state of the current connection

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

Use regular expressions to match the matching sql

� match - db � match - user � match - host

See of knowledge meaning

Common usage

Kill idle links

pt-kill, match-ES134en, host 5, port 139en, print, kill, all

Kill links that take longer than 5s

pt-Query by ES151en-ES155en 5 by host by port by kill by victims by all by host by time by port by interval by victims by all

Kill the running sql that matches a rule

pt-kill, 170en-ES171en, 174en 5, 175en 6, 177en 6, 177en 7, 178en 7, 181en 8, 183en 8

Kill sql who is doing filesort

pt-kill by ES192en-ES193en by match "Sorting result" by ES199en-ES200en 5 by host by port by interval by kill by victims by all

Kill sql to tmp table

pt-kill by ES219en-ES221en by Copying tmp by Copying tmp by ES228en-ES229en 5 by host port by kill by all


Related articles: