您的位置:首页 > 数据库 > SQL

mysql监控管理工具--innotop

2013-02-25 16:21 453 查看
author:skate

time:2013/02/25

mysql监控管理工具--innotop



INNOTOP是一个通过文本模式显示MySQL和InnoDB的监测工具。INNOTOP是用PERL语言写成的,这使它能更加灵活的使用在各种操作平台之上,它能详细的的监控出当前MYSQL和INNODB运行的状态,以DBA根据结果,可以合理的优化MYSQL,让MYSQL更稳定更高效的运行。

1.innotop安装

参考官网:http://innotop.googlecode.com/svn/html/installing.html

# wget http://innotop.googlecode.com/files/innotop-1.9.0.tar.gz

# tar -zxvf innotop-1.9.0.tar.gz

# cd innotop-1.9.0

安装INNOTOP工具非常简单,其是由PERL写的,当然需要PERL环境和相关的工具包。在安装之前先要确定你的系统安装了Time::HiRes,Term::ReadKey,DBI,DBD::mysql这四个包

# perl -MCPAN -eshell

CPAN> install Time::HiRes

CPAN> install Term::ReadKey

CPAN> install DBI

CPAN> install DBD::mysql



在解压缩后的源码路径下有安装帮助文件,如下:

# perl Makefile.PL

如果没有报错,然后,使用

# make install

这样就安装 innotop,安装之后系统就会多出一个命令,innotop

得到帮助

# innptop --help

2.使用方法

参考官网:http://innotop.googlecode.com/svn/html/manual.html

使用方法:

# innotop -uroot -proot -h127.0.0.1

[root@racdb2 innotop-1.9.0]# innotop -uroot -proot -h127.0.0.1

[RO] Dashboard (? for help) 127.0.0.1, 3h, 0.06 QPS, 2/1/0 con/run/cac thds, 5.1.67-log

Uptime MaxSQL ReplLag Cxns Lock QPS QPS Run Run Tbls Repl SQL

3h 2 0 0.06 13 Off

输入“?”得到帮助

Switch to a different mode:

A Dashboard I InnoDB I/O Info Q Query List

B InnoDB Buffers K InnoDB Lock Waits R InnoDB Row Ops

C Command Summary L Locks S Variables & Status

D InnoDB Deadlocks M Replication Status T InnoDB Txns

F InnoDB FK Err O Open Tables U User Statistics

Actions:

d Change refresh interval p Pause innotop

k Kill a query's connection q Quit innotop

n Switch to the next connection x Kill a query

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监控mysql,例如可以看当前正在运行的sql,并查看执行计划,如下:

进入innotop时,按shift+q进入sql查询列表,

When Load Cxns QPS Slow Se/In/Up/De% QCacheHit KCacheHit BpsIn BpsOut

Now 0.10 2 0.46 0 0/ 0/ 0/ 0 0.00% 100.00% 19.79 1.11k

Total 0.00 151 0.08 5 2/ 0/ 0/ 0 4.17% 100.00% 3.29 223.67

Cmd ID State User Host DB Time Query

Query 1 Sending data root localhost test 03:20 insert into user select * from user

Query 21 Locked root localhost test 00:04 insert into user select * from user

Select a thread to analyze: 21

然后按e并输入thread ID显示执行计划或者按f显示完整sql语句,或者按o显示系统优化过的语句(需要MySQL的版本支持EXPLAIN EXTENDED)

EXPLAIN PARTITIONS

select * from user

____ Sub-Part 1 _____

Select Type: SIMPLE

Table: user

Partitions:

Type: ALL

Poss. Keys:

Index:

Key Length:

Index Ref:

Row Count: 41943040

Special:

[This query has been re-written to be explainable]

Press e to explain, f for full query, o for optimized query

innotop是通过information_schema.processlist来获得完整的sql语句,并且根据COMMAND来过滤掉空闲线程的



---end---
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: