4

MySQL Seems to be crashing quite often, I'd say every hour or so.

The only thing running on this server that is using MySQL is a Drupal installation that I'm working on, there's only one person that's using it and it literally has around three pages - from what I can gather this seems to be a memory issue with innoDB? I'm not great at this stuff so I'm unsure.

Any guidance? Here's the relevant parts from my error.log

140216 14:20:01 [Note] Plugin 'FEDERATED' is disabled.
140216 14:20:01 InnoDB: The InnoDB memory heap is disabled
140216 14:20:01 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140216 14:20:01 InnoDB: Compressed tables use zlib 1.2.3.4
140216 14:20:01 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(135987200 bytes) failed; errno 12
140216 14:20:01 InnoDB: Completed initialization of buffer pool
140216 14:20:01 InnoDB: Fatal error: cannot allocate memory for the buffer pool
140216 14:20:01 [ERROR] Plugin 'InnoDB' init function returned error.
140216 14:20:01 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140216 14:20:01 [ERROR] Unknown/unsupported storage engine: InnoDB
140216 14:20:01 [ERROR] Aborting

140216 14:20:01 [Note] /usr/sbin/mysqld: Shutdown complete

140216 14:20:02 [Note] Plugin 'FEDERATED' is disabled.
140216 14:20:02 InnoDB: The InnoDB memory heap is disabled
140216 14:20:02 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140216 14:20:02 InnoDB: Compressed tables use zlib 1.2.3.4
140216 14:20:02 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(135987200 bytes) failed; errno 12
140216 14:20:02 InnoDB: Completed initialization of buffer pool
140216 14:20:02 InnoDB: Fatal error: cannot allocate memory for the buffer pool
140216 14:20:02 [ERROR] Plugin 'InnoDB' init function returned error.
140216 14:20:02 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140216 14:20:02 [ERROR] Unknown/unsupported storage engine: InnoDB
140216 14:20:02 [ERROR] Aborting

140216 14:20:02 [Note] /usr/sbin/mysqld: Shutdown complete

EDIT
The server is the lowest-spec DigitalOcean Droplet with 512MB RAM. This particular Droplet is running NodeJS, MySQL and Apache. There's a low-traffic static site, a Ghost blog and this Drupal site I'm developing.

Should I just upgrade the RAM, or is there something I can do to fix this?

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
Luke Berry
  • 141
  • 1
  • 5

1 Answers1

2

MySQL doesn't start because it cannot allocate 128M for the InnoDB buffer pool.

You have to either set lower innodb_buffer_pool_size or limit number of Apache processes so they don't consume all memory. I had the same problem and described it in a blog

akuzminsky
  • 738
  • 4
  • 9
  • I see... It's strange though, because it runs fine at 128M initially, then after around an hour (I don't even have to be working on the Drupal site) it will crash. I run my personal site from the same server, and it is very, very low traffic and is just a simple HTML site, the blog is using Ghost which runs using NodeJS so surely that bypasses Apache all together? I'll stick innodb_buffer_pool_size down to 64M and see if that helps. Cheers. – Luke Berry Feb 16 '14 at 14:44
  • Why strange? MySQL needs 128 continuous megabytes for the buffer pool. You have 512M, it's not a problem to allocate 128 if number of httpd processes is low. But over time, number of idle httpd processes increases and it becomes not possible to find 128M anymore. But check why MySQL crashes. That's worrying – akuzminsky Feb 16 '14 at 14:52
  • You may also have other memory consumers. Check that too. – akuzminsky Feb 16 '14 at 14:53
  • I would guess the oom-killer was why MySQL crashed in the first place. MySQL is a favourite of the oom-killer. It logs what it does and why. Grep for "oom" or "Killed" in your logs. – Ladadadada Feb 16 '14 at 23:53
  • Mod_php and the Apache prefork MPM will chew up a lot of RAM. CGI mode with a different MPM (or a different http daemon altogether) will help. – Ladadadada Feb 16 '14 at 23:57