缘由
已经两三次英国同事找到我说网站除了首页其他页面都访问不了了,然后迅速看了下网站,发现日志如下1
2
3
4
5
6
7
8
9
10
11
12
13
14160605 20:55:51 mysqld_safe mysqld restarted
160605 20:55:52 [Note] Plugin 'FEDERATED' is disabled.
160605 20:55:52 InnoDB: The InnoDB memory heap is disabled
160605 20:55:52 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160605 20:55:52 InnoDB: Compressed tables use zlib 1.2.3
160605 20:55:52 InnoDB: Using Linux native AIO
160605 20:55:52 InnoDB: Initializing buffer pool, size = 64.0M
InnoDB: mmap(68681728 bytes) failed; errno 12
160605 20:55:52 InnoDB: Completed initialization of buffer pool
160605 20:55:52 InnoDB: Fatal error: cannot allocate memory for the buffer pool
160605 20:55:52 [ERROR] Plugin 'InnoDB' init function returned error.
160605 20:55:52 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
160605 20:55:52 [ERROR] Unknown/unsupported storage engine: InnoDB
160605 20:55:52 [ERROR] Aborting
1 | 160606 10:46:03 InnoDB: The InnoDB memory heap is disabled |
果然是挂了,发现是mysql的问题,之后试着重启了下mysql就好了,任务多就没多大体会,然后就搁置了。
正好找了空今天把这个问题解决了,解决方法当然是google了,这么好的工具不用浪费啦,发现原来是swap问题。O(∩_∩)O哈哈~
解决方法:
在 /etc/my.cnf 的 mysqld 下增加下面一句:
1 | innodb_buffer_pool_size = 512M |
设置一下swap分区,通过fdisk -l 和 1mount 看不到swap的信息,需要手动添加一下。
1 | dd if=/dev/zero of=/swapfile bs=1M count=1024 |
重启mysql
1 | /etc/init.d/mysqld restart |
或者1
service mysqld restart
参考链接: