Skip to content

Instantly share code, notes, and snippets.

@garenchan
Last active July 13, 2018 06:43
Show Gist options
  • Save garenchan/bb8f7c05f486e9a7adb1326b97a51b6d to your computer and use it in GitHub Desktop.
Save garenchan/bb8f7c05f486e9a7adb1326b97a51b6d to your computer and use it in GitHub Desktop.
increase open files

增大open-files

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
  • 重启, 验证是否生效
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment