用阿里雲的vps用做blog服務器,系統很穩定,已經100多天一直運行正常,大概從上個月開始發現blog的mysql會有時掛掉,會收到短信通知。以前沒太追究,從新啓動了mysql解決的。今天上午又收到短信,已經第三次了。mysql
查了一下日誌,三次基本都是同樣的:sql
130728 6:50:14 [Note] Plugin 'FEDERATED' is disabled. 130728 6:50:14 InnoDB: The InnoDB memory heap is disabled 130728 6:50:14 InnoDB: Mutexes and rw_locks use GCC atomic builtins 130728 6:50:14 InnoDB: Compressed tables use zlib 1.2.3.4 130728 6:50:14 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 130728 6:50:14 InnoDB: Completed initialization of buffer pool 130728 6:50:14 InnoDB: Fatal error: cannot allocate memory for the buffer pool 130728 6:50:14 [ERROR] Plugin 'InnoDB' init function returned error. 130728 6:50:14 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 130728 6:50:14 [ERROR] Unknown/unsupported storage engine: InnoDB 130728 6:50:14 [ERROR] Aborting 130728 6:50:14 [Note] /usr/sbin/mysqld: Shutdown complete
解決方法:
1) 在 /etc/mysql/my.cnf 的 mysqld 下增長下面一句:服務器
innodb_buffer_pool_size = 64M
還要設置一下swap分區,由於個人vps是沒有swap分區的,經過fdisk -l
和 1mount
看不到swap的信息,須要手動添加一下。ui
2) 添加swap分區的步驟:阿里雲
2.1) dd if=/dev/zero of=/swapfile bs=1M count=1024 2.2) mkswap /swapfile 2.3) swapon /swapfile 2.4) 添加這行: /swapfile swap swap defaults 0 0 到 /etc/fstab
目前已經設置了swap分區,並重啓了mysql,後續觀察一下看看還會不會出現吧。atom
參考:http://stackoverflow.com/questions/10284532/amazon-ec2-mysql-aborting-start-because-innodb-mmap-x-bytes-failed-errno-12spa
補充,通過近2個月觀察,沒再發生down掉的狀況。日誌