使用Mina 2.0.8时,如何增加在ubuntu上打开的套接字数量?一旦服务器达到约1700个连接,我就会在日志中得到此信息:
2013-01-24 04:21:49,465 [NioSocketAcceptor-1] WARN o.a.m.util.DefaultExceptionMonitor - Unexpected exception.
java.io.IOException: Too many open files
at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method) ~[na:1.6.0_20]
at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:163) ~[na:1.6.0_20]
at org.apache.mina.transport.socket.nio.NioSocketAcceptor.accept(NioSocketAcceptor.java:159) ~[mina-core-2.0.8-SNAPSHOT.jar:na]
at org.apache.mina.transport.socket.nio.NioSocketAcceptor.accept(NioSocketAcceptor.java:50) ~[mina-core-2.0.8-SNAPSHOT.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoAcceptor$Acceptor.processHandles(AbstractPollingIoAcceptor.java:506) ~[mina-core-2.0.8-SNAPSHOT.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoAcceptor$Acceptor.run(AbstractPollingIoAcceptor.java:447) ~[mina-core-2.0.8-SNAPSHOT.jar:na]
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64) [mina-core-2.0.8-SNAPSHOT.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.6.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.6.0_20]
at java.lang.Thread.run(Thread.java:636) [na:1.6.0_20]
当我的文件句柄硬和软设置为最大331278时,这怎么可能?
运行“ulimit -n”报告
331287
并运行“sysctl fs.file-nr”报告
fs.file-nr = 1728 0 331287
/etc/security/limits.conf文件的内容
*硬nofile 331287
*软nofile 331287
最佳答案
两件事似乎已经解决了我上面遇到的问题: