【mysql】mysql 内存配置调优

阅读更多

 

 

mysql的内存计算公式:

mysql used mem = key_buffer_size + query_cache_size + tmp_table_size
+ innodb_buffer_pool_size + innodb_additional_mem_pool_size
+ innodb_log_buffer_size
+ max_connections * (
read_buffer_size + read_rnd_buffer_size
+ sort_buffer_size+ join_buffer_size
+ binlog_cache_size + thread_stack
)

 

 

mysql中输入以下命令,可以查出内存总量及各个参数的配置情况:

SET @kilo_bytes = 1024;
SET @mega_bytes = @kilo_bytes * 1024;
SET @giga_bytes = @mega_bytes * 1024;

SELECT
( @@key_buffer_size + @@query_cache_size + @@tmp_table_size
+ @@innodb_buffer_pool_size + @@innodb_additional_mem_pool_size
+ @@innodb_log_buffer_size
+ @@max_connections * (
@@read_buffer_size + @@read_rnd_buffer_size + @@sort_buffer_size
+ @@join_buffer_size + @@binlog_cache_size + @@thread_stack
) ) / @giga_bytes AS MAX_MEMORY_GB;

select @@key_buffer_size / @mega_bytes;
select @@query_cache_size / @mega_bytes;
select @@innodb_buffer_pool_size / @mega_bytes;
select @@innodb_additional_mem_pool_size / @mega_bytes;
select @@innodb_log_buffer_size / @mega_bytes;
select @@read_buffer_size / @mega_bytes;
select @@read_rnd_buffer_size / @mega_bytes;
select @@sort_buffer_size / @mega_bytes;
select @@join_buffer_size / @mega_bytes;
select @@binlog_cache_size / @mega_bytes;
select @@thread_stack/ @mega_bytes;
select @@max_connections;

 

 

参数配置:

在/etc/mysql/my.cnf中的[mysqld]段中配置对应的参数,如:

max_connections = 128
innodb_buffer_pool_size = 2G

 参考链接:http://blog.sina.com.cn/s/blog_47186b8b0100vp5n.html

你可能感兴趣的:(mysql,ofmall)