Plesk or website are not working: Unable to connect to database MySQL server has gone away: Full server backup is created with warning: errno: 24 - Too many open files

Created:

2016-11-16 13:08:04 UTC

Modified:

2017-08-18 08:58:19 UTC

3

Was this article helpful?


Have more questions?

Submit a request

Plesk or website are not working: Unable to connect to database MySQL server has gone away: Full server backup is created with warning: errno: 24 - Too many open files

Applicable to:

  • Plesk 12.5 for Linux
  • Plesk Onyx for Linux
  • Plesk 12.0 for Linux

Symptoms

  1. Plesk or a website is not accessible:

    ERROR: PleskDBException: Unable to connect to database: mysql_connect(): MySQL server has gone away (Error code: 2006) (Abstract.php:69)
  2. One of the following errors can be found in /var/log/plesk/panel.log :

    ERR [1] SQLSTATE[HY000] [2006] MySQL server has gone away
    ERR [1] Unable to connect to database: (Error code: 2006)

    ERROR: [pool example.com] cannot get uid for user 'root': Too many open files (24)

    Error: SQLSTATE[HY000]: General error: 23 Out of resources when opening file '/tmp/#***.MYD' (Errcode: 24 - Too many open files)
  3. /var/log/mysql/error.log file contains the following error:

    [ERROR] /usr/sbin/mysqld: Can't open file: './usr_web587_1/etqvi_languages.frm' (errno: 24 - Too many open files)
  4. In /var/log/syslog one of the following errors can be found:

    [ERROR] /usr/sbin/mysqld: Can't open file: './usr_1/contrexx_voting_results.frm' (errno: 24 - Too many open files)

    Failed to process database 'wordpress_f' from domain 'example.com': MySQL error 1018: Can't read dir of './wordpress_f/' (errno: 24 "Too many open files") executing query: SHOW TABLE STATUS FROM `wordpress_f`

    [ERROR] Error in accept: Too many open files

    systemd[1]: Stopping LSB: Start and stop the mysql database server daemon...
    mysql[27839]: Stopping MariaDB database server: mysqld failed!
  5. MySQL goes down periodically and cannot be started without rebooting the server itself.

  6. Full server backup is created with the warning:

    WARNING:      (mysql object 'ghweddin_opencart_e')      Not all the data was backed up into /var/lib/psa/dumps/clients/ghweddin/domains/ghweddingplanner.com/databases/ghweddin_opencart_e_1 successfully. mysqldump: Couldn't execute 'show table status like 'address'': Can't read dir of './ghweddin_opencart_e/' (errno: 24 - Too many open files) (1018)
  7. Disk usage statistics for subscriptions are not calculated.

Cause

Limit on number of open files has been reached on the MySQL server. When MySQL fails to open required files, the process gets hanged and systemd fails to stop MySQL process.

Resolution

For Systemd(Centos 7/Debian 8/Ubuntu 16) Operation Systems:

  • Create a new directory for mariadb/mysql service changes:

    # mkdir -p /etc/systemd/system/mariadb.service.d/
    # touch /etc/systemd/system/mariadb.service.d/limits.conf
  • Configure systemd open files limit for mariadb/mysql:

    # cat /etc/systemd/system/mariadb.service.d/limits.conf
    [Service]
    LimitNOFILE=1024000
  • Restart mariadb/mysql and daemon loader:

    # systemctl daemon-reload
    # systemctl restart mariadb

    Note: For Debian 8/Ubuntu 16 all the actions are the same, but the name of the service should be mysql instead of mariadb

For other Operation Systems:

  • Increase open_files_limit in /etc/mysql/my.cnf for both sections [mysqld] and [mysqld_safe] :

    [mysqld]
    open_files_limit = 1024000

    [mysqld_safe]
    open_files_limit = 1024000
  • Restart MySQL:

    # service mysqld restart

    Or MariaDB:

    # service mariadb restart
  • Perform mysqlcheck if needed

Have more questions? Submit a request
Please sign in to leave a comment.