ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【LISTENER】实现将数据库实例同时动态注册到两个非默认监听端口

【LISTENER】实现将数据库实例同时动态注册到两个非默认监听端口

原创 Linux操作系统 作者:secooler 时间:2011-05-15 23:36:42 0 删除 编辑
  本文给出将数据库实例同时动态注册到两个非默认监听端口的手工配置方法。

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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle ACE 总监,阿里云MVP,北京大学理学硕士,恩墨学院创始人,教育专家,中国区 Cloudera 首位官方授权大数据讲师,金牌培训专家,BDA大数据联盟创始人,OCM联盟创始人,ACCUG创始人、ACOUG核心专家,Blogger。

注册时间:2008-03-16

  • 博文量
    797
  • 访问量
    8199784