[MySQL 工具]percona-toolkit使用(1)源码安装

1、percona-toolkit简介
percona-toolkit是一组高级命令行工具的集合,用来执行各种通过手工执行非常复杂和麻烦的mysql和系统任务,这些任务包括:
l  检查master和slave数据的一致性
l  有效地对记录进行归档
l  查找重复的索引
l  对服务器信息进行汇总
l  分析来自日志和tcpdump的查询
l  当系统出问题的时候收集重要的系统信息
percona-toolkit源自Maatkit 和Aspersa工具,这两个工具是管理mysql的最有名的工具,现在Maatkit工具已经不维护了,请大家还是使用percona-toolkit吧!这些工具主要包括开发、性能、配置、监控、复制、系统、实用六大类,作为一个优秀的DBA,里面有的工具非常有用,如果能掌握并加以灵活应用,将能极大的提高工作效率。


2、下载
Download address:  
http://www.percona.com/redir/downloads/percona-toolkit/LATEST/percona-toolkit-2.2.5.tar.gz


[root@472322 ~]# cd down/
[root@472322 down]# wget http://www.percona.com/redir/downloads/percona-toolkit/LATEST/percona-toolkit-2.2.5.tar.gz
--2013-10-30 23:27:56--  http://www.percona.com/redir/downloads/percona-toolkit/LATEST/percona-toolkit-2.2.5.tar.gz
Resolving www.percona.com... 74.121.199.234
Connecting to www.percona.com|74.121.199.234|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: /downloads/percona-toolkit/LATEST/percona-toolkit-2.2.5.tar.gz [following]
--2013-10-30 23:27:56--  http://www.percona.com/downloads/percona-toolkit/LATEST/percona-toolkit-2.2.5.tar.gz
Reusing existing connection to www.percona.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 1447292 (1.4M) [application/x-gzip]
Saving to: 鈥減ercona-toolkit-2.2.5.tar.gz鈥


100%[=============================================================================================================================>] 1,447,292    874K/s   in 1.6s    


2013-10-30 23:27:57 (874 KB/s) - 鈥減ercona-toolkit-2.2.5.tar.gz鈥saved [1447292/1447292]


下载完毕。


3、安装
[root@472322 percona-toolkit-2.2.5]# tar -xvf percona-toolkit-2.2.5.tar.gz
[root@472322 percona-toolkit-2.2.5]# cd percona-toolkit-2.2.5


3.1 perl Makefile.PL
[root@472322 percona-toolkit-2.2.5]# perl Makefile.PL
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 1.
BEGIN failed--compilation aborted at Makefile.PL line 1.


可能是perl,make没有安装吧,yum安装下perl以及make试试:
[root@472322 percona-toolkit-2.2.5]# yum install perl
Loaded plugins: dellsysid, fastestmirror, presto
Determining fastest mirrors
epel/metalink                                                                                                                                   |  16 kB     00:00     
 * base: mirror.rackspace.com
 * dell-community: linux.dell.com
 * epel: fedora-epel.mirror.lstn.net
 * extras: mirrordenver.fdcservers.net
 * updates: centos.mirror.lstn.net
............................... 此处省略..............................
Updated:
  perl.x86_64 4:5.10.1-131.el6_4                                                                                                                                       


Dependency Updated:
  perl-Compress-Raw-Zlib.x86_64 1:2.020-131.el6_4         perl-Compress-Zlib.x86_64 0:2.020-131.el6_4           perl-IO-Compress-Base.x86_64 0:2.020-131.el6_4        
  perl-IO-Compress-Zlib.x86_64 0:2.020-131.el6_4          perl-Module-Pluggable.x86_64 1:3.90-131.el6_4         perl-Pod-Escapes.x86_64 1:1.04-131.el6_4              
  perl-Pod-Simple.x86_64 1:3.13-131.el6_4                 perl-libs.x86_64 4:5.10.1-131.el6_4                   perl-version.x86_64 3:0.77-131.el6_4                  


Complete!


[root@472322 percona-toolkit-2.2.5]# make
make: *** No targets specified and no makefile found.  Stop.
[root@472322 percona-toolkit-2.2.5]# yum install -y make
Loaded plugins: dellsysid, fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base: mirror.rackspace.com
 * dell-community: linux.dell.com
 * epel: fedora-epel.mirror.lstn.net
 * extras: mirrordenver.fdcservers.net
 * updates: centos.mirror.lstn.net
