myeclipse連接到oracle10g,過段時間後自動斷開,報ORA-03135錯誤

 

問題描述:

開發人員報告,用myeclipse連接oracle後,過一段時間,連接斷開,報ORA-03135錯誤。

 

問題挖掘:

用pl/sql和sqlplus連接oracle,也存在該問題,確定該問題與連接方式無關。

查看服務器,發現沒有防火牆,防火牆因素排除。

ping -t 服務器地址,發現沒有丟包,都100%收到,網絡通暢。

基本可以肯定問題出在oracle參數配置上。但也不排除其他因素。

 

解決過程:

 

根據ora-03135查詢到oracle官方的解決方案:

ORA-03135: connection lost contact

Cause: 1) Server unexpectedly terminated or was forced to terminate. 2) Server timed out the connection.

Action: 1) Check if the server session was terminated. 2) Check if the timeout parameters are set properly in sqlnet.ora.

 

查詢相關資料,發現該問題可能與sqlnet.ora設置參數SQLNET.EXPIRE_TIME 有關。因此在server上面的sqlnet.ora設置參數SQLNET.EXPIRE_TIME = 5(需在服務器監聽reload一下使參數生效:lsnrctl reload),而在client不設置該參數,。等待一段時間後,沒有出現該問題了,問題解決。

 

知識擴展:

在server端的sqlnet.ora文件中設置SQLNET.EXPIRE_TIME這一參數可以啓用DCD功能,DCD是Dead Connection Detection的縮寫,用於檢查死掉但沒有斷開的session。


例如:
SQLNET.EXPIRE_TIME = 20
可以設置爲任意數值,單位分鐘。

 

 

 

DCD可以用於防止防火牆的timeout。

 

當新連接建立的時候,會讀取sqlnet.ora中的這一設定,當20分鐘間隔到達時,對inactive的session發送”probe” SQL*NET packet來確認client是否活着。如果已經死掉,那麼相對應的resource會被自動清除。
如果client和server中間有防火牆,防火牆設有timeout參數,例如設置爲一個小時,當一個小時中client和server間沒有數據傳輸的時候,防火牆會斷開連接。開啓DCD後,通過設置SQLNET.EXPIRE_TIME的值小於防火牆的timeout參數可以避免這一情況。“probe” package確保防火牆不會斷開idle的session。

 

 

參考資料:

sqlnet.ora http://www.orafaq.com/wiki/Sqlnet.ora

oracle DCD  http://www.dbafan.com/blog/?p=174

sqlnet.expire_time and IDLE_TIME http://space.itpub.net/10687595/viewspace-420407

SQLNET.EXPIRE_TIME 的官方說明

Purpose

Use parameter SQLNET.EXPIRE_TIME to specify a the time interval, in minutes, to send a probe to verify that client/server connections are active. Setting a value greater than 0 ensures that connections are not left open indefinitely, due to an abnormal client termination. If the probe finds a terminated connection, or a connection that is no longer in use, it returns an error, causing the server process to exit. This parameter is primarily intended for the database server, which typically handles multiple connections at any one time.

Limitations on using this terminated connection detection feature are:

·         It is not allowed on bequeathed connections.

·         Though very small, a probe packet generates additional traffic that may downgrade network performance.

·         Depending on which operating system is in use, the server may need to perform additional processing to distinguish the connection probing event from other events that occur. This can also result in degraded network performance.

Default

0

Minimum Value

0

Recommended Value

10

Example

SQLNET.EXPIRE_TIME=10
發佈了11 篇原創文章 · 獲贊 6 · 訪問量 15萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章