`
bdk82924
  • 浏览: 569783 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

tomcat 报 “too many open files Too many open files" 问题的解决思路

    博客分类:
  • Web
 
阅读更多
转:http://blog.csdn.net/big1980/article/details/6166122

linux系统出现Too many open files 错误,这是因为文件描述符大小不够,或者有不正常的网络连接(Socket也是一种特殊的文件)、

文件IO没有关闭并释放出文件描述符(文件句柄,File Operator)。


网上可以查询到解决方法 ,但是试了好几次都不成功,为什么呢?

先看下网上提供的方法

ulimit -u 查看open files设置 默认好像是1024 linux
ulimit -a 查看所有设置
ulimit -u 65535(新的open files 值)修改设置
ulimit -n 65536 设置用户可以同时打开的最大文件数(max open files) 默认是2048
如果本参数设置过小,对于并发访问量大的网站,可能会出现too many open files的错误 
使用lsof -p pid [httpd进程的 pid、java的pid]来查看系统中apache进程和java运行时进程当前打开的文件资源,发现两者之和已
经接近1024,大于了默认的设置




1、修改配置:(我看机器上好像都有)
修改/etc/security/limits.conf,在文件末加上
* soft nofile 65536
* hard nofile 65536


2、检查 /etc/bashrc文件
看是否有  ulimit -n 2048 ,有的话注释掉

3、修改 /etc/profile 文件
添加
ulimit -u 65535
ulimit -SHn 65535

4、 /etc/pam.d/su /etc/pam.d/sshd /etc/pam.d/login 文件中添加
      session    required     pam_limits.so
这个也看到过 ,加不加不知道有没有效果


5、修改 /etc/security/limits.d/90-nproc.conf
*          soft    nproc     10240
这个很少有看到


最终设置好后,重新登录下,检查下

ulimit -u
ulimit -n

分享到:
评论

相关推荐

    Too many open files 解决方法

    ### Too many open files 解决方法 #### 背景与问题描述 在将Web服务器从Windows环境迁移到Linux环境后,...通过上述解决方案,可以有效地解决“Too many open files”问题,保证Web服务器在高并发环境下的稳定运行。

    Linux下打开的文件过多错误

    Linux下运行tomcat或者was出现java.net.SocketException: 打开的文件过多错误 tomcat报“too many open files”的错误,解决办法如下:

    Tomcat优化-Tomcat 的性能调优的原理和方法

    - 如果在日志中出现“too many open files”的异常,则需要检查并适当增大`maxfiles`的值。 - 使用命令`ulimit-n`来设置`maxfiles`参数。 - **Windows操作系统的优化**:推荐使用服务器版本的Windows操作系统,...

    基于JFinal的开源博客系统JFinal_Blog2.0版本

    3、解决Lucene全文检索出现"too many open files "的bug问题; 4、解决Linux中tomcat容器乱码问题(URLEncoding="UTF-8"); 二、开源地址: 1、OSC介绍:http://www.oschina.net/p/jfinal_blog 2、GIT版本:...

    基于JFinal的开源博客系统JFinal_Blog2.0版本.zip

    3、解决Lucene全文检索出现"too many open files "的bug问题; 4、解决Linux中tomcat容器乱码问题(URLEncoding="UTF-8"); 二、开源地址: 1、OSC介绍:http://www.oschina.net/p/jfinal_blog 2、GIT版本:...

    goon:一款集合了fscan和kscan等优秀工具功能的扫描爆破工具

    新增 -no 选项,不保存文件,适用于linux下报错open too many files title、finger扫描可以直接输入domain和url 爆破类支持输入ip、ip段和127.0.0.1:6379格式数据 2022年08月19日 v3.5 端口指纹优化,不输出无关...

    JAVA-WEB应用服务器调优方案

    默认情况下,每个进程可打开的文件数量有限制,可能引发“too many open files”错误。通过修改`ulimit`命令,将参数提升至65535,同时在`/root/.bash_profile`和`/etc/rc.local`中持久化这些设置,可以有效避免这一...

    外文翻译 stus MVC

    Struts——an open-source MVC implementation This article introduces Struts, a Model-View-Controller implementation that uses servlets and JavaServer Pages (JSP) technology. Struts can help you control...

Global site tag (gtag.js) - Google Analytics