如何永久修改SUSE Linux Enterprise Server 10.4上打开文件的ulimit?


9
SERVER:/etc # ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 96069
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 96069
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
SERVER:/etc # 

如何将root用户的限制永久设置为1024?如何全局设置ulimit?更改是否会立即生效?

ps:我已经用它搜索了一下,但是找不到可以永久设置的文件:

SERVER:/etc # grep -RiI ulimit * 2>/dev/null | egrep -v ":#|#ulimit"
init.d/boot.multipath:      ulimit -n $MAX_OPEN_FDS
init.d/multipathd:      ulimit -n $MAX_OPEN_FDS
rc.d/boot.multipath:        ulimit -n $MAX_OPEN_FDS
rc.d/multipathd:        ulimit -n $MAX_OPEN_FDS

和..:

SERVER:/etc # grep -RiI 'MAX_OPEN_FDS' * 2>/dev/null
init.d/boot.multipath:MAX_OPEN_FDS=4096
init.d/boot.multipath:  if [ -n "$MAX_OPEN_FDS" ] ; then
init.d/boot.multipath:      ulimit -n $MAX_OPEN_FDS
init.d/multipathd:MAX_OPEN_FDS=4096
init.d/multipathd:  if [ -n "$MAX_OPEN_FDS" ] ; then
init.d/multipathd:      ulimit -n $MAX_OPEN_FDS
rc.d/boot.multipath:MAX_OPEN_FDS=4096
rc.d/boot.multipath:    if [ -n "$MAX_OPEN_FDS" ] ; then
rc.d/boot.multipath:        ulimit -n $MAX_OPEN_FDS
rc.d/multipathd:MAX_OPEN_FDS=4096
rc.d/multipathd:    if [ -n "$MAX_OPEN_FDS" ] ; then
rc.d/multipathd:        ulimit -n $MAX_OPEN_FDS
SERVER:/etc # 

Answers:


9

使用pam_limits(8)模块,将以下两行添加到/etc/security/limits.conf

root hard nofile 8192
root soft nofile 8192

下次登录时,这会将root的RLIMIT_NOFILE资源限制(软和硬)增加到8192。


1
我对其进行了修改,但是即使重新登录后,看到带有根目录的ulimit -a时,它似乎也不起作用,如何在不重新启动的情况下将此更改应用于limits.conf?:D
加斯科彼得,2012年

1
ulimit -n 8192将立即为当前shell及其所有子进程设置限制。
Petr Uzel 2012年

我接受..但afaik机器需要重新启动:)-直到那时.bash_profile .. ulimit -n 8192
gasko peter 2012年

该文件/etc/security/limits.conf仅是事实的一半:该文件由读取pam_limits.so,而该文件又必须进行配置。手册页上/etc/pam.d/login应有一行session required pam_limits.so
U. Windl
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.