我在digitalocean(1G RAM)上安装了VPS(Ubuntu 14.04),我安装了VestaCP。每次我重新启动服务器mysql都会因内存不足而崩溃(它缓冲超过1G)尽管我配置了我的RAM(我的/etc/mysql/my.cnf):
[client]
port=3306
socket=/var/run/mysqld/mysqld.sock
[mysqld_safe]
socket=/var/run/mysqld/mysqld.sock
[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
log_error=/var/log/mysql/error.log
max_user_connections=30
wait_timeout=30
interactive_timeout=50
long_query_time=5
innodb_file_per_table
#fibhost 1G RAM
key_buffer_size = 8M
query_cache_size = 0M
tmp_table_size = 64M
innodb_buffer_pool_size = 128M
innodb_additional_mem_pool_size = 8M
innodb_log_buffer_size = 8M
max_connections = 150
sort_buffer_size = 4M
read_buffer_size = 128k
read_rnd_buffer_size = 256k
join_buffer_size = 128M
thread_stack = 256k
binlog_cache_size = 32k
!includedir /etc/mysql/conf.d/
当我sudo service mysql
重新启动时,它会正常工作并缓冲550M,直到下次重新启动shutdown -r +5
或reboot
/var/log/mysql/error.log:
150529 0:36:43 InnoDB: Could not open or create data files.
150529 0:36:43 InnoDB: If you tried to add new data files, and it failed here,
150529 0:36:43 InnoDB: you should now edit innodb_data_file_path in my.cnf back
150529 0:36:43 InnoDB: to what it was, and remove the new ibdata files InnoDB created
150529 0:36:43 InnoDB: in this failed attempt. InnoDB only wrote those files full of
150529 0:36:43 InnoDB: zeros, but did not yet use them in any way. But be careful: do not
150529 0:36:43 InnoDB: remove old data files which contain your precious data!
150529 0:36:43 [ERROR] Plugin 'InnoDB' init function returned error.
150529 0:36:43 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
150529 0:36:43 [ERROR] Unknown/unsupported storage engine: InnoDB
150529 0:36:43 [ERROR] Aborting
150529 0:36:43 [Note] /usr/sbin/mysqld: Shutdown complete
150529 00:36:43 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
答案 0 :(得分:0)
日志文件听起来像MySQL想要放置其内容的目录或者那里的文件存在权限问题。不要直接从非root用户运行mysqld;服务命令可能是“正确”的方式。