我有一个客户,我为其做 Web 开发,该客户有一台运行 Ubuntu 12.x、带有 PHP 和 MySQL 的服务器。
我的问题似乎是随机出现的,大约每周两次,我会接到电话说 MySQL 服务器宕机了,在这种情况下,我会登录并重新启动 MySQL,然后一切都会正常运行几天,直到它再次发生。
这次我查看了这个日志文件......
/var/log/mysql/error.log
error.log 内容如下。有人能告诉我可能发生了什么以及我该如何修复吗?
151117 0:19:26 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
151117 0:19:26 [Note] Plugin 'FEDERATED' is disabled.
151117 0:19:26 InnoDB: The InnoDB memory heap is disabled
151117 0:19:26 InnoDB: Mutexes and rw_locks use GCC atomic builtins
151117 0:19:26 InnoDB: Compressed tables use zlib 1.2.8
151117 0:19:26 InnoDB: Using Linux native AIO
151117 0:19:26 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
151117 0:19:26 InnoDB: Completed initialization of buffer pool
151117 0:19:26 InnoDB: Fatal error: cannot allocate memory for the buffer pool
151117 0:19:26 [ERROR] Plugin 'InnoDB' init function returned error.
151117 0:19:26 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
151117 0:19:26 [ERROR] Unknown/unsupported storage engine: InnoDB
151117 0:19:26 [ERROR] Aborting
151117 0:19:26 [Note] /usr/sbin/mysqld: Shutdown complete
151117 0:19:27 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
151117 0:19:27 [Note] Plugin 'FEDERATED' is disabled.
151117 0:19:27 InnoDB: The InnoDB memory heap is disabled
151117 0:19:27 InnoDB: Mutexes and rw_locks use GCC atomic builtins
151117 0:19:27 InnoDB: Compressed tables use zlib 1.2.8
151117 0:19:27 InnoDB: Using Linux native AIO
151117 0:19:27 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
151117 0:19:27 InnoDB: Completed initialization of buffer pool
151117 0:19:27 InnoDB: Fatal error: cannot allocate memory for the buffer pool
151117 0:19:27 [ERROR] Plugin 'InnoDB' init function returned error.
151117 0:19:27 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
151117 0:19:27 [ERROR] Unknown/unsupported storage engine: InnoDB
151117 0:19:27 [ERROR] Aborting
151117 0:19:27 [Note] /usr/sbin/mysqld: Shutdown complete
答案1
... InnoDB:mmap(137363456 字节)失败;错误号 12
...
151117 0:19:27 InnoDB:致命错误:无法为缓冲池分配内存
看起来你的内存不够了——添加更多内存或者调整你的 innodb 参数以减少内存使用。