ORA-12541: TNS:no listener (DBD ERROR: OCIServerAttach) (轉)

genweihua發表於2012-03-11

     http://space.itpub.net/540962/viewspace-708279
      有一次,裝完資料庫後,並配置好監聽,當使用SQL*PLUS,PL/SQL DEVELOPER工具登入都沒有問題,但是使用OEM管理介面的時候就報錯了,下面是我的整個排錯過程,
1)檢查告警日誌(alert_SID.log)

仔細看了下日誌,沒有相關的報警資訊,同時也檢視了listener.ora的檔案,連線也正常

2)檢查監聽檔案

由於用其它工具可以連線,首先當時我沒有懷疑監聽的問題,我記得當時建監聽檔案是從正式庫執行的複製過來的,啟動完監聽後,資訊如下:

lsnrctl stat

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 06-DEC-2010 10:25:27

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.100.99)(PORT=1521)))
STATUS of the LISTENER
22275400------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                06-DEC-2010 10:18:17
Uptime                    0 days 0 hr. 7 min. 10 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/db10g/network/admin/listener.ora
Listener Log File         /u01/app/oracle/db10g/network/log/listener.log
istening Endpoints Summary...
b1W5`)N#? }a22275400  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=df2)(PORT=1521)))
Services Summary...
Service "df2" has 2 instance(s).
Instance "df2", status UNKNOWN, has 1 handler(s) for this service...

當時就懷疑這個監聽有點怪,後面經開發人員反映也沒有什麼問題,就一直沒有去理會,經過二個星期,由於使用oracle 10g OEM的功能進行資料庫的監聽就出現了上述的問題

3)啟用oem

emctl start dbconsole  --正常

4)瀏覽   就出現了訪問不了,提示是監聽的問題

5)後面根據網上的一些方法,說是listener.ora和tnsnames.ora檔案的配置問題,不過我仔細看了下IP,PORT,ORACLE_HOME,沒有什麼問題,苦苦想了很久,從報錯的資訊來看,還是監聽的問題,然後使用netca重新進行了配置,發現用lsnrctl stat終於有了不一樣的變化了,如下:

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 06-DEC-2010 10:25:27

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.100.99)(PORT=1521)))
STATUS of the LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                06-DEC-2010 10:18:17
Uptime                    0 days 0 hr. 7 min. 10 sec
Trace Level               off
Security                  ON: Local OS AuthenticationI
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/db10g/network/admin/listener.ora
Listener Log File         /u01/app/oracle/db10g/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=df2)(PORT=1521)))
Services Summary...
Service "df2" has 2 instance(s).
  Instance "df2", status UNKNOWN, has 1 handler(s) for this service...
  Instance "df2", status READY, has 1 handler(s) for this service...
Service "df2XDB" has 1 instance(s).
Instance "df2", status READY, has 1 handler(s) for this service...
Service "df2_XPT" has 1 instance(s).
  Instance "df2", status READY, has 1 handler(s) for this service...
The command completed successfully

就像看到了久違的老朋友一樣,讓我歡喜萬分,馬上開啟瀏覽器,輸入地址一看,錯誤消失,監控瀏覽正常

總結:

導致這個問題的最終原因,是listener.ora配置的問題,後面進行了前後的listener.ora對比:

出錯前:

# listener.ora Network Configuration File: /u01/app/oracle/db10g/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
   (SID_DESC =
      (GLOBAL_DBNAME = df2)
      (ORACLE_HOME = /u01/app/oracle/db10g)
      (SID_NAME = df2)
    )
  )

LISTENER =
(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.100.99)(PORT = 1521))
  )

解決後:

# listener.ora Network Configuration File: /u01/app/oracle/db10g/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
     (GLOBAL_DBNAME = df2)
   (ORACLE_HOME = /u01/app/oracle/db10g)
      (SID_NAME = df2)
    )
  )

LISTENER =
 (DESCRIPTION_LIST =
  (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.100.99)(PORT = 1521))
    )
  )
標示紅色的地方是有點不同,我後面想了下,由於之前是手工配置的檔案,而且進行了修改,是標點符號誤差原因造成,所以一定要謹慎監聽檔案的配置,為什麼開發人員可以使用呢?看之前的監聽狀態,有一個是unkown的,意思是說監聽是靜態註冊的,因此都可以使用,但OEM會呼叫相關的ORACLE內部的一些服務就最後失敗了


 

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

相關文章