【LISTENER】實現將資料庫例項同時動態註冊到兩個非預設監聽埠

secooler發表於2011-05-15
  本文給出將資料庫例項同時動態註冊到兩個非預設監聽埠的手工配置方法。

1.編寫listener.ora檔案給出1526和1528兩個非預設埠監聽配置
ora10g@secdb /home/oracle$ vi $ORACLE_HOME/network/admin/listener.ora
listener_1526=
  (description=
    (address=(protocol=tcp)(host=secdb)(port=1526)))

listener_1528=
  (description=
    (address=(protocol=tcp)(host=secdb)(port=1528)))
~
~

2.同時啟動兩個非預設埠監聽器
1)啟動監聽埠為1526的監聽器listener_1526
ora10g@secdb /home/oracle$ lsnrctl start listener_1526

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 15-MAY-2011 22:08:25

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

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_1526.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb.localdomain)(PORT=1526)))

Connecting to (DESCRIPTION=(address=(protocol=tcp)(host=secdb)(port=1526)))
STATUS of the LISTENER
------------------------
Alias                     listener_1526
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                15-MAY-2011 22:08:25
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_1526.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb.localdomain)(PORT=1526)))
The listener supports no services
The command completed successfully


2)啟動監聽埠為1528的監聽器listener_1528
ora10g@secdb /home/oracle$ lsnrctl start listener_1528

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 15-MAY-2011 22:08:28

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

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_1528.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb.localdomain)(PORT=1528)))

Connecting to (DESCRIPTION=(address=(protocol=tcp)(host=secdb)(port=1528)))
STATUS of the LISTENER
------------------------
Alias                     listener_1528
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                15-MAY-2011 22:08:28
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_1528.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb.localdomain)(PORT=1528)))
The listener supports no services
The command completed successfully

3.配置tnsnames.ora檔案
ora10g@secdb /home/oracle$ vi $ORACLE_HOME/network/admin/tnsnames.ora
listener_ora10g =
  (ADDRESS_LIST =
    (address = (protocol = tcp)(host = secdb)(port = 1526))
    (address = (protocol = tcp)(host = secdb)(port = 1528))
  )

ora10g_1526=
 (description=
   (address=(protocol=tcp)(host=secdb)(port=1526))
   (connect_data=
     (service_name=ora10g)))

ora10g_1528=
 (description=
   (address=(protocol=tcp)(host=secdb)(port=1528))
   (connect_data=
     (service_name=ora10g)))
~
~

其中“listener_ora10g”使用者在資料庫例項中設定local_listener引數實現動態註冊;“ora10g_1526”是用於測試1526埠是否可用的連線串;“ora10g_1528”是用於測試1528埠是否可用的連線串.

4.在資料庫例項中透過修改local_listener引數實現動態註冊
sys@ora10g> show parameter local_listener

NAME                        TYPE                 VALUE
--------------------------- -------------------- ------------------
local_listener              string
sys@ora10g> alter system set local_listener='listener_ora10g';

System altered.

sys@ora10g> show parameter local_listener

NAME                        TYPE                 VALUE
--------------------------- -------------------- ------------------
local_listener              string               listener_ora10g

5.檢視1526以及1528埠監聽狀態
1)檢視1526埠監聽狀態
ora10g@secdb /home/oracle$ lsnrctl status listener_1526

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 15-MAY-2011 22:13:27

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

Connecting to (DESCRIPTION=(address=(protocol=tcp)(host=secdb)(port=1526)))
STATUS of the LISTENER
------------------------
Alias                     listener_1526
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                15-MAY-2011 22:08:25
Uptime                    0 days 0 hr. 5 min. 1 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_1526.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb.localdomain)(PORT=1526)))
Services Summary...
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

狀態顯示,1526埠已經能夠成功監聽到ora10g例項。

2)檢視1528埠監聽狀態
ora10g@secdb /home/oracle$ lsnrctl status listener_1528

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 15-MAY-2011 22:13:34

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

Connecting to (DESCRIPTION=(address=(protocol=tcp)(host=secdb)(port=1528)))
STATUS of the LISTENER
------------------------
Alias                     listener_1528
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                15-MAY-2011 22:08:28
Uptime                    0 days 0 hr. 5 min. 5 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_1528.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb.localdomain)(PORT=1528)))
Services Summary...
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

狀態顯示,1528埠也已經能夠同時監聽到ora10g例項。

註釋:如果短時間內例項沒有完成自動註冊,可以使用如下命令加速動態註冊。
sys@ora10g> alter system register;

6.測試1526以及1528埠是否可用
1)使用ora10g_1526連線串測試1526埠是否可用
ora10g@secdb /home/oracle$ sqlplus system/oracle@ora10g_1526

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 15 22:15:22 2011

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


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

system@ora10g>

使用監聽器1526埠成功連線到資料庫例項。

2)使用ora10g_1528連線串測試1528埠是否可用
ora10g@secdb /home/oracle$ sqlplus system/oracle@ora10g_1528

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 15 22:15:29 2011

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


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

system@ora10g>

使用監聽器1528埠成功連線到資料庫例項。

到此,我們便實現了將資料庫例項同時註冊到兩個非預設埠這個任務。

7.小結
  透過調整listener.ora和tnsnames.ora檔案可以實現監聽器的多種配置方法,本文給出的是實現將資料庫例項同時動態註冊到兩個非預設監聽埠的方法。大家可以嘗試給出其他的實現方法。

Good luck.

secooler
11.05.15

-- The End --

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

相關文章