Setting up Install Process
Package 1:make-3.81-20.el6.x86_64 already installed and latest version
Nothing to do
[root@472322 percona-toolkit-2.2.5]# 


[root@472322 percona-toolkit-2.2.5]# perl Makefile.PL
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 1.
BEGIN failed--compilation aborted at Makefile.PL line 1.

google,找到需要安装一些perl组件: 
[root@472322 percona-toolkit-2.2.5]# yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
Loaded plugins: dellsysid, fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base: mirror.rackspace.com
 * dell-community: linux.dell.com
 * epel: fedora-epel.mirror.lstn.net
 * extras: mirrordenver.fdcservers.net
 * updates: centos.mirror.lstn.net
Setting up Install Process
............................... 此处省略..............................


Dependency Installed:
  perl-ExtUtils-ParseXS.x86_64 1:2.2003.0-131.el6_4             perl-Test-Harness.x86_64 0:3.17-131.el6_4             perl-devel.x86_64 4:5.10.1-131.el6_4            


Complete!


OK,再试下:
[root@472322 percona-toolkit-2.2.5]# perl Makefile.PL
Checking if your kit is complete...
Warning: the following files are missing in your kit:
        bin/pt-agent.~1~
        bin/pt-agent.~2~
        bin/pt-align.~1~
        bin/pt-align.~2~
        bin/pt-archiver.~1~
        bin/pt-archiver.~2~
        bin/pt-config-diff.~1~
        bin/pt-config-diff.~2~
        bin/pt-deadlock-logger.~1~
        bin/pt-deadlock-logger.~2~
        bin/pt-diskstats.~1~
        bin/pt-diskstats.~2~
        bin/pt-duplicate-key-checker.~1~
        bin/pt-duplicate-key-checker.~2~
        bin/pt-fifo-split.~1~
        bin/pt-fifo-split.~2~
        bin/pt-find.~1~
        bin/pt-find.~2~
        bin/pt-fingerprint.~1~
        bin/pt-fingerprint.~2~
        bin/pt-fk-error-logger.~1~
        bin/pt-fk-error-logger.~2~
        bin/pt-heartbeat.~1~
        bin/pt-heartbeat.~2~
        bin/pt-index-usage.~1~
        bin/pt-index-usage.~2~
        bin/pt-ioprofile.~1~
        bin/pt-ioprofile.~2~
        bin/pt-kill.~1~
        bin/pt-kill.~2~
        bin/pt-mext.~1~
        bin/pt-mext.~2~
        bin/pt-mysql-summary.~1~
        bin/pt-mysql-summary.~2~
        bin/pt-online-schema-change.~1~
        bin/pt-online-schema-change.~2~
        bin/pt-pmp.~1~
        bin/pt-pmp.~2~
        bin/pt-query-digest.~1~
        bin/pt-query-digest.~2~
        bin/pt-show-grants.~1~
        bin/pt-show-grants.~2~
        bin/pt-sift.~1~
        bin/pt-sift.~2~
        bin/pt-slave-delay.~1~
        bin/pt-slave-delay.~2~
        bin/pt-slave-find.~1~
        bin/pt-slave-find.~2~
        bin/pt-slave-restart.~1~
        bin/pt-slave-restart.~2~
        bin/pt-stalk.~1~
        bin/pt-stalk.~2~
        bin/pt-summary.~1~
        bin/pt-summary.~2~
        bin/pt-table-checksum.~1~
        bin/pt-table-checksum.~2~
        bin/pt-table-sync.~1~
        bin/pt-table-sync.~2~
        bin/pt-table-usage.~1~
        bin/pt-table-usage.~2~
        bin/pt-upgrade.~1~
        bin/pt-upgrade.~2~
        bin/pt-variable-advisor.~1~
        bin/pt-variable-advisor.~2~
        bin/pt-visual-explain.~1~
        bin/pt-visual-explain.~2~
        Changelog.~1~
        Changelog.~2~
        Makefile.PL.~1~
        Makefile.PL.~2~
        MANIFEST.~1~
Please inform the author.
Warning: prerequisite DBD::mysql 3 not found.
Warning: prerequisite DBI 1.46 not found.
Writing Makefile for percona-toolkit


