ITPub博客

首页 > 数据库 > Oracle > Oracle 监听动态注册与静态注册

Oracle 监听动态注册与静态注册

Oracle 作者:simplewp 时间:2013-12-02 13:58:28 0 删除 编辑

静态注册

  静态注册是在启动listener时,listener会从listener.ora文件中获取服务名及相关信息。信息包括:实例名和服务名等。

--静态注册时,listener.ora中的内容如下:

复制代码
 1 #SID_LIST_LISTENER描述对外提供数据库服务的列表;  2 #两个实例sun,+ASM分别对应服务名orcl01,orcl02  3 SID_LIST_LISTENER =  4 (  5  SID_LIST =  6  (  7  SID_DESC =  8  (SID_NAME = PLSExtProc)  9  (ORACLE_HOME = /u01/oracle) 10  (PROGRAM = extproc) 11  ) 12 13  ( 14  SID_DESC = 15  (SID_NAME = sun)          --提供注册的实例名 16  (ORACLE_HOME = /u01/oracle) 17  (GLOBAL_DBNAME =orcl01)   --向外提供服务名 18  ) 19 20  ( 21  SID_DESC = 22  (SID_NAME = +ASM) 23  (ORACLE_HOME = /u01/oracle) 24  (GLOBAL_DBNAME =orcl02) 25  ) 26 ) 27 28 #LISTENER部分描述了主机地址、端口及协议 29 LISTENER = 30  (DESCRIPTION = 31  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.128)(PORT = 1521)) 32 ) 
复制代码

--配置对应的tnsnames.ora 中的节点

复制代码
 1 -bash-3.00$ more tnsnames.ora  2 # tnsnames.ora Network Configuration File: /u01/oracle/network/admin/tnsnames.ora  3 # Generated by Oracle configuration tools.  4  5 #通过实例名连接  6 SUN01 =  7  (DESCRIPTION =  8  (ADDRESS_LIST =  9  (ADDRESS = (PROTOCOL = TCP)(HOST = mysolaris)(PORT = 1521)) 10  ) 11  (CONNECT_DATA = 12  (SID = sun) 13  ) 14  ) 15 16 #通过服务名连接 17 SUN02 = 18  (DESCRIPTION = 19  (ADDRESS_LIST = 20  (ADDRESS = (PROTOCOL = TCP)(HOST = mysolaris)(PORT = 1521)) 21  ) 22  (CONNECT_DATA = 23  (SERVICE_NAME = orcl01) 24  ) 25  ) 26 27 #通过实例名连接 28 ASM01 = 29  (DESCRIPTION = 30  (ADDRESS_LIST = 31  (ADDRESS = (PROTOCOL = TCP)(HOST = mysolaris)(PORT = 1521)) 32  ) 33  (CONNECT_DATA = 34  (SID = +ASM) 35  ) 36  ) 37 38 #通过服务名连接 39 ASM02 = 40  (DESCRIPTION = 41  (ADDRESS_LIST = 42  (ADDRESS = (PROTOCOL = TCP)(HOST = mysolaris)(PORT = 1521)) 43  ) 44  (CONNECT_DATA = 45  (SERVICE_NAME = orcl02) 46  ) 47  ) 48 49 50 EXTPROC_CONNECTION_DATA = 51  (DESCRIPTION = 52  (ADDRESS_LIST = 53  (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) 54  ) 55  (CONNECT_DATA = 56  (SID = PLSExtProc) 57  (PRESENTATION = RO) 58  ) 59 )     
复制代码

--启动监听

复制代码
-bash-3.00$ lsnrctl start

LSNRCTL for Solaris: Version 10.2.0.2.0 - Production on 10-AUG-2013 20:50:35

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

Starting /u01/oracle/bin/tnslsnr: please wait...

