This server host about 4 blogs that all run with MariaDB 10. After a few days running, MariaDB service keep failing on this micro EC2 AWS with error like this.
120423 09:13:38 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended120423 09:14:27 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql120423 9:14:27 [Note] Plugin 'FEDERATED' is disabled.120423 9:14:27 InnoDB: The InnoDB memory heap is disabled120423 9:14:27 InnoDB: Mutexes and rw_locks use GCC atomic builtins120423 9:14:27 InnoDB: Compressed tables use zlib 1.2.3120423 9:14:27 InnoDB: Using Linux native AIO120423 9:14:27 InnoDB: Initializing buffer pool, size = 512.0MInnoDB: mmap(549453824 bytes) failed; errno 12120423 9:14:27 InnoDB: Completed initialization of buffer pool120423 9:14:27 InnoDB: Fatal error: cannot allocate memory for the buffer pool120423 9:14:27 [ERROR] Plugin 'InnoDB' init function returned error.120423 9:14:27 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.120423 9:14:27 [ERROR] Unknown/unsupported storage engine: InnoDB120423 9:14:27 [ERROR] AbortingError 12 is OS error code:(ENOMEM) Out of memory, so of course you could just throw more memory to it. Or you could just enable swap to make MariaDB didn’t crash anymore. By default micro EC2 didn’t have a swap, so we should run a few linux command to make one.
sudo dd if=/dev/zero of=/swaps bs=1M count=1024sudo mkswap /swapssudo swapon /swapsTaadaa!! Your MariaDB instance should run flawlessly now. To make your change run for every reboot, Add this line /swaps swap swap defaults 0 0 to /etc/fstab.