Linux Too many open files

查看系统资源限制信息:

sudo -s -u root -H id

sudo -s lsof | awk '{ print $2 " " $1; }' | sort -rn | uniq -c | sort -rn | head -20

sudo -s ulimit -Sn

sudo -s ulimit -Hn

sudo cat /proc/sys/fs/file-max

sudo -s cat /etc/security/limits.conf

最后当我们尝试$ cat /proc/<processId>/limits; 我们注意到“打开文件数”仍显示为4096,这是旧值; 虽然对于root来说它显示了更高的值。

最后,我们可以通过修改 /etc/default/tomcat7 [或与您的进程相对应的任何其他文件]并添加以下行来解决此问题:

ulimit -Hn 10000
ulimit -Sn 10000

无需重启系统; 只需重新启动进程,然后检查 cat /proc/<processId>/limits

在ubuntu 16.04下,tomcat的最大文件数受systemd限制,并自动设置为4096.您可以通过运行更改此值

systemctl edit tomcat7

添加以下行:

[Service]
LimitNOFILE=8192

或者你可以自己创建配置:

mkdir /etc/systemd/system/tomcat7.service.d/
nano /etc/systemd/system/tomcat7.service.d/override.conf

之后重新加载tomcat:

服务tomcat7重启

并仔细检查是否正确设置了限制

ps ax | grep tomcat
cat /proc/<processId>/limits

1. 使用以下行修改/etc/systemd/user.conf和/etc/systemd/system.conf(这将负责图形登录):
DefaultLimitNOFILE=65535

2. 使用以下行修改/etc/security/limits.conf(这将负责非GUI登录):
* hard nofile 65535
* soft nofile 65535
root hard nofile 65535
root soft nofile 65535

3. 可选操作,编辑 /etc/pam.d/common-session和/etc/pam.d/common-session-noninteractive 文件并添加以下行到最后:
session required pam_limits.so

4. 重新启动计算机以使更改生效。

No need to change anything in the /etc/security/limits.conf file, it is ignored if you are using systemd.

(reproducing a modified answer to another question on the network...)

An alternative for those who prefer not to edit the default /etc/systemd/system.conf and /etc/systemd/user/conf files:

  1. create a new file /etc/systemd/system.conf.d/limits.conf with these contents:

    [Manager]
    DefaultLimitNOFILE=65535
  2. run systemctl daemon-reexec as root

  3. logout and login again

  4. check your new limit with ulimit -n.

Refer to the systemd-system.conf manpage for details.

System.IO.IOException: Too Many Open Files (Mono .NET on Ubuntu)

sudo ps -waux | grep mono | grep -v grep | awk '{print $2}' | xargs kill -9

export MONO_MANAGED_WATCHER=disabled

================ End

最新文章

  1. Android数据加密之SHA安全散列算法
  2. Spring操作指南-针对JDBC配置声明式事务管理(基于注解)
  3. 基于uploadify.js实现多文件上传和上传进度条的显示
  4. Mysql导出函数、存储过程
  5. C#属性和变量的区别学习
  6. eclipse插件安装 (zhuan)
  7. ngcordova 监控网络制式改变
  8. Oracle ROWNUM用法和分页查询总结(转)
  9. epoll模型的et模式和lt模式
  10. 【PAT】1009. Product of Polynomials (25)
  11. Vue动态组件
  12. phpstorm及webstorm密钥
  13. [BJOI2006]狼抓兔子
  14. python多任务抓取图片
  15. JPA、Hibernate框架、通用mapper之间的关系及通用mapper的具体实现
  16. C++开发者都应该使用的10个C++11特性 转
  17. BIO、NIO实战
  18. 将SQL for xml path(&#39;&#39;)中转义的字符正常显示
  19. WPF:理解ContentControl——动态添加控件和查找控件
  20. 通过Jenkins在IIS上布署站点

热门文章

  1. vsCoad设置代码自动换行
  2. ContentProvider 共享数据
  3. 深度学习之加载VGG19模型分类识别
  4. c语言数组类型默认值(c99)
  5. redis开启持久化、redis 数据备份与恢复
  6. chrome下常用插件
  7. web赛题2
  8. springboot使用elasticsearch的客户端操作eslaticsearch
  9. Linux 脚本
  10. android简易计算器