解决openwrt报“Too many open files”错误的方法

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/boliang319/article/details/38865495

1、查看当前参数

root@OpenWrt:~# cat /proc/sys/fs/file-max

65535

2、重新设置参数:编辑.etc/sysctl.conf,插入:

fs.file-max=70000

3、生效设置

root@OpenWrt:~# sysctl -p



展开阅读全文

Too many open files 错信息

07-02

服务器配置:linuxrn服务:resin3.2 默认使用内存1024Mrnrnrnrnrnrnrnjava.io.FileNotFoundException: /www/tmp/digi/smallpic.properties (Too many open files)rn at java.io.FileOutputStream.open(Native Method)rn at java.io.FileOutputStream.(FileOutputStream.java:179)rn at java.io.FileOutputStream.(FileOutputStream.java:70)rn at com.tom.webutil.refresh.manager.BuildFile.bulidFile(Unknown Source)rn at _jsp._pages._getpice__jsp._jspService(_getpice__jsp.java:134)rn at com.caucho.jsp.JavaPage.service(JavaPage.java:60)rn at com.caucho.jsp.Page.pageservice(Page.java:570)rn at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:159)rn at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:75)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)rn at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)rn at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)rn at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)rn at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:178)rn at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)rn at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268)rn at com.caucho.server.port.TcpConnection.run(TcpConnection.java:389)rn at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:492)rn at com.caucho.util.ThreadPool.run(ThreadPool.java:425)rn at java.lang.Thread.run(Thread.java:595) 论坛

java.net.SocketException too many open files

06-07

下面是错误信息:rn2013-6-3 11:10:52 org.apache.http.impl.client.DefaultRequestDirector tryConnectrn信息: I/O exception (java.net.SocketException) caught when connecting to the target host: Too many open filesrn2013-6-3 11:10:52 org.apache.http.impl.client.DefaultRequestDirector tryConnectrn信息: Retrying connectrnjava.net.SocketException: Too many open filesrn at java.net.Socket.createImpl(Socket.java:397)rn at java.net.Socket.getImpl(Socket.java:460)rn at java.net.Socket.setSoTimeout(Socket.java:1017)rn at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:126)rn at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)rn at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)rn at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:640)rn at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)rn at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)rn at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)rn at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)rn at org.whu.weibo.util.NextPage.getPage(NextPage.java:48)rn at org.whu.weibo.content.NTESweibo.crawler(NTESweibo.java:42)rn at org.whu.Scan.scanByPage(Scan.java:27)rn at org.whu.Scan.run(Scan.java:17)rn at java.lang.Thread.run(Thread.java:662) 问答

Too many open files 问题的解决

10-15

非常着急,困扰了我很长时间了。rn我在网站上找了很多资料,包括这里的解决的方式,都没有能够得到解决。我的服务器已经放了100多个网站了。rn有时候服务器晚上刚刚重起,第二天刚上班访问就会出现too many open files。rn注:我这里某些网站用了oscache。并且每次重起计算机的时候都是直接reboot。rn下面是ulimit -a打印出来的问题。rn# ulimit -arncore file size (blocks, -c) 0rndata seg size (kbytes, -d) unlimitedrnfile size (blocks, -f) unlimitedrnpending signals (-i) 1024rnmax locked memory (kbytes, -l) 32rnmax memory size (kbytes, -m) unlimitedrnopen files (-n) 65536rnpipe size (512 bytes, -p) 8rnPOSIX message queues (bytes, -q) 819200rnstack size (kbytes, -s) 300000rncpu time (seconds, -t) unlimitedrnmax user processes (-u) 32762rnvirtual memory (kbytes, -v) unlimitedrnfile locks (-x) unlimitedrnrn rnrn------------------------------------------------------------------------rnrn rnrn键入以下命令查找打开文件最多的信息如下:rnrn# lsof -n|awk 'print $2'|sort|uniq -c |sort -nr|morernrn[root@linux tomcat-5.5]# ps -aef|grep 8375rnroot 8375 1 9 08:39 pts/1 00:02:30 /pro/java/jdk1.5.0_11/bin/java -Xms512m -Xmx900m -XX:PermSize=300m -XX:MaxPermSize=512m -XX:MaxNewSize=300m -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/opt/tomcat-5.5/conf/logging.properties -Djava.endorsed.dirs=/opt/tomcat-5.5/common/endorsed -classpath :/opt/tomcat-5.5/bin/bootstrap.jar:/tpo/tomcat-5.5/bin/commons-logging-api.jar -Dcatalina.base=/tpo/tomcat-5.5 -Dcatalina.home=/tpo/tomcat-5.5 -Djava.io.tmpdir=/tpo/tomcat-5.5/temp org.apache.catalina.startup.Bootstrap startrnroot 8764 8292 0 09:05 pts/1 00:00:00 grep 8375rnrnrn------------------------------------------------------------------------rnrn我的这里tomcat出异常如下:rnrn2008-10-15 8:15:00 org.apache.tomcat.util.net.PoolTcpEndpoint acceptSocketrn严重: Endpoint ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=80] ignored exception: java.net.SocketException: Too many open filesrnjava.net.SocketException: Too many open filesrnat java.net.PlainSocketImpl.socketAccept(Native Method)rnat java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)rnat java.net.ServerSocket.implAccept(ServerSocket.java:450)rnat java.net.ServerSocket.accept(ServerSocket.java:421)rnat org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61)rnat org.apache.tomcat.util.net.PoolTcpEndpoint.acceptSocket(PoolTcpEndpoint.java:408)rnat org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:71)rnat org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)rnat java.lang.Thread.run(Thread.java:595)rn2008-10-15 8:15:00 org.apache.tomcat.util.net.PoolTcpEndpoint acceptSocketrn警告: Reinitializing ServerSocketrnjava.io.FileNotFoundException: /webadmin/set_formxx.jsp (Too many open files)rnat java.io.FileInputStream.open(Native Method)rnat java.io.FileInputStream.(FileInputStream.java:106)rnat org.apache.naming.resources.FileDirContext$FileResource.streamContent(FileDirContext.java:975)rnat org.apache.naming.resources.DirContextURLConnection.getInputStream(DirContextURLConnection.java:307)rnat org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:370)rnat org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:333)rnat org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:561)rnat org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)rnat org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)rnat org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rnat javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)rnat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rnat org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)rnat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)rnat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rnat jereh.web21sun.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:121)rnat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)rnat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rnat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)rnat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)rnat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rnat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)rnat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)rnat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)rnat org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)rnat org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)rnat org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)rnat org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)rnat org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)rnat java.lang.Thread.run(Thread.java:595) 论坛

