我正在尝试增加系统上进程的默认文件描述符限制。具体来说,我试图在机器启动时获取适用于 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
显然,我想避免必须启动机器,然后重新启动需要应用这些增加的限制的进程——我做错了什么,导致机器启动时无法将这些限制应用到进程?
答案1
添加ulimit -n 262144到Condor初始化脚本。