MySQL Crashes Frequently with Plugin ‘FEDERATED’ is Disabled Error

I’ve been having troubles with my MySQL server as of late, it’s been shutting down and not restarting. Earlier the problem was that the actual HD space was at 92% capacity, but I’ve fixed that by transferring my db to a new block, dropping the OS HD to 70% capacity. A little bit more workable.

However, now the problem is that it will start when I start it manually, but occasionally shuts down when under operation. Reading into the error.log I find:

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

Now, according to a few forums, this is telling us that the memory limit has been reached. No bueno.

The solution is to create a swap partition.

I’m running an Ubuntu box in an AWS environment, so by default swap space isn’t setup. To see the memory usage of the machine, type:

cat /proc/meminfo

This will give a fairly long list of random types of memory that are being used on the machine and a bit of their stats. You’ll probably notice that your main memory is maxed out.

Creating a Swap Space

Creating a swap space is relatively straight forward.

Initially, we need to decide where we will create our swap space. Using the df command in the terminal, you can see the mounted filesystems available to your use. I had the filesystem /mnt available, so that’s what I’ll be using.

    1. First, we must create the file we will use as our swap space. We will name the file 1GiB.swap:
      sudo fallocate -l 1g /mnt/1GiB.swap

      Note: If this doesn’t work, giving a “fallocate failed: Operation not supported” error, then the following old style command can be used:

      sudo dd if=/dev/zero of=/mnt/1GiB.swap bs=1024 count=1048576

    2. Change the ownership of the file, or at least ensure it’s set securely:

      sudo chmod 600 /mnt/1GiB.swap

    3. Add the swap to the system:

      sudo swapon /mnt/512MiB.swap

    4. Edit the fstab file to ensure the swap storage will be recognized and start with the system:

      sudo vi /etc/fstab

      and add the following to the end of the fstab file:

      /mnt/1GiB.swap none swap sw 0 0

That should be it. Your system needs to be rebooted have it start working. After the reboot, the command:

sudo cat /proc/meminfo

should let you view the increase or new swap space used.

Another helpful command is:

free

Which will show you a nice memory usage table.

The following pages have been used as reference:

Leave a Reply

4 + 18 =