有没有办法增加 Amazon EC2 实例的 ulimit -n(打开文件)?我正在运行 amazon m3.2xlarge ubuntu 实例用于测试目的。 ulimit -Hn 是 4096,但我需要超过 10k。我什至尝试过暂时获得更高的实例类型,但没有成功。
我已经在谷歌上搜索了很长一段时间,但只有几年前的主题。大多数人建议更改/etc/security/limits.conf 中的 limit.conf 文件,但该限制是只读的,因此我无法更改权限。
有没有其他方法可以改变这种情况?
编辑 - 我的 etc/security/limits.conf 文件
#* soft core 0
#root hard core 100000
root soft nofile 16500
root hard nofile 16500
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#ftp - chroot /ftp
#@student - maxlogins 4
最佳答案
我最近遇到了这个问题,并导致在我的 UserData 中编辑 /etc/security/limits.conf
脚本。它最终看起来像这样:
#!/bin/bash
echo "* hard nofile 65535" | tee --append /etc/security/limits.conf
echo "* soft nofile 65535" | tee --append /etc/security/limits.conf
请注意,limits.conf 的“用户”是 *
,这意味着所有用户都将 65535
作为其限制。
关于node.js - 更改 Amazon EC2 上的 ulimit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24834549/