>>listener的动态注册

导读:

  在oracle中,我们除了可以利用listener.ora文件实现静态的注册外,我们还能自动的实现动态注册。

  通过lsnrctl status我们可以看到unknown状态的侦听是静态注册的侦听,因为它无法知道当前instance的状态,而ready状态的侦听是动态注册的侦听,在instance启动的时候,会向侦听进行动态注册,告知侦听已经启动的instance name和service names——也基于这个原因,如果在instance启动后,再重启lsnr,lnsr会在刚刚开始的一段时间内(大约不到1分钟)无法得知instance的状态,只有等待pmon进程动态注册。下面的例子就是演示重启侦听但是不重启instance,在刚刚开始的一段时间内会提示侦听不提供服务:

  (1)通过ls看到,listener.ora已经被重命名成listener.ora111,oracle找不到静态侦听的文件listener.ora,因此采用动态注册:

  D:/oracle/ora92/network/admin>ls

  SAMPLE listener.bak master.cfg snmp_rw.ora tnsnames.ora 复件 tnsnames.ora

  encaps.cfg listener.ora111 snmp_ro.ora sqlnet.ora 复件 (2)tnsnames.ora

  (2)停lsnr,重启lsnr:

  D:/oracle/ora92/network/admin>lsnrctlstop LSNRCTLfor32-bitWindows: Version9.2.0.1.0- Productionon22-JUL-200700:35:37 Copyright(c)1991, 2002, OracleCorporation. Allrightsreserved.

  Connectingto(ADDRESS=(PROTOCOL=tcp)(PORT=1521))

  Thecommandcompletedsuccessfully D:/oracle/ora92/network/admin>D:/oracle/ora92/network/admin>D:/oracle/ora92/network/admin>lsnrctlstart LSNRCTLfor32-bitWindows: Version9.2.0.1.0- Productionon22-JUL-200700:35:46 Copyright(c)1991, 2002, OracleCorporation. Allrightsreserved.

  Startingtnslsnr: pleasewait...

  TNSLSNRfor32-bitWindows: Version9.2.0.1.0- Production写入D:/oracle/ora92/network/log/listener.log的日志信息

  监听:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hejianmin)(PORT=1521))) Connectingto(ADDRESS=(PROTOCOL=tcp)(PORT=1521))

  STATUSoftheLISTENER------------------------

  Alias LISTENER

  Version TNSLSNRfor32-bitWindows: Version9.2.0.1.0- Production

  StartDate 22-7月 -200700:35:48

  Uptime 0days0hr. 0min. 2sec

  TraceLevel off

  Security OFF

  SNMP OFF

  ListenerLogFile D:/oracle/ora92/network/log/listener.log

  ListeningEndpointsSummary...

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

  Thelistenersupportsnoservices

  Thecommandcompletedsuccessfully

  进一步查看其对外的service,也是发现没有提供:

  D:/oracle/ora92/network/admin>lsnrctlservice LSNRCTLfor32-bitWindows: Version9.2.0.1.0- Productionon22-JUL-200700:36:02 Copyright(c)1991, 2002, OracleCorporation. Allrightsreserved.

  Connectingto(ADDRESS=(PROTOCOL=tcp)(PORT=1521))

  Thelistenersupportsnoservices

  Thecommandcompletedsuccessfully

  (3)重启instance,再检查lnsr的状态

  sys@ORALOCAL(192.168.0.22)>shutdownimmediate

  Databaseclosed.Databasedismounted.ORACLEinstanceshutdown.sys@ORALOCAL(192.168.0.22)>startup

  ORACLEinstancestarted.

  TotalSystemGlobalArea 133765984bytes

  FixedSize 453472bytes

  VariableSize 79691776bytes

  DatabaseBuffers 50331648bytes

  RedoBuffers 3289088bytes

  Databasemounted.Databaseopened.sys@ORALOCAL(192.168.0.22)>exit

  DisconnectedfromOracle9iEnterpriseEditionRelease9.2.0.1.0- Production

  WiththePartitioning, OLAPandOracleDataMiningoptions

  JServerRelease9.2.0.1.0- Production D:/oracle/ora92/network/admin>lsnrctlservice LSNRCTLfor32-bitWindows: Version9.2.0.1.0- Productionon22-JUL-200700:37:15 Copyright(c)1991, 2002, OracleCorporation. Allrightsreserved.

  Connectingto(ADDRESS=(PROTOCOL=tcp)(PORT=1521))

  ServicesSummary...Service"oralocal"has1instance(s).

  Instance"oralocal", statusREADY, has1handler(s)forthisservice...

  Handler(s):

  "DEDICATED"established:0refused:0state:ready LOCALSERVER

  Service"oralocalXDB"has1instance(s).

  Instance"oralocal", statusREADY, has1handler(s)forthisservice...

  Handler(s):

  "D000"established:0refused:0current:0max:1002state:ready DISPATCHER

  (ADDRESS=(PROTOCOL=tcp)(HOST=hejianmin)(PORT=1951))

  Thecommandcompletedsuccessfully D:/oracle/ora92/network/admin>

  发现重启instance后,instance重新注册lnsr,在lsnrctl service也看到了其对外已经重新提供了服务。

  注:如果不重启instance,将有pmon进行动态注册。

  另外,如果要实现动态注册,我们在对初始化文件还有有一定的设置,必须设置instance_name和service_names参数(我试了一下,其实只要设置了service_names就能实现动态注册的,并且用这个服务名对外提供服务)。

  修改初始化文件,先全部取消instanace_name和service_names,然后逐个设定测试:

  (1)先设置instance_name

  sys@ORALOCAL(192.168.0.22)>altersystemsetinstance_name='oralocal'scope=spfile

  系统已更改。

  

  已用时间: 00: 00: 00.01

  sys@ORALOCAL(192.168.0.22)>startupforce

  ORACLE例程已经启动。

  TotalSystemGlobalArea 133765984bytes

  FixedSize 453472bytes

  VariableSize 79691776bytes

  DatabaseBuffers 50331648bytes

  RedoBuffers 3289088bytes数据库装载完毕。

  数据库已经打开。sys@ORALOCAL(192.168.0.22)>showparameterinstance_name NAME TYPE VALUE------------------------------------ ----------- ------------------------------

  instance_name string oralocal sys@ORALOCAL(192.168.0.22)>showparameterservice_names NAME TYPE VALUE------------------------------------ ----------- ------------------------------

  service_names string

  sys@ORALOCAL(192.168.0.22)>exit

  检查lsnr的状况:

  C:/DocumentsandSettings/Administrator>lsnrctlstatus LSNRCTLfor32-bitWindows: Version9.2.0.1.0- Productionon22-7月 -200700:42:56 Copyright(c)1991, 2002, OracleCorporation. Allrightsreserved.

  

  正在连接到 (ADDRESS=(PROTOCOL=tcp)(PORT=1521))

  LISTENER的 STATUS------------------------

  别名 LISTENER版本 TNSLSNRfor32-bitWindows: Version9.2.0.1.0- Production启动日期 22-7月 -200700:35:48正常运行时间 0天 0小时 7分 9秒

  跟踪级别 off安全性 OFF

  SNMP OFF监听器日志文件 D:/oracle/ora92/network/log/listener.log监听端点概要...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hejianmin)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hejianmin)(PORT=8080))(Presentation=HTTP)(Session=RAW)) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hejianmin)(PORT=2100))(Presentation=FTP)(Session=RAW))服务摘要..

  服务 "oralocalXDB"包含 1个例程。

  命令执行成功

  C:/DocumentsandSettings/Administrator>lsnrctlservice LSNRCTLfor32-bitWindows: Version9.2.0.1.0- Productionon22-7月 -200700:43:09 Copyright(c)1991, 2002, OracleCorporation. Allrightsreserved.

  

  正在连接到 (ADDRESS=(PROTOCOL=tcp)(PORT=1521))服务摘要..

  服务 "oralocalXDB"包含 1个例程。

  处理程序:

  "D000"已建立:0已被拒绝:0当前: 0最大: 1002状态: ready DISPATCHER

  (ADDRESS=(PROTOCOL=tcp)(HOST=hejianmin)(PORT=2066))命令执行成功

  C:/DocumentsandSettings/Administrator>sqlplususername/password@oralocal SQL*Plus: Release9.2.0.1.0- Productionon星期日 7月 2200:47:092007 Copyright(c)1982, 2002, OracleCorporation. Allrightsreserved.

  ERROR:ORA-12514: TNS: 监听进程不能解析在连接描述符中给出的 SERVICE_NAME

  发现其还是没有提供oralocal的服务,登录也不能成功。并且,如果在客户端的tnsnames中设置:INSTANCE_NAME = oralocal,通过这个虽然能解析到提供的服务,但是登录还是不能登录,会报错:

  ERROR:

  ORA-12504: TNS: 监听器在 CONNECT_DATA 中未获得 SID

  (2)设置service_names,取消instance_name的设置

  username@ORALOCAL(192.168.0.22)>showparameterinstance_name NAME TYPE VALUE------------------------------------ ----------- ------------------------------

  instance_name string

  username@ORALOCAL(192.168.0.22)> showparameterservice_names NAME TYPE VALUE------------------------------------ ----------- ------------------------------

  service_names string oralocal

  username@ORALOCAL(192.168.0.22)>exit从Oracle9iEnterpriseEditionRelease9.2.0.1.0- Production

  WiththePartitioning, OLAPandOracleDataMiningoptions

  JServerRelease9.2.0.1.0- Production中断开

  C:/DocumentsandSettings/Administrator>lsnrctlstatus LSNRCTLfor32-bitWindows: Version9.2.0.1.0- Productionon22-7月 -200700:51:03 Copyright(c)1991, 2002, OracleCorporation. Allrightsreserved.

  

  正在连接到 (ADDRESS=(PROTOCOL=tcp)(PORT=1521))

  LISTENER的 STATUS------------------------

  别名 LISTENER版本 TNSLSNRfor32-bitWindows: Version9.2.0.1.0- Production启动日期 22-7月 -200700:35:48正常运行时间 0天 0小时 15分 17秒

  跟踪级别 off安全性 OFF

  SNMP OFF监听器日志文件 D:/oracle/ora92/network/log/listener.log监听端点概要...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hejianmin)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hejianmin)(PORT=8080))(Presentation=HTTP)(Session=RAW)) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hejianmin)(PORT=2100))(Presentation=FTP)(Session=RAW))服务摘要..

  服务 "oralocal"包含 1个例程。

  服务 "oralocalXDB"包含 1个例程。

  命令执行成功

  C:/DocumentsandSettings/Administrator>lsnrctlservice LSNRCTLfor32-bitWindows: Version9.2.0.1.0- Productionon22-7月 -200700:51:13 Copyright(c)1991, 2002, OracleCorporation. Allrightsreserved.

  

  正在连接到 (ADDRESS=(PROTOCOL=tcp)(PORT=1521))服务摘要..

  服务 "oralocal"包含 1个例程。

  处理程序:

  "DEDICATED"已建立:0已拒绝:0状态:ready LOCALSERVER服务 "oralocalXDB"包含 1个例程。

  处理程序:

  "D000"已建立:0已被拒绝:0当前: 0最大: 1002状态: ready DISPATCHER

  (ADDRESS=(PROTOCOL=tcp)(HOST=hejianmin)(PORT=2288))命令执行成功

  C:/DocumentsandSettings/Administrator>sqlplususername/password@oralocal SQL*Plus: Release9.2.0.1.0- Productionon星期日 7月 2200:51:302007 Copyright(c)1982, 2002, OracleCorporation. Allrightsreserved.

  

  

  连接到:Oracle9iEnterpriseEditionRelease9.2.0.1.0- Production

  WiththePartitioning, OLAPandOracleDataMiningoptions

  JServerRelease9.2.0.1.0- Production username@ORALOCAL(192.168.0.22)>exit从Oracle9iEnterpriseEditionRelease9.2.0.1.0- Production

  WiththePartitioning, OLAPandOracleDataMiningoptions

  JServerRelease9.2.0.1.0- Production中断开

  C:/DocumentsandSettings/Administrator>C:/DocumentsandSettings/Administrator>

  发现其能提供对外服务。

  最后,如果lsnr使用了不是默认的设置,如不使用1521端口,不使用TCP协议,必须在初始化文件中设置

  local_listener=”(ADDRESS_LIST = (Address =(Protocol = TCP) (Host=weishan) (Port=1522)))”的参数。



本文转自

http://www.oracleblog.cn/study-note/dynamic-registration-of-services/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值