InnoDB Adaptive Hash Index
InnoDB Buffer Pool Activity
InnoDB Buffer Pool
InnoDB Checkpoint Age
InnoDB Current Lock Waits
InnoDB I/O
InnoDB I/O Pending
InnoDB Insert Buffer
InnoDB Insert Buffer Usage
InnoDB Internal Hash Memory Usage
InnoDB Lock Structures
InnoDB Log
InnoDB Memory Allocation
InnoDB Row Lock Time
InnoDB Row Lock Waits
InnoDB Row Operations
InnoDB Semaphores Wait Time
InnoDB Semaphores Waits
InnoDB Semaphores
InnoDB Tables In Use
InnoDB Transactions Active/Locked
InnoDB Transactions
MyISAM Indexs
MyISAM Key Cache
MySQL Binary/Relay Logs
MySQL Command Counts
MySQL Connections
MySQL Files and Tables
MySQL Handler
MySQL Network Traffic
MySQL Processlist
MySQL Query Cache
MySQL Query Cache Memory
MySQL Query Response Time (Microseconds)
MySQL Query Time Histogram(Count)
MySQL Replication
MySQL Select Types
MySQL Sorts
MySQL Table Locks
MySQL Temporary Objects
MySQL Threads
MySQL Transaction Handler
InnoDB Adaptive Hash Index
顯示了“自適應哈希索引”的使用情況,哈希索引只能用來搜索等值的查詢.
# Hash table size 17700827, node heap has 35112 buffer(s)
# 3577.42 hash searches/s, 507.49 non-hash searches/s
Hash Index Cells Total
自適應哈希表的槽數=innodb_buffer_pool_size/256
Hash Index Cells Used
用到自適應哈希表的查詢個數
InnoDB Buffer Pool Activity
顯示Innodb緩衝池的內部活動,頁的創建,讀取,寫入.如果有突然的增加或者減少,需要檢查應用
Pages Created
Pages Read
Pages Written
InnoDB Buffer Pool
Pool Size
InnoDB緩衝池的頁數量,每頁大小16K
Database Pages
數據頁大小
Free Pages
空閒頁大小
Modified Pages
"髒"數據頁.如果髒數據頁太多,則需要檢查磁盤IO狀態.
InnoDB Checkpoint Age
Uncheckpointed Bytes
顯示了未寫入磁盤的數據量.如果該值的大小接近innodb_log_file_size * n 的總大小,則需要增加innodb_log_file_size的值,但是要注意,如果發生宕機,則需要更長的回覆時間.(從redolog恢復)
InnoDB Current Lock Waits
InnoDB Lock Wait Secs
顯示每秒處於鎖等待的innodb事務總數.如果有一個非常大的值,應該檢查LOCK WAIT transactions,請看下面的模板
InnoDB I/O
File Reads
顯示每秒文件的讀次數
File Writes
顯示每秒文件的寫次數
Log Writes
寫日誌的次數
File Fsyncs
調用fsync()函數的次數.與innodb_flush_log_at_trx_commit值的設置有關.
InnoDB I/O Pending
顯示了InnoDB掛起的同步或異步IO操作.如果掛起的操作太多,則需要更大的RAM,更大的緩衝池,更快的磁盤.
Pending Aio Log Ios
Pending Aio Sync Ios
Pending Buf Pool Flushes
Pending Chkp Writes
Pending Ibuf Aio Reads
Pending Log Flushe
Pending Log Writes
Pending Normal Aio Reads
Pending Normal Aio Writes
InnoDB Insert Buffer
插入緩衝,並不是緩存的一部分,而是物理頁,對於非聚集索引的插入或更新操作,不是每一次直接插入索引頁.而是先判斷插入的非聚集索引頁是否在緩衝池中.如果在,則直接插入,如果不再,則先放入一個插入緩衝區中.然後再以一定的頻率執行插入緩衝和非聚集索引頁子節點的合併操作.
使用條件:非聚集索引,非唯一
Ibuf Inserts
插入的記錄數
Ibuf Merged
合併的頁的數量
Ibuf Merges
合併的次數
如果merges/merged的值等於3/1,則代表插入緩衝對於非聚集索引頁的IO請求大約降低了3倍
InnoDB Insert Buffer Usage
Ibuf Cell Count
分段大小
Ibuf Used Cells
插入緩衝區的大小
Ibuf Free Cells
"自由列表"的長度
InnoDB Internal Hash Memory Usage
顯示了InnoDB內部各種哈希結構(不可人工干預),佔用的內存大小.
Adaptive Hash Memory
自適應哈希索引佔用的內存大小
Page Hash Memory
Dictionary Cache Memory
File System Memory
Lock System Memory
Recovery System Memory
Thread Hash Memory
InnoDB Lock Structures
InnoDB Lock Structs
該圖形顯示了在innodb內部有多少鎖結構(不是死鎖).這大致與當前事務鎖住的行數有關係.可以用來判斷是否存在鎖爭用.
對於數量多少算好或者算壞,沒有硬性的規定.實際情況下,大量的事務在等待鎖,很明顯,該值越小越好.
這個數據來源是SHOW ENGINE INNODB STATUS;
# 23 lock struct(s), heap size 3024, undo log entries 27
# LOCK WAIT 12 lock struct(s), heap size 3024, undo log entries 5
# LOCK WAIT 2 lock struct(s), heap size 368
InnoDB Log
相關變量:innodb_log_buffer_size
InnoDB Log Buffer Size
Log Bytes Written
Log sequence number
當前日誌的位置
Log Bytes Flushed
Log flushed up to
日誌已經刷新的位置
Unflushed Log
是log_bytes_written與log_bytes_flushed的差值,表示日誌緩存區裏還有多少數據沒被刷新到日誌文件裏.
如果這個差值超過了innodb_log_buffer_size設置的30%,則需要考慮是否加大該參數值.
InnoDB Memory Allocation
# Total memory allocated 8824815616; in additional pool allocated 0
Total Mem Alloc
InnoDB申請的總內存量,單位字節
Additional Pool Alloc
分配給額外內存的總量,單位字節
InnoDB Row Lock Time
InnoDB Row Lock Time
該模板讀取的Innodb_row_lock_time狀態變量,表示InnoDB引擎在每次申請數據行鎖定時等待的總時間(以毫秒爲單位).
InnoDB Row Lock Waits
InnoDB Row Lock Waits
讀取的Innodb_row_lock_waits狀態變量,表示InnoDB經過這麼長時間才獲得一個行鎖.(毫秒)
InnoDB Row Operations
# Number of rows inserted 50678311, updated 66425915, deleted 20605903, read 454561562
大致能表現InnoDB內部的操作
Row Read
Row Deleted
Row Updated
Row Inserted
InnoDB Semaphores Wait Time
InnoDB Sem Wait Time Ms
顯示當前正在等待互斥量的InnoDB線程的等待時間的總耗時(毫秒).
分析:
正常情況下,InnoDB Semaphores Wait Time和 InnoDB Semaphores Waits應該是空的.除非服務器運行着高併發的工作負載,它促使InnoDB採取讓操作系統等待的措施.信息位於SHOW ENGINE INNODB STATUS的SEMAPHORES片段.
相關php腳本代碼部分如下:
elseif (strpos($line, 'seconds the semaphore:') > 0) {
# --Thread 907205 has waited at handler/ha_innodb.cc line 7156 for 1.00 seconds the semaphore:
increment($results, 'innodb_sem_waits', 1);
increment($results, 'innodb_sem_wait_time_ms', to_int($row[9]) * 1000);
}
其中innodb_sem_waits的值是多少,表示有多少線程在等待,而innodb_sem_wait_time_ms表示所有線程等待的時間,默認單位是秒,在腳本中乘以1000,所以監控圖中的單位是毫秒.
應對這個問題
InnoDB採取多階段等待策略.首先,嘗試對鎖進行循環等待.如果經過了一個預設的循環等待週期(innodb_sync_spin_loops = 30,當前配置文件默認爲30次)之後還沒有成功,就會退到更昂貴更復雜的等待陣列裏,如果併發量太大的話,則導致系統負載突增.
循環等待的成本相對比較低,但是需要不停地檢查一個資源是否被鎖定,消耗CPU週期,也就是說,當另外一條線程能處理事情時,循環等待也會獨佔處理器.
循環等待的替換方案就是讓操作系統做上下文切換(等待陣列),每秒鐘幾千次的切換會引發大量的系統開銷.
解決辦法
根據具體的應用,調整參數;或者優化應用,減少併發.
InnoDB Semaphores Waits
InnoDB Sem Waits
顯示當前正在等待互斥量的InnoDB線程的數量.
InnoDB Semaphores
顯示innodb內部的信號活動狀態.
包括Mutex spin waits,RW-shared spins,RW-excl spins等各種信號量的數量總和.
Spin Rounds
InnoDB內部預設的互斥量信號數量
Spin Waits
InnoDB內部對鎖進行循環等待的數量(與innodb_sync_spin_loops參數有關)
Os Wait系統等待
事務退到操作系統的等待陣列的數量
在高併發的情況,會發現這個值有尖峯狀,不穩定.圖像主要顯示了,不合理的設計情況下,不同的連接類型之間的行鎖或互斥鎖的爭用.
InnoDB Tables In Use
# mysql tables in use 2, locked 2
InnoDB Tables In Use
所有事務用到的表的數量
InnoDB Locked Tables
所有事務鎖定的表的數量
InnoDB Transactions Active/Locked
該圖顯示了InnoDB事務的狀態數量.
Active Transactions
正在執行的事務數量
Locked Transactions
鎖住的事務數量
Current Transactions
當前的事務數量(包括not started,ACTIVE,...等各種狀態)
not started # 事務已經提交到磁盤
ACTIVE # 正在執行的事務
Read Views(待更新)
read views open inside InnoDB
InnoDB Transactions
顯示了InnoDB事務相關的信息
InnoDB Transactions
InnoDB內部的事務總數.由以下數值計算出:
Trx id counter 89F56195 # 當前事務ID,每創建一個新事務就會累加
Purge done for trx's n:o < 89F5609C undo n:o < 0 # InnoDB清除舊版本MVCC時所用的事務ID.這個ID之前的老版本數據已經清除.
該數值就是由當前事務ID減去清除舊數據的事務ID再由十六進制轉成十進制的值.(參考ss_get_mysql_stats.php腳本902行)
History List
歷史記錄的長度.位於InnoDB數據文件的撤銷空間裏的未清除事務的數目.當一個事務執行了更新並提交後,這個數字就會累加,當清除進程移除一箇舊版本數據時,它就會遞減.
MyISAM Indexs
顯示了在MyISAM索引上的讀寫情況
Key Reads Requests
從鍵緩存讀出索引塊的讀操作的次數
Key Reads
從磁盤讀出索引塊的讀操作次數
Key Write Requests
向鍵緩存寫一個索引塊的請求的個數
Key Writes
把索引塊寫入磁盤的寫操作的次數
MyISAM Key Cache
Key Buffer Size
鍵緩存大小
Key Buf Bytes Used
同Key_blocks_used變量
鍵緩存裏已經被使用的緩存塊的個數
Key Buf Bytes Unused
同Key_blocks_unused
鍵緩存裏尚未被使用過的緩存塊的個數
MySQL Binary/Relay Logs
Binlog Cache Use
保存在二進制日誌緩存裏的事務的個數
Binlog Cache Disk Use
超過binlog_cache_size設置的緩存大小,使用磁盤臨時文件的事務的個數
Binlog Log Space
二進制日誌的大小
Relay Log Space
中繼日誌的大小
如果Binlog Cache Disk Use/Binlog Cache Use的值較大,那麼應該嘗試增加binlog_cache_size的大小.但是,也不要期望改善過多,如果寫臨時文件的數量從每秒1個減少到每分鐘一個,這已經證明優化的足夠好了.沒必要耗費大量的內存,來處理binlog_cache_size中的事務.
MySQL Command Counts
命令計數器,顯示了MySQL(在過去1秒內)執行各種命令的次數
Questions
記錄了服務器收到的查詢和命令的總數.(Com_*變量的總數不一定相等.)
Com Select
Com Delete
Com Insert
Com Update
Com Replace
Com Load
Com Delete Multi
Com Insert Select
Com Update Multi
Com Replace Select
MySQL Connections
Max Connections
允許同時保持在打開狀態的客戶連接的最大個數
Max Used Connections
此前曾同時打開處於打開狀態的連接的最大個數
Aborted Clients
因客戶端沒有正確地關閉而被丟棄的連接的個數
Aborted Connects
試圖連接MySQL服務器但沒有成功的次數
Threads Connectd
現在正處於打開狀態的連接的個數
Connections
試圖連接MySQL服務器的嘗試次數
MySQL Files and Tables
Table Cache
Open Tables
當前處於打開狀態的數據表的個數.不包括TEMPORARY
Open Files
當前處於打開狀態的文件的個數,如果與open_files_limit接近,則應該加大open_files_limit的值.
Opened Tables
MySQL服務器已打開的數據表總數(包括顯式定義的臨時表).如果這個值很高,應該慎重考慮,是否加大數據表緩存(table_open_cache).
MySQL Handler
Handler_writer 向數據表裏插入一個數據行的請求的個數
Handler_update 對數據表裏的一個數據行進行修改的請求的個數
Handler_delete 從數據表刪除一個數據行的請求的個數
Handler_read_first 讀取索引中第一個索引項的請求的個數
Handler_read_key 根據一個索引值而讀取一個數據行的請求的個數
Handler_read_next 按索引順序讀取下一個數據行的請求的個數
Handler_read_prev 按索引逆序讀取前一個數據行的請求的個數
Handler_read_rnd 根據某個數據行的位置而讀取該數據行的請求的個數
Handler_read_rnd_next 讀取下一個數據行的請求的個數.如果這個數字很高,就說明有很多語句需要通過全表掃描才能完成或有很多查詢沒有使用適當的索引
MySQL Network Traffic
Bytes Send
發送字節數
Bytes Received
收到字節數
MySQL Processlist
http://dev.mysql.com/doc/refman/5.5/en/general-thread-states.html
State Closing Tables
The thread is flushing the changed table data to disk and closing the used tables. This should be a fast operation. If not, verify that you do not have a full disk and that the disk is not in very heavy use.
State Copying To Tmp Table
The server is copying to a temporary table in memory
State End
This occurs at the end but before the cleanup of ALTER TABLE, CREATE VIEW, DELETE, INSERT, SELECT, or UPDATE statements
State Freeing Items
The thread has executed a command. Some freeing of items done during this state involves the query cache. This state is usually followed by cleaning up
State Init
This occurs before the initialization of ALTER TABLE, DELETE, INSERT, SELECT, or UPDATE statements. Actions taken by the server in this state include flushing the binary log, the InnoDB log, and some query cache cleanup operations.
For the end state, the following operations could be happening:
Removing query cache entries after data in a table is changed
Writing an event to the binary log
Freeing memory buffers, including for blobs
State Locked
The query is locked by another query.
As of MySQL 5.5.3, this state was removed because it was equivalent to the Table lock state and no longer appears in SHOW PROCESSLIST output.
State Login
login
The initial state for a connection thread until the client has been authenticated successfully.
State Preparing
This state occurs during query optimization.
State Reading From Net
The server is reading a packet from the network.
State Sengding Data
The thread is reading and processing rows for a SELECT statement, and sending data to the client. Because operations occurring during this this state tend to perform large amounts of disk access (reads), it is often the longest-running state over the lifetime of a given query.
State Sorting Result
For a SELECT statement, this is similar to Creating sort index, but for nontemporary tables
State Statistics
The server is calculating statistics to develop a query execution plan. If a thread is in this state for a long time, the server is probably disk-bound performing other work.
State Updating
The thread is searching for rows to update and is updating them
State Writing To Net
The server is writing a packet to the network.
State None
什麼都沒有的,空的,注意不是NULL狀態
State Other
其他
MySQL Query Cache
MySQL Query Cache Memory
MySQL Query Response Time (Microseconds)
Percona文檔
MySQL Query Time Histogram(Count)
Percona文檔
MySQL Replication
默認用SHOW SLAVE STATUS命令獲取各狀態值
Slave Running
從服務器的I/O線程和SQL線程是否在運行
Slave Stopped
Slave Lag
複製延遲
Slave Open Tmp Tables
從服務器中的SQL線程曾經打開的臨時文件的個數
Slave Retried Transactions
從服務器中的SQL線程重新嘗試執行一個事務的次數
MySQL Select Types
Select Full Join
沒有使用索引而完成的多表聯接操作的次數.這種情況是性能殺手,最好去優化sql.
Select Full Range Join
利用一個輔助性的參照表(reference table)上的區間搜索(range search)操作而完成的多數據表聯接操作的次數.
該值表示使用了範圍查詢聯接表的次數.
Select Range
利用第一個數據表上的某個區間而完成的多數據表聯接操作的次數.
Select Range Check
該變量記錄了在聯接時,對每一行數據重新檢查索引的查詢計劃的數量,它的開銷很大.
如果該值較高或正在增加,說明一些查詢沒有找到好索引.
Select Scan
通過對第一個數據表進行全表掃描而完成的多數據表聯接操作的次數.
MySQL Sorts
Sort Rows
對多少行排序
Sort Range
利用一個區間進行的排序操作的次數
Sort Merge Passes
查詢導致了文件排序的次數.可以優化sql或者適當增加sort_buffer_size變量
Sort Scan
利用一次全表掃作而完成的排序操作的次數
MySQL Table Locks
Table Locks Immediate
無需等待就能夠立刻得到滿足的數據表鎖定請求的個數
Table Locks Waited
顯示了有多少表被鎖住了並且導致服務器級的鎖等待(存儲引擎級的鎖,如InnoDB行級鎖,不會使該變量增加).
如果這個值比較高或者正在增加,那麼表明存在嚴重的併發瓶頸.
Slow Queries
慢查詢的次數(執行時間超過long_query_time值)
MySQL Temporary Objects
Created_tmp_tables
MySQL服務器在對SQL查詢語句進行處理時在內存裏創建的臨時數據表的個數.
如果該值太高,唯一的解決辦法是:優化查詢語句.
Created_tmp_disk_tables
MySQL服務器在對SQL查詢語句進行處理時在磁盤上創建的臨時數據表的個數,如果這個值比較高,可能的原因:
a.查詢在選擇BLOB或者TEXT列的時候創建了臨時表
b.tmp_table_size和max_heap_table_size的值也許太小
Created_tmp_files
MySQL服務器所創建的臨時文件的個數
MySQL Threads
Thread Cache Size
線程緩存所能容納的線程的最大個數.斷開的mysql連接會放到這個緩存裏,新建立的連接就會重複使用它們而不創建新的線程.
如果緩存中有自由的線程,MySQL就能很快的響應連接請求,不必爲每個連接都創建新的線程.每個在緩存中的線程通常消耗256KB內存.
Thread Created
爲處理連接創建的線程總數
MySQL Transaction Handler
Handler Commit
提交一個事務的請求的個數
Handler Rollback
回滾一個事務的請求的個數
Handler Savepoint
創建一個事務保存點的請求的個數
Handler Savepoint Rollback
回滾到一個事務保存點的請求的個數.
參考:
http://www.percona.com/doc/percona-monitoring-plugins/cacti/mysql-templates.html
http://www.mysqlperformanceblog.com/2006/07/17/show-innodb-status-walk-through/
以Percona提供的模板爲例.其中信息獲取命令如下(不包括pt-heartbeat).
SHOW /*!50002 GLOBAL */ STATUS;
SHOW VARIABLES;
SHOW SLAVE STATUS;
SHOW MASTER LOGS;
SHOW PROCESSLIST;
SHOW /*!50000 ENGINE*/ INNODB STATUS;