listener.ora静态注册和动态注册

参考oracle联机丛书中   Net Services Reference的第7章 Listener Parameters (listener.ora)
 
oracle的Database services有2种注册方式,静态和动态。
 
Dynamic   service registration, a feature of Oracle9i and Oracle8, eliminates the need for static configuration of supported services. However, static service configuration is required if you plan to use Oracle Enterprise Manager.
动态服务注册,是9i和8的特性,消除了为了提供服务而需要原来静态配置的需求。然而, 如果你打算使用oem,那么对于9i和8还是需要进行静态服务注册。10G之后已经不需要了,我尝试将listener.ora完全清空。重启lsnrctl和emctl后,oem仍能够正常使用
 
For later database releases, the listener uses the dynamic service information about the database and instance it has received through service registration   before using statically configured information  in the   listener.ora  file. Therefore, the   SID_LIST  is not required, unless Oracle Enterprise Manager is used to monitor an Oracle9i or Oracle8 database.
 
如果使用动态注册方式。他是通过PMON进程进行的,一般在启动数据库后PMON进程会一分钟执行一次,检测到没有注册的服务会进行注册。如果等不了一分钟,也可以使用 alter system register;命令进行手动注册。
 
Process Monitor Process (PMON)
The   process monitor (PMON)  performs process recovery when a user process fails. PMON is responsible for cleaning up the database buffer cache and freeing resources that the user process was using. For example, it resets the status of the active transaction table, releases locks, and removes the process ID from the list of active processes.
PMON periodically checks the status of dispatcher and server processes, and restarts any that have stopped running (but not any that Oracle has terminated intentionally).   PMON also registers information about the instance and dispatcher processes with the network listener.
(PMON进程负责网络监听信息的注册)
Like SMON, PMON checks regularly to see whether it is needed and can be called if another process detects the need for it.
 
 
SQL> show parameter service
NAME                                  TYPE
------------------------------------ ----------------------
VALUE
------------------------------
service_names                         string
orcl.oracle.com
[oracle@test64 admin]$ sqlplus   scott/oracle@192.168.2.66:1521/orcl.oracle.com
 
 
[oracle@test64 admin]$   cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER  =                                             #静态注册
   (SID_LIST =
     (SID_DESC =
       (SID_NAME = PLSExtProc)
       (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
       (PROGRAM = extproc)
     )
     (SID_DESC =
       (GLOBAL_DBNAME = orcl.oracle.com)
       (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
       (SID_NAME = orcl)
     )
     (SID_DESC =
       (GLOBAL_DBNAME = ocp)
       (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
       (SID_NAME = ocp)
     )
   )
LISTENER  =                                                        #动态注册
   (DESCRIPTION_LIST =
     (DESCRIPTION =
       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
     )
     (DESCRIPTION =
       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.66)(PORT = 1521))
     )
   )
 
[oracle@test64 admin]$   lsnrctl status
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 01-MAR-2012 01:14:03
Copyright (c) 1991, 2005, Oracle.   All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                      LISTENER
Version                    TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                 01-MAR-2012 01:13:04
Uptime                     0 days 0 hr. 0 min. 58 sec
Trace Level                off
Security                   ON: Local OS Authentication
SNMP                       OFF
Listener Parameter File    /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File          /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.2.66)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
   Instance "PLSExtProc", status   UNKNOWN, has 1 handler(s) for this service...
Service "ocp" has 1 instance(s).
   Instance "ocp", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl.oracle.com" has 2 instance(s).
   Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
   Instance "orcl", status   READY, has 1 handler(s) for this service...
Service "orclXDB.oracle.com" has 1 instance(s).
   Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl_XPT.oracle.com" has 1 instance(s).
   Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
  UNKNOWN表示静态注册, READY表示动态注册
 
=================================================================================================
以下转于 http://blog.itpub.net/post/37743/511624未验证
 
由于动态注册需要pmon进程,所以监听必须在数据库启动之前启动,否则动态注册将失败;在数据库运行的过程中,如果重启监听也会造成动态注册失败
动态注册只是注册默认的监听器上(名称是listener、端口是1521、协议时TCP),如果需要向非默认的监听注册,则需要改变local_listener参数
将监听的信息添加到tnsnames.ora 文件中。 注意,是tnsnames.ora 文件, 因为pmon在动态注册监听时要从tnsnames.ora中读取相关信息。
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = DaveDai)(PORT = 1522))
)
然后以sys用戶运行:
SQL> alter system set local_listener=listener;
SQL> alter system register;
或者:
SQL> alter system set LOCAL_LISTENER='(ADDRESS = (PROTOCOL = TCP)(HOST = DaveDai)(PORT = 1522))';
SQL> alter system register;
动态注册的好处是简单方便,但是容易发生注册失败