一、如果使用預設的1521連接埠,讓執行個體自動註冊到該監聽上,那麼local_listener無需設定,listener.ora檔案按照正常方式配置即可。
二、如果使用非預設1521連接埠,讓執行個體自動註冊到該監聽上,那麼需要設定local_listerner參數,local_listener = 'lsnr2' (可以動態修改)
三、編輯listener.ora檔案,該監聽為兩個,一個為動態註冊使用預設連接埠,一個為靜態註冊使用了非預設連接埠:
LISTENER1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oms)(PORT = 1526))
)
SID_LIST_LISTENER1 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = guuc)
(Oracle_HOME = /oracle/product/10201)
(SID_NAME = cuug)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /oracle/product/10201)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oms)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
三、資料庫監聽兩個啟動後的情況,此時資料庫未啟動,預設的的現在還沒有,非預設的現在有了一個靜態:
[oracle@oms admin]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-APR-2010 00:12:37
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oms)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias listener
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 14-APR-2010 00:07:35
Uptime 0 days 0 hr. 5 min. 1 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/product/10201/network/admin/listener.ora
Listener Log File /oracle/product/10201/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oms)(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
======================
[oracle@oms admin]$ lsnrctl status listener1
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-APR-2010 00:12:40
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oms)(PORT=1526)))
STATUS of the LISTENER
------------------------
Alias listener1
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 14-APR-2010 00:06:56
Uptime 0 days 0 hr. 5 min. 43 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/product/10201/network/admin/listener.ora
Listener Log File /oracle/product/10201/network/log/listener1.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oms)(PORT=1526)))
Services Summary...
Service "guuc" has 1 instance(s).
Instance "cuug", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
四、啟動資料庫,觀察監聽的變化,預設的註冊了一個執行個體,非預設的不變:
[oracle@oms admin]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-APR-2010 00:18:40
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oms)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias listener
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 14-APR-2010 00:07:35
Uptime 0 days 0 hr. 11 min. 4 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/product/10201/network/admin/listener.ora
Listener Log File /oracle/product/10201/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oms)(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 "cuug" has 1 instance(s).
Instance "cuug", status READY, has 1 handler(s) for this service...
Service "cuug_XPT" has 1 instance(s).
Instance "cuug", status READY, has 1 handler(s) for this service...
The command completed successfully
==========================
[oracle@oms admin]$ lsnrctl status listener1
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-APR-2010 00:18:42
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oms)(PORT=1526)))
STATUS of the LISTENER
------------------------
Alias listener1
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 14-APR-2010 00:06:56
Uptime 0 days 0 hr. 11 min. 45 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/product/10201/network/admin/listener.ora
Listener Log File /oracle/product/10201/network/log/listener1.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oms)(PORT=1526)))
Services Summary...
Service "guuc" has 1 instance(s).
Instance "cuug", status UNKNOWN, has 1 handler(s) for this servi
五、配置本地的tnsnames.ora檔案
LSNR2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = oms)(PORT = 1526))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cuug) #此名字可以自訂,一般定義為執行個體的名字
)
)
六、動態更改local_listener的值:
SQL> alter system set local_listener = lsnr2;
七、注意兩個監聽的變化,預設的監聽沒有執行個體註冊,非預設的註冊了一個執行個體:
[oracle@oms admin]$ lsnrctl status listener
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-APR-2010 00:25:50
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oms)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias listener
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 14-APR-2010 00:07:35
Uptime 0 days 0 hr. 18 min. 14 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/product/10201/network/admin/listener.ora
Listener Log File /oracle/product/10201/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oms)(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
=========================
[oracle@oms admin]$ lsnrctl status listener1
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-APR-2010 00:26:03
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oms)(PORT=1526)))
STATUS of the LISTENER
------------------------
Alias listener1
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 14-APR-2010 00:24:35
Uptime 0 days 0 hr. 1 min. 28 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/product/10201/network/admin/listener.ora
Listener Log File /oracle/product/10201/network/log/listener1.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oms)(PORT=1526)))
Services Summary...
Service "cuug" has 1 instance(s).
Instance "cuug", status READY, has 1 handler(s) for this service...
Service "cuug_XPT" has 1 instance(s).
Instance "cuug", status READY, has 1 handler(s) for this service...
Service "guuc" has 1 instance(s).
Instance "cuug", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
注意:發現執行個體註冊到這個連接埠的監聽上了,至此,終於明白local_listener參數的作用,預設的值是資料庫的global_name,則註冊到預設監聽;如果設定了新值,比如lsnr2,則根據tnsnames.ora的設定,註冊到指定的連接埠的監聽,該連接埠與某個監聽指定的連接埠一致。
更多Oracle相關資訊見Oracle 專題頁面 http://www.bkjia.com/topicnews.aspx?tid=12