linux修改用户打开文件数量的限制

原文地址:https://doc.nuxeo.com/display/KB/java.net.SocketException+Too+many+open+files

Raising the Global Limit

Edit /etc/sysctl.conf and add the following line:
fs.file-max = 65536

Apply the changes with:
sudo sysctl -p /etc/sysctl.conf

Raising the per-User Limit

On some systems it is possible to use the ulimit -Hn 8192 and ulimit -Sn 4096 commands. However most of the time this is forbidden and you will get an error such as:
ulimit: open files: cannot modify limit: Operation not permitted

In those cases, you must:

Edit as root the following system configuration file:
% sudo vi /etc/security/limits.conf

Modify the values for nuxeo user (we assume here JBOSS is launched with the sytem user “nuxeo”

nuxeo           soft    nofile          4096
nuxeo           hard    nofile          8192

If you want to raise the limits for all users you can do instead:

*           soft    nofile          4096
*           hard    nofile          8192

Once you save file, you may need to logout and login again.

To check whether changes are taken into account, open a new session with the user that starts the nuxeo process. And check that the change has been taken into account:

% su nuxeo
% ulimit -n
1024

Here we can see that the new value has not been taken into account.
To fix this:
Edit /etc/pam.d/su:
% sudo vi /etc/pam.d/su
Uncomment the line:
session required pam_limits.so

The change should now be taken into account the next time you login with your user:

% su nuxeo
% ulimit -n
4096
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值