Linux用户资源限制-ulimit

若是你的linux用户跑了不少程序,java进程等等,就有可能出现以下问题:
There is insufficient memory for the Java Runtime Environment to continue.
Cannot create GC thread. Out of system resources.
或者
java.io.IOException: Too many open files
出现这个缘由,有多是系统限制了用户的资源使用,因此须要使用ulimit来设置用户能得到的资源,使用命令:ulimit -a,查看资源配置状况,通常咱们须要修改的是open files和max user processes,open files对应的配置是nofile,用户打开文件最大的数量,max user processes对应的配置是nproc,用户启动最大的线程数。java

  • 修改/etc/security/limits.conf文件,将noproc和nofile修改为以下值:
* soft noproc 143622
* hard noproc 143622
* soft nofile 196605
* hard nofile 196605
  • nproc在/etc/security/limit.conf中修改有可能不生效,在/etc/security/limits.d/90-nproc.conf中修改才生效,修改/etc/security/limits.d/90-nproc.conf文件,将nproc修改为以下值:
* soft nproc 143622
* hard nproc 143622

修改后重启或从新ssh链接服务器,使用命令ulimit -a便可看到效果。
参考:
ulimit -a详解
Linux下修改ulimit设置的最大进程linux

相关文章
相关标签/搜索