简体   繁体   中英

Amazon EC2 - Error Establishing Database Connection - mysql dead but subsys locked

I know that there are lots of questions about this out there but unfortunately none of the solution seems to fix my problem. I have been spending lot of time finding the solution and did not achieve much from my reading with my limited knowledge.

I am using Amazon free tier and hosting a Wordpress site. I have installed LAMP and Wordpress. The website is now in the development mode. Initially everything was good but after some time suddenly I started to receive problem of Error Establishing Database Connection very frequent.

Some findings when the problem appeared:

  1. sudo service mysqld status returned mysqld dead but subsys locked
  2. Deeper in the log:

     InnoDB: Initializing buffer pool, size = 10.0M InnoDB: mmap(10731520 bytes) failed; errno 12 InnoDB: Completed initialization of buffer pool InnoDB: Fatal error: cannot allocate memory for the buffer pool Completed initialization of buffer pool InnoDB: Fatal error: cannot allocate memory for the buffer pool [ERROR] Plugin 'InnoDB' init function returned error. [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. [ERROR] Unknown/unsupported storage engine: InnoDB [ERROR] Aborting /usr/libexec/mysql55/mysqld: Shutdown complete 

So what I have done are as below but none of them works for me yet:

  1. Restart httpd and mysqld >>>>> OK for few minutes then got the problem again
  2. Make swap file of 1GB >>>>> even 2GB did not work for me. OK for a while (few hours) but the problem come back
  3. Decreased innodb_buffer_pool_size down to 10MB but still not happy

I really have no idea on how to sort this issue. What I realized is whenever I start on the new server, it is good for a while then the problem comes. Any help and guidance are greatly appreciated.

Thanks.

All the above problems you have mentioned happens when you run MYSQL on a AWS free tier EC2 micro instance as it already has less memory. This problem will escalate more when you launch your site live. I will suggest you launch a separate AWS RDS MYSQL server in free tier and use that as the database for your Wordpress website. Check this link AWS RDS Free Tier

You will have many advantages like there is no need to keep up with vendor security and performance patches when you use Amazon RDS, this is taken care of by the AWS. RDS also includes backup and recovery services, eliminating another common task on to-do lists.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM