2014年2月3日 星期一

[記事] Too many open files (in Jboss)

屬於阿宅世界的技術文章,想看的再點開,切莫自誤 !



可能是過年大家都塞在馬路上,所以生意好到 AP Server 葛了,徵狀包含 netstat 裡很多TIME_WAIT,log 只有下面的錯誤訊息 :

14:45:24,228 ERROR [org.apache.tomcat.util.net.JIoEndpoint] (http--0.0.0.0-80-Acceptor-0) Socket accept failed: java.net.SocketException: Too many open files
at java.net.PlainSocketImpl.socketAccept(Native Method) [rt.jar:1.6.0_32]
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:408) [rt.jar:1.6.0_32]
at java.net.ServerSocket.implAccept(ServerSocket.java:462) [rt.jar:1.6.0_32]
at java.net.ServerSocket.accept(ServerSocket.java:430) [rt.jar:1.6.0_32]
at org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:321) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_32]

ulimit -a shows
open files (-n) SOME_NUM_SMALL

Cat /proc/<PID>/limits , the value of (Max)open files is not big enough neigther,
Max open files SOME_NUM_SMALL SOME_NUM_SMALL files

Seems not a really problem, modify those lines in  /etc/security/limits.conf

* soft nofile SOME_NUM_NOT_THAT_BIG
* hard nofile SOME_NUM_BIG

Restart the application and it should be done!

ps. If those above not work(?!) ,try to add those lines in the beginning of the startup script
ulimit -Hn SOME_NUM_BIG # set the hard limit of max open files
ulimit -Sn SOME_NUM_NOT_THAT_BIG # set the soft limit of max open files

0 意見:

張貼留言