答案1
将文件放在此处 ( /etc/security/limits.d
),而不是编辑实际/etc/security/limits.conf
文件。
$ cat /etc/security/limits.d/90-arcgis.conf
siteadmin - nofile 65536
siteadmin - nproc 25059
例子
在这里,我设置了一个用户siteadmin
并登录。这是该用户的默认限制:
$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 3875
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 3875
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
用户的nproc
和nofile
默认的如下:
max user processes (-u) 3875
open files (-n) 1024
笔记:这些值将用户在他们可能调用的所有进程中限制为这些上限。限制由用户控制,例如,如果您运行 10 个进程,则它们的打开时间限制为 1024 个。
现在如果我们将文件添加到/etc/security/limits.d/90-arcgis.conf
:
$ cat /etc/security/limits.d/90-arcgis.conf
siteadmin - nofile 65536
siteadmin - nproc 25059
如果我们登录siteadmin
:
$ su - siteadmin
Last login: Fri Jul 20 14:07:10 EDT 2018 on pts/0
$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 3875
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 25059
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
现在我们看到我们的极限正在被突破。
这是怎么回事-
在 limit.conf 文件中,您可以指定soft
或hard
两者。意思-
是两者都有。
根据man limits.conf
手册页:
<type>
hard
for enforcing hard resource limits. These limits are set by the
superuser and enforced by the Kernel. The user cannot raise his
requirement of system resources above such values.
soft
for enforcing soft resource limits. These limits are ones that
the user can move up or down within the permitted range by any
pre-existing hard limits. The values specified with this token
can be thought of as default values, for normal system usage.
-
for enforcing both soft and hard resource limits together.
Note, if you specify a type of '-' but neglect to supply the item
and value fields then the module will never enforce any limits on
the specified user/group etc. .