Process

系統重新啟動後文件描述符限制失去

  • July 23, 2011

我正在嘗試增加系統上程序的預設文件描述符限制。具體來說,我試圖在機器啟動時獲得適用於 Condor 守護程序及其子程序的限制。但是這些限制永遠不會應用於機器啟動。

我設置了以下限制/etc/sysctl.conf

[root@mybox ~]# cat /etc/sysctl.conf
# TUNED PARAMETERS FOR CONDOR PERFORMANCE
# See http://www.cs.wisc.edu/condor/condorg/linux_scalability.html for more information

# Allow for more PIDs (to reduce rollover problems); may break some programs
kernel.pid_max = 4194303

# increase system file descriptor limit
fs.file-max = 262144

# increase system IP port limits
net.ipv4.ip_local_port_range = 1024 65535

並在/etc/security/limits.conf

[root@mybox ~]# cat /etc/security/limits.conf
# TUNED PARAMETERS FOR CONDOR PERFORMANCE
# See http://www.cs.wisc.edu/condor/condorg/linux_scalability.html for more information
# Increase the limit for a user continuously by editing etc/security/limits.conf.
*        soft  nofile        32768
*        hard  nofile      262144 #65536

我遇到的麻煩是,在系統重新啟動時,這些限制似乎不適用於 Condor 及其程序。重新啟動後,如果我查看 Condor 程序的文件描述符限制,我會看到:

[root@mybox proc]# cat /proc/`/sbin/pidof condor_schedd`/limits | grep 'Max open files'
Max open files            1024                1024

但是,如果我在重新啟動condor_schedd後重新啟動該過程,則限制會按預期增加:

[root@mybox proc]# cat /proc/`/sbin/pidof condor_schedd`/limits | grep 'Max open files'
Max open files            32768                262144

表示這些boot.log限制是在我的 Condor 守護程序及其程序啟動之前設置的:

May 18 07:51:52 mybox sysctl: net.ipv4.ip_forward = 0
May 18 07:51:52 mybox sysctl: net.ipv4.conf.default.rp_filter = 1
May 18 07:51:52 mybox sysctl: net.ipv4.conf.default.accept_source_route = 0
May 18 07:51:52 mybox sysctl: kernel.sysrq = 0
May 18 07:51:52 mybox sysctl: kernel.core_uses_pid = 1
May 18 07:51:52 mybox sysctl: kernel.pid_max = 4194303
May 18 07:51:52 mybox sysctl: fs.file-max = 262144
May 18 07:51:52 mybox sysctl: net.ipv4.ip_local_port_range = 1024 65535
May 18 07:51:52 mybox network: Setting network parameters: succeeded
May 18 07:51:52 mybox network: Bringing up loopback interface: succeeded
May 18 07:51:57 mybox ifup: Enslaving eth0 to bond0
May 18 07:51:57 mybox ifup: Enslaving eth1 to bond0
May 18 07:51:57 mybox network: Bringing up interface bond0: succeeded
May 18 07:52:17 mybox hpsmhd: smhstart startup succeeded
May 18 07:52:17 mybox condor: Starting up Condor
May 18 07:52:17 mybox rc: Starting condor:  succeeded
May 18 07:52:17 mybox crond: crond startup succeeded

顯然,我想避免必須啟動機器,然後重新啟動我需要應用這些增加的限制的程序——我做錯了什麼,阻止這些限制在機器啟動時應用到程序?

ulimit -n 262144添加到 condor 初始化腳本。

引用自:https://unix.stackexchange.com/questions/16604