二月 12th, 2011

MySQL 数据库性能调优介绍(附修改后的My.ini文件)

数据库性能优化方案, by 小哥.

试验一:
table_cache=512或1024
innodb_additional_mem_pool_size=2M
innodb_flush_log_at_trx_commit=0
innodb_log_buffer_size=1M
innodb_thread_concurrency=8       你的服务器CPU有几个就设置为几,默认为8
key_buffer_size=128M
tmp_table_size=128M
read_buffer_size=64K或128K
read_rnd_buffer_size=256K
sort_buffer_size=512K
max_connections=1024

试验二:
table_cache=512或1024
innodb_additional_mem_pool_size=8M
innodb_flush_log_at_trx_commit=0
innodb_log_buffer_size=4M
innodb_thread_concurrency=8
key_buffer_size=128M
tmp_table_size=128M
read_buffer_size=4M
read_rnd_buffer_size=16M
sort_buffer_size=32M
max_connections=1024

一般:
table_cache=512
innodb_additional_mem_pool_size=8M
innodb_flush_log_at_trx_commit=0
innodb_log_buffer_size=4M
innodb_thread_concurrency=8
key_buffer_size=128M
tmp_table_size=128M
read_buffer_size=4M
read_rnd_buffer_size=16M
sort_buffer_size=32M
max_connections=1024

经过测试.没有特殊情况,最好还是用默认的.

2G内存,针对站多,抗压型的设置,最佳:
table_cache=1024 物理内存越大,设置就越大.默认为2402,调到512-1024最佳
innodb_additional_mem_pool_size=4M   默认为2M
innodb_flush_log_at_trx_commit=1(设置为0就是等到innodb_log_buffer_size列队满后再统一储存,默认为1)
innodb_log_buffer_size=2M             默认为1M
innodb_thread_concurrency=8       你的服务器CPU有几个就设置为几,建议用默认一般为8
key_buffer_size=256M                       默认为218       调到128最佳
tmp_table_size=64M                      默认为16M        调到64-256最挂
read_buffer_size=4M                       默认为64K
read_rnd_buffer_size=16M              默认为256K
sort_buffer_size=32M                   默认为256K
max_connections=1024                 默认为1210
thread_cache_size=120             默认为60
query_cache_size=64M

以下是我所作的配置文件
–>
# MySQL Server Instance Configuration File

[client]
port=9011

[mysql]
default-character-set=gbk

[mysqld]
port=9011
basedir=”C:/Program Files/MySQL/MySQL Server 5.5/”
datadir=”C:/Documents and Settings/All Users/Application Data/MySQL/MySQL Server 5.5/Data/”
character-set-server=gbk
default-storage-engine=INNODB
sql-mode=”NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”
max_connections=1024
query_cache_size=64M
table_cache=512
tmp_table_size=64M
thread_cache_size=120
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=205M
key_buffer_size=256M
read_buffer_size=64K
read_rnd_buffer_size=4M
sort_buffer_size=32M
innodb_additional_mem_pool_size=8M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=4M
innodb_buffer_pool_size=256M
innodb_log_file_size=170M
innodb_thread_concurrency=8
<–

经测试占用服务器内存60-80MB,还算比较合理,性能有明显提升

Back Top