Yum安装
检查和安装与Perl相关的模块
参考地址
PT工具是使用Perl语言编写和执行的,所以需要系统中有Perl环境。
依赖包检查命令为:
rpm -qa perl-DBI perl-DBD-MySQL perl-Time-HiRes perl-IO-Socket-SSL
如果有依赖包确实,可以使用下面的命令安装:
yum install perl-DBI perl-DBD-MySQL perl-Time-HiRes perl-IO-Socket-SSL -y
下载和安装percona toolkit的包
https://www.percona.com/doc/percona-toolkit/3.0/installation.html#installing-percona-toolkit-on-red-hat-or-centos
yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
查看可以安装的包
yum list | grep percona-toolkit
出现complete!即表示安装成功:
编译安装
依赖安装
yum install -y perl perl-IO-Socket-SSL perl-DBD-MySQL perl-Time-HiRes perl-Digest-MD5 perl-ExtUtils-MakeMaker
官网下载地址
#先下载Percona Toolkit工具编译包
wget "https://www.percona.com/downloads/percona-toolkit/3.0.3/binary/tarball/percona-toolkit-3.0.3_x86_64.tar.gz"
#解压
tar xf percona-toolkit-3.0.3.tar.gz
#进入目录安装
cd percona-toolkit-3.0.3.tar.gz
#开始编译安装
perl Makefile.PL
make
make install
#安装完了就有命令了
ll /usr/local/bin/pt-*
-r-xr-xr-x 1 root root 41480 Jan 19 11:03 /usr/local/bin/pt-align
-r-xr-xr-x 1 root root 263438 Jan 19 11:03 /usr/local/bin/pt-archiver
-r-xr-xr-x 1 root root 168985 Jan 19 11:03 /usr/local/bin/pt-config-diff
-r-xr-xr-x 1 root root 166210 Jan 19 11:03 /usr/local/bin/pt-deadlock-logger
-r-xr-xr-x 1 root root 164927 Jan 19 11:03 /usr/local/bin/pt-diskstats
-r-xr-xr-x 1 root root 168895 Jan 19 11:03 /usr/local/bin/pt-duplicate-key-checker
-r-xr-xr-x 1 root root 49890 Jan 19 11:03 /usr/local/bin/pt-fifo-split
-r-xr-xr-x 1 root root 149727 Jan 19 11:03 /usr/local/bin/pt-find
-r-xr-xr-x 1 root root 67037 Jan 19 11:03 /usr/local/bin/pt-fingerprint
-r-xr-xr-x 1 root root 133187 Jan 19 11:03 /usr/local/bin/pt-fk-error-logger
-r-xr-xr-x 1 root root 218381 Jan 19 11:03 /usr/local/bin/pt-heartbeat
-r-xr-xr-x 1 root root 226009 Jan 19 11:03 /usr/local/bin/pt-index-usage
-r-xr-xr-x 1 root root 32345 Jan 19 11:03 /usr/local/bin/pt-ioprofile
-r-xr-xr-x 1 root root 250059 Jan 19 11:03 /usr/local/bin/pt-kill
-r-xr-xr-x 1 root root 21753 Jan 19 11:03 /usr/local/bin/pt-mext
-r-xr-xr-x 1 root root 102147 Jan 19 11:03 /usr/local/bin/pt-mysql-summary
-r-xr-xr-x 1 root root 393892 Jan 19 11:03 /usr/local/bin/pt-online-schema-change
-r-xr-xr-x 1 root root 24594 Jan 19 11:03 /usr/local/bin/pt-pmp
-r-xr-xr-x 1 root root 520502 Jan 19 11:03 /usr/local/bin/pt-query-digest
-r-xr-xr-x 1 root root 75713 Jan 19 11:03 /usr/local/bin/pt-show-grants
-r-xr-xr-x 1 root root 37724 Jan 19 11:03 /usr/local/bin/pt-sift
-r-xr-xr-x 1 root root 145553 Jan 19 11:03 /usr/local/bin/pt-slave-delay
-r-xr-xr-x 1 root root 128910 Jan 19 11:03 /usr/local/bin/pt-slave-find
-r-xr-xr-x 1 root root 181316 Jan 19 11:03 /usr/local/bin/pt-slave-restart
-r-xr-xr-x 1 root root 69580 Jan 19 11:03 /usr/local/bin/pt-stalk
-r-xr-xr-x 1 root root 90418 Jan 19 11:03 /usr/local/bin/pt-summary
-r-xr-xr-x 1 root root 422772 Jan 19 11:03 /usr/local/bin/pt-table-checksum
-r-xr-xr-x 1 root root 398202 Jan 19 11:03 /usr/local/bin/pt-table-sync
-r-xr-xr-x 1 root root 246864 Jan 19 11:03 /usr/local/bin/pt-table-usage
-r-xr-xr-x 1 root root 330806 Jan 19 11:03 /usr/local/bin/pt-upgrade
-r-xr-xr-x 1 root root 177020 Jan 19 11:03 /usr/local/bin/pt-variable-advisor
-r-xr-xr-x 1 root root 102278 Jan 19 11:03 /usr/local/bin/pt-visual-explain
ok了
工具类别 |
工具命令 |
工具作用 |
备注 |
开发类 |
pt-duplicate-key-checker |
列出并删除重复的索引和外键 |
|
pt-online-schema-change |
在线修改表结构 |
|
pt-query-advisor |
分析查询语句,并给出建议,有bug |
已废弃 |
pt-show-grants |
规范化和打印权限 |
|
pt-upgrade |
在多个服务器上执行查询,并比较不同 |
|
性能类 |
pt-index-usage |
分析日志中索引使用情况,并出报告 |
|
pt-pmp |
为查询结果跟踪,并汇总跟踪结果 |
|
pt-visual-explain |
格式化执行计划 |
|
pt-table-usage |
分析日志中查询并分析表使用情况 |
pt 2.2新增命令 |
配置类 |
pt-config-diff |
比较配置文件和参数 |
|
pt-mysql-summary |
对mysql配置和status进行汇总 |
|
pt-variable-advisor |
分析参数,并提出建议 |
|
监控类 |
pt-deadlock-logger |
提取和记录mysql死锁信息 |
|
pt-fk-error-logger |
提取和记录外键信息 |
|
pt-mext |
并行查看status样本信息 |
|
pt-query-digest |
分析查询日志,并产生报告 |
常用命令 |
pt-trend |
按照时间段读取slow日志信息 |
已废弃 |
复制类 |
pt-heartbeat |
监控mysql复制延迟 |
|
pt-slave-delay |
设定从落后主的时间 |
|
pt-slave-find |
查找和打印所有mysql复制层级关系 |
|
pt-slave-restart |
监控salve错误,并尝试重启salve |
|
pt-table-checksum |
校验主从复制一致性 |
|
pt-table-sync |
高效同步表数据 |
|
系统类 |
pt-diskstats |
查看系统磁盘状态 |
|
pt-fifo-split |
模拟切割文件并输出 |
|
pt-summary |
收集和显示系统概况 |
|
pt-stalk |
出现问题时,收集诊断数据 |
|
pt-sift |
浏览由pt-stalk创建的文件 |
pt 2.2新增命令 |
pt-ioprofile |
查询进程IO并打印一个IO活动表 |
pt 2.2新增命令 |
实用类 |
pt-archiver |
将表数据归档到另一个表或文件中 |
|
pt-find |
查找表并执行命令 |
|
pt-kill |
Kill掉符合条件的sql |
常用命令
|
pt-align |
对齐其他工具的输出 |
pt 2.2新增命令 |
pt-fingerprint |
将查询转成密文 |
pt 2.2新增命令 |