Mysql重點監控指標

1、QPS:queries per seconds 每秒鐘查詢數量,計算方式queris/seconds。在mysql中的查詢語句,show global status like'%Quetions%'

2、TPS:tranaction per seconds 每秒鐘處理事務數,計算方式(com_commit+com_rollback)/seconds。mysql中查詢語句,show global status like 'Com_commit';show global status like 'Com_rollback'

3、線程連接數:show global status like 'Max_used_connections';show global status like 'Threads%';

4、最大連接數:show variables like 'max_connections';(設置的最大連接數)

5、Query Cache:查詢緩存用於緩存select查詢結果,當下次接收到相同查詢請求時,不再執行實際查詢處理而直接返回結果。適用於大量查詢,很少改變表中數據

如何開啓Query Cache

1、修改my.cnf

2、將query_cache_size設置爲具體的大小,具體大小是多少取決於實際的查詢情況。但最好爲1024的倍數,參考值爲32M

3、增加一行:query_cache_type=0/1/2。如果設置爲1,將會緩存所有結果,除非select語句使用SQL_NO_CACHE禁用了查詢緩存;如果設置爲2,只會緩存在select語句中通過SQL_CACHE指定需要緩存的查詢(需與開發配合)

Query Cache命中率

1、show status like 'Qcache%';

2、Query_cache_hits=(Qcache_hits/(Qcache_hits+Qcache_inserts))*100%

鎖定狀態

1、show global status like '%lock%';

2、Table_locks_waited/Table_locks_immediate值越大代表表鎖造成的阻塞越嚴重

3、Innodb_row_lock_wait,Innodb行鎖太大,可能間隙鎖造成的

主從延時

1、查詢主從延時時間:show slave status

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章