轉自:http://kerry.blog.51cto.com/172631/300784
limits.conf 文件實際是 Linux PAM(插入式認證模塊,Pluggable Authentication Modules)中 pam_limits.so 的配置文件,而且只針對於單個會話。
limits.conf的格式如下:
username|@groupname type resource limit
username|@groupname:設置需要被限制的用戶名,組名前面加@和用戶名區別。也可以用通配符*來做所有用戶的限制。
type:有 soft,hard 和 -,soft 指的是當前系統生效的設置值。hard 表明系統中所能設定的最大值。soft 的限制不能比har 限制高。用 - 就表明同時設置了 soft 和 hard 的值。
resource:
core - 限制內核文件的大小
date - 最大數據大小
fsize - 最大文件大小
memlock - 最大鎖定內存地址空間
nofile - 打開文件的最大數目
rss - 最大持久設置大小
stack - 最大棧大小
cpu - 以分鍾為單位的最多 CPU 時間
noproc - 進程的最大數目
as - 地址空間限制
maxlogins - 此用戶允許登錄的最大數目
要使 limits.conf 文件配置生效,必須要確保 pam_limits.so 文件被加入到啟動文件中。查看 /etc/pam.d/login 文件中有:
session required /lib/security/pam_limits.so
例如:修改文件描述符大小(65536)
vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536