vps Linode提供了一个用于低内存服务器的MySQL内存占用优化建议,可以用来参考(转)
Linode提供了一个用于低内存服务器的MySQL内存占用优化建议,可以用来参考。
配置文件:/etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# Low memory optimizations
skip-bdb
skip-innodb
skip-networking
server-id = 1
key_buffer = 256K
max_allowed_packet=1M
thread_stack = 64K
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K
query_cache_limit=256K
query_cache_size = 2M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/my
################################################
修改以下值,没有的行请自行添加,并保存退出
key_buffer = 256K
max_allowed_packet = 2M
thread_stack = 128K
table_cache = 4
sort_buffer = 64K
net_buffer_length = 2K
skip-innodb
然后运行以下命令重启MySQL服务,以使新配置生效
#service mysql restart
或者
#/etc/init.d/mysql restart
现在重新查看以下剩余内存,应该有不小改善的,特别是增加了skip-innodb之后。
评论: