wordpress 不定期出现 数据库连接错误

cd /var/log/mysql

nano error.log     //查看错误日志

翻到最后,发现以下错误

InnoDB: mmap(137428992 bytes) failed; errno 12

百度搜索之后,发现是swap 问题,以下操作解决问题

收到报警发现一台MySQL服务器异常,登入发现无法启动。该机器仅供临时测试使用,故此没有太多配置,查看err日志中发现

130629  5:46:48 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
130629  5:46:48 InnoDB: Completed initialization of buffer pool
130629  5:46:48 InnoDB: Fatal error: cannot allocate memory for the buffer pool
130629  5:46:48 [ERROR] Plugin 'InnoDB' init function returned error.
130629  5:46:48 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
130629  5:46:48 [ERROR] Unknown/unsupported storage engine: InnoDB
130629  5:46:48 [ERROR] Aborting

 

查看内存
$ free
             total       used       free     shared    buffers     cached
Mem:        608476     565044      43432          0       1284      53996
-/+ buffers/cache:     509764      98712
Swap:            0          0          0

 

好吧,明显的swap问题。适当增加swap,采用
$ sudo dd if=/dev/zero of=/swapfile bs=1M count=1024 #增加1G的SWAP进去
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
$ free
             total       used       free     shared    buffers     cached
Mem:        608476     601432       7044          0        824      88752
-/+ buffers/cache:     511856      96620
Swap:      1048572          0    1048572

此处不建议将swapon 写到/etc/fstab这里,直接写到/etc.rc.local中更为稳妥

问题解决。。。

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.