Use Pt-kill to kill a connection based on certain rules _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.

Parameters

–busy-time

Run time

–idle-time

Free time

–victims

All matching connections, with the longest connection

–interval

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

–print

Print out a Kill connection

–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

Match the status 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 compliant SQL

–match-db–match-user–match-host

See the name of the idea

Common usage

Kill off the free links

Pt-kill–match-command Sleep–idle-time 5–host–port–interval–print–kill–victims All

Kill a link that runs longer than 5s

Pt-kill–match-command Query–busy-time 5–host–port–interval–print–kill–victims All

Kill the running SQL that matches a rule

Pt-kill–match-command query–busy-time 5–host–port–interval–print–kill–victims All–match-info

Kill the SQL that's being Filesort

Pt-kill–match-command query–match-state "Sorting result" busy-time 5–host–port–interval–print–kill–victims all

Kill the SQL that is copying to TMP table

Pt-kill–match-command query–match-state "Copying to tmp table" Busy-time 5–host–port–interval–print–kill–victims A ll

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.