Changing open files limit

vps

#1

Hi, I want to change open files limit on VPS but I am running into issues with that:

I am on root and when I run:

ulimit -n 32384

bash: ulimit: open files: cannot modify limit: Operation not permitted

I unchecked dreamhost managed mode for that server. Do you know what I might be missing and how to change open files limit on VPS?
[hr]
Ok, I found the other way to do that. You need to edit /etc/security/limits.conf file instead. Thread can be closed.


#2

Ok, it is not that easy. My problem with too many open files for nginx is back. It looks like setting is not working.

In the nxginx init script I can see:

ulimit -Sn 8000
ulimit -Su 2000

but whenever I run it with sudo to restart. I can see:
[ps126641]$ sudo /etc/init.d/nginx restart
/etc/init.d/nginx: line 13: ulimit: open files: cannot modify limit: Invalid argument

Can anyone help?


#3

1 thing I noticed is that the problem is that nginx is running as dhapache user and inherits different set of limit. Reboot didn’t help for that.

In /proc/pid/limits for nginx I can see:

[ps126641]$ cat /proc/19381/limits
Max open files 1024 1024 files

for processed running under my account:

[ps126641]$ cat /proc/29907/limits
Max open files 132384 132384 files

Which is what I set in /etc/security/limits.conf.

  • soft nofile 132384
  • hard nofile 132384

Do you know how to bump that for dhapache user as well?


#4

/etc/pam.d/login
session required pam_limits.so

/etc/security/limits.conf

  • hard nofile 8000
  • soft nofile 8000

/etc/init.d/httpd2
ulimit -Sn 8000

/etc/init.d/nginx
ulimit -Sn 8000

Note: Untested on DH VPS


#5

Check your current hard limits (“ulimit -aH”). You can’t set soft limits (which is what “ulimit” modifies by default) higher than hard limits.


#6

thanks, this was helpful… just to get rid of the annoying error message i’ve been getting on su about ulimit… dreamhost keeps overwriting my /etc/profile even though i changed everything on my host to not managed, and putting in the same ulimit lines that were giving an error. increasing the limits in /etc/security/limits.conf removed the error and my irritation. i had totally forgotten about that. it seems there’s several different conf files for each feature these days…