mysql查看資料庫狀態show status

來源:互聯網
上載者:User

標籤:mysql   show status   資料庫狀態   

show [global | session] status [like ‘xxx‘];

global選項,查看mysql所有串連狀態

session選項,查看當前串連狀態,預設session選項


flush status;可以將很多狀態值重設清零。


擷取mysql使用者進程總數

ps -ef |awk ‘{print $1}‘ |grep mysql |grep -v "grep" |wc -l


查看mysql當前串連數

netstat -an |grep 3306 |grep "ESTABLISHED" |wc -l


查看主機效能狀態

uptime

 11:03:30 up 91 days,  9:48,  3 users,  load average: 0.70, 0.91, 2.63

查看伺服器啟動時間長度,使用者數,負載


top  vmstat,top   查看cpu使用率

vmstat  iostat  查看io狀態

free -h  查看記憶體使用量情況


資料庫效能狀態查詢:


1)QPS每秒query量

show global status like ‘Question%‘;

+---------------+----------+

| Variable_name | Value    |

+---------------+----------+

| Questions     | 39661402 |

+---------------+----------+


2)TPS每秒事務量

show global status like ‘Com_commit‘;

+---------------+---------+

| Variable_name | Value   |

+---------------+---------+

| Com_commit    | 8495153 |

+---------------+---------+

show global status like ‘Com_rollback‘;

+---------------+-------+

| Variable_name | Value |

+---------------+-------+

| Com_rollback  | 0     |

+---------------+-------+


(3)key Buffer 命中率
mysql>show  global   status  like   ‘key%‘;

key_buffer_read_hits = (1-key_reads / key_read_requests) * 100%
key_buffer_write_hits = (1-key_writes / key_write_requests) * 100%


(4)InnoDB Buffer命中率
mysql> show status like ‘innodb_buffer_pool_read%‘;

innodb_buffer_read_hits = (1 - innodb_buffer_pool_reads / innodb_buffer_pool_read_requests) * 100%


(5)Query Cache命中率
mysql> show status like ‘Qcache%‘;

Query_cache_hits = (Qcahce_hits / (Qcache_hits + Qcache_inserts )) * 100%;


(6)Table Cache狀態量
mysql> show global  status like ‘open%‘;
比較 open_tables  與 opend_tables 值

(7)Thread Cache 命中率
mysql> show global status like ‘Thread%‘;
mysql> show global status like ‘Connections‘;

Thread_cache_hits = (1 - Threads_created / connections ) * 100%

 

(8)鎖定狀態
mysql> show global  status like ‘%lock%‘;

Table_locks_waited/Table_locks_immediate=0.3%  如果這個比值比較大的話,說明表鎖造成的阻塞比較嚴重
Innodb_row_lock_waits innodb行鎖,太大可能是間隙鎖造成的


(9)複製延時量
mysql > show slave status
查看延時時間


(10) Tmp Table 狀況(暫存資料表狀況)
mysql > show status like ‘Create_tmp%‘;

Created_tmp_disk_tables/Created_tmp_tables比值最好不要超過10%,如果Created_tmp_tables值比較大,
可能是排序句子過多或者是串連句子不夠最佳化


(11) Binlog Cache 使用狀況
mysql > show status like ‘Binlog_cache%‘;

如果Binlog_cache_disk_use值不為0 ,可能需要調大 binlog_cache_size大小


(12) Innodb_log_waits 量
mysql > show status like ‘innodb_log_waits‘;

Innodb_log_waits值不等於0的話,表明 innodb log  buffer 因為空白間不足而等待


13)show variables like ‘%timeout%‘;查看連線逾時配置


mysql查看資料庫狀態show status

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.