设为首页 收藏本站
查看: 811|回复: 0

[经验分享] mytop-MySQL监控工具

[复制链接]

尚未签到

发表于 2018-9-27 08:13:47 | 显示全部楼层 |阅读模式
  最近研究了下MySQL的监控工具mytop,也在网络上搜罗了很久,按照他们的流程总是安装不成功,也许是环境不一样的原因吧。在安装的过程中遇到很多问题,迟迟不能解决,但是,在经过一番努力之后终于安装成功了,现在加以详细汇总,以备将来使用,同时也可以给各位博友提供一份参考,将我个人的安装过程贴出来,仅供参考,如有疑问请联系QQ:349871740,欢迎指正^_^

  1、OS版本:Red Hat Enterprise Linux Server>  MySQL版本:4.0.26
  2、安装文件列表:
  MySQL-shared-compat-5.1.57-1.rhel5.i386.rpm
  mytop-1.6.tar.gz
  perl-DBD-MySQL-3.0007-2.el5.i386.rpm
  perl-DBI-1.52-2.el5.i386.rpm
  TermReadKey-2.30.tar.gz
  3、相关文件下载链接:
  wget http://search.cpan.org/CPAN/authors/id/J/JS/JSTOWE/TermReadKey-2.30.tar.gz
  wget http://jeremy.zawodny.com/mysql/mytop/mytop-1.6.tar.gz
  wget ftp://mirror.switch.ch/pool/1/mirror/mysql/Downloads/MySQL-5.1/MySQL-shared-compat-5.1.57-1.rhel5.i386.rpm
  wget ftp://ftp.icm.edu.pl/vol/rzm2/linux-slc/slc54/i386/SL/perl-DBD-MySQL-3.0007-2.el5.i386.rpm
  wget ftp://ftp.icm.edu.pl/vol/rzm2/linux-slc/slc58/i386/SL/perl-DBI-1.52-2.el5.i386.rpm
  4、安装流程如下:
  [root@tech tmp]# tar zxvf TermReadKey-2.30.tar.gz && cd TermReadKey-2.30
  [root@tech TermReadKey-2.30]# perl Makefile.PL && make && make install
  [root@tech TermReadKey-2.30]# cd ..
  [root@tech tmp]# rpm -Uvh MySQL-shared-compat-5.1.57-1.rhel5.i386.rpm perl-DBD-MySQL-3.0007-2.el5.i386.rpm perl-DBI-1.52-2.el5.i386.rpm
  [root@tech tmp]# tar zxvf mytop-1.6.tar.gz && cd mytop-1.6
  [root@tech mytop-1.6]# perl Makefile.PL && make && make install
  5、配置mytop并运行
  [root@tech mytop-1.6]# mytop
  Cannot connect to MySQL server. Please check the:
  * database you specified "test" (default is "test")
  * username you specified "root" (default is "root")
  * password you specified "" (default is "")
  * hostname you specified "localhost" (default is "localhost")
  * port you specified "3306" (default is 3306)
  * socket you specified "" (default is "")
  The options my be specified on the command-line or in a ~/.mytop
  config file. See the manual (perldoc mytop) for details.
  Here's the exact error from DBI. It might help you debug:
  Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
  [root@tech mytop-1.6]# cat /root/.mytop
  > user=root
  > pass=123456
  > host=127.0.0.1
  > db=cacti
  > delay=10
  > port=3306
  > resolve=0
  > socket=/tmp/mysql.sock
  > EOF
  [root@tech mytop-1.6]# mytop
  6、更详细的参数选项请参考man手册,这里不再赘述。
  [root@tech mytop-1.6]# man mytop
  7、以下是我的安装和配置过程:
  [root@tech ~]# uname -a
  Linux tech 2.6.18-128.el5PAE #1 SMP Wed Dec 17 12:02:33 EST 2008 i686 i686 i386 GNU/Linux
  [root@tech ~]# lsb_release -a
  LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch

  Distributor>
  Description:    Red Hat Enterprise Linux Server>  Release:        5.3
  Codename:       Tikanga
  [root@tech ~]# cat /etc/issue

  Red Hat Enterprise Linux Server>  Kernel \r on an \m
  [root@tech ~]# cd /tmp
  [root@tech tmp]# ll
  total 6144
  -rw-r--r-- 1 root root 5443408 Mar 24 19:17 MySQL-shared-compat-5.1.57-1.rhel5.i386.rpm
  -rw-r--r-- 1 root root   19720 Mar 24 18:39 mytop-1.6.tar.gz
  -rw-r--r-- 1 root root  150649 Oct 16  2008 perl-DBD-MySQL-3.0007-2.el5.i386.rpm
  -rw-r--r-- 1 root root  613929 Mar 24 19:06 perl-DBI-1.52-2.el5.i386.rpm
  -rw-r--r-- 1 root root   37006 Jun 13 10:56 TermReadKey-2.30.tar.gz
  -rw-r--r-- 1 root root       0 Jun 16 14:42 typescript
  [root@tech tmp]# tar zxvf TermReadKey-2.30.tar.gz && cd TermReadKey-2.30
  TermReadKey-2.30/
  TermReadKey-2.30/genchars.pl
  TermReadKey-2.30/Makefile.PL
  TermReadKey-2.30/Configure.pm
  TermReadKey-2.30/test.pl
  TermReadKey-2.30/ReadKey.pm
  TermReadKey-2.30/META.yml
  TermReadKey-2.30/ReadKey.xs
  TermReadKey-2.30/ppport.h
  TermReadKey-2.30/MANIFEST
  TermReadKey-2.30/README
  [root@tech TermReadKey-2.30]# perl Makefile.PL && make && make install
  Checking if your kit is complete...
  Looks good
  Writing Makefile for Term::ReadKey
  cp ReadKey.pm blib/lib/Term/ReadKey.pm
  AutoSplitting blib/lib/Term/ReadKey.pm (blib/lib/auto/Term/ReadKey)
  /usr/bin/perl -I/usr/lib/perl5/5.8.8 genchars.pl
  Writing termio/termios section of cchars.h... Done.
  Checking for sgtty...
  Sgtty NOT found.
  Writing sgtty section of cchars.h... Done.
  /usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp -noprototypes -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap  ReadKey.xs > ReadKey.xsc && mv ReadKey.xsc ReadKey.c
  gcc -c   -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables   -DVERSION=\"2.30\" -DXS_VERSION=\"2.30\" -fPIC "-I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE"   ReadKey.c
  In file included from ReadKey.xs:6:
  ppport.h:230:1: warning: "PERL_UNUSED_DECL" redefined
  In file included from ReadKey.xs:4:
  /usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE/perl.h:163:1: warning: this is the location of the previous definition
  In file included from ReadKey.xs:375:
  cchars.h: In function 'XS_Term__ReadKey_GetControlChars':
  cchars.h:244: warning: unused variable 'i'
  ReadKey.xs: In function 'ReadMode':
  ReadKey.xs:770: warning: unused variable 'Perl___notused'
  ReadKey.c: In function 'XS_Term__ReadKey_SetTerminalSize':
  ReadKey.c:1999: warning: unused variable 'targ'
  Running Mkbootstrap for Term::ReadKey ()
  chmod 644 ReadKey.bs
  rm -f blib/arch/auto/Term/ReadKey/ReadKey.so
  gcc  -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -L/usr/local/lib ReadKey.o  -o blib/arch/auto/Term/ReadKey/ReadKey.so      \
  \
  chmod 755 blib/arch/auto/Term/ReadKey/ReadKey.so
  cp ReadKey.bs blib/arch/auto/Term/ReadKey/ReadKey.bs
  chmod 644 blib/arch/auto/Term/ReadKey/ReadKey.bs
  Manifying blib/man3/Term::ReadKey.3pm
  Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Term/ReadKey/ReadKey.bs
  Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Term/ReadKey/ReadKey.so
  Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
  Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Term/ReadKey/autosplit.ix
  Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Term/ReadKey.pm
  Installing /usr/share/man/man3/Term::ReadKey.3pm
  Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Term/ReadKey/.packlist
  Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod
  [root@tech TermReadKey-2.30]# cd ..
  [root@tech tmp]# rpm -Uvh MySQL-shared-compat-5.1.57-1.rhel5.i386.rpm perl-DBD-MySQL-3.0007-2.el5.i386.rpm perl-DBI-1.52-2.el5.i386.rpm

  warning: perl-DBD-MySQL-3.0007-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key>
  warning: perl-DBI-1.52-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key>  Preparing...                ########################################### [100%]
  1:perl-DBI               ########################################### [ 33%]
  2:MySQL-shared-compat    ########################################### [ 67%]
  3:perl-DBD-MySQL         ########################################### [100%]
  [root@tech tmp]# tar zxvf mytop-1.6.tar.gz && cd mytop-1.6
  mytop-1.6/
  mytop-1.6/MANIFEST
  mytop-1.6/test.pl
  mytop-1.6/mytop
  mytop-1.6/Changes
  mytop-1.6/INSTALL
  mytop-1.6/README
  mytop-1.6/Makefile.PL
  mytop-1.6/META.yml
  [root@tech mytop-1.6]# perl Makefile.PL && make && make install
  Checking if your kit is complete...
  Looks good
  Writing Makefile for mytop
  cp mytop blib/script/mytop
  /usr/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" blib/script/mytop
  Manifying blib/man1/mytop.1
  Installing /usr/share/man/man1/mytop.1
  Installing /usr/bin/mytop
  Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/mytop/.packlist
  Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod
  [root@tech mytop-1.6]# mytop
  Cannot connect to MySQL server. Please check the:
  * database you specified "test" (default is "test")
  * username you specified "root" (default is "root")
  * password you specified "" (default is "")
  * hostname you specified "localhost" (default is "localhost")
  * port you specified "3306" (default is 3306)
  * socket you specified "" (default is "")
  The options my be specified on the command-line or in a ~/.mytop
  config file. See the manual (perldoc mytop) for details.
  Here's the exact error from DBI. It might help you debug:
  Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
  [root@tech mytop-1.6]# cat /root/.mytop
  > user=root
  > pass=123456
  > host=127.0.0.1
  > db=cacti
  > delay=10
  > port=3306
  > resolve=0
  > socket=/tmp/mysql.sock
  > EOF
  [root@tech mytop-1.6]# mytop
  MySQL on 127.0.0.1 (4.0.26)                                                                                                                             up 10+22:18:53 [14
  :52:13]
  Queries: 81.6k  qps:    0 Slow:   810.0         Se/In/Up/De(%):    23/36/40/01
  Cache Hits: 6.8k  Hits/s:  0.0 Hits now:   0.0  Ratio: 35.8% Ratio now:  0.0%
  Key Efficiency: 100.0%  Bps in/out:  73.3/ 2.6k

  >  --      ----         -------         --      ----    --- ----------
  156      root       localhost        cacti         0  Query show full processlist
  8、总结:将以上安装过程写成脚本进行快速安装,由于IDC做了ACL限制,不能直接进行wget对安装文件进行下载,个人是首先将安装文件下载到个人电脑,然后上传到服务器的,以下是脚本示例,
  [root@tech ~]# cat mytop_install.sh
  _DIR=/tmp/wyq
  cd ${_DIR}
  tar zxvf TermReadKey-2.30.tar.gz && cd TermReadKey-2.30
  perl Makefile.PL && make && make install
  cd ..
  rpm -Uvh MySQL-shared-compat-5.1.57-1.rhel5.i386.rpm perl-DBD-MySQL-3.0007-2.el5.i386.rpm perl-DBI-1.52-2.el5.i386.rpm
  tar zxvf mytop-1.6.tar.gz && cd mytop-1.6
  perl Makefile.PL && make && make install
  cd ..
  rm -rf TermReadKey-2.30 mytop-1.6
  cat /root/.mytop
  user=root
  pass=123456
  host=127.0.0.1
  db=cacti
  delay=10
  port=3306
  resolve=0
  socket=/tmp/mysql.sock
  EOF
  9、提示:请根据自己的实际环境修改mytop的配置文件以及安装脚本
  注:2012年06月18号增加安装效果图,如下
DSC0000.jpg



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-602549-1-1.html 上篇帖子: MySQL入门(二) 下篇帖子: CentOS+Apache+Mysql+Php安装及优化配置小记
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表