innotop監控mysql

來源:互聯網
上載者:User

標籤:線程   memory   其他   dead   header   top   sql語句   ever   statistic   

InnoTop

是一個系統活動報告,類似於Linux效能工具,它與Linux的top命令相仿,並參考mytop工具而設計.

它專門用後監控InnoDB效能和MySQL伺服器.主要用於監控事務,死結,外鍵,查詢活動,複製活動,系統變數的主要統計資訊
及主機的其他詳情。InnoTop被廣泛使用,並被當做常用效能監控工具。

由於InnoTop使用Perl語言寫成,所以需要安裝perl環境和相關的工具包。

安裝perl:

yum install perl* -y


必須安裝Time::HiRes,Term::ReadKey,DBI,DBD::mysql這四個包

[[email protected] data]# perl -MCPAN -eshell

CPAN> install Time::HiRes
 cd
CPAN> install Term::ReadKey
 
CPAN> install DBI
 
CPAN> install DBD::mysql

一.下載安裝innotop-1.8

[[email protected] data]# wget http://innotop.googlecode.com/files/innotop-1.8.0.tar.gz

[[email protected] data]# tar xvzf innotop-1.8.0.tar.gz 

[[email protected] data]# cd innotop-1.8.0

[[email protected] data]# perl Makefile.PL 

[[email protected] data]# make

[[email protected] data]# make install

二.使用 

innotop -u <username> -p <password> -h <hostname> -P <port> -S <socket>

樣本: innotop -usystem  -p‘HD_root2010!‘ -P 3306 -S /data/mysqldata/3306/mysql.sock

以下是進入的頁面狀態

When   Load  QPS   Slow   Se/In/Up/De%       QCacheHit  KCacheHit  BpsIn   BpsOut 
Now    0.05  0.19  0       0/ 0/550/50           0.00%     92.31%  32.67k    1.18k
Total  0.00  0.36  1.24k  20/3838/1473/3297      0.00%     93.88%  36.83k  284.40k

Cmd    ID      State  User   Host           DB      Time   Query

其中 Load 是負載
     QPS  (Query Per Second) 表示每秒的查詢率
     Slow 代錶慢查詢的個數
     Se/In/Up/De%: 增,刪,改,查的比率
     QCacheHit:查詢緩衝的命中率
     KCacheHit:索引的命中率
     BpsIn (bytes Per Second in) 每秒鐘輸入的位元組數
     BpsOut(bytes Per Second Out)每秒鐘輸出的位元組數
    

輸入?可以進入協助介面:如下:

Switch to a different mode:
   B  InnoDB Buffers    L  Locks               R  InnoDB Row Ops
   C  Command Summary   M  Replication Status  S  Variables & Status
   D  InnoDB Deadlocks  O  Open Tables         T  InnoDB Txns
   F  InnoDB FK Err     Q  Query List          U  User Statistics
   I  InnoDB I/O Info                          

Actions:
   a  Toggle the innotop process    k  Kill a query‘s connection
   c  Choose visible columns        n  Switch to the next connection
   d  Change refresh interval       p  Pause innotop
   e  Explain a thread‘s query      q  Quit innotop
   f  Show a thread‘s full query    r  Reverse sort order
   h  Toggle the header on and off  s  Change the display‘s sort column
   i  Toggle idle processes         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

各種模式的切換都是:shift+字母

B模式:InnoDB Buffers

____________________________ Buffer Pool ____________________________
Size     Free Bufs  Pages   Dirty Pages  Hit Rate  Memory  Add‘l Pool
512.00k      17863  495843            0  --         8.19G           0

_____________________ Page Statistics ______________________
Reads   Writes   Created  Reads/Sec  Writes/Sec  Creates/Sec
443950  5953289    51893       0.00        0.00         0.00

______________________ Insert Buffers ______________________
Inserts  Merged Recs  Merges  Size  Free List Len  Seg. Size
                                                            

_________________ Adaptive Hash Index __________________
Size  Cells Used  Node Heap Bufs  Hash/Sec  Non-Hash/Sec
                                      0.00          0.00

其中:
Buffer Pool:
Size: 某sql使用的Buffer pool的大小
Free Bufs : Innodb_buffer_pool_pages_free的值,空頁數。
Pages:      Innodb_buffer_pool_pages_data的值,包含資料的頁數(髒或乾淨).
Dirty Pages: Innodb_buffer_pool_pages_dirty的值,當前的髒頁數
Hit Rate:    命中率
Memory  :    Innodb_buffer_pool_size的值
Add‘l Pool: Innodb_additional_mem_pool_size的值

Page Statisics(頁面統計)
Reads: Innodb_pages_read的值,讀取的頁數
Writes:Innodb_pages_written的值,寫入的頁數
Created:Innodb_pages_created的值,建立的頁數


C模式:Command Summary (show Global status)
顯示的值按降序排序,變數必須是數字,先按S再輸入相關的參數的首碼名:

按s建:輸入innodb 則:

D模式:InnoDB Deadlocks(產生的死結,和產生死結的語句)

____________________________________________________________________________________ Deadlock Transactions ____________________________________________________________________________________
ID         Timestring           User       Host  Victim  Time   Undo  LStrcts  Query Text                                                                                                      
182513696  2012-11-15 15:39:30  apps_oper  192   No      00:00   215        9  insert into category_doc_info (category_id,doc_title,category_show,category_Coordinate) values(23692,‘1941‘,1,2)
182519005  2012-11-15 15:39:30  apps_oper  192   Yes     00:00     0        4  delete from category_doc_info where (category_id = 23692)                                                       

______________________________________ Deadlock Locks ______________________________________
ID         Waiting  Mode  DB    Table              Index         Special          Ins Intent
182513696        0  X     apps  category_doc_info  INDEX_SEARCH  rec but not gap           0
182513696        1  S     apps  category_doc_info  INDEX_SEARCH                            0
182519005        1  X     apps  category_doc_info  INDEX_SEARCH  rec but not gap           0


其中
ID:連接線程ID號
Timestring: 死結發生的時間
User:使用者名稱
Host:主機


M模式:Replication Status(查看複製狀態的資訊)

I模式: InnoDB I/O Info (查看InnoDB對應的I/O的資訊)

O模式: 查看開啟的表

Q模式(非常管用的一項):

然後e輸入thread ID顯示執行計畫或者按F顯示完整的sql語句。

innotop監控mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.