Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation of pt software and usage of pt-kill

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Used when modifying table structure: pt_online-schema-change

2.percona-toolkit tool set

Wget https://percona.com/downloads/percona-toolkit/2.2.16/tarball/percona-toolkit-2.2.16.tar.gz

Tar zxvf percona-toolkit-2.2.16.tar.gz

Wget https://www.percona.com/downloads/percona-toolkit/3.0.10/binary/tarball/percona-toolkit-3.0.10_x86_64.tar.gz

Yum install perl-DBD-MySQL

Yum install perl-ExtUtils-Embed-y

Yum install perl-Digest-MD5

Yum install perl-devel

Perl Makefile.PL

Make

Make install

Post-installation tool catalog: / usr/local/bin

A.pt-kill

-- victims all needs to be available, otherwise only one connection will be processed (the one that connects to the database first)

-- interval 30 is executed in a loop every 30 seconds by default, and can be adjusted according to the actual situation. If you don't add it, it will only be executed once; plus, it will be executed continuously in the background.

The replication thread is filtered by default, so don't worry about killing the replication thread.

-- run-time, if specified, executes for a specified long time, otherwise executes at a cycle time every multiple times.

-- help can view help information, except for the negative relationship between-- busy-time and-- idle-time, only one can be selected; the other options are union, An and B, and-- ignore and-- match information can be used together.

The key point of use is the flexible combination of ignore and match.

Here is some information about the content of help, which can be used to limit the conditions under which connections are killed.

-- database (No value)

-- defaults-file (No value)

-- each-busy-time (No value)

-- execute-command (No value)

-- filter (No value)

-- group-by (No value)

-- help TRUE

-- host localhost

-- idle-time (No value)

-- ignore-command (No value)

-- ignore-db (No value)

-- ignore-host (No value)

-- ignore-info (No value)

-- ignore-self TRUE

-- ignore-state Locked

-- ignore-user (No value)

-- interval 30

-- kill FALSE

-- kill-query FALSE

-- log (No value)

-- log-dsn (No value)

-- match-all FALSE

-- match-command (No value)

-- match-db (No value)

-- match-host (No value)

-- match-info (No value)

-- match-state (No value)

-- match-user (No value)

Kill all sleep connections for more than 200s every 10 seconds and print

/ usr/local/bin/pt-kill-idle-time 200-victims all-interval 10-S

/ var/lib/mysql/mysql.sock-uroot-p111111-- kill-- print

Kill all sleep connections with host 127.0.0.1 every 10 seconds and print

/ usr/local/bin/pt-kill-match-host='127.0.0.1'-idle-time 200-victims all-interval 10-S

/ var/lib/mysql/mysql.sock-uroot-p123456-kill-print

Kill all sleep connections to dbhospital for more than 200s every 10 seconds and print

/ usr/local/bin/pt-kill-match-db='hospital'-idle-time 200-victims all-interval 10-S

/ var/lib/mysql/mysql.sock-uroot-p123456-kill-print

-every 10 seconds kills connections whose execution time exceeds a specific time and a specific sql (5 seconds)

/ usr/local/bin/pt-kill-busy-time=1-match-info='SELECT | select | Select'-victims all-interval 10-S

/ var/lib/mysql/mysql.sock-uroot-p123456-kill-print

Kill the pt-kill process

Kill-9 $(ps-ef | grep pt-kill | grep-v grep | awk'{print $2}')

2.pt-align alignment tool

Use pt-align filename

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report