《mysql性能優(yōu)化之配置參數(shù)Mysql實(shí)例》要點(diǎn):
本文介紹了mysql性能優(yōu)化之配置參數(shù)Mysql實(shí)例,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
導(dǎo)讀:修改以下參數(shù)配置項(xiàng)的值,參考如下1、連接設(shè)置show variables like '%max_connection%';show status like '%Max_used_co...
修改以下參數(shù)配置項(xiàng)的值,參考如下
1、連接設(shè)置
show variables like '%max_connection%';
show status like '%Max_used_connections%';
Max_used_connections/max_connection <=85%
2、存儲(chǔ)在堆棧中的連接數(shù)量
show variables like '%back_log%';
back_log 默認(rèn)為50 建議修改為 128~512
3、數(shù)據(jù)連接關(guān)閉前等待時(shí)間
show variables like '%timeout%';
修改interactive_timeout wait_timeout 2項(xiàng)的值,默認(rèn)為28800,建議修改為7200
4、索引緩沖區(qū)的大小
show status like '%read%';
索引未緩存命中率 key_read/key_request_reads ~=0.001~0.01
5、查詢緩沖區(qū)的大小(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、順序讀、隨機(jī)讀、排序、連接緩沖區(qū)的大小,每個(gè)線程獨(dú)占,建議設(shè)置為16MB
show status like '%buffer%';
read_buffer_size
read_rnd_buffer_size
sort_buffer_size
join_buffer_size
7、表緩沖區(qū)大小
show status like '%tables%';
table_cache 根據(jù) open_tables opented_tables 大小來(lái)調(diào)整
8、內(nèi)存表和臨時(shí)表
show status like '%table%';
max_heap_table_size
tmp_table_size
內(nèi)存表超過(guò)臨時(shí)表大小,才需要調(diào)整內(nèi)存表的大小
9、磁盤上臨時(shí)表大小
show status like '%tmp%';
(Created_tmp_disk_tables/Created_tmp_tables)*100<25%
10、緩存線程的數(shù)量
show variables like '%tmp%';
thread_cache_size
11、并發(fā)線程的數(shù)量
show variables like '%thread%';
innodb_thread_concurrency (cpu+磁盤)數(shù)量的2倍
12、其他
數(shù)據(jù)和索引緩沖區(qū)的大小 innodb_buffer_pool_size 物理內(nèi)容的80%
日志緩沖區(qū)的大小 innodb_log_buffer_size 1~8MB
數(shù)據(jù)字段和其他數(shù)據(jù)結(jié)構(gòu)的大小 innodb_additional_mem_pool_size 20MB
事物處理機(jī)制 innodb_flush_log_at_trx_commit
0 提交事物不寫入日志,每秒日志文件寫入和flush磁盤
1 每秒或每次事物提交時(shí),日志文件寫入 flush磁盤
2 每次事物提交時(shí),日志文件寫入,每秒flush磁盤
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.snjht.com/jiaocheng/5602.html