3.2 make
[root@472322 percona-toolkit-2.2.5]# make
cp bin/pt-mysql-summary blib/script/pt-mysql-summary
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-mysql-summary
cp bin/pt-kill blib/script/pt-kill
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-kill
cp bin/pt-online-schema-change blib/script/pt-online-schema-change
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-online-schema-change
cp bin/pt-table-sync blib/script/pt-table-sync
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-table-sync
cp bin/pt-upgrade blib/script/pt-upgrade
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-upgrade
cp bin/pt-table-usage blib/script/pt-table-usage
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-table-usage
cp bin/pt-fifo-split blib/script/pt-fifo-split
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-fifo-split
cp bin/pt-slave-find blib/script/pt-slave-find
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-slave-find
cp bin/pt-agent blib/script/pt-agent
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-agent
cp bin/pt-ioprofile blib/script/pt-ioprofile
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-ioprofile
cp bin/pt-find blib/script/pt-find
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-find
cp bin/pt-archiver blib/script/pt-archiver
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-archiver
cp bin/pt-deadlock-logger blib/script/pt-deadlock-logger
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-deadlock-logger
cp bin/pt-fingerprint blib/script/pt-fingerprint
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-fingerprint
cp bin/pt-mext blib/script/pt-mext
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-mext
cp bin/pt-slave-restart blib/script/pt-slave-restart
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-slave-restart
cp bin/pt-summary blib/script/pt-summary
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-summary
cp bin/pt-fk-error-logger blib/script/pt-fk-error-logger
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-fk-error-logger
cp bin/pt-table-checksum blib/script/pt-table-checksum
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-table-checksum
cp bin/pt-query-digest blib/script/pt-query-digest
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-query-digest
cp bin/pt-show-grants blib/script/pt-show-grants
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-show-grants
cp bin/pt-pmp blib/script/pt-pmp
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-pmp
cp bin/pt-align blib/script/pt-align
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-align
cp bin/pt-heartbeat blib/script/pt-heartbeat
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-heartbeat
cp bin/pt-slave-delay blib/script/pt-slave-delay
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-slave-delay
cp bin/pt-sift blib/script/pt-sift
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-sift
cp bin/pt-diskstats blib/script/pt-diskstats
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-diskstats
cp bin/pt-visual-explain blib/script/pt-visual-explain
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-visual-explain
cp bin/pt-variable-advisor blib/script/pt-variable-advisor
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-variable-advisor
cp bin/pt-index-usage blib/script/pt-index-usage
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-index-usage
cp bin/pt-duplicate-key-checker blib/script/pt-duplicate-key-checker
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-duplicate-key-checker
cp bin/pt-config-diff blib/script/pt-config-diff
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-config-diff
cp bin/pt-stalk blib/script/pt-stalk
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pt-stalk
Manifying blib/man1/pt-mysql-summary.1p
Manifying blib/man1/pt-kill.1p
Manifying blib/man1/pt-online-schema-change.1p
Manifying blib/man1/pt-table-sync.1p
Manifying blib/man1/pt-upgrade.1p
Manifying blib/man1/pt-table-usage.1p
Manifying blib/man1/pt-fifo-split.1p
Manifying blib/man1/pt-slave-find.1p
Manifying blib/man1/pt-agent.1p
Manifying blib/man1/pt-ioprofile.1p
Manifying blib/man1/pt-find.1p
Manifying blib/man1/pt-archiver.1p
Manifying blib/man1/pt-deadlock-logger.1p
Manifying blib/man1/pt-fingerprint.1p
Manifying blib/man1/pt-mext.1p
Manifying blib/man1/pt-slave-restart.1p
Manifying blib/man1/pt-summary.1p
Manifying blib/man1/pt-fk-error-logger.1p
Manifying blib/man1/pt-table-checksum.1p
Manifying blib/man1/pt-query-digest.1p
Manifying blib/man1/pt-show-grants.1p
Manifying blib/man1/percona-toolkit.1p
Manifying blib/man1/pt-pmp.1p
Manifying blib/man1/pt-align.1p
Manifying blib/man1/pt-heartbeat.1p
Manifying blib/man1/pt-slave-delay.1p
Manifying blib/man1/pt-sift.1p
Manifying blib/man1/pt-diskstats.1p
Manifying blib/man1/pt-visual-explain.1p
Manifying blib/man1/pt-variable-advisor.1p
Manifying blib/man1/pt-index-usage.1p
Manifying blib/man1/pt-duplicate-key-checker.1p
Manifying blib/man1/pt-config-diff.1p
Manifying blib/man1/pt-stalk.1p




3.3  make install

