日期:2014-05-16  浏览次数:20735 次

linux 下Too many open files 问题

运行在linux 的tomcat 报如下错误:

INFO | jvm 1 | 2012/06/20 11:11:13 | java.net.SocketException: Too many open files
INFO | jvm 1 | 2012/06/20 11:11:13 | at java.net.PlainSocketImpl.socketAccept(Native Method)
INFO | jvm 1 | 2012/06/20 11:11:13 | at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:408)
INFO | jvm 1 | 2012/06/20 11:11:13 | at java.net.ServerSocket.implAccept(ServerSocket.java:462)
INFO | jvm 1 | 2012/06/20 11:11:13 | at java.net.ServerSocket.accept(ServerSocket.java:430)
INFO | jvm 1 | 2012/06/20 11:11:13 | at org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61)
INFO | jvm 1 | 2012/06/20 11:11:13 | at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:352)
INFO | jvm 1 | 2012/06/20 11:11:13 | at java.lang.Thread.run(Thread.java:662)
INFO | jvm 1 | 2012/06/20 11:11:13 | 2012-6-20 11:11:13 org.apache.tomcat.util.net.JIoEndpoint$Acceptor run

<!--StartFragment -->

这个问题通过设置系统最大打开文件数解决。

操作:在/etc/profile最后 增加
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi


执行source /etc/profile 使修改生效。