TLDR
Mysql无法重新启动,因为内存不足,请检查是否配置了适当的交换文件。
帮不上忙?如果这不是你的问题,更适合继续研究的问题是:
背景
我在EC2上建立的第一个系统就遇到了这个问题,其特点是托管在那里的wordpress站点有时会出现“建立数据库连接时出错”的情况。
日志显示的错误与OP发布的相同。我读取的错误(删除时间戳)是:内存不足错误:
InnoDB: Fatal error: cannot allocate memory for the buffer pool
没有足够的内存InnoDB无法启动
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting
mysqld正在关闭,这意味着无法重新启动!
[Note] /usr/sbin/mysqld: Shutdown complete
检查/var/log/syslog并搜索mysql产生:Out of memory: Kill process 15452 (mysqld) score 93 or sacrifice child
Killed process 15452 (mysqld) total-vm:888672kB, anon-rss:56252kB, file-rss:0kB
init: mysql main process (15452) killed by KILL signal
init: mysql main process ended, respawning
type=1400 audit(1443812767.391:30): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=21984 comm="apparmor_parser"
init: mysql main process (21996) terminated with status 1
init: mysql main process ended, respawning
init: mysql post-start process (21997) terminated with status 1
注意:如果错误发生在cron轮换日志之前,则可能需要对存档日志进行压缩和搜索。
解决方案
在我的例子中,根本的问题是我忽略了配置交换文件。
您可以通过运行free -m检查是否配置了一个。
total used free shared buffers cached
Mem: 604340 587364 16976 0 29260 72280
-/+ buffers/cache: 485824 118516
Swap: 0 0 0
在上面的示例中,Swap:0表示没有swapfile。
关于设置一个的教程:
注意,越大未必越好!来自Ubuntu guide:The "diminishing returns" means that if you need more swap space than twice your RAM size, you'd better add more RAM as Hard Disk Drive (HDD) access is about 10³ slower then RAM access, so something that would take 1 second, suddenly takes more then 15 minutes! And still more then a minute on a fast Solid State Drive (SSD)...
关于这里的其他答案
The InnoDB memory heap is disabledThis isn’t really an error, just an indication that InnoDB is using the system’s internal memory allocator instead of its own. The default is yes/1, and is acceptable for production.
According to the docs, this command is deprecated, and will be removed in MySQL versions above 5.6 (and I assume MariaDB):
[Note] Plugin 'FEDERATED' is disabled.The message about FEDERATED disabled is not an error. It just meant that the FEDERATED engine its not ON for your mysql server. It's not used by default. If you don't need it, don't care about this message.