【故障處理】【LISTENER】主機名修改為IP地址後LISTENER無法監聽到例項

secooler發表於2009-07-21
1.【環境資訊】
作業系統
ora10g@testdb /home/oracle$ uname -a
Linux testdb 2.6.18-53.el5xen #1 SMP Wed Oct 10 16:48:44 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
資料庫
sys@ora10g> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

2.【問題現象】
一句話描述:將listener.ora和tnsnames.ora檔案中的HOST資訊從原來的主機名字修改為IP地址後,監聽可以啟動,但是無論如何也監聽不到資料庫例項的資訊(即使反覆重啟資料庫)。

問題展開描述:
修改前的listener.ora內容如下:
ora10g@testdb /oracle/app/oracle/product/10.2.0/db_1/network/admin$ cat listener.ora
# listener.ora Network Configuration File: /oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /oracle/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = testdb)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

修改後的listener.ora內容如下:
ora10g@testdb /oracle/app/oracle/product/10.2.0/db_1/network/admin$ cat listener.ora
# listener.ora Network Configuration File: /oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /oracle/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 144.194.192.183)(PORT = 1521)(IP = FIRST))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

對應的tnsnames.ora檔案中也同樣的將主機名testdb修改為IP地址144.194.192.183。

修改後重新啟動監聽,但是監聽一直保持在如下的狀態
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=144.194.192.183)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                21-JUL-2009 14:34:20
Uptime                    0 days 0 hr. 0 min. 36 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /oracle/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=144.194.192.183)(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.【問題原因】
罪魁禍首在/etc/hosts檔案!!
先看一下在我處理之前該檔案的內容:
[root@testdb ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1   testdb  localhost.localdomain   localhost
::1     localhost6.localdomain6 localhost6

先提示到這裡,停一停,想一想,這到底是為什麼呢?如果您也遇到了這個問題,處理思路是什麼呢?

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

好了,不賣關子了,問題出在,在這種預設配置下(作業系統安裝後的狀態),主機名字和本機的IP地址沒有對應起來.
換一種好理解的方式講,在這種情況下如果您ping主機名testdb的話:
ora10g@testdb /home/oracle$ ping testdb
PING testdb (127.0.0.1) 56(84) bytes of data.
64 bytes from testdb (127.0.0.1): icmp_seq=1 ttl=64 time=0.076 ms
64 bytes from testdb (127.0.0.1): icmp_seq=2 ttl=64 time=0.052 ms
64 bytes from testdb (127.0.0.1): icmp_seq=3 ttl=64 time=0.053 ms

結果是主機名testdb直接對應到了127.0.0.1地址,沒有對應到正確的144.194.192.183地址!!

4.【問題解決】
(1)將/etc/hosts內容修改為:
[root@testdb ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost
::1     localhost6.localdomain6 localhost6
144.194.192.183   testdb

比較一下與之前檔案的不同,這裡修改的內容如下:
1)將127.0.0.1後面的testdb主機名刪除
2)新增IP地址和主機名對應關係144.194.192.183   testdb

透過ping主機名testdb的方式驗證一下修改後的效果:
ora10g@testdb /home/oracle$ ping testdb
PING testdb (144.194.192.183) 56(84) bytes of data.
64 bytes from testdb (144.194.192.183): icmp_seq=1 ttl=64 time=0.082 ms
64 bytes from testdb (144.194.192.183): icmp_seq=2 ttl=64 time=0.047 ms
64 bytes from testdb (144.194.192.183): icmp_seq=3 ttl=64 time=0.050 ms
到此,主機名testdb與IP地址
144.194.192.183建立起了對應關係。

(2)重新啟動監聽
LSNRCTL> stop
LSNRCTL> start
Starting /oracle/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=144.194.192.183)(PORT=1521)(IP=FIRST)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                21-JUL-2009 15:05:08
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /oracle/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=144.194.192.183)(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
LSNRCTL>

過大概半分鐘的樣子,LISTENER即可監聽到資料庫的例項ora10g:
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=144.194.192.183)(PORT=1521)(IP=FIRST)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                21-JUL-2009 15:05:08
Uptime                    0 days 0 hr. 0 min. 36 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /oracle/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=144.194.192.183)(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 "ora10g_XPT" has 1 instance(s).
  Instance "ora10g", status READY, has 1 handler(s) for this service...
The command completed successfully

5.總結
資料庫的任何修改都是存在風險的,即使您“覺得”沒有問題,永遠記得“墨菲定律”--Anything that can go wrong will go wrong!
(1)任何事都沒有表面看起來那麼簡單;
(2)所有的事都會比你預計的時間長;
(3)會出錯的事總會出錯;
(4)如果你擔心某種情況發生,那麼它就更有可能發生。
所以,在做任何事情之前都要充分的測試,否則就有可能被“墨菲”到!

-- The End --

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

相關文章