mysql效能最佳化配置總結

來源:互聯網
上載者:User

標籤: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效能最佳化配置總結

聯繫我們

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