我对于更改my.conf文件中的哪些设置来优化服务器感到有些困惑(由于流量大,mysql服务器不断崩溃)。
这是my.cnf文件:
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
key_buffer = 16M
max_allowed_packet = 16M
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
query_cache_limit = 1M
query_cache_size = 16M
服务器规格为:
CPU Cores 2 cores
RAM (Memory) 1GB
SSD (Disk Space) 20GB
运行Ubuntu 12.04 LTS
这是我的分区:
NAME FSTYPE SIZE MOUNTPOINT LABEL
vda 20G
├─vda1 ext4 476M /boot
├─vda2 swap 477M [SWAP]
└─vda3 ext4 19.1G /
任何帮助将非常感激。
查看错误日志,可以看到mysqld内存不足:
Feb 17 11:02:06 111488 kernel: [8276839.559141] Out of memory: Kill process 20719 (mysqld) score 75 or sacrifice child
Feb 17 11:02:06 111488 kernel: [8276839.559209] Killed process 20719 (mysqld) total-vm:1347424kB, anon-rss:30524kB, file-rss:0kB