問題描述:
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
可以設置為任意數值,單位分鍾。
重啟listener
bash-2.05$ lsnrctl reload
……
The command completed successfully
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。
大多數情況下,這樣操作就好了,要是還是不行就進行停止oracle實例和重啟操作
1、啟動數據庫:
oracle@suse92:~> sqlplus /nolog
SQL*Plus: Release 9.2.0.4.0 - Production on Fri Jan 20 02:29:37 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> connect /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 135352820 bytes
Fixed Size 455156 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 679936 bytes
Database mounted.
2、關閉數據庫:
oracle@suse92:~> sqlplus /nolog
SQL*Plus: Release 9.2.0.4.0 - Production on Fri Jan 20 02:29:37 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> connect /as sysdba
Connected to an idle instance.
SQL> shutdwon abort;
3、啟動監聽器
oracle@suse92:~> lsnrctl start
4、停止監聽器
oracle@suse92:~> lsnrctl stop
5、查看監聽器狀態
lsnrctl">oracle@suse92:~>lsnrctl
LSNRCTL> status
LSNRCTL> exit
參考資料:
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