mysql效能檢測常用命令
阿新 • • 發佈:2019-01-23
1效能檢測常用命令
show status
show processlist
show variables
2瓶頸分析常用命令
獲取mysql使用者下的程序總數
SQL | 複製1 |
ps -ef | awk '{print $1}' | grep "mysql" | grep -v "grep" | wc -l
|
主機效能狀態
Text | 複製1 2 |
# uptime
13:05:52 up 53 days, 52 min, 1 user, load average: 0.00, 0.00, 0.00
|
CPU使用率
Text1 |
# top 或 # vmstat
|
磁碟IO量
Text | 複製1 |
# vmstat 或 # iostat
|
swap進出量[記憶體]
Text | 複製1 |
# free -m
|
資料庫效能狀態
QPS(每秒Query量)
QPS = Questions(or Queries) / seconds
1 |
mysql > show /* global */ status like 'Question' ;
|
TPS(每秒事務量)
TPS = (Com_commit + Com_rollback) / seconds
1 2 |
mysql > show status like 'Com_commit' ;
mysql > show status like 'Com_rollback' ;
|
key Buffer 命中率
key_buffer_read_hits = (1-key_reads / key_read_requests) * 100%
key_buffer_write_hits = (1-key_writes / key_write_requests) * 100%
1 |
mysql> show status like 'Key%' ;
|
InnoDB Buffer命中率
innodb_buffer_read_hits = (1 - innodb_buffer_pool_reads / innodb_buffer_pool_read_requests) * 100%
SQL | 複製1 |
mysql> show status like 'innodb_buffer_pool_read%' ;
|
Query Cache命中率
Query_cache_hits = (Qcahce_hits / (Qcache_hits + Qcache_inserts )) * 100%;
SQL | 複製1 |
mysql> show status like 'Qcache%' ;
|
Table Cache狀態量
SQL | 複製1 |
mysql> show status like 'open%' ;
|
Thread Cache 命中率
Thread_cache_hits = (1 - Threads_created / connections ) * 100%
SQL | 複製1 2 |
mysql> show status like 'Thread%' ;
mysql> show status like 'Connections' ;
|
鎖定狀態
SQL | 複製1 |
mysql> show status like '%lock%' ;
|
複製延時量
SQL | 複製1 |
mysql > show slave status
|
Tmp Table 狀況(臨時表狀況)
SQL | 複製