[root@472322 percona-toolkit-2.2.5]# make install
Installing /usr/local/share/man/man1/pt-ioprofile.1p
Installing /usr/local/share/man/man1/pt-sift.1p
Installing /usr/local/share/man/man1/pt-query-digest.1p
Installing /usr/local/share/man/man1/pt-table-sync.1p
Installing /usr/local/share/man/man1/pt-summary.1p
Installing /usr/local/share/man/man1/pt-duplicate-key-checker.1p
Installing /usr/local/share/man/man1/pt-online-schema-change.1p
Installing /usr/local/share/man/man1/pt-pmp.1p
Installing /usr/local/share/man/man1/pt-mext.1p
Installing /usr/local/share/man/man1/pt-kill.1p
Installing /usr/local/share/man/man1/pt-config-diff.1p
Installing /usr/local/share/man/man1/pt-slave-restart.1p
Installing /usr/local/share/man/man1/pt-deadlock-logger.1p
Installing /usr/local/share/man/man1/pt-variable-advisor.1p
Installing /usr/local/share/man/man1/pt-index-usage.1p
Installing /usr/local/share/man/man1/pt-fk-error-logger.1p
Installing /usr/local/share/man/man1/pt-find.1p
Installing /usr/local/share/man/man1/pt-upgrade.1p
Installing /usr/local/share/man/man1/pt-fingerprint.1p
Installing /usr/local/share/man/man1/pt-show-grants.1p
Installing /usr/local/share/man/man1/pt-archiver.1p
Installing /usr/local/share/man/man1/pt-visual-explain.1p
Installing /usr/local/share/man/man1/pt-stalk.1p
Installing /usr/local/share/man/man1/pt-slave-delay.1p
Installing /usr/local/share/man/man1/pt-diskstats.1p
Installing /usr/local/share/man/man1/pt-heartbeat.1p
Installing /usr/local/share/man/man1/pt-table-checksum.1p
Installing /usr/local/share/man/man1/pt-agent.1p
Installing /usr/local/share/man/man1/percona-toolkit.1p
Installing /usr/local/share/man/man1/pt-fifo-split.1p
Installing /usr/local/share/man/man1/pt-align.1p
Installing /usr/local/share/man/man1/pt-table-usage.1p
Installing /usr/local/share/man/man1/pt-slave-find.1p
Installing /usr/local/share/man/man1/pt-mysql-summary.1p
Installing /usr/local/bin/pt-table-usage
Installing /usr/local/bin/pt-find
Installing /usr/local/bin/pt-kill
Installing /usr/local/bin/pt-ioprofile
Installing /usr/local/bin/pt-stalk
Installing /usr/local/bin/pt-agent
Installing /usr/local/bin/pt-deadlock-logger
Installing /usr/local/bin/pt-sift
Installing /usr/local/bin/pt-pmp
Installing /usr/local/bin/pt-fingerprint
Installing /usr/local/bin/pt-heartbeat
Installing /usr/local/bin/pt-summary
Installing /usr/local/bin/pt-diskstats
Installing /usr/local/bin/pt-slave-restart
Installing /usr/local/bin/pt-index-usage
Installing /usr/local/bin/pt-variable-advisor
Installing /usr/local/bin/pt-archiver
Installing /usr/local/bin/pt-duplicate-key-checker
Installing /usr/local/bin/pt-slave-find
Installing /usr/local/bin/pt-visual-explain
Installing /usr/local/bin/pt-align
Installing /usr/local/bin/pt-table-checksum
Installing /usr/local/bin/pt-mysql-summary
Installing /usr/local/bin/pt-fifo-split
Installing /usr/local/bin/pt-show-grants
Installing /usr/local/bin/pt-query-digest
Installing /usr/local/bin/pt-upgrade
Installing /usr/local/bin/pt-slave-delay
Installing /usr/local/bin/pt-online-schema-change
Installing /usr/local/bin/pt-fk-error-logger
Installing /usr/local/bin/pt-mext
Installing /usr/local/bin/pt-table-sync
Installing /usr/local/bin/pt-config-diff
Appending installation info to /usr/lib64/perl5/perllocal.pod


此致,percona-toolkit安装完毕。


4、后话
percona-toolkit的rpm安装方式,google得到的,杉树自己没有安装过。
rpm -ivh perl-TermReadKey-2.30-1.el5.rf.x86_64.rpm
rpm -ivh percona-toolkit-2.1.1-1.noarch.rpm

你可能感兴趣的:([MySQL 工具]percona-toolkit使用(1)源码安装)