Oracle静态监听和动态监听
一、静态注册
静态注册指实例启动时读取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来进行客户端的连接。
摘自:http://space.itpub.net/14284241/viewspace-462978
another:
一、静态注册
静态注册指实例启动时读取listener.ora配置文件,将实例和服务注册到监听程序。无论何时启动一个数据库,默认都有两条信息注册到监听器中:实例和服务。
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = rman)
(ORACLE_HOME =
/u01/oracle
)
(SID_NAME = rman)
)
(SID_DESC =
(GLOBAL_DBNAME = xienfei)
(ORACLE_HOME =
/u01/oracle
)
(SID_NAME = xff)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
)
|
说明:
1)(ORACLE_HOME = /u01/oracle) oracle_home目录,测试不加也行
2)本静态监听两个数据库实例,每个实例的静态监听写到SID_DESC中
3)在数据库未open状态中,就可以远程连接到数据库,对数据库进行操作
4)使用静态监听时,客户端的tns最好配置为SERVICE_NAME,当然也可以同时配置SID和SERVICE_NAME,等数据库启动后,tns中无论是sid还是SERVICE_NAME均能访问数据库
二、动态注册
动态注册不需要显示的配置listener.ora文件,实例启动的时候,PMON进程根据instance_name,service_name参数将实例和服务动态注册到listerer中。如果没有设定instance_name,将使用db_name初始化参数值。如果没有设定service_names,将拼接db_name和db_domain参数值来注册监听。
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME =
/u01/oracle
)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
|
说明:
1)不需要人工干预在lsnrctl start后,会自动注册数据库的instance_name,service_name,然后tns不论使用SID和SERVICE_NAME均可以连接上来
2)修改了SERVICE_NAME或者SID不用修改listener.ora文件
posted @ 2013-10-26 16:49 newmanzhang 阅读(3) 评论(0) 编辑