mysql監控管理工具--innotop
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
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
[[email protected] 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---