Mysql-mytop安装与使用

来源:互联网 发布:java 邮箱匹配 编辑:程序博客网 时间:2024/04/20 22:01
安装参考文章:
http://blog.csdn.net/u010391029/article/details/50596913
http://blog.csdn.net/hhq163/article/details/72916013?utm_source=itdadao&utm_medium=referral


环境信息:

服务器CentOS6.5

mysql5.7.17


一.前置准备工作
1、先安装perl相关工具包: 
yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker


2、安装相关支持库: 
wget http://search.cpan.org/CPAN/authors/id/J/JS/JSTOWE/TermReadKey-2.37.tar.gz

wget http://down1.chinaunix.net/distfiles/DBI-1.622.tar.gz

tar -zxvf TermReadKey-2.37.tar.gz 
cd TermReadKey-2.37 
perl Makefile.PL 
make 
make install 
cd ..

tar -zxvf DBI-1.622.tar.gz 
cd DBI-1.622 
perl Makefile.PL 
make 
make install

注:TermReadKey和DBI安装失败可使用如下替代方案进行安装
yum list|grep TermReadKey
yum -y install perl-TermReadKey.x86_64
yum list|grep DBD
yum -y install perl-DBD-MySQL.x86_64


二.安装mytop
wget http://jeremy.zawodny.com/mysql/mytop/mytop-1.6.tar.gz
注:mytop最新版本可去官网查看http://jeremy.zawodny.com/mysql/mytop/
tar -zxvf mytop-1.6.tar.gz 
cd mytop-1.6 
perl Makefile.PL 
make 
make test 
make install


find / -name mytop
/usr/local/bin/mytop -uroot -pC8dM1B9wd1iQC7Y -h 10.100.24.15 -d xiaodai


三.命令使用
命令介绍相关文章:
http://blog.csdn.net/u011871037/article/details/52608831

http://blog.csdn.net/u010391029/article/details/50596913


四.遇到的相关问题

1.执行 mytop -uroot -pxxxxx 可能会出现报错:
MySQL on localhost (5.1.43-log)                                                                                                   up 345+20:36:31 [09:07:11]
 Queries: 3.0    qps:    0 Slow:     0.0         Se/In/Up/De(%):    00/00/00/00 


 Key Efficiency: 100.0%  Bps in/out:   0.0/  0.0   


      Id      User         Host/IP         DB      Time    Cmd Query or State                                                                               
      --      ----         -------         --      ----    --- ----------                                                                                   
Use of uninitialized value in substitution (s///) at ./mytop line 955.
Use of uninitialized value in substitution (s///) at ./mytop line 955.
...................................................
Use of uninitialized value in substitution (s///) at ./mytop line 955.


解决方法:
vi mytop
跳到955行,找到 
$host =~ s/^([^.]+).*/$1/;
$thread->{Host} = $host;
改为:
    if ($host)
       {
                $host =~ s/^([^.]+).*/$1/;
                $thread->{Host} = $host;
                   }

2.报错:Error in option spec: "long|!"
解决:http://blog.csdn.net/zxnm55/article/details/19040205
编辑 mytop vim /usr/bin/mytop
找到 "long|!" => \$config{long_nums},修改成 "long|long_nums|l!" => \$config{long_nums},