java.net.SocketException: Too many open files,toomany
今天實施同事報現場有一個節點無法訪問,把現場的weblogic日誌拿回來,顯示如下:
<2014-8-13 下午01時15分01秒 CST> <Warning> <JDBC> <BEA-001129> <Received exception while creating connection for pool "wzDataSource": Io 異常: The Network Adapter could not establish the connection>
<2014-8-13 下午01時15分01秒 CST> <Warning> <JDBC> <BEA-001129> <Received exception while creating connection for pool "wzDataSource": Io 異常: The Network Adapter could not establish the connection>
<2014-8-13 下午01時15分01秒 CST> <Warning> <JDBC> <BEA-001129> <Received exception while creating connection for pool "wzDataSource": Io 異常: The Network Adapter could not establish the connection>
<2014-8-13 下午01時15分01秒 CST> <Critical> <Server> <BEA-002616> <Failed to listen on channel "Default" on 10.91.1.111:7003, failure count: 1, failing for 0 seconds, java.net.SocketException: Too many open files>
<2014-8-13 下午01時15分01秒 CST> <Warning> <JDBC> <BEA-001129> <Received exception while creating connection for pool "wzDataSource": Io 異常: The Network Adapter could not establish the connection>
<2014-8-13 下午01時15分02秒 CST> <Critical> <Server> <BEA-002616> <Failed to listen on channel "Default" on 10.91.1.111:7003, failure count: 2, failing for 1 seconds, java.net.SocketException: Too many open files>
<2014-8-13 下午01時15分04秒 CST> <Critical> <Server> <BEA-002616> <Failed to listen on channel "Default" on 10.91.1.111:7003, failure count: 3, failing for 3 seconds, java.net.SocketException: Too many open files>
<2014-8-13 下午01時15分07秒 CST> <Critical> <Server> <BEA-002616> <Failed to listen on channel "Default" on 10.91.1.111:7003, failure count: 4, failing for 6 seconds, java.net.SocketException: Too many open files>
<2014-8-13 下午01時15分11秒 CST> <Critical> <Server> <BEA-002616> <Failed to listen on channel "Default" on 10.91.1.111:7003, failure count: 5, failing for 10 seconds, java.net.SocketException: Too many open files>
<2014-8-13 下午01時15分16秒 CST> <Critical> <Server> <BEA-002616> <Failed to listen on channel "Default" on 10.91.1.111:7003, failure count: 6, failing for 15 seconds, java.net.SocketException: Too many open files>
<2014-8-13 下午01時15分22秒 CST> <Critical> <Server> <BEA-002616> <Failed to listen on channel "Default" on 10.91.1.111:7003, failure count: 7, failing for 21 seconds, java.net.SocketException: Too many open files>
<2014-8-13 下午01時15分29秒 CST> <Critical> <Server> <BEA-002616> <Failed to listen on channel "Default" on 10.91.1.111:7003, failure count: 8, failing for 28 seconds, java.net.SocketException: Too many open files>
<2014-8-13 下午01時15分37秒 CST> <Critical> <Server> <BEA-002616> <Failed to listen on channel "Default" on 10.91.1.111:7003, failure count: 9, failing for 36 seconds, java.net.SocketException: Too many open files>
<2014-8-13 下午01時15分46秒 CST> <Critical> <Server> <BEA-002616> <Failed to listen on channel "Default" on 10.91.1.111:7003, failure count: 10, failing for 45 seconds, java.net.SocketException: Too many open files>
<2014-8-13 下午01時15分46秒 CST> <Critical> <Server> <BEA-002617> <Attempting to close and reopen the server socket on on channel "Default" on 101.91.1.111:6003.>
<2014-8-13 下午01時15分56秒 CST> <Notice> <Server> <BEA-002614> <Reopening channel "Default" on 101.91.1.111:6003.>
<2014-8-13 下午01時15分56秒 CST> <Error> <Server> <BEA-002606> <Unable to create a server socket for listening on channel "Default". The address 10.91.1.111 might be incorrect or another process is using port 6003: java.net.SocketException: Too many open files.>
分析日誌:出現無法開啟檔案的情況,是unix開啟檔案數量設定受限,據悉現場是安全整改將應用參數調整,改小了open file的設定,作如下調整:
1.設定 ulimit -u 65535
2.修改/etc/ security/ limits.conf在檔案末加上
soft nofile 65535
hard nofile 65535
javanetSocketException: Too many open filesSocket的問題
補充回答:你是遠端管理伺服器,不能重新啟動嗎?那你把ulimit -a 這個命令放到tomcat的啟動指令碼中,當每次啟動tomcat前,都把開啟檔案的最大數,設定成你需要的值.
/proc/sys/fs/file-max是系統總的限制,是由sysctl.conf來決定的。
而ulimit -a擷取的值是目前使用者允許開啟的最大檔案數(包括socket串連等)
ulimit -n 命令修改後值,只對當前登入使用者的目前使用環境有效,系統重啟或者使用者退出後就會失效.
如果需要永久修改,你可以修改/etc/security/limits.conf
這個檔案中對參數的修改格式說明的比較詳細,如果你想設定為4096,可以添加如下內容:
* soft nofile 4096
* hard nofile 4096
如果你用的Linux是RedHat8或者9,需要在 /etc/pam.d/login 檔案中加入如下一行
session required /lib/security/pam_limits.so
或者是
session required pam_limits.so
Tomcat Too Many Open Files
Tomcat Too Many Open Files ;Too many open files tomcat 6.0報“too many open files Too many open files 問題的解決 linux 故障解決,tomcat 故障處理,too many open files 故障處理
發表於 2011 年 01 月 06 日 由 admin
Tomcat Too Many Open Files ;Too many open files tomcat 6.0報“too many open files Too many open files 問題的解決
linux 故障解決,tomcat 故障處理,too many open files 故障處理這個問題是第一次在Linux環境下碰到,把解決的方法記錄下來。
伺服器配置:兩個雙核CPU 2.0G,4G記憶體
作業系統:CentOS,核心2.6.18
應用1、搜尋伺服器,負責全站的搜尋和提供內容相關性介面
應用伺服器:Tomcat6.0.16+Apache2.2.8,其中兩個Tomcat執行個體,一個對外提供服務,一個對內管理索引(建立、刪除、檢索等)
Web方案:Solr1.3(With Solr Client For Java)、Java Servlet(Web Service 介面)
應用2、類似於百度知道的一個應用
應用伺服器:與搜尋伺服器共用Apache2.2.8
Web方案:Php+Mysql
問題癥狀:搜尋服務停止,應用2響應逾時,牽連全站的搜尋介面調用內容的輸出,查看Catalina日誌,大量的如下資訊:
<!--[if !supportLineBreakNewLine]-->
Java代碼
org.apache.jk.common.ChannelSocket acceptConnections
WARNING: Exception executing accept
java.net.SocketException: Too many open files
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(Unknown Source)
at java.net.ServerSocket.implAccept(Unknown Source)
at java.net.ServerSocket.accept(Unknown Source)
at org.apache.jk.common.ChannelSocket.accept(ChannelSocket.java:295)
at org.apache.jk.common.ChannelSocket.acceptConnections(ChannelSocket.java:641)
at org.apache.jk.common.SocketAcceptor.runIt(ChannelSocket.java:852)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
org.apache.jk.common.ChannelSocket acceptConnections
......餘下全文>>