Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot set limit of MySQL open-files-limit from 1024 to 65535

Tags:

linux

mysql

I have mysql ver. 5.1.49-3, I am working on linux debian. I am trying to set open-files-limit to 65535. so I edited te my.cnf in /etc/mysql/

[mysqld]
open_files_limit = 65535
[mysqld_safe]
open_files_limit = 65535

then in /etc/security/limit.conf

*   soft    nofile  100000
*   hard    nofile  200000

After restarting mysql service, when I run this command in linux

ps -ef|grep mysql

I got 65535. when I log into mysql as root and fetch the value of open-files-limit

show global variables like "%open_files_limit%";

I got 1024. Please help.

like image 647
Joey Avatar asked Mar 19 '14 02:03

Joey


People also ask

How do I change the open limit in MySQL?

To change the number of file descriptors available to mysqld, you can use the --open-files-limit option to mysqld_safe or set the open_files_limit system variable. See Section 5.1. 8, “Server System Variables”. The easiest way to set these values is to add an option to your option file.

What is open_files_limit?

The open_files_limit is a soft limit set by MySQL. The operating system determines the hard limit on file descriptors. That is why, even if the open_files_limit variable is set to a high value, mysqld service shows the warning, [Warning] Could not increase number of max_open_files to more than xxxx.


2 Answers

If mysql is started with systemd, this setting is important:

In the file /lib/systemd/system/mysql.service you have to add this 2 lines in the [Service] section at the end:

LimitNOFILE = infinity
LimitMEMLOCK = infinity

After this restart systemctl and mysql:

systemctl daemon-reload
/etc/init.d/mysql restart

To check if the configuration is effective, you can get the parameter from the running mysql process like this:

cat /proc/$(pgrep mysqld$)/limits | grep files
like image 177
minni Avatar answered Nov 01 '22 18:11

minni


All I need is to add this line to /etc/pam.d/common-session: session required pam_limits.so

then restart apache

like image 44
Joey Avatar answered Nov 01 '22 17:11

Joey