How to change "ulimit" and mysql "open-files-limit"
I think that the mentioned failure (
http://forum.parallels.com/showthread.php?317753-Fed-up-with-Plesk&p=753989&viewfull=1#post753989 ) resists in fact, that mysql can't have more open files than the actual "ulimit" definitions, with are defined with 1024 as a standard. Normally, this standard configuration is quite o.k., but when you have mail-server, webserver, nginx, php5-fpm and other things running on your webserver, it should be raised to be sure, that you don't reach the maximum. Some users already have higher definitions ( root and www-data ), but there is still room to adjust these settings for the user nginx, psaadm, psaserv, psacln, sw-cp-server and mysql. Be aware that each system has a global system-wide limit, which you may discover with "
cat /proc/sys/fs/file-max" ... please don't change the ulimits to a higher definition, because it won't work.
First, you might want to check your ulimit for the current user logged in:
ulimit -n
As you now can see ( if you didn't change it ^^ ), it will display 1024 .... with the command:
ulimit -a
... you could check all limits. - Please see the man-pages for more options in ulimit.
You could do the following steps to define some higher standards:
vi /etc/security/limits.conf
you will now see something like this:
Code:
# End of file
root hard nofile 64000
root hard nofile 64000
www-data hard nofile 64000
www-data hard nofile 64000
Short explanation: You can see in the description, that you have several ways to limit some rules. There are always "4" rows in that table definition. The first row defines the user/group/wildcard ( * means all ) and you can define the range from soft to hard, The "hard limit" for file identifiers for each prozess is defined for root and www-data and because there is no "soft limit" defined, the standard of 1024 is used ... o.k. back to the possible changes. ^^
Under the previous defintions, you might now add for a pretty good standard for all users:
Code:
* soft nofile 4096
* hard nofile 40960
* soft nproc 4096
* hard nproc 40960
If you would to define the above mentioned users in detail, you would change the previous definitions as well
Code:
root soft nofile 6400
root hard nofile 64000
root soft nproc 6400
root hard nproc 64000
www-data soft nofile 6400
www-data hard nofile 64000
www-data soft nproc 6400
www-data hard nproc 64000
nginx soft nofile 6400
nginx hard nofile 64000
nginx soft nproc 6400
nginx hard nproc 64000
psaadm soft nofile 6400
psaadm hard nofile 64000
psaadm soft nproc 6400
psaadm hard nproc 64000
psaserv soft nofile 6400
psaserv hard nofile 64000
psaserv soft nproc 6400
psaserv hard nproc 64000
psacln soft nofile 6400
psacln hard nofile 64000
psacln soft nproc 6400
psacln hard nproc 64000
sw-cp-server soft nofile 6400
sw-cp-server hard nofile 64000
sw-cp-server soft nproc 6400
sw-cp-server hard nproc 64000
mysql soft nofile 6400
mysql hard nofile 64000
mysql soft nproc 6400
mysql hard nproc 64000
Now, you changed some ulimits... but actually, you sure want these limits as well in your database - server, so you have to change some config as well:
vi /etc/mysql/my.cnf
Under the definition of "
[mysqld]", please add the following.
[mysqld]
open_files_limit = 6400
Now restart your mysql with:
service mysql restart
or
service mysqld restart
.... and lean back with a smile on your face and a cup of coffee. ^^ - To see the changes, you might like to logout of your shell and login in again and type "
ulimit -n" to see your own user changes and if you would like to see the changes for the mysql - server, just connect to your mysql - server, using the plesk short-command:
plesk db
and use the command while your are connected to your mysql - server:
show global variables like 'open%';
... type:
exit
... to get back to your shell.