【監聽】listener.ora檔案理解

lusklusklusk發表於2015-11-26

listener.ora檔案裡面配置的內容主要是靜態監聽,需要listener.ora檔案主要為了新增靜態監聽global_dbname\sid_nameSID_LIST_LISTENER)和新增額外的監聽器名稱


預設的監聽器hosthostname不是ip、埠是1521、協議是TCP,無listener.ora檔案情況下預設監聽器繼續存在(監聽器名稱預設LISTENER,hosthostname不是ip、埠是1521、協議是TCP),如果需要向非預設監聽註冊,則需要配置local_listener引數

註冊是把資料庫資訊作為一個服務註冊(註冊內容是servcice_name和instance_name)到監聽中的hostport中,listener.ora中如果host配置的資訊為ip,但是實際伺服器上不存在這個ip則無法註冊,如果host中配置的是伺服器名稱,而伺服器名稱不存在或伺服器名在/etc/hosts中對應的ip不存在或與實際IP不一致則無法註冊,DB預設監聽器的hosthostname

 


listener.ora中靜態監聽的SID_NAME的值一定要區分大小寫

listener.ora檔案中不會出現service_nameservice_names,只有GLOBAL_DBNAMESID_NAME,出現service_nameservice_nameslsnrctl start listenername會報錯

 

 

 

靜態監聽如果有非預設監聽器listener以外的其他名稱的監聽器,則操作方式如下,前提是兩個監聽中的port和key不能一樣,否則也只能啟動一個。

lsnrctl start listenername

lsnrctl status listenername

lsnrctl stop listenername

 

 

 

 

 


安裝完資料庫軟體時預設的listener.ora如下,只有預設監聽的資訊

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

      (ADDRESS = (PROTOCOL = TCP)(HOST = M0776)(PORT = 1521))

    )

  )

 

 

 

新增一個靜態監聽listener2後如下

LISTENER2 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.98.0.31)(PORT = 1522))

  )

 

SID_LIST_LISTENER2 =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = luxus)

      (ORACLE_HOME = E:\app\luxus.liao\product\11.1.0\db_1)

      (SID_NAME = luxus)

    )

  )

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = M0776)(PORT = 1521))

    )

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

    )

  )

 

 

 

 

listener.ora想對監聽名為listener的監聽新增一個靜態註冊,只有如下內容時,是沒有靜態註冊的

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.98.0.122)(PORT = 1521))

    )

  )

 

 

[oracle@DEMOSFCS admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAY-2015 20:08:31

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.98.0.122)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Start Date                14-MAY-2015 20:03:59

Uptime                    0 days 0 hr. 4 min. 32 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/DEMOSFCS/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.98.0.122)(PORT=1521)))

Services Summary...

Service "DEMOSFCS" has 1 instance(s).

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

Service "DEMOSFCSXDB" has 1 instance(s).

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

The command completed successfully

 

 

 

 

 

內容是如下時(新增了SID_LIST_LISTENER資訊),才有靜態註冊

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.98.0.122)(PORT = 1521))

    )

  )

 

SID_LIST_LISTENER =

  (SID_LIST =

 

    (SID_DESC =

      (GLOBAL_DBNAME = DEMOSFCS)

      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)

      (SID_NAME = DEMOSFCS)

    )

    (SID_DESC =

      (SID_NAME = PLSExtProc)

      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)

      (PROGRAM = extproc)

     )

  )

 

 

 

 

[oracle@DEMOSFCS admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAY-2015 20:08:41

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.98.0.122)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Start Date                14-MAY-2015 20:03:59

Uptime                    0 days 0 hr. 4 min. 42 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/DEMOSFCS/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.98.0.122)(PORT=1521)))

Services Summary...

Service "DEMOSFCS" has 2 instance(s).

  Instance "DEMOSFCS", status UNKNOWN, has 1 handler(s) for this service...

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

Service "DEMOSFCSXDB" has 1 instance(s).

  Instance "DEMOSFCS", 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


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

相關文章