Chinaunix首页 | 论坛 | 博客
  • 博客访问: 279170
  • 博文数量: 38
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 1051
  • 用 户 组: 普通用户
  • 注册时间: 2012-06-05 09:52
文章分类

全部博文(38)

文章存档

2013年(37)

2012年(1)

我的朋友

分类: 系统运维

2013-05-23 10:17:25


Maatkit是非常不错的mysql管理工具,网络评价非常不错。包含以下主要工具:
1、mk-table-checksum 检查主从表是否一致的有效工具
2、mk-table-sync 有效保证表一致的工具,不必重载从表而能够保证一致。
3、mk-visual-explain  exlpain解释工具
4、mk-heartbeat 主从同步的监视工具,能够给出从落后于主多少
5、mk-parallel-dump 多线程的mysqldump工具
6、mk-parallel-restore 多线程的表回复工具
7、mk-query-profiler 查询检测分析工具
8、mk-deadlock-logger 死锁的记录工具,支持innodb
9、mk-duplicate-key-checker key侦测工具
10、mk-show-grants 权限管理显示工具
11、mk-slave-restart slave的检测和重启工具
12、mk-slave-delay slave delay replication 的工具
13、mk-slave-prefetch
This tool implements Paul Tuckfield’s famous “oracle” algorithm to read ahead of the slave SQL thread in the relay logs, rewriting queries as SELECT and executing them to warm the slave’s caches. This can help an I/O-bound slave SQL thread run faster under some conditions, because it doesn’t have to wait for as much I/O to complete. 这个看起来非常不错。

maatkit 安装
安装在perl环境下安装
先检查perl环境是否存在。
perl -v

1.mysql安装在此省略。

2.安装DBI 下载地址: http://ftp.cuhk.edu.hk/pub/packages/perl/CPAN/authors/id/T/TI/TIMB/

  1. [root@localhost ~]# wget http://ftp.cuhk.edu.hk/pub/packages/perl/CPAN/authors/id/T/TI/TIMB/DBI-1.616.tar.gz  
  2. [root@localhost ~]# tar zxvf DBI-1.616.tar.gz  
  3. [root@localhost ~]# cd DBI-1.616  


   [root@localhost ~]# perl Makefile.PL 

  1. *** Your LANG environment variable is set to 'en_US.UTF-8'  
  2. *** This may cause problems for some perl installations.  
  3. *** If you get test failures, please try again with LANG unset.  
  4. *** If that then works, please email dbi-dev@perl.org with details  
  5. *** including the output of 'perl -V'  
  6.   
  7. *** You are using a perl configured with threading enabled.  
  8. *** You should be aware that using multiple threads is  
  9. *** not recommended for production environments.  
  10.   
  11. Your perl was compiled with gcc (version 4.1.2 20080704 (Red Hat 4.1.2-46)), okay.  
  12. Creating test wrappers for DBD::Gofer:  
  13. ....  
  14. Warning: prerequisite ExtUtils::MakeMaker 6.48 not found. We have 6.30.  
  15. Warning: prerequisite Test::Simple 0.90 not found. We have 0.62.  
  16.   
  17.     I see you're using perl 5.008008 on x86_64-linux-thread-multi, okay.  
  18.     Remember to actually *read* the README file!  
  19.     Use  'make' to build the software (dmake or nmake on Windows).  
  20.     Then 'make test' to execute self tests.  
  21.     Then 'make install' to install the DBI and then delete this working  
  22.     directory before unpacking and building any DBD::* drivers.  
  23.   
  24. Writing Makefile for DBI  

 
