I found MySQL was being annoying earlier and not ‘accepting’ my max_connections = 450 directive on a Debian Wheezy install, and being seemingly stuck on having 214 connections….
It turns out, Debian Wheezy doesn’t have pam_limits.so enabled by default in /etc/pam.d/* files. (But it is commented out, so easy enough to put into place).
/etc/pam.d/common-session :
# without comments. session [default=1] pam_permit.so session requisite pam_deny.so session required pam_permit.so session required pam_unix.so session required pam_limits.so session optional pam_ck_connector.so nox11 # end of pam-auth-update config
Once that’s enabled, you can edit /etc/security/limits.conf and adjust the maximum number of file handles (nofile) levels appropriately – which fixes the problem of the system not allowing MySQL to use more file handles for more connections.
e.g.
/etc/security/limits.conf :
.... other stuff ... * hard nofile 8192 * soft nofile 4096
(If you then login to the system again, and run ‘ulimit -a’ you’ll see the new numbers appear)
Next – reconfigure MySQL :
/etc/my.cnf:
[mysqld] .... max_connections = 450 ....
and now, once MySQL is restarted :
mysql> show variables like '%max_connecti%'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 450 | +-----------------+-------+ 1 row in set (0.00 sec)
and
mysql> show variables like '%open_files_limit%'; +----------------------------+----------+ | Variable_name | Value | +----------------------------+----------+ | open_files_limit | 5000 | +----------------------------+----------+
Leave a Reply