溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

mysql性能優(yōu)化配置總結(jié)

發(fā)布時(shí)間:2020-07-08 01:42:07 來源:網(wǎng)絡(luò) 閱讀:320 作者:吳金瑞 欄目:MySQL數(shù)據(jù)庫

    

看了一些優(yōu)化mysql運(yùn)維的一些書籍,在此記錄總結(jié)下:
進(jìn)入mysql客戶端輸入以下sql:
1、連接設(shè)置

show variables like '%max_connection%';
show status like '%Max_used_connections%';

Max_used_connections/max_connection <=85%,參數(shù)配置項(xiàng)的值可對(duì)照修改

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 大小來調(diào)整

8、內(nèi)存表和臨時(shí)表

show status like '%table%';

max_heap_table_size
tmp_table_size
內(nèi)存表超過臨時(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磁盤


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI