使用 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 文件的内容
* 硬文件 331287 * 软文件 331287