mysql 5.6优化,性能提升6倍 ,mysql5.6占用内存大,通过state优化

2024-09-13RAC

http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html1. 连接请求的变量:## 1) max_connections

2) back_log

3) interactive_timeout

  1. 缓冲区变量全局缓冲:## 4) key_buffer_size

5) query_cache_size

每个连接的缓冲## 6) record_buffer_size

7) read_rnd_buffer_size

8) sort_buffer_size

9) join_buffer_size

record_buffer_size,read_rnd_buffer_size,sort_buffer_size,join_buffer_size为每个线程独占,也就是说,如果有100个线程连接,则占用为16M*100## 10) table_cache 通过检查峰值时间的状态值和,可以决定是否需要增加的值。## 11) max_heap_table_size

12) tmp_table_size

建议尽量优化查询,要确保查询过程中生成的临时表在内存中,避免临时表过大导致生成基于硬盘的MyISAM表## 13) thread_cache_size

14) thread_concurrency

15) wait_timeout

  1. 配置InnoDB的几个变量innodb_buffer_pool_sizeinnodb_flush_log_at_trx_commitinnodb_log_buffer_sizeinnodb_additional_mem_pool_sizeinnodb_thread_concurrency=8mysql> show variables;

> > > > > > >

> > > > > >

> > > > >

> > > > >

Max_used_connections / max_connections * 100% ≈ 85%

> > > > >

> > > > > >

key_cache_miss_rate = Key_reads / Key_read_requests * 100%

> > > > > >

Key_blocks_used / (Key_blocks_unused + Key_blocks_used) * 100% ≈ 80%

> > > > > > >

Created_tmp_disk_tables / Created_tmp_tables * 100% <= 25%

> > > > > >

> > > > > >

> > > > >

>

> >

六、进程使用情况> > > > > > > > > >

> > > > > > >

> 七、查询缓存(query cache)> > > > > > > > > > > > > >

> > > > > > > > >

> > > > > > > > > > >

各字段的解释:> > > > > >

> 查询缓存碎片率 = Qcache_free_blocks / Qcache_total_blocks * 100%

> 查询缓存利用率 = (query_cache_size – Qcache_free_memory) / query_cache_size * 100%

> 查询缓存命中率 = (Qcache_hits – Qcache_inserts) / Qcache_hits * 100%

> 八、排序使用情况> > > > > > > > > >

> > 九、文件打开数(open_files)> > > > > > > >

> > > > >

> 十、表锁情况> > > > > > > >

> 十一、表扫描情况> > > > > > > > > > > >

> > > > > > >

> 表扫描率 = Handler_read_rnd_next / Com_select

>

> > >