`
sqiutz
  • 浏览: 71339 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

WAS 中Too many open files问题

阅读更多

WAS下的应用系统,在对其他性能开至较大时出现系统无法返回的情况,查看日志错误为Too Many Open Files.

处理方法如下:

 

1. ulimit -a 查看系统目前资源限制的设定。

[root@test security]# ulimit -a  /*etc/security*/

core file size        (blocks, -c) 0

data seg size         (kbytes, -d) unlimited

file size             (blocks, -f) unlimited

max locked memory     (kbytes, -l) unlimited

max memory size       (kbytes, -m) unlimited

open files                    (-n) 1024

pipe size          (512 bytes, -p) 8

stack size            (kbytes, -s) 8192

cpu time             (seconds, -t) unlimited

max user processes            (-u) 7168

virtual memory        (kbytes, -v) unlimited

通过以上命令,我们可以看到open files 的最大数为1024

那么我们可以通过一下命令修改该参数的最大值

ulimit -HSn 4096

[root@test security]# ulimit -n 4096

[root@test security]# ulimit -a

core file size        (blocks, -c) 0

data seg size         (kbytes, -d) unlimited

file size             (blocks, -f) unlimited

max locked memory     (kbytes, -l) unlimited

max memory size       (kbytes, -m) unlimited

open files                    (-n) 4096

pipe size          (512 bytes, -p) 8

stack size            (kbytes, -s) 8192

cpu time             (seconds, -t) unlimited

max user processes            (-u) 7168

virtual memory        (kbytes, -v) unlimited 

 

使用lsof |wc -l进行监控

修改etc/profile,添加一行,则重启生效

检查/proc/sys/fs/file-max文件来确认最大打开文件数

这样的优化后 lsof -p $java_pid|wc -l可以跑到4千以上都不会抛出too many open files。 

打开的文件句柄是在 /proc/sys/fs/file-nr

lsof -n |awk '{print $2}'|sort|uniq -c |sort -nr|more 

 

# cat /proc/sys/fs/file-max 如果设置值太小, 修改文件/etc/sysctl.conf的变量到合适的值。 这样会在每次重启之后生效。 如果设置值够大,跳过下步。 # echo 2048 > /proc/sys/fs/file-max 。编辑文件/etc/sysctl.conf,插入下行:fs.file-max = 8192

 

 

在/etc/security/limits.conf文件中设置最大打开文件数, 下面是一行提示: 

#<domain>      <type>  <item>         <value>  添加如下这行。 

* - nofile 8192 

    这行设置了每个用户的默认打开文件数为2048。 注意"nofile"项有两个可能的限制措施。就是<type>项下的hard和soft。 要使修改过得最大打开文件数生效,必须对这两种限制进行设定。 如果使用"-"字符设定<type>, 则hard和soft设定会同时被设定。

 

 

/etc/sysctl.conf 

添加: 

# Decrease the time default value for tcp_fin_timeout connection

net.ipv4.tcp_fin_timeout = 30

# Decrease the time default value for tcp_keepalive_time connection

net.ipv4.tcp_keepalive_time = 1800

# Turn off tcp_window_scaling

net.ipv4.tcp_window_scaling = 0

# Turn off the tcp_sack

net.ipv4.tcp_sack = 0

#Turn off tcp_timestamps 

net.ipv4.tcp_timestamps = 0 

然后 service network restart,这些都和TCP sockets有关的优化。 

另外需要在 /etc/rc.d/rc.local里添加已使得重启的时候生效。 

echo "30">/proc/sys/net/ipv4/tcp_fin_timeout

echo "1800">/proc/sys/net/ipv4/tcp_keepalive_time

echo "0">/proc/sys/net/ipv4/tcp_window_scaling

echo "0">/proc/sys/net/ipv4/tcp_sack

echo "0">/proc/sys/net/ipv4/tcp_timestamps 

 

2. 标准 stdio  函数库可用的 FILE 结构数目导致数量过载

 

3. 引起文件描述符打开的JAVA函数:BufferReader

分享到:
评论

相关推荐

    Linux下打开的文件过多错误

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

    如何对AIX、ORACLE、WebLogic和WebSphere进行调优

    大并发时后台报too many open files - 这个问题是由于系统打开文件数量限制导致的。 - 可以通过调整操作系统的文件描述符限制来解决,例如使用`ulimit -n`命令。 ##### 3. 修改`/ehr/weblogic11/user_projects/...

    NFS Illustrated by Brent Callaghan (z-lib.org).pdf

    has been almost too successful at making remote files indistinguishable from local files. For instance, a program that backs up files on a local disk to tape needs to avoid stumbling into NFS file...

    C语言编程错误信息表

    Too many open files (打开文件过多) 当程序尝试同时打开的文件数量超过了操作系统允许的限制时,会遇到这个错误。这可能是因为没有正确关闭不再需要的文件,或者一次性打开了大量文件。优化文件处理逻辑,确保...

    010.Editor.x32.v6.0.1.Cracked

    Made the color of the Startup page darker (was too bright on some monitors). Can now change or reset the color of the Startup page by clicking the 'Options' button on the Startup page. Fixed some ...

    计算机专科专业英语试卷

    8. Too many files are open - 打开的文件太多 9. Receive and send data error - 接收和发送数据错误 10. online processing - 在线处理 这些短语涵盖了常见的计算机错误提示、系统组件和网络通信问题,有助于提高...

    VclZip pro v3.10.1

    This was due to a problem where it would be freed automatically if there was a problem with the ArchiveStream when trying to open it as a zip file (possibly corrupt). Best practice is that ...

    Sublime Text Build 3124 x64 Setup.exe

    minihtml: Fixed a stack overflow on Windows with too many unclosed tags API: Added Phantom and PhantomSet API: Added ViewEventListener API: Added View.is_primary() API: Added EventListener.on_hover...

    clucene源码

    'Too many open files' Some platforms don't provide enough file handles to run CLucene properly. To solve this, increase the open file limit: On Solaris: ulimit -n 1024 set rlim_fd_cur=1024 ...

    Bloodshed Dev-C++

    * Multi-select files in project-view (when "double-click to open" is configured in Environment Settings) * Resource files are treated as ordinary files now * Updates in "Project Options/Files" code * ...

    无刷马达调速

    This project aims to create a fully open-source Brushless Drive Controller. Where is the hardware --------------------- The hardware design files got split into a separate repository on github called...

    曲线拟合工具CurveExpert 1.0

    reading system was implemented to read files with any type of (unspecified) delimiter between the data columns + if a data file was not read correctly, the filename in the status bar showed the ...

    Delphi2010皮肤控件AlphaControls6.21FS

    + Property AcceptFiles was added to TsFilenameEdit and TsDirectoryEdit controls (dragging files to controls) + OnDrawDay event added to the TsDateEdit component * Improved PngHints editor * Solved...

    CE中文版-启点CE过NP中文.exe

    Disassembler: Several disassembler instructions had a comma too many or too few ,fixed those Disassembler: Fixed the description for ret # Disassembler/Debug: Fixed the address that is being edited ...

    opensc-0.12.0.tar.gz

    * use new pkcs11.h from scute with an open source license * add support for sha2 to pkcs15-crypt * add piv-tool for managing piv cards * add muscle driver (still work in progress) * improved oberthur ...

    ActiveState Komodo IDE 10.2.1.89853 Setup + Keygen

    how many files have changed and allow you to quickly open eg. file or project history, or the commit dialog. The dynamic toolbar is very developer friendly, so you can easily create your own ...

    OutlookAttachView v2.73

    o Added 'Recent Config Files' menu, which allows you to easily open the last 10 configuration files that you used. * Version 2.61 o Added GB and Automatic to the 'File Size Unit' option. * ...

    ICS delphixe10源码版

    .\Source\Include (was Delphi\Vc32) .inc files (including OverbyteIcsDefs.inc) .\Source\Extras (was Delphi\Vc32) Extra source code not built into packages .\Source\zobj125 (was Delphi\Vc32) ZLIB C OBJ ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    C++ is the main development language used by many of Google's open-source projects. As every C++ programmer knows, the language has many powerful features, but this power brings with it complexity, ...

    VB编程资源大全(英文源码 数据库)

    With sample files and help, as well as ample remarks.&lt;END&gt;&lt;br&gt;9 , pb_test.zip Test project illustrating high performance Data Access for SQL Server using ADO command objects and Stored Procedures ...

Global site tag (gtag.js) - Google Analytics