在 Ubuntu Server 18.04 上更新 Limits.conf 时出现问题

在 Ubuntu Server 18.04 上更新 Limits.conf 时出现问题

我正在尝试在其上安装应用程序Ubuntu Server LTS 18.04,但收到此错误:

在此输入图像描述

所以我打电话给:

$ gedit admin:///etc/security/limits.conf

limits.conf打开。然后我在文件末尾添加了一些行,如下所示:

![在此输入图像描述

但保存后运行:

$ ulimit -Hn -Hu
$ ulimit -Sn -Su

我仍然得到与他们相同的金额:

在此输入图像描述

你能让我知道我做错了什么以及如何解决这个问题吗?

答案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

用户的nprocnofile默认的如下:

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 文件中,您可以指定softhard两者。意思-是两者都有。

根据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. .

参考

相关内容