salt-formulas / salt-formula-galera

Other
8 stars 21 forks source link

add open-files-limits to upstart/init.d scripts #4

Open epcim opened 8 years ago

epcim commented 8 years ago

http://askubuntu.com/questions/288471/mysql-cant-open-files-after-updating-server-errno-24

OS: Ubuntu (Debian) deployments

For init.d probably setting ulimit -n xxx might be accepted. For upstart etc..:

MySQL Server Option: open-files-limit

It seems that the Debian upstart doesn't use the parameters defined in /etc/security/limits.conf, so when you launch mysql through the service command (and so, under upstart), it overrides those defined limits and uses the default 1024.

The solution is to modify the mysql.conf file that defines the upstart service, it is located in /etc/init/mysql.conf and add the following lines before the pre-start block:

# NB: Upstart scripts do not respect
# /etc/security/limits.conf, so the open-file limits
# settings need to be applied here.
limit nofile 32000 32000
limit nproc 32000 32000
References:

http://serverfault.com/questions/440878/changing-open-files-limit-in-mysql-5-5
http://dev.mysql.com/doc/refman/5.5/en/server-options.html#c12634
shareimprove this answer
answered Apr 30 '13 at 14:21
epcim commented 8 years ago

Proposed solution:

http://duntuk.com/how-raise-ulimit-open-files-and-mysql-openfileslimit

/etc/init.d/mysqld ulimit -S -n ${DAEMON_FILES_LIMIT:-102400} >/dev/null 2>&1

/etc/my.cnf

[myqld_safe]
open_files_limit = 102400

[myqld]
open_files_limit = 102400

for systemd

cd /etc/systemd/system/

rm mysql.service
#Copy service to services directory (so it won't be overwritten by any upgrade):
cp /usr/lib/systemd/system/mysqld.service mysqld.service

# In the Service section add LimitNOFILE=1024000.
[Service]
User=mysql
Group=mysql
LimitNOFILE=1024000```