mysql監控管理工具--innotop

author:skate
time:2013/02/25html

mysql監控管理工具--innotopmysql

 

INNOTOP是一個經過文本模式顯示MySQL和InnoDB的監測工具。INNOTOP是用PERL語言寫成的,這使它能更加靈活的使用在各類操做平臺之上,它能詳細的的監控出當前MYSQL和INNODB運行的狀態,以DBA根據結果,能夠合理的優化MYSQL,讓MYSQL更穩定更高效的運行。sql


1.innotop安裝
參考官網:http://innotop.googlecode.com/svn/html/installing.htmlshell

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

安裝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優化

 

在解壓縮後的源碼路徑下有安裝幫助文件,以下:ui

# perl Makefile.PLgoogle

若是沒有報錯,而後,使用
# make installspa

這樣就安裝 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---

相關文章
相關標籤/搜索