【LISTENER】Oracle監聽TNS-12545及TNS-00515錯誤處理一例

secooler發表於2011-03-25
Oracle的監聽程式與作業系統的設定資訊結合的很緊密,稍有不慎便會遇到無法啟動的問題。
本文就監聽的TNS-12560及TNS-00515錯誤給出分析及處理方法。

1.TNS-12560及TNS-00515報錯現象
1)使用監聽status命令獲取到的報錯資訊
ora10g@secdb /home/oracle$ lsnrctl

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 25-MAR-2011 21:18:03

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

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=secdb)(PORT=1521)))
TNS-12545: Connect failed because target host or object does not exist
 TNS-12560: TNS:protocol adapter error
  TNS-00515: Connect failed because target host or object does not exist

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 2: No such file or directory


2)使用監聽start命令獲取到的報錯資訊
LSNRCTL> start
Starting /oracle/ora10gR2/product/10.2.0/db_2/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /oracle/ora10gR2/product/10.2.0/db_2/network/admin/listener.ora
Log messages written to /oracle/ora10gR2/product/10.2.0/db_2/network/log/listener.log
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=secdb)(PORT=1521)))
TNS-12545: Connect failed because target host or object does not exist
 TNS-12560: TNS:protocol adapter error
  TNS-00515: Connect failed because target host or object does not exist


Listener failed to start. See the error message(s) above...

注意這裡連續丟擲TNS-12545和TNS-00515資訊均給出同樣的報錯內容“
Connect failed because target host or object does not exist”。

2.問題原因
/etc/hosts檔案內容設定不正確是本例問題的所在。
1)/etc/hosts檔案內容如下
[root@secdb ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6

2)獲取主機名資訊
[root@secdb ~]# hostname
secdb

導致監聽無法正常啟動的原因便在這裡:hosts檔案內容與主機名設定的不一致!

3.問題處理
1)修改hosts檔案內容
確保hosts檔案中的內容與主機名保持一致。否則便會出現監聽無法啟動的問題。
[root@secdb ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               secdb localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
~
~

2)嘗試啟動監聽
LSNRCTL> start
Starting /oracle/ora10gR2/product/10.2.0/db_2/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /oracle/ora10gR2/product/10.2.0/db_2/network/admin/listener.ora
Log messages written to /oracle/ora10gR2/product/10.2.0/db_2/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=secdb)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                25-MAR-2011 21:20:55
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/ora10gR2/product/10.2.0/db_2/network/admin/listener.ora
Listener Log File         /oracle/ora10gR2/product/10.2.0/db_2/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

3)檢視監聽狀態
稍等片刻,等待資料庫例項動態註冊到監聽中。
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=secdb)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                25-MAR-2011 21:52:51
Uptime                    0 days 0 hr. 3 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/ora10gR2/product/10.2.0/db_2/network/admin/listener.ora
Listener Log File         /oracle/ora10gR2/product/10.2.0/db_2/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "ora10g" has 1 instance(s).
  Instance "ora10g", status READY, has 1 handler(s) for this service...
Service "ora10gXDB" has 1 instance(s).
  Instance "ora10g", status READY, has 1 handler(s) for this service...
Service "ora10g_XPT" has 1 instance(s).
  Instance "ora10g", status READY, has 1 handler(s) for this service...
Service "ora11g" has 1 instance(s).
  Instance "ora11g", status READY, has 1 handler(s) for this service...
The command completed successfully


可見,此時監聽已經成功啟動並執行正常。

4.小結
處理有關監聽方面的故障時,多注意觀察錯誤提示資訊的內容,60%的情況下錯誤提示資訊本身包含了比較有意義的資訊。例如本例中,錯誤提示反覆提到“target host”目標主機這個關鍵字,可以由此深入進去進行問題排查。

Good luck.

secooler
11.03.25

-- The End --

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

相關文章