0

I want to fix this issue, I actually don't have a clear Idea of what is happening when my application runs over a CentOs environment and after some days I start getting the following exceptions:

2011-07-12 21:58:03,598 12155907 ERROR [org.jboss.naming.Naming] (JBoss System Threads(1)-2:) Naming accept handler stopping
java.net.SocketException: Too many open files
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:408)
    at java.net.ServerSocket.implAccept(ServerSocket.java:462)
    at java.net.ServerSocket.accept(ServerSocket.java:430)
    at org.jnp.server.Main$AcceptHandler.run(Main.java:481)
    at org.jboss.util.threadpool.RunnableTaskWrapper.run(RunnableTaskWrapper.java:148)
    at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
    at java.lang.Thread.run(Thread.java:662)
2011-07-12 21:58:03,600 12155909 ERROR [org.jboss.naming.Naming] (JBoss System Threads(1)-2:) Naming accept handler stopping
java.net.SocketException: Too many open files
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:408)
    at java.net.ServerSocket.implAccept(ServerSocket.java:462)
    at java.net.ServerSocket.accept(ServerSocket.java:430)
    at org.jnp.server.Main$AcceptHandler.run(Main.java:481)
    at org.jboss.util.threadpool.RunnableTaskWrapper.run(RunnableTaskWrapper.java:148)
    at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
    at java.lang.Thread.run(Thread.java:662)
2011-07-12 21:58:03,600 12155909 ERROR [org.jboss.naming.Naming] (JBoss System Threads(1)-2:) Naming accept handler stopping
java.net.SocketException: Too many open files
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:408)
    at java.net.ServerSocket.implAccept(ServerSocket.java:462)
    at java.net.ServerSocket.accept(ServerSocket.java:430)
    at org.jnp.server.Main$AcceptHandler.run(Main.java:481)
    at org.jboss.util.threadpool.RunnableTaskWrapper.run(RunnableTaskWrapper.java:148)
    at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
    at java.lang.Thread.run(Thread.java:662)
2011-07-12 21:58:03,601 12155910 ERROR [org.jboss.naming.Naming] (JBoss System Threads(1)-2:) Naming accept handler stopping
java.net.SocketException: Too many open files
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:408)
    at java.net.ServerSocket.implAccept(ServerSocket.java:462)
    at java.net.ServerSocket.accept(ServerSocket.java:430)
    at org.jnp.server.Main$AcceptHandler.run(Main.java:481)
    at org.jboss.util.threadpool.RunnableTaskWrapper.run(RunnableTaskWrapper.java:148)
    at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
    at java.lang.Thread.run(Thread.java:662)

The logs start growing quick... I am using some JBOSS QUEUES in my application, as well some JMX connections, I want to know how to detect the problem quickly or if this is caused by other component in the computer. Any suggestions, please I am totally worried about this issue.

4

2 回答 2

5

以下是调试打开文件过多情况的一些提示。两个可以提供帮助的 unix 命令是ulimitlsof

我建议您man ulimit首先了解您可以更改进程的最大打开文件数。只需ulimit在命令行上键入即可为您提供 ulimit 的默认值。例如,对我来说:

$ ulimit
unlimited

我在香草 Ubuntu 11.04 发行版上运行,所以看起来无限制是默认设置。在我的大多数生产机器上,默认值为 1024。

接下来,lsof -p <pid>它将列出 ID 为 <pid> 的进程的所有打开文件。

也许您会发现您没有关闭文件,或者您只是打开了太多文件(基于设置的限制 ulimit)?

下一步,您将运行 Java 进程,以便在出现打开文件过多的情况时获取进程的线程转储。要获取线程转储,请发送进程 a kill -3 <pid>,或者如果您已在当前 shell 中启动 Java 进程,则可以键入 CTRL-Break 以获取线程转储。在一两分钟内收集 3 个或更多线程转储特别有用,并且从这个线程转储集合中收集,因此线程转储中存在的线程值得一看。

如果这些都对您没有帮助,请在 SO 中搜索“打开的文件过多”。我做了并找到了这个链接,接受的答案可能会对你有所帮助

Java 打开的文件太多

于 2011-07-13T15:38:03.517 回答
0

我认为您遇到了这个问题 - AJP 连接保留为 CLOSE_WAIT

于 2012-06-19T16:25:54.663 回答