我添加了一行/etc/security/limits.conf
以增加打开文件的数量。
* hard nofile 4096
root hard nofile 16384
Run Code Online (Sandbox Code Playgroud)
但是,当我运行时,ulimit -n
它说 1024 是默认值。我注销并登录,但仍然看到 1024。我该如何应用更改?
Tom*_*art 23
ulimit
命令所做的更改:
$ ulimit -n 4096
$ ulimit -Hn 16384
Run Code Online (Sandbox Code Playgroud)
将仅适用于当前用户和会话。为了使其永久化,您必须/etc/security/limits.conf
通过添加限制进行修改:
* soft nofile 4096
* hard nofile 16384
Run Code Online (Sandbox Code Playgroud)
但是,通配符*
不适用于root
用户。为此,您必须明确说明:
* soft nofile 4096
* hard nofile 16384
root soft nofile 4096
root hard nofile 16384
Run Code Online (Sandbox Code Playgroud)
这些限制将在重新启动后应用。
如果要在不重启的情况下应用更改,请/etc/pam.d/common-session
在文件末尾添加以下行进行修改:
session required pam_limits.so
Run Code Online (Sandbox Code Playgroud)
下次登录时,您应该会看到更新的限制,您可以检查它们(软限制和硬限制):
$ ulimit -a
$ ulimit -Ha
Run Code Online (Sandbox Code Playgroud)
Flu*_*lup 11
如果您使用bash
,ulimit -n
将只显示软限制。要获得硬限制,您需要执行ulimit -Hn
.
在我的系统上,我看到了这个:
$ ulimit -n
1024
$ ulimit -Hn
4096
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
81934 次 |
最近记录: |