发布新日志

  • mysqldumpslow使用

    2009-09-17 16:54:27

    在安装好的MYSQL配置文件中加入以下二行参数,配置文件位置在MYSQL目录下,与bin文件同级,文件名为my.ini:
    log-slow-queries=D:\Test\slowquery.log
    long_query_time=3
    表示超过3秒的操作就会被当作为慢查询而写入日志,可以根据实际情况进行修改。
    然后重启MYSQL,接下来会在D盘下生成一个名为Test slowquery.log的日志文件,可能因为操作系统的原因吧,这个工具一般是用在LINUX下的,没有在Test的文件夹下产生这个日志文件。
    windows下安装的MYSQL没有带mysqldumpslow,所以无法在windows下分析生成的log文件。
    但可以把产生的日志文件放到LINUX下的MYSQL进行分析,可在命令行下用如下命令(进入到mysql/bin目录下,把windows下产生的日志文件Test slowquery.log重命名为slowquery.log,放至mysql/bin目录下):
    mysqldumpslow slowquery.log
    则可以看到分析的内容。
  • 一款开源的监控MYSQL性能的工具—INNOTOP(转载)

    2009-08-19 11:28:50

    INNOTOP是一个通过文本模式显示MySQL和InnoDB的监测工具。它有很多特点,快速的配置的,易于使用等。它吸取了MYTOP的精华这使它变得更加强大。INNOTOP是用PERL语言写成的,这是它能更加灵活的使用在各种操作平台之上,它能详细的的监控出当前MYSQL和INNODB运行的状态,以便维护人员根据结果合理的优化MYSQL,让MYSQL更稳定更高效的运行。

    安装INNOTOP工具非常的简单,既然是由PERL写的,当然需要PERL环境和相关的工具包。

    在安装之前先要确定你的系统安装了Time::HiRes,Term::ReadKey,DBI,DBD::mysql这四个包。安装可以把包下载下来通过编译安装完成也可以用PERL模块安装方式来完成。

    安装Time::HiRes,Term::ReadKey,DBI,DBD::mysql库文件

    通过PERL模块来安装

    [root@web1477 local]# perl -MCPAN -eshell

    CPAN> install Time::HiRes

    CPAN> install Term::ReadKey

    CPAN> install DBI

    CPAN> install DBD::mysql

    通过编译来安装

    [root@web1477 tmp]# tar zxvf Time-HiRes-01.20.tar

    [root@web1477 tmp]# cd Time-HiRes-01.20

    [root@web1477 Time-HiRes-01.20]# perl Makefile.PL

    [root@web1477 Time-HiRes-01.20]# make

    [root@web1477 Time-HiRes-01.20]# make install

    其他三个库文件也如法炮制。环境安装好了就可以开始安装INNOTOP软件了。

    [root@web1477 local]# tar zxvf innotop-1.6.0.tar.gz

    [root@web1477 local]# ln -s innotop-1.6.0/ innotop

    [root@web1477 local]# cd innotop

    [root@web1477 innotop]# perl Makefile.PL

    Checking if your kit is complete…

    Looks good

    Writing Makefile for innotop

    [root@web1477 innotop]# make

    cp InnoDBParser.pm blib/lib/InnoDBParser.pm

    cp innotop blib/script/innotop

    /usr/bin/perl “-MExtUtils::MY” -e “MY->fixin(shift)” blib/script/innotop

    Manifying blib/man1/innotop.1

    Manifying blib/man3/InnoDBParser.3

    [root@web1477 innotop]# make install

    Installing /usr/lib/perl5/5.8.8/html/site/lib/InnoDBParser.html

    Installing /usr/lib/perl5/5.8.8/html/bin/innotop.html

    Installing /usr/lib/perl5/5.8.8/site/lib/InnoDBParser.pm

    Installing /usr/lib/perl5/5.8.8/site/man/man1/innotop.1

    Installing /usr/lib/perl5/5.8.8/site/man/man3/InnoDBParser.3

    Installing /usr/lib/perl5/5.8.8/site/bin/innotop

    Appending installation info to /usr/lib/perl5/5.8.8/lib/perllocal.pod

    [root@web1477 innotop]#

    安装完成了,下面就是要开始设置它

    [root@web1477 innotop]# ./innotp

    You have not defined any database connections.

    Choose a name for the connection.  It cannot contain whitespace, colons or semicolons.

    Enter a name: localhost

    Typical DSN strings look like

       DBI:mysql:;host=hostname;port=port

    The db and port are optional and can usually be omitted.

    If you specify ‘mysql_read_default_group=mysql’ many options can be read

    from your mysql options files (~/.my.cnf, /etc/my.cnf).

    Enter a DSN string: DBI:mysql:;mysql_read_default_group=mysql;host=localhost

      Optional: enter a table (must not exist) to use when resetting InnoDB deadlock information: test.innotop_dl 

      Do you want to specify a username for localhost?: y

      Do you want to specify a password for localhost?: y

      Enter username for localhost: root

    Enter password for ‘root’ on localhost:

    Save password in plain text in the config file?: y

    完成这些INNOTOP就可以开始工作了。

    # ./innotop

    uery List (? for help)                                                         localhost, 23+12:35:18, 0.30 QPS, 22 thd, 5.0.45-log

     

    CXN        When   Load  QPS     Slow    QCacheHit  KCacheHit  BpsIn   BpsOut

    localhost  Now    0.73    0.30   0          0.00%    100.00%    9.47    1.41k

    localhost  Total  0.00  329.49  11.50k     67.13%     99.86%  486.35  774.07

     

    CXN     Cmd    ID      User   Host           DB      Time   Query

    INNOTOP查看各种监控状态的命令

    Switch to a different mode:

       B  InnoDB Buffers    I  InnoDB I/O Info     Q  Query List

       C  Command Summary   L  Locks               R  InnoDB Row Ops

       D  InnoDB Deadlocks  M  Replication Status  S  Variables & Status

       F  InnoDB FK Err     O  Open Tables         T  InnoDB Txns

    Actions:

       d  Change refresh interval            p  Pause innotop

       i  Toggle incremental status display  q  Quit innotop

       n  Switch to the next connection     

    Other:

     TAB  Switch to the next server group   /  Quickly filter what you see

       !  Show license and warranty         =  Toggle aggregation

       #  Select/create server groups       @  Select/create server connections

       $  Edit configuration settings       \  Clear quick-filters

    Press any key to continue

    如何获得INNOTOP软件呢?

    你可以到http://innotop.sourceforge.net/去下载,因为GW屏蔽了国外某些站点,但是可以通过其他的代理连接上去下载。另外你可以通过

    wget http://nchc.dl.sourceforge.net/sourceforge/innotop/innotop-1.6.0.tar.gz直接下载该软件。

Open Toolbar