MySQL服务器不断崩溃

我正面临一个问题,我无法弄清楚,出于某种原因,我的MySQL服务器在30-40分钟后不断崩溃,服务器负载本身不是太高,甚至不是0.5(对于2 CPU的机器)一直试图在错误日志/var/log/mysql/error.log中窥探,但无法find任何线索,但我会第一个承认我可能是由于缺乏知识。

服务器是Ubuntu的12.04与基本的光设置..每一次服务器崩溃,我必须手动重新启动MySQL,否则将停留下来。

这是我有错误日志:

130623 15:09:18 [Note] Plugin 'FEDERATED' is disabled. 130623 15:09:18 InnoDB: The InnoDB memory heap is disabled 130623 15:09:18 InnoDB: Mutexes and rw_locks use GCC atomic builtins 130623 15:09:18 InnoDB: Compressed tables use zlib 1.2.3.4 130623 15:09:18 InnoDB: Initializing buffer pool, size = 128.0M 130623 15:09:18 InnoDB: Completed initialization of buffer pool 130623 15:09:18 InnoDB: highest supported file format is Barracuda. 130623 15:09:18 InnoDB: Waiting for the background threads to start 130623 15:09:19 InnoDB: 5.5.31 started; log sequence number 2220260 130623 15:09:19 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306 130623 15:09:19 [Note] - '127.0.0.1' resolves to '127.0.0.1'; 130623 15:09:19 [Note] Server socket created on IP: '127.0.0.1'. 130623 15:09:19 [Note] Event Scheduler: Loaded 0 events 130623 15:09:19 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.5.31-0ubuntu0.12.04.2' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu) 130623 15:27:48 [Note] Plugin 'FEDERATED' is disabled. 130623 15:27:48 InnoDB: The InnoDB memory heap is disabled 130623 15:27:48 InnoDB: Mutexes and rw_locks use GCC atomic builtins 130623 15:27:48 InnoDB: Compressed tables use zlib 1.2.3.4 130623 15:27:48 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 130623 15:27:48 InnoDB: Completed initialization of buffer pool 130623 15:27:48 InnoDB: Fatal error: cannot allocate memory for the buffer pool 130623 15:27:48 [ERROR] Plugin 'InnoDB' init function returned error. 130623 15:27:48 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 130623 15:27:48 [ERROR] Unknown/unsupported storage engine: InnoDB 130623 15:27:48 [ERROR] Aborting 130623 15:27:48 [Note] /usr/sbin/mysqld: Shutdown complete 130623 15:27:49 [Note] Plugin 'FEDERATED' is disabled. 130623 15:27:49 InnoDB: The InnoDB memory heap is disabled 130623 15:27:49 InnoDB: Mutexes and rw_locks use GCC atomic builtins 130623 15:27:49 InnoDB: Compressed tables use zlib 1.2.3.4 130623 15:27:49 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 130623 15:27:49 InnoDB: Completed initialization of buffer pool 130623 15:27:49 InnoDB: Fatal error: cannot allocate memory for the buffer pool 130623 15:27:49 [ERROR] Plugin 'InnoDB' init function returned error. 130623 15:27:49 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 130623 15:27:49 [ERROR] Unknown/unsupported storage engine: InnoDB 130623 15:27:49 [ERROR] Aborting 

有没有人看到我不?

呃,它在你的日志文件中出现两次

 InnoDB: Fatal error: cannot allocate memory for the buffer pool 

编辑你的/etc/mysql/my.cnfjoin这一行

 innodb_buffer_pool_size = 64M 

然后重新启动mysql

 service mysql restart 

如果你没有足够的内存,使用Swap是件好事。 看看这个不错的文章:

https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04

这对我来说很好。