Pt-kill of Percona Utility tools

Source: Internet
Author: User
Tags mysql in print print percona

Pt-kill

Overview

Obtain a connection that satisfies the condition from show processlist or read the connection that satisfies the condition from the file containing show processlist and print or kill or perform other actions, this tool is very practical in work, When the server connection has an exception the first thought is Pt-kill, write a script can also, but the function is still not pt-kill strong; Generally I like to put the necessary information to connect local MySQL in a file file, when you need to connect local MySQL directly specify the configuration file;


Common function Introduction

Pt-kill--defaults-file xx--match-command--kill--victims all--interval 10 kill the number of connections in the sleep state every 10s;

Pt-kill defaults-file xx--busy-time--kill--victims all--interval 10 Every 10s of the initial runnning the number of connections exceeding 60s;


several important parameters 
  
   --daemonize is  placed in the background to run as a daemon  ,--interval How often to run, units can be s,m,h,d, etc. default is s
--victims default is oldest, only kill the oldest query. This is not really a long run of inquiries to prevent being killed, they just wait for a long time. This kind of match is queried by time, killing a maximum of time.
               all kill all satisfied threads kill
               all but the longest keep do not kill

action
--kill Kill the connection and exit
--kill-query only kill the connection execution statement , but the thread will not be terminated
--print Print the statement that satisfies the condition


  
QUERY matches--busy-time The batch query has been running for more than this time thread;--idle-time kill the number of hours of sleep of the connection thread, it must be in the--match-command to be effective--ignore-command

type:string; Group:query matches

Ignore queries whose Command matches this Perl regex.

--match-command. --ignore-db

type:string; Group:query matches

Ignore queries whose db (database) matches this Perl regex.

--match-db. --ignore-host

type:string; Group:query matches

Ignore queries whose Host matches this Perl regex.

--match-host. --ignore-info

type:string; Group:query matches

Ignore queries whose Info (query) matches this Perl regex.

--match-info. --[No]ignore-self

Default:yes; Group:query matches

Don ' t kill Pt-kill' s own connection. --ignore-state

type:string; Group:query matches; Default:locked

Ignore queries whose state matches the this Perl regex. The keepthreads from being killed if they are locked waiting for another thread.

--match-state. --ignore-user

type:string; Group:query matches

Ignore queries whose user matches this Perl regex.

--match-user. --match-all

Group:query matches

Match all queries this are not ignored. If no ignore options are specified,then every query matches (except-Replication threads, Unless--replication-threads is Al So specified). This option allows for you tospecify negative matches, i.e. "match every query except ..." Where theexceptions are defined by s Pecifying various--ignore options.

This option isn't the same as--victims all. This option Matchesall queries within a class, whereas--victims all specifies "Allmatching" in a Class (queries R they matched) 'll be killed. Normally,however, the two are used together because if, for example, your specify--victims oldest, then although all Querie s may match, only the Oldestwill is killed. --match-command

type:string; Group:query matches

Match only queries whose Command matches this Perl regex.

Common Command values are:

Query
sleep
binlog Dump
Connect
delayed insert
Execute
Fetch
Init DB
Kill
Prepare
processlist
Quit
Reset stmt
Table Dump

Http://dev.mysql.com/doc/refman/5.1/en/thread-commands.html for a fulllist and description of Command values. --match-db

type:string; Group:query matches

Match only queries whose db (database) matches the this Perl regex. --match-host

type:string; Group:query matches

Match only queries whose Host matches the This Perl regex.

The Host value often time includes the port like "Host:port". --match-info

type:string; Group:query matches

Match only queries whose Info (query) matches the this Perl regex.

The Info column of the processlist shows the query this is being Executedor NULL if no query is being executed. --match-state

type:string; Group:query matches

Match only queries whose state matches the this Perl regex.

Common state values are:

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

http://dev.mysql.com/doc/refman/5.1/en/general-thread-states.html fora full list and description of the state values. --match-user

type:string; Group:query matches

Match only queries whose User matches this Perl regex. --replication-threads

Group:query matches

Allow matching and killing replication threads.

By default, matches don't apply to replication threads; i.e. Replicationthreads are completely ignored. Specifying this option allows matches tomatch (and potentially kill) replication threads on masters and slaves. --test-matching

Type:array; Group:query matches

The Files with processlist snapshots to test matching options against. Sincethe matching options Can is complex, you can save snapshots of processlistin files, then test matching options agains t queries in those files.

This option disables--run-time,--interval,and--[no]ignore-self.



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.