Oracle 动态监听注册

来源:互联网 发布:html5交互动画软件 编辑:程序博客网 时间:2024/04/29 16:23
      ORACLE实例在启动时,或使用命令ALTER SYSTEM REGISTER ,或每隔一分钟,PMON进程会向监听进行动态注册 


1、监听在启动时,会从$ORACLE_HOME/network/admin/listener.ora读取监听配置,如果该文件不存在,则监听会在主机名对应的IP和1521端口上进行监听。可以看到监听刚刚启动的时候,并没有注册的服务
LSNRCTL> start
Starting tnslsnr: please wait...


TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production
Log messages written to f:\oracle\product\10.2.0\network\log\listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linan)(PORT=1521)))


Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production
Start Date                14-APR-2008 21:29:40
Uptime                    0 days 0 hr. 0 min. 2 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         f:\oracle\product\10.2.0\network\log\listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linan)(PORT=1521)))
The listener supports no services
The command completed successfully


2、过了大概1分钟,PMON进程会将服务注册进来
LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production
Start Date                14-APR-2008 21:29:40
Uptime                    0 days 0 hr. 1 min. 57 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         f:\oracle\product\10.2.0\network\log\listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linan)(PORT=1521)))
Services Summary...
Service "test" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
Service "testXDB" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
Service "test_XPT" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
The command completed successfully


3、但是PMON进程只向默认的1521端口的监听注册,当监听不在1521端口时,需要使用下面的方法:


a、直接在参数local_listener中输入监听地址,PMON进程会根据此信息,并进行注册
sys@TEST>altersystem set local_listener='(address=(protocol=tcp)(port=1522)(host=linan))';


System altered.


b、或者只在参数local_listener中输入监听的名称
sys@TEST>altersystem set local_listener='test';


System altered.


在$ORACLE_HOME/network/admin/tnsnames.ora中包含监听地址,PMON进程会从此处得监听信息,并进行注册
TEST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1522))


4、但有3点需要注意的地方:
a、PMON进程1分钟运行一次,当监听刚刚启动的时候,可能服务还没有注册进去,这时候是不能使用此服务的
b、在修改local_listener参数时,PMON进程也会重新注册一次
c、如果数据库shutdown后,PMON进程也停止了,服务会从监听中删除,这时候只能使用OS认证的方式连入数据库


LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=linan)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     listener1
Version                   TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production
Start Date                14-APR-2008 21:14:04
Uptime                    0 days 0 hr. 10 min. 15 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   f:\oracle\product\10.2.0\network\admin\listener.ora
Listener Log File         f:\oracle\product\10.2.0\network\log\listener1.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linan)(PORT=1522)))
Services Summary...
Service "test" has 1 instance(s).
  Instance "test", status BLOCKED, has 1 handler(s) for this service...
Service "testXDB" has 1 instance(s).
  Instance "test", status BLOCKED, has 1 handler(s) for this service...
Service "test_XPT" has 1 instance(s).
  Instance "test", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully


sys@TEST>shutimmediate
Database closed.
Database dismounted.
ORACLE instance shut down.


LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=linan)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     listener1
Version                   TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production
Start Date                14-APR-2008 21:14:04
Uptime                    0 days 0 hr. 10 min. 49 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   f:\oracle\product\10.2.0\network\admin\listener.ora
Listener Log File         f:\oracle\product\10.2.0\network\log\listener1.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linan)(PORT=1522)))
The listener supports no services
The command completed successfully
http://space.itpub.net/498744/viewspace-237817  
原创粉丝点击