mysql 效能監控

2021-07-22 22:42:00 字數 2963 閱讀 1223

show status;

flush status;

檢視當前連線數 show status like 'thread_%';

thread_cached:被快取的執行緒的個數

thread_running:處於啟用狀態的執行緒的個數

thread_connected:當前連線的執行緒的個數

thread_created:總共被建立的執行緒的個數

thread cache hits 

thread_connected = show global status like thread_created;

connections = show global status like 'connections';

tch=(1 - (threads_created / connections)) * 100

檢視活動連線內容

show processlist;

如果 tch數小於90%,建立連線耗費了時間,增大thread_cached數量

qpsquestions = show global status like 'questions';

uptime = show global status like 'uptime';

qps=questions/uptime 

tpscom_commit = show global status like 'com_commit';

com_rollback = show global status like 'com_rollback';

uptime = show global status like 'uptime';

tps=(com_commit + com_rollback)/uptime

qps 和 tps值一定要實時監控,如果接近架構搭建時的測試峰值,願上帝與你同在

read/writes ratio

qcache_hits = show global status like 'qcache_hits';

com_select = show global status like 'com_select';

com_insert = show global status like 'com_insert';

com_update = show global status like 'com_update';

com_delete = show global status like 'com_delete';

com_replace = show global status like 'com_replace';

r/w=(com_select + qcache_hits) / (com_insert + com_update + com_delete + com_replace) * 100

讀寫比,優化資料庫的重要依據,讀的多就去優化讀,寫的多就去優化寫

slow queries per minute

slow_queries = show global status like 'slow_queries';

uptime = show global status like 'uptime';

sqpm=slow_queries / (uptime/60)

slow queries /questions ratio

slow_queries = show global status like 'slow_queries';

questions = show global status like 'questions';

s/q=slow_queries/questions 

新版本上線時要著重關注慢查詢,讓測試去踢開發者的屁股吧

full_join per minute

select_full_join = show global status like 'select_full_join';

uptime = show global status like 'uptime';

fjpm=select_full_join / (uptime/60)

沒有使用索引而造成的full_join,優化索引去吧

innodb buffer read hits

innodb_buffer_pool_reads = show global status like 'innodb_buffer_pool_reads';

innodb_buffer_pool_read_requests = show global status like 'innodb_buffer_pool_read_requests';

ifrh=(1 - innodb_buffer_pool_reads/innodb_buffer_pool_read_requests) * 100

innodb buffer命中率 目標 95%-99%;

table cache

open_tables= show global status like 'open_tables';

opened_tables= show global status like 'opened_tables';

table_cache= show global status like 'table_cache';

table_cache應該大於 open_tables 小於 opened_tables 

temp tables to disk ratio

created_tmp_tables = show global status like 'created_tmp_tables';

created_tmp_disk_tables = show global status like 'created_tmp_disk_tables';

tdr=(created_tmp_disk_tables/created_tmp_tables)*100

show global status like 'innodb_row_lock_%';

mysql效能監控

使用mysql不僅僅需要能簡單的crud,還需要進行效能調優,不管是工作中還是去面試這都比較重要,要想學會mysql調優首先得學會監控mysql的效能,不多說廢話,直接開幹 mysql是自帶監控工具的,有的版本可能預設開啟,有的可能關閉的,所以首先檢查profiling是否開啟 如上profilin...

mysql效能監控指令

qps queries per seconds 每秒鐘查詢數量 查詢所有的全域性狀態 show global status 查詢qps show global status like questions tps tranaction per seconds 每秒鐘事務數 tps com commit...

spotlight監控mysql效能

spotlight可以監控mysql效能,同監控linux一樣配置 目錄1 安裝spotlight 2 引數認識 1 安裝spotlight spotlight不僅僅只是監控mysql,還可以完成資料庫以及其他作業系統等的監控。本篇介紹的是監控mysql效能,因此安裝監控mysql的那一部分就可以了...