ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle静态监听和动态监听

oracle静态监听和动态监听

原创 Linux操作系统 作者:randyamor 时间:2008-09-25 09:24:15 0 删除 编辑
一、静态注册

静态注册指实例启动时读取listener.ora配置文件,将实例和服务注册到监听程序。无论何时启动一个数据库,默认都有两条信息注册到监听器中:实例和服务。

SID_LIST_LISTENER =
  ( SID_LIST =
      (SID_DESC =
         (GLOBAL_DBNAME = Ora8)
         (SID_NAME = test)
      )
  )

LISTENER =
  ( DESCRIPTION =
     (ADDRESS = (HOST = 192.168.0.88)(PROTOCOL = TCP)(PORT = 1522))
  )

这是一个最简单的静态监听配置文件,SID_LIST_LISTENER部分的GLOBAL_DBNAME表示向外提供的服务名,SID_NAME是提供注册的实例。

在tnsnames.ora文件中的CONNECT_DATA部分,可分别选择SERVICE_NAME=Ora8或SID=test为客户端提供连接。

对于配置非1521监听端口,只能选择静态注册方式。

二、动态注册

动态注册不需要显示的配置listener.ora文件,实例启动的时候,PMON进程根据instance_name,service_name参数将实例和服务动态注册到listerer中。如果没有设定instance_name,将使用db_name初始化参数值。如果没有设定service_names,将拼接db_name和db_domain参数值来注册监听。

SQL> show parameter service_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      test
SQL> show parameter instance_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_name                        string      test

LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                24-SEP-2008 16:50:01
Uptime                    0 days 0 hr. 0 min. 33 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test1)(PORT=1521)))
Services Summary...
Service "test" 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

SQL> alter system set service_names='oratest' scope=both;

System altered.

SQL> alter system set instance_name='instest' scope=spfile;

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area   96468992 bytes
Fixed Size                  1217884 bytes
Variable Size              88083108 bytes
Database Buffers            4194304 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.

LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                24-SEP-2008 16:52:44
Uptime                    0 days 0 hr. 1 min. 52 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test1)(PORT=1521)))
Services Summary...
Service "oratest" has 1 instance(s).
  Instance "instest", status READY, has 1 handler(s) for this service...
Service "test" has 1 instance(s).
  Instance "instest", status READY, has 1 handler(s) for this service...
Service "test_XPT" has 1 instance(s).
  Instance "instest", status READY, has 1 handler(s) for this service...
The command completed successfully

可以看到,监听注册的服务和实例已发生了相应的变化。同静态监听,这里也可以分别使用SERVICE_NAME=oratest或SID=instest来进行客户端的连接。

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

下一篇: 遭遇ORA-01552错误
请登录后发表评论 登录
全部评论

注册时间:2008-05-20

  • 博文量
    31
  • 访问量
    119541