Ubuntu默认的open files为1024, 可以通过ulimit -n
来查看;
在高并发场景下, 网络服务打开的文件描述符可能会超过这个限制, 那么我们需要来增大这个值
执行如下命令, 会增大open files值, 但是重启后会被恢复
$ ulimit -n 10240
- 编辑
/etc/security/limits.conf
, 追加如下行(带星号的行表示对root以外的用户有效):
* soft nofile 64000
* hard nofile 64000
root soft nofile 64000
root hard nofile 64000
- 编辑
/etc/pam.d/common-session
和/etc/pam.d/common-session-noninteractive
, 分别追加如下行:
session required pam_limits.so
- 重启, 验证是否生效