標籤:status mysql 用戶端 書籍 記錄
看了一些最佳化mysql營運的一些書籍,在此記錄總結下:
進入mysql用戶端輸入以下sql:
1、串連設定
show variables like ‘%max_connection%‘;show status like ‘%Max_used_connections%‘;
Max_used_connections/max_connection <=85%,參數配置項的值可對照修改
2、儲存在堆棧中的串連數量
show variables like ‘%back_log%‘;
back_log 預設為50 建議修改為 128~512
3、資料連線關閉前等待時間
show variables like ‘%timeout%‘;
修改interactive_timeout wait_timeout 2項的值,預設為28800,建議修改為7200
4、索引緩衝的大小
show status like ‘%read%‘;
索引未快取命中率 key_read/key_request_reads ~=0.001~0.01
5、查詢緩衝區的大小(query_cache_size)
show variables like ‘%cache%‘;show status like ‘%qcache%‘;
緩衝片段率 Qcache_free_blocks/Qcache_total_blocks <20%
緩衝利用率 (query_cache_size-Qcache_free_memory)/query_cache_size<25%
快取命中率 Qcache_hits/Qcache_inserts>95%
6、順序讀、隨機讀、排序、串連緩衝區的大小,每個線程獨佔,建議設定為16MB
show status like ‘%buffer%‘;
read_buffer_size
read_rnd_buffer_size
sort_buffer_size
join_buffer_size
7、表緩衝區大小
show status like ‘%tables%‘;
table_cache 根據 open_tables opented_tables 大小來調整
8、記憶體表和暫存資料表
show status like ‘%table%‘;
max_heap_table_size
tmp_table_size
記憶體表超過暫存資料表大小,才需要調整記憶體表的大小
9、磁碟上暫存資料表大小
show status like ‘%tmp%‘;
(Created_tmp_disk_tables/Created_tmp_tables)*100<25%
10、緩衝線程的數量
show variables like ‘%tmp%‘;
thread_cache_size
11、並發線程的數量
show variables like ‘%thread%‘;
innodb_thread_concurrency (cpu+磁碟)數量的2倍
12、其他
資料和索引緩衝的大小 innodb_buffer_pool_size 物理內容的80%
日誌緩衝區的大小 innodb_log_buffer_size 1~8MB
資料欄位和其他資料結構的大小 innodb_additional_mem_pool_size 20MB
事物處理機制 innodb_flush_log_at_trx_commit
0 提交事物不寫入日誌,每秒記錄檔寫入和flush磁碟
1 每秒或每次事物提交時,記錄檔寫入 flush磁碟
2 每次事物提交時,記錄檔寫入,每秒flush磁碟
mysql效能最佳化配置總結