LoginSignup
4
4

More than 5 years have passed since last update.

ulimit の変更

Posted at

/etc/security/limits.conf による設定変更

以下は全ユーザの nofile (max number of open files) の変更例。

/etc/security/limits.conf
*    soft nofile 10000
*    hard nofile 20000
$ ulimit -n -S
10000
$ ulimit -n -H
20000

サービスの設定変更

/etc/security/limits.conf の変更は、サービスには反映されないため、個々のサービス毎に行う必要がある。
以下は httpd での設定変更例。

RHEL6 の場合

$ echo "ulimit -SHn 8192   # nofile" >>/etc/sysconfig/httpd
$ service httpd restart

RHEL7 の場合

$ mkdir /etc/systemd/system/httpd.service.d
$ echo [Service] >/etc/systemd/system/httpd.service.d/ulimit.conf
$ echo LimitNOFILE=8000 >>/etc/systemd/system/httpd.service.d/ulimit.conf
$ systemctl restart httpd

以下の通り設定反映済み。

$ cat /proc/$(</var/run/httpd/httpd.pid)/limits| grep "Max open files"
Max open files            8000                 8000                 files

参考情報

How to set ulimit values
https://access.redhat.com/solutions/61334

What is the actual meaning of "Soft limit" and "Hard limit" in limits.conf file ?
https://access.redhat.com/solutions/648113

How to increase max file descriptor (nofile ulimit) for Apache httpd on RHEL 6
https://access.redhat.com/solutions/130573

How to set limits (ulimit) for services in RHEL6 and older with upstart, sysvinit
https://access.redhat.com/solutions/253043

How to set limits (ulimit) for services run by systemd
https://access.redhat.com/solutions/1346533

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4