oracle監聽之動態和靜態註冊

賀子_DBA時代發表於2016-07-06
一:EM無法使用的解決:首先我們知道EM只支援動態註冊的監聽。哪怕是有動態註冊資訊就可以
首先我先配置了listener這個監聽,具體配置如下:
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = edb1.example.com)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
很顯然這個是動態監聽,正好這時候我用這個監聽配置了EM。
EM配置完成之後,我繼續配置lsnr2 ,具體配置如下:
LSNR2 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = edb1.example.com)(PORT = 1526))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1526))
    )
  )
要求要lsnr也能動態註冊到資料庫資訊,這時候我們發現這個監聽的埠非預設埠。然而oracle預設動態是註冊到1521埠上的,所有這時候lsnr2是不能動態註冊到資料庫資訊的,如下:
[oracle@edb1 admin]$ lsnrctl status lsnr2 

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 05-JUL-2016 23:34:29 

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edb1.example.com)(PORT=1526))) 
STATUS of the LISTENER 
------------------------ 
Alias lsnr2 
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production 
Start Date 05-JUL-2016 23:34:06 
Uptime 0 days 0 hr. 0 min. 22 sec 
Trace Level off 
Security ON: Local OS Authentication 
SNMP OFF 
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 
Listener Log File /u01/app/oracle/diag/tnslsnr/edbjr2p1/lsnr2/alert/log.xml 
Listening Endpoints Summary... 
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edb1.example.com)(PORT=1526))) 
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1526))) 
The listener supports no services 
The command completed successfully 
可以通過  local_listener這個引數來修改oracle預設動態註冊的埠,使lsnr2可以動態註冊到資訊。
1)在tnsname.ora 檔案裡新增
LSNR2 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = edb1.example.com)(PORT = 1526))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1526))
    )
  ) 
2)然後 修改資料庫引數
sqlplus  / as sysdba
SQL> alter system set local_listener='lSNR2';
SQL> alter system register;     ###動態監聽如果先於資料庫啟動,那就不必要執行這個命令。
3)再次檢視監聽狀態,發現動態註冊到了資訊
[oracle@edbjr2p1 admin]$ lsnrctl status lsnr2 

。。。。。。。
Services Summary...

Service "PROD1.us.oracle.com" has 1 instance(s).

Instance "PROD1", status READY, has 1 handler(s) for this service...

Service "PROD1XDB.us.oracle.com" has 1 instance(s).

Instance "PROD1", status READY, has 1 handler(s) for this service...

The command completed successfully

這樣我覺得OK了,可是等到後面使用EM的時候,我發現報錯,說 database  is  down,
可是我檢查發現資料庫正常, 然後檢視監聽listener的狀態:發現原本動態註冊的資訊已經沒有了。如下:
[oracle@edb1 admin]$ lsnrctl status  

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 05-JUL-2016 23:34:29 

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edb1.example.com)(PORT=1521))) 
STATUS of the LISTENER 
------------------------ 
Alias listener 
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production 
Start Date 05-JUL-2016 23:34:06 
Uptime 0 days 0 hr. 0 min. 22 sec 
Trace Level off 
Security ON: Local OS Authentication 
SNMP OFF 
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 
Listener Log File /u01/app/oracle/diag/tnslsnr/edbjr2p1/lsnr2/alert/log.xml 
Listening Endpoints Summary... 
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edb1.example.com)(PORT=1521))) 
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1526))) 
The listener supports no services 
The command completed successfully 
可以推測出可能是這裡的原因導致報錯 :database is down
那麼是什麼原因導致的呢?
原來 當你設定local_listener=lsnr2後,資料庫資訊就會動態的註冊到1526埠,他就不會動態的註冊到1521,所以listener這個監聽註冊不到資訊,導致EM連結不到資料庫,報錯  database is down。
 
解決辦法:只需要修改引數 local_listener='listener','lsnr2';   即可,這樣oracle會動態註冊到兩個埠上。
然後發現EM可以使用了。

二:關於oracle監聽動態和靜態的分析
oracle靜態監聽如下:
[oracle@edb1 admin]$ cat listener.ora 
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 
# Generated by Oracle configuration tools. 

LISTENER = 
(DESCRIPTION_LIST = 
(DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST = edb1.example.com)(PORT = 1521)) 
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) 


SID_LIST_LISTENER= 
(SID_LIST= 
(SID_DESC= 
(GLOBAL_DBNAME=PROD1) 
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1) 
(SID_NAME=PROD1)) 
(SID_DESC= 
(SID_NAME=plsextproc) 
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1) 
(PROGRAM=extproc))) 

儘管是靜態監聽,但是他也會有動態註冊資訊,如下  ready代表動態,unknown代表靜態。如果你剛才用這樣的話已經配置好的EM是可以使用這個監聽的,可不要認為靜態監聽也可以了,真正的原因是雖然是靜態監聽配置,但是oracle會預設動態的註冊到1521這個埠上,所以既有動態又有靜態的註冊資訊(前提是沒有修改local_listener這個引數)
[oracle@edb1 admin]$ lsnrctl status 

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 05-JUL-2016 23:45:04 

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edb1.example.com)(PORT=1521))) 
STATUS of the LISTENER 
------------------------ 
Alias LISTENER 
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production 
Start Date 05-JUL-2016 23:43:44 
Uptime 0 days 0 hr. 1 min. 20 sec 
Trace Level off 
Security ON: Local OS Authentication 
SNMP OFF 
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 
Listener Log File /u01/app/oracle/diag/tnslsnr/edbjr2p1/listener/alert/log.xml 
Listening Endpoints Summary... 
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edb1.example.com)(PORT=1521))) 
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "PROD1" has 1 instance(s).
  Instance "PROD1", status UNKNOWN, has 1 handler(s) for this service...
Service "PROD1.us.oracle.com" has 1 instance(s).
  Instance "PROD1", status READY, has 1 handler(s) for this service...
Service "PROD1XDB.us.oracle.com" has 1 instance(s).
  Instance "PROD1", status READY, has 1 handler(s) for this service...
Service "plsextproc" has 1 instance(s).
  Instance "plsextproc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully





如果你配置EM使用的監聽沒有動態註冊資訊,那麼當你使用EM的時候就會報錯,具體如下:

oracle監聽之動態和靜態註冊


小結:EM管理器,配置和使用只支援動態註冊的監聽,如果你剛開始是用動態註冊的監聽配置好了EM,你又把動態的監聽改成了靜態的,這時候你沒有修改local_listener這個引數,正常情況還是可以使用EM的,因為這時候你的監聽既有靜態註冊資訊又有動態註冊資訊,EM使用的是動態資訊,說白了就是保證有動態註冊的資訊即可。


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

相關文章