Linux Too many open files
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:
create a new file
/etc/systemd/system.conf.d/limits.conf
with these contents:[Manager]
DefaultLimitNOFILE=65535
run
systemctl daemon-reexec
as rootlogout and login again
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
最新文章
- Android数据加密之SHA安全散列算法
- Spring操作指南-针对JDBC配置声明式事务管理(基于注解)
- 基于uploadify.js实现多文件上传和上传进度条的显示
- Mysql导出函数、存储过程
- C#属性和变量的区别学习
- eclipse插件安装 (zhuan)
- ngcordova 监控网络制式改变
- Oracle ROWNUM用法和分页查询总结(转)
- epoll模型的et模式和lt模式
- 【PAT】1009. Product of Polynomials (25)
- Vue动态组件
- phpstorm及webstorm密钥
- [BJOI2006]狼抓兔子
- python多任务抓取图片
- JPA、Hibernate框架、通用mapper之间的关系及通用mapper的具体实现
- C++开发者都应该使用的10个C++11特性 转
- BIO、NIO实战
- 将SQL for xml path(&#39;&#39;)中转义的字符正常显示
- WPF:理解ContentControl——动态添加控件和查找控件
- 通过Jenkins在IIS上布署站点