java.io.FileNotFoundException: test/fileThread-494 (Too many open files)

09-14

先说一下程序的流程:rn写SocketServer端的接收程序,接收Client端的请求后创建文件,并将接收到的数据流写在新创建的文件里,最后关闭数据流和Socket。如此多线程执行500次。rn问题是这样的:rn当Client端发送请求并发送数据,这样Server端接收请求后本地创建文件,并将接收到的数据写到文件中,程序运行正常。rn当Client端发送请求但不发送数据,也就是Server端接收请求后,只创建本地空文件,并没有写数据,就会报这样的错误:rnrnjava.io.FileNotFoundException: test/fileThread-494 (Too many open files)rn at java.io.FileOutputStream.open(Native Method)rn at java.io.FileOutputStream.(FileOutputStream.java:179)rn at java.io.FileOutputStream.(FileOutputStream.java:70)rn at OutputThread.run(SimpleServer.java:52)rnException in thread "main" java.io.FileNotFoundException: test/fileThread-495 (Too many open files)rn at java.io.FileOutputStream.open(Native Method)rn at java.io.FileOutputStream.(FileOutputStream.java:179)rn at java.io.FileOutputStream.(FileOutputStream.java:70)rn at OutputThread.run(SimpleServer.java:52)rnException in thread "Thread-494" java.lang.NullPointerExceptionrn at OutputThread.run(SimpleServer.java:60)rnjava.net.SocketException: Too many open filesrn at java.net.PlainSocketImpl.socketAccept(Native Method)rn at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)rn at java.net.ServerSocket.implAccept(ServerSocket.java:453)rn at java.net.ServerSocket.accept(ServerSocket.java:421)rn at SimpleServer.main(SimpleServer.java:26)rnrn每次写文件后都会关闭文件流和socket。rn问题应该定位在Linux系统的打开最大文件数,这个不是我要问的问题。rn程序是并发执行的,不解的是Server端创建文件后并写数据,再关闭文件,这样的流程不会报上面的错误,然而,Server端创建空文件,再关闭文件,这样就会报上面的错误。rn后者的情况是创建空文件并马上关闭,应该不会达到系统最大文件数啊,至少比前一种情况处于打开状态的文件数少啊,为什么前一种情况没有出错,后一种情况会出现错误呢。rnrn说的有些乱,不知道能不能让大家理解我的意思,希望朋友们帮忙看一下。rn 论坛

java.net.SocketException: Too many open files 什么原因呢

11-11

报这是什么原因,应该如何解决rnrnrnjava.net.SocketException: Too many open filesrn at java.net.PlainSocketImpl.socketAccept(Native Method)rn at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)rn at java.net.ServerSocket.implAccept(ServerSocket.java:448)rn at java.net.ServerSocket.accept(ServerSocket.java:419)rn at org.apache.jk.common.ChannelSocket.accept(ChannelSocket.java:287)rn at org.apache.jk.common.ChannelSocket.acceptConnections(ChannelSocket.java:581)rn at org.apache.jk.common.SocketAcceptor.runIt(ChannelSocket.java:767)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)rn at java.lang.Thread.run(Thread.java:534)rnjava.net.SocketException: Too many open filesrn at java.net.PlainSocketImpl.socketAccept(Native Method)rn at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)rn at java.net.Sern[1]+ Stopped cat catalina.outrn[root@localhost logs]# tail catalina.out rnjava.net.SocketException: Too many open filesrn at java.net.PlainSocketImpl.socketAccept(Native Method)rn at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)rn at java.net.ServerSocket.implAccept(ServerSocket.java:448)rn at java.net.ServerSocket.accept(ServerSocket.java:419)rn at org.apache.jk.common.ChannelSocket.accept(ChannelSocket.java:287)rn at org.apache.jk.common.ChannelSocket.acceptConnections(ChannelSocket.java:581)rn at org.apache.jk.common.SocketAcceptor.runIt(ChannelSocket.java:767)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)rn at java.lang.Thread.run(Thread.java:534)rn rn rnrn rn 论坛

没有更多推荐了,返回首页