Plesk

MySQL/MariaDB crashes with error: Fatal error: cannot allocate memory for the buffer pool

Symptoms

  1. Plesk is not accessible: 

    Error 2002. ERROR: PleskDBException: Unable to connect to database: mysql_connect(): Connection refused /var/run/mysqld/mysqld.sock (Error code: 2002)

  2. MySQL/MariaDB crashes intermittently. There is an error in
    /var/log/mysqld.log
    file:

    InnoDB: Initializing buffer pool, size = 128.0M
    InnoDB: mmap(137363456 bytes) failed; errno 12
    InnoDB: 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

Cause

MySQL/MariaDB buffer size is bigger than free RAM available on the server.

Resolution

Contact system administrator to allocate more RAM to the server.

As a temporary workaround:

  1. Connect to the server using SSH.
  2. Check how much free RAM there is on the server:

    # free -hm
    total used free shared buffers cached
    Mem: 1.0G  122M 901M 92K 0B 61M
    -/+ buffers/cache: 61M 962M
    Swap: 1.0G 0B 1.0G

  3. Set MySQL/MariaDB buffer pool size in
    /etc/my.cnf
    less than amount of free RAM:

    innodb_buffer_pool_size=100M

  4. Restart MySQL/MariaDB service:

    # service mysqld restart || service mysql restart || service mariadb restart

Exit mobile version