TNSLSNR for Solaris: Version 10.2.0.2.0 - Production
System parameter file is /u01/oracle/network/admin/listener.ora
Log messages written to /u01/oracle/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.2.100)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.100)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Solaris: Version 10.2.0.2.0 - Production
Start Date                10-AUG-2013 20:50:35
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/oracle/network/admin/listener.ora
Listener Log File         /u01/oracle/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.2.100)(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 "orcl01" has 1 instance(s).
  Instance "sun", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl02" has 1 instance(s).
  Instance "+ASM", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
复制代码

--可以看到实例sun及实例+ASM都在被监听

1 Service "orcl01" has 1 instance(s). 2  Instance "sun", status UNKNOWN, has 1 handler(s) for this service... 3 Service "orcl02" has 1 instance(s). 4 Instance "+ASM", status UNKNOWN, has 1 handler(s) for this service...

   从上面信息可以看到,静态注册时监听程序所获取的实例名或服务名均来自listener.ora文件

动态注册

  动态注册是在instance启动的时候PMON进程根据init.ora中的instance_name,service_names两个参数将实例和服务动态注册到listener中。

  • instance_name默认是:db_name
  • service_names默认是:db_name.db_domain 

  在启动listener时,会从listener.ora读取监听配置,如果该文件不存在,则监听会在主机名对应的IP和1521端口上进行监听。但监听刚刚启动的时候,并没有注册的服务。

1.配置默认端口的动态服务注册

--关闭实例,关闭监听,备份listener.ora

1 -bash-3.00$ ls -l 2 -rw-r--r-- 1 oracle   oinstall 603 Aug 10 20:50 listener.ora.bak 3 drwxr-x--- 2 oracle   oinstall 512 Jan 21 2013 samples 4 -rw-r----- 1 oracle   oinstall 172 Dec 26 2003 shrept.lst 5 -rw-r--r-- 1 oracle   oinstall 1056 Aug 10 20:40 tnsnames.ora

--启动监听

复制代码
 1 -bash-3.00$ lsnrctl start  2 .........  3 Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))  4 STATUS of the LISTENER  5 ------------------------  6 Alias                     LISTENER  7 Version                   TNSLSNR for Solaris: Version 10.2.0.2.0 - Production  8 Start Date 10-AUG-2013 22:20:20  9 Uptime 0 days 0 hr. 0 min. 0 sec 10 Trace Level               off 11 Security                  ON: Local OS Authentication 12 SNMP                      OFF 13 Listener Log File         /u01/oracle/network/log/listener.log 14 Listening Endpoints Summary... 15 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mysolaris)(PORT=1521))) 16 The listener supports no services 17 The command completed successfully
复制代码

  可以看到:监听会在主机名对应的IP和1521端口上进行监听;监听刚刚启动的时候,并没有注册的服务

--启动实例后,查看监听 发现PMON进程会将服务注册进来

复制代码
 1 -bash-3.00$ lsnrctl status  2 ........  3 Listening Endpoints Summary...  4 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mysolaris)(PORT=1521)))  5 Services Summary...  6 Service "+ASM" has 1 instance(s).  7 Instance "+ASM", status BLOCKED, has 1 handler(s) for this service...  8 Service "+ASM_XPT" has 1 instance(s).  9 Instance "+ASM", status BLOCKED, has 1 handler(s) for this service... 10 Service "sun" has 1 instance(s). 11 Instance "sun", status READY, has 1 handler(s) for this service... 12 Service "sun_XPT" has 1 instance(s). 13 Instance "sun", status READY, has 1 handler(s) for this service... 14 The command completed successfully
复制代码

2.配置非默认端口的动态服务注册

服务器端的配置

a.配置非默认的listener.ora

复制代码
1 -bash-3.00$ more listener.ora 2 3 LISTENER02 =     --这个名字最好不要用默认的LISTENER 4 (DESCRIPTION_LIST = 5 (DESCRIPTION = 6 (ADDRESS = (PROTOCOL = TCP)(HOST = mysolaris)(PORT = 1522)) 7 (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) 8  ) 9 )
复制代码

b.在配置文件tnsnames.ora中加入

复制代码
 1 -bash-3.00$ more tnsnames.ora  2 # tnsnames.ora Network Configuration File: /u01/oracle/network/admin/tnsnames.ora  3 # Generated by Oracle configuration tools.  4  5 LISTENER02 = (  6 ADDRESS = (PROTOCOL = TCP)  7 (HOST = mysolaris)  8 (PORT = 1522)  9 ) 10 -bash-3.00$ 
复制代码

c.启动非默认的侦听器

复制代码
 1 -bash-3.00$ lsnrctl start LISTENER02  2  3 STATUS of the LISTENER  4 ------------------------  5 Alias                     LISTENER02  6 Version                   TNSLSNR for Solaris: Version 10.2.0.2.0 - Production  7 Start Date 10-AUG-2013 23:22:01  8 Uptime 0 days 0 hr. 0 min. 0 sec  9 Trace Level               off 10 Security                  ON: Local OS Authentication 11 SNMP                      OFF 12 Listener Parameter File   /u01/oracle/network/admin/listener.ora 13 Listener Log File         /u01/oracle/network/log/listener.log 14 Listening Endpoints Summary... 15 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.2.100)(PORT=1522))) 16 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0))) 17 The listener supports no services 18 The command completed successfully 19 -bash-3.00$ 
复制代码

d.设定local_listener参数

1 SQL> alter system set local_listener = 'LISTENER02'; --LISTENER2为tnsnames.ora中的监听名称

e.手动使动态注册立即生效(此操作可有可无)

1 SQL> alter system register;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27009266/viewspace-1061841/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: oracle execution plan
请登录后发表评论 登录
全部评论

注册时间:2012-05-26

  • 博文量
    45
  • 访问量
    106488