[root@localhost DBI-1.616]# make

  1. /usr/bin/perl "-MExtUtils::Command" -e mkpath blib/lib/DBI  
  2. rm -f blib/lib/DBI/Changes.pm  
  3. cp Changes blib/lib/DBI/Changes.pm  
  4. cp Driver_xst.h blib/arch/auto/DBI/Driver_xst.h  
  5. cp lib/DBD/Proxy.pm blib/lib/DBD/Proxy.pm  
  6. cp lib/DBI/Gofer/Response.pm blib/lib/DBI/Gofer/Response.pm  
  7. cp lib/DBI/Util/_accessor.pm blib/lib/DBI/Util/_accessor.pm  
  8. cp lib/DBI/Gofer/Transport/Base.pm blib/lib/DBI/Gofer/Transport/Base.pm  
  9. ....  
  10. Manifying blib/man3/Win32::DBIODBC.3pm  
  11. Manifying blib/man3/DBI::DBD::SqlEngine.3pm  
  12. Manifying blib/man3/DBI::PurePerl.3pm  
  13. Manifying blib/man3/DBI::ProfileData.3pm  

 
 [root@localhost DBI-1.616]# make install

    1. Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/.packlist  
    2. Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod  


    3 安装data-showtable包 下载地址: 
    1. [root@localhost ~]# wget 
    2. [root@localhost ~]# tar zxvf Data-ShowTable-3.3.tar.gz  
    3. [root@localhost ~]# cd Data-ShowTable-3.3  
    1. [root@localhost Data-ShowTable-3.3]# perl Makefile.PL  
    1. Checking if your kit is complete...  
    2. Looks good  
    3. Writing Makefile for Data::ShowTable  
    1. [root@localhost Data-ShowTable-3.3]# make  
    1. cp ShowTable.pm blib/lib/Data/ShowTable.pm  
    2. cp showtable blib/script/showtable  
    3. /usr/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" blib/script/showtable  
    4. Manifying blib/man1/showtable.1  
    5. Manifying blib/man3/Data::ShowTable.3pm  
    6. *** ERROR: unterminated I<...> at line 724 in file ShowTable.pm  
    7. *** ERROR: unterminated I<...> at line 724 in file ShowTable.pm  
     
      make的时候报错了:
    1. *** ERROR: unterminated I<...> at line 724 in file ShowTable.pm  
    2. *** ERROR: unterminated I<...> at line 724 in file ShowTable.pm  
  1. 编辑一下ShowTable.pm 找到724行,修改
    1. I<\@title_formats  改为I<\@title_formats>  
    2. I<\@data_formats 改为I<\@data_formats>  
     重新make
     [root@localhost Data-ShowTable-3.3]# make 
    1. cp ShowTable.pm blib/lib/Data/ShowTable.pm  
    2. Manifying blib/man3/Data::ShowTable.3pm  
    1. [root@localhost Data-ShowTable-3.3]# make install  
    1. Installing /usr/lib/perl5/site_perl/5.8.8/Data/ShowTable.pm  
    2. Installing /usr/share/man/man1/showtable.1  
    3. Installing /usr/share/man/man3/Data::ShowTable.3pm  
    4. Installing /usr/bin/showtable  
    5. Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Data/ShowTable/.packlist  
    6. Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod  


    4.安装msql-mysql-modules 下载地址: 
  1. [root@localhost ~]# wget 
  2. [root@localhost ~]# tar zxvf Msql-Mysql-modules-1.2219.tar.gz  
  3. [root@localhost ~]# cd Msql-Mysql-modules-1.2219  
  1. [root@localhost Msql-Mysql-modules-1.2219]# perl Makefile.PL  
  1. Which drivers do you want to install?  
  2.   
  3.     1)  MySQL only  
  4.     2)  mSQL only (either of mSQL 1 or mSQL 2)  
  5.     3)  MySQL and mSQL (either of mSQL 1 or mSQL 2)  
  6.   
  7.     4)  mSQL 1 and mSQL 2  
  8.     5)  MySQL, mSQL 1 and mSQL 2  
  9.   
  10. Enter the appropriate number:  [3] 1  
  11.   
  12.   
  13. Do you want to install the MysqlPerl emulation? You might keep your old  
  14. Mysql module (to be distinguished from DBD::mysql!) if you are concerned  
  15. about compatibility to existing applications! [n] n  
  16. Where is your MySQL installed? Please tell me the directory that  
  17. contains the subdir 'include'. [/usr/local/mysql]   
  18. Which database should I use for testing the MySQL drivers? [test]   
  19. On which host is database test running (hostname, ip address  
  20. or host:port) [localhost]   
  21. User name for connecting to database test? [undef] root  
  22. Password for connecting to database test? [undef] rootpassword  
  23. Creating files for MySQL ....................  
  24. WARNING: PL_FILES takes a hash reference not a array reference.  
  25.          Please inform the author.  
  26. Checking if your kit is complete...  
  27. Looks good  
  28. Note (probably harmless): No library found for -lgz  
  29. Using DBI 1.616 (for perl 5.008008 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/  
  30. Writing Makefile for DBD::mysql  
  31. Writing Makefile for Msql-Mysql-modules  

 [root@localhost Msql-Mysql-modules-1.2219]# make 

  1. /usr/bin/pod2text mysql/lib/DBD/mysql.pm >README  
  2. /usr/bin/perl -Iblib/arch -Iblib/lib -I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi \  
  3.                 -I/usr/lib/perl5/5.8.8 -Ilib -MExtUtils::PerlPP \  
  4.                 -e ppp "dbd/dbimon.in" "dbimon" "lib/DBD/mysql/Install/Config.pm"  
  5. make[1]: Entering directory `/home/zengxiong/maatkit/Msql-Mysql-modules-1.2219/mysql'  
  6. cp lib/DBD/mysql.pm ../blib/lib/DBD/mysql.pm  
  7. cp lib/Mysql.pm ../blib/lib/Mysql.pm  
  8. ....  
  9. mysql.xs: In function ‘XS_DBD__mysql__db__ListDBs’:  
  10. mysql.xs:250: warning: passing argument 3 of ‘mysql_dr_error’ discards qualifiers from pointer target type  
  11. mysql.xs: In function ‘XS_DBD__mysql__db__ListTables’:  
  12. mysql.xs:271: warning: passing argument 3 of ‘mysql_dr_error’ discards qualifiers from pointer target type  
  13. make[1]: *** [mysql.o] Error 1  
  14. make[1]: Leaving directory `/home/zengxiong/maatkit/Msql-Mysql-modules-1.2219/mysql'  
  15. make: *** [subdirs] Error 2  

  make的时候报错了:

  1. make[1]: *** [mysql.o] Error 1  
  2. make[1]: Leaving directory `/root/Msql-Mysql-modules-1.2219/mysql'  
  3. make: *** [subdirs] Error 2  

  第5步在执行到make的时候会在目录下生成mysql.o文件,cp /home/maatkit/DBD-mysql-4.019/mysql.o /home/maatkit/Msql-Mysql-modules-1.2219/mysql/
  后,重新make一下就不会报错了。(Msql-Mysql-modules其实只是包含DBD:Msql和DBD:mysql??)

 [root@localhost Msql-Mysql-modules-1.2219]# make 

  1. make[1]: Entering directory `/home/zengxiong/maatkit2/Msql-Mysql-modules-1.2219/mysql'  
  2. Running Mkbootstrap for DBD::mysql ()  
  3. chmod 644 mysql.bs  
  4. rm -f ../blib/arch/auto/DBD/mysql/mysql.so  
  5. gcc  -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic dbdimp.o mysql.o -L/usr/local/mysql/lib/mysql  -o ../blib/arch/auto/DBD/mysql/mysql.so     \  
  6.            -L/usr/local/mysql/lib/mysql -lmysqlclient -lm -lz -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 -lgcc    \  
  7.             
  8. chmod 755 ../blib/arch/auto/DBD/mysql/mysql.so  
  9. cp mysql.bs ../blib/arch/auto/DBD/mysql/mysql.bs  
  10. chmod 644 ../blib/arch/auto/DBD/mysql/mysql.bs  
  11. Manifying ../blib/man3/DBD::mysql.3pm  
  12. Manifying ../blib/man3/Mysql.3pm  
  13. Manifying ../blib/man3/Bundle::DBD::mysql.3pm  
  14. make[1]: Leaving directory `/root/Msql-Mysql-modules-1.2219/mysql'  
  15. cp dbimon blib/script/dbimon  
  16. /usr/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" blib/script/dbimon  
  17. Manifying blib/man1/dbimon.1  
  1. [root@localhost Msql-Mysql-modules-1.2219]# make install  
  1. make[1]: Entering directory `/root/Msql-Mysql-modules-1.2219/mysql'  
  2. make[1]: Leaving directory `/root/Msql-Mysql-modules-1.2219/mysql'  
  3. Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/mysql/mysql.so  
  4. Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/mysql/mysql.bs  
  5. Files found in blib/arch: installing files in blib/lib into architecture dependent library tree  
  6. Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Mysql.pm  
  7. Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Mysql/Statement.pm  
  8. Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/DBD/mysql.pm  
  9. Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Bundle/DBD/mysql.pm  
  10. Installing /usr/share/man/man1/dbimon.1  
  11. Installing /usr/share/man/man3/DBD::mysql.3pm  
  12. Installing /usr/share/man/man3/Mysql.3pm  
  13. Installing /usr/share/man/man3/Bundle::DBD::mysql.3pm  
  14. Installing /usr/bin/dbimon  
  15. Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Msql-Mysql-modules/.packlist  
  16. Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod 

5.安装DBD-mysql 下载地址: 

  1. [root@localhost ~]# wget 
  2. [root@localhost ~]# tar zxvf DBD-mysql-4.019.tar.gz  
  3. [root@localhost ~]# cd DBD-mysql-4.019 
  1. [root@localhost DBD-mysql-4.019]# perl Makefile.PL --mysql_config=/usr/bin/mysql_config  
  1. PLEASE NOTE:  
  2.   
  3. For 'make test' to run properly, you must ensure that the database user 'root' can connect to your MySQL server and has the proper privileges that these tests require such as 'drop table', 'create table', 'drop procedure', 'create procedure' as well as others.   
  4.   
  5. mysql> grant all privileges on test.* to 'root'@'localhost' identified by 's3kr1t';  
  6.   
  7. You can also optionally set the user to run 'make test' with:  
  8.   
  9. perl Makefile.PL --testuser=username  
  10.   
  11. I will use the following settings for compiling and testing:  
  12.   
  13.   cflags        (mysql_config) = -I/usr/include/mysql  -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv  
  14.   embedded      (mysql_config) =  
  15.   libs          (mysql_config) = -rdynamic -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib64 -lssl -lcrypto  
  16.   mysql_config  (Users choice) = /usr/bin/mysql_config  
  17.   nocatchstderr (default     ) = 0  
  18.   nofoundrows   (default     ) = 0  
  19.   ssl           (guessed     ) = 1  
  20.   testdb        (default     ) = test  
  21.   testhost      (default     ) =  
  22.   testpassword  (default     ) =  
  23.   testsocket    (default     ) =  
  24.   testuser      (guessed     ) = root  
  25.   
  26. To change these settings, see 'perl Makefile.PL --help' and  
  27. 'perldoc INSTALL'.  
  28.   
  29. Checking if your kit is complete...  
  30. Looks good  
  31. Unrecognized argument in LIBS ignored: '-rdynamic'  
  32. Multiple copies of Driver.xst found in: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/ /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/ at Makefile.PL line 914  
  33. Using DBI 1.616 (for perl 5.008008 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/  
  34. Writing Makefile for DBD::mysql 
  1. [root@localhost DBD-mysql-4.019]# make  
  1. cp lib/DBD/mysql.pm blib/lib/DBD/mysql.pm  
  2. cp lib/DBD/mysql/GetInfo.pm blib/lib/DBD/mysql/GetInfo.pm  
  3. cp lib/DBD/mysql/INSTALL.pod blib/lib/DBD/mysql/INSTALL.pod  
  4. cp lib/Bundle/DBD/mysql.pm blib/lib/Bundle/DBD/mysql.pm  
  5. ....  
  6. chmod 755 blib/arch/auto/DBD/mysql/mysql.so  
  7. cp mysql.bs blib/arch/auto/DBD/mysql/mysql.bs  
  8. chmod 644 blib/arch/auto/DBD/mysql/mysql.bs  
  9. Manifying blib/man3/DBD::mysql.3pm  
  10. Manifying blib/man3/DBD::mysql::INSTALL.3pm  
  11. Manifying blib/man3/Bundle::DBD::mysql.3pm  
  1. [root@localhost DBD-mysql-4.019]# make test  
  1. PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t  
  2. t/00base....................ok 1/6                                             
  3. #   Failed test 'use DBD::mysql;'  
  4. #   in t/00base.t at line 21.  
  5. #     Tried to use 'DBD::mysql'.  
  6. #     Error:  Can't load '/home/zengxiong/maatkit/DBD-mysql-4.020/blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: libmysqlclient.so.16: cannot open shared object file: No such file or directory at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/DynaLoader.pm line 230.  
  7. #  at (eval 6) line 2  
  8. # Compilation failed in require at (eval 6) line 2.  
  9. # BEGIN failed--compilation aborted at t/00base.t line 21.  
  10. t/00base....................NOK 2FAILED--Further testing stopped: Unable to load DBD::mysql  
  11. make: *** [test_dynamic] Error 9  

  make test出错了,如果报错像上面一样,那么就执行

  1. [root@localhost DBD-mysql-4.019]# cp /usr/local/mysql/lib/*so* /usr/lib  
  1. [root@localhost DBD-mysql-4.019]# cp /usr/local/mysql/lib/*so* /usr/lib64/(如果64位 否则是lib)  

  如果上面这一步没做,则到安装maatkit的时候,在perl Makefile.PL会出现警告:prerequisite DBD::mysql 1 not found.


    1. Checking if your kit is complete...  
    2. Looks good  
    3. Warning: prerequisite DBD::mysql 1 not found.  
    4. Writing Makefile for maatkit
     

     [root@localhost DBD-mysql-4.019]# make test 



    1. PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t  
    2. t/00base....................ok                                                 
    3. t/10connect.................skipped  
    4.         all skipped: ERROR: Access denied for user 'root'@'localhost' (using password: NO) Can't continue test  
    5. t/20createdrop..............skipped  
    6.         all skipped: ERROR: Access denied for user 'root'@'localhost' (using password: NO). Can't continue test  
    7. t/25lockunlock..............skipped  
    8. ....  
    9.         all skipped: ERROR: Access denied for user 'root'@'localhost' (using password: NO). Can't continue test  
    10. t/86_bug_36972..............skipped  
    11.         all skipped: ERROR: DBI connect('test','root',...) failed: Access denied for user 'root'@'localhost' (using password: NO) at t/86_bug_36972.t line 14  
    12. All tests successful, 39 tests skipped.  
    13. Files=40, Tests=6,  3 wallclock secs ( 2.08 cusr +  0.30 csys =  2.38 CPU)  
      
     
    1. [root@localhost DBD-mysql-4.019]# make  
    2. [root@localhost DBD-mysql-4.019]# make install
      1. Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/mysql/mysql.so  
      2. Files found in blib/arch: installing files in blib/lib into architecture dependent library tree  
      3. Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/DBD/mysql.pm  
      4. Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/DBD/mysql/GetInfo.pm  
      5. Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/DBD/mysql/INSTALL.pod  
      6. Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Bundle/DBD/mysql.pm  
      7. Installing /usr/share/man/man3/DBD::mysql::INSTALL.3pm  
      8. Installing /usr/share/man/man3/DBD::mysql.3pm  
      9. Installing /usr/share/man/man3/Bundle::DBD::mysql.3pm  
      10. Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/mysql/.packlist  
      11. Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod  

6.安装maatkit 下载地址:  

    1. [root@localhost ~]# wget 
    2. [root@localhost ~]# tar zxvf maatkit-7486.tar.gz  
    3. [root@localhost ~]# cd maatkit-7486  
     
    1. [root@localhost maatkit-7486]# perl Makefile.PL  
    2. Checking if your kit is complete...  
    3. Looks good  
    4. Writing Makefile for maatkit  
    5. [root@localhost maatkit-7486]# make install  
    6. cp maatkit.pod blib/lib/maatkit.pod  
    7. cp bin/mk-slave-move blib/script/mk-slave-move  
    8. ....  
    9. Installing /usr/bin/mk-config-diff  
    10. Installing /usr/bin/mk-archiver  
    11. Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/maatkit/.packlist  
    12. Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod  
    安装的工具如下在/usr/bin 下:mk-%
     
阅读(7028) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~