October 27th, 2003

lung

Hmmm. [g]

There are a few linux types out there, maybe someone has some ideas.

I'm trying to change the number of file descriptors a non-root user can have in Redhat. Adding the user to /etc/security/limits.conf works the first time the user tries to change the values, but fails every time afterwards. The user can always set the limits to 1024 to less but can't go back over 1024 if they do.

Here's what I've got in my limits.conf:

ntang soft nofile 32000
ntang hard nofile 32000


Here's what happens when I try to change the limits:

[root@dhcp-101-144 sys]# su - ntang
[ntang@dhcp-101-144 ntang]$ ulimit -n
32000
[ntang@dhcp-101-144 ntang]$ ulimit -n 20000
[ntang@dhcp-101-144 ntang]$ ulimit -n
20000
[ntang@dhcp-101-144 ntang]$ ulimit -n 10000
[ntang@dhcp-101-144 ntang]$ ulimit -n
10000
[ntang@dhcp-101-144 ntang]$ ulimit -n 20000
-bash: ulimit: open files: cannot modify limit: Operation not permitted
[ntang@dhcp-101-144 ntang]$ ulimit -Hn
10000
[ntang@dhcp-101-144 ntang]$ ulimit -n 10000
[ntang@dhcp-101-144 ntang]$ ulimit -n 5000
[ntang@dhcp-101-144 ntang]$ ulimit -n 10000
-bash: ulimit: open files: cannot modify limit: Operation not permitted
[ntang@dhcp-101-144 ntang]$ ulimit -Hn
5000
[ntang@dhcp-101-144 ntang]$ ulimit -Sn 2500
[ntang@dhcp-101-144 ntang]$ ulimit -Hn
5000
[ntang@dhcp-101-144 ntang]$ ulimit -Sn
2500
[ntang@dhcp-101-144 ntang]$


So basically, the user can drop their hard limit but can't raise it up again. This sort of makes sense, but is sort of stupid as well. Why? Well, when you start MySQL, it (as far as we can tell) sets the ulimit down to 1024 and then tries to raise it back up to whatever you configured it for - but it changes the hard limit, at which point it fails. We've got the limits.conf limits set to 32000 for the mysql user, but thanks to the way MySQL works it shoots itself in the foot and makes that useless.

Anyone know any workarounds? I'm a bit baffled.

[g] - for geekery, of course.