ora-12542(Windows2003下 Oracle監聽器啟動後自動關閉)

kuqlan發表於2011-09-17

今天發現Windows 2003server上的Oracle 監聽器無法啟動,在Windows服務裡啟動後立即停止,在cmd環境下執行lsnrctl start命令會報ora-12542錯誤。

實際上以上監聽器異常現象在前幾天偶爾出現,後來監聽器埠被佔用原因,應用系統所對應的資料庫使用者無法連結資料庫。

處理過程:

1、重建監聽器沒有用,重啟伺服器後也是沒法連線資料庫(sys / as sysdba可以連線,並可以正常啟動和關閉資料庫);

2、因資料庫小,因此先備份(expdp)好資料後重新安裝Oracle並重建資料庫,還是不行。

[@more@]

3、以上方法都失敗後,我開始搜尋網路,如下是從 中得到metalink 解答內容,解釋很好:

Cause

Problem is caused due to the fact that the free ports in the windows client has been exhausted and it is trying to make use of a port which is in TIME_WAIT state which gives the error TNS-12542: Address already in use.

Solution

There are 2 solutions available:

1.) Increase the free port range:

======================

Start Registry Editor (Regedt32.exe).

Locate the following key in the registry:

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters

On the Edit menu, click Add Value, and then add the following registry value:

Value Name: MaxUserPort Data Type: REG_DWORD Value: 65534

Valid Range: 5000-65534 (decimal) Default: 0x1388 (5000 decimal)

Description: This parameter controls the maximum port number used when an application requests any available user port from the system. Normally, ephemeral (that is, short-lived) ports are allocated between the values of 1024 and 5000 inclusive.

2.) Decrease the value for TIME_WAIT state:

================================

TcpTimedWaitDelay (new in Windows NT versions 3.51 SP5 and later)

Key: TcpipParameters

Value Type: REG_DWORD - Time in seconds

Valid Range: 30-300 (decimal)

Default: 0xF0 (240 decimal)

Description: This parameter determines the length of time that a connection will stay in the TIME_WAIT state when being closed. While a connection is in the TIME_WAIT state, the socket pair cannot be re- used. This is also known as the "2MSL" state, as by RFC the value should be twice the maximum segment lifetime on the network. See RFC793 for further details.

這主要是由於作業系統的臨時埠不夠用而引起的。一般系統的臨時埠為 1024-5000,這在多使用者的環境下,3000多個oracle連結就用光了。由於每個連結斷開以後,還要有一個等待時間,例如在 windows 系統中,這個時間是 120秒。

這就導致了一個現象: 一會可以聯通,一會又出現 ora-12542 address in used 。如果有臨時埠可以使用,可以聯通oracle;如果暫時埠沒有了,就連不通了。

一下是在 windows 系統下的解決辦法。

1 進入登錄檔編輯器(regedit),在 HKEY_LOCAL_MACHINEsystemCurrentControlSetServicesTcpipParameters 裡,編譯-> 新增-> MaxUserPort (型別 REG_DWORD ), 值中填寫 65534,(十進位制,可以的範圍是5000-65534).

2 、退出 登錄檔編輯器,重新啟動機器.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18841027/viewspace-1055122/,如需轉載,請註明出處,否則將追究法律責任。

相關文章