VPS的内存对性能至关重要,所以很有必要优化一下。
看了几篇针对vps小内存优化的文章,于是自己也动手参照优化下自己的mysql。
修改过调整好的 my.cnf ,service mysqld restart 启动时报错。
查看log,发现 skip-innodb / skip-bdb / skip-locking,这几个参数有问题。
继续学习,查资料,得知 使用的参数都是老版本的参数,mysql5.1对应的为:
skip-innodb –> loose-skip-innodb
skip-locking –> skip-external-locking
skip-bdb (已经废除了skip-bdb这个参数!)
配置文件: /etc/my.cnf
# low memory stuff – Mr.Tang
# Tue May 26 22:23:15 CST 2015[mysqld]
loose-skip-innodb
skip-external-locking
skip-host-cache
skip-name-resolvecharacter_set_server = utf8
default-storage-engine = myisamkey_buffer_size = 256M
key_buffer = 256K
max_allowed_packet = 1M
myisam_sort_buffer_size = 8M
net_buffer_length = 128K
query_cache_size= 16M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
sort_buffer_size = 1M
table_cache = 4M
table_open_cache = 16M
thread_cache_size = 8M
thread_stack = 131072[mysqldump]
quick
max_allowed_packet = 16M[mysql]
no-auto-rehash
#safe-updates[isamchk]
key_buffer = 8M
sort_buffer_size = 8M[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M[mysqlhotcopy]
interactive-timeout