listener之一二
一、注册
知道该数据库对外提供的服务名就可以申请连接到数据库。这个服务名可以与实例名一致,也可以不
一致,且可以注册多个服务。
注册可以分为静态注册与动态注册,下面分别介绍静态注册和动态注册。
二、静态注册
静态注册就是预先配置好listener.ora文件,配置信息如下:
#listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = orcl)##数据库的实例名
(ORACLE_HOME = /u01/app/oracle/product/10.2/db_1)##监听程序所在路径
(GLOBAL_DBNAME = test01)##数据库对外提供的服务名
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db01)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
当用户通过客户端申请连接数据库时,首先通过监听程序读取listener.ora中的配置信息(无论数据库
是否启动,用户的连接请求都会通过监听程序的检查,因为静态监听是无法识别数据库的启动状态的
,只有用户试图连接数据库时,数据库才会返回相关信息。)
下面我们来看下数据库处于打开和关闭状态时,服务test01的实例状态:
1、打开状态
[oracle@db01 admin]$ lsnrctl status LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 16-OCT-2013 06:58:27 Copyright (c) 1991, 2005, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db01)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR forLinux: Version 10.2.0.1.0 - Production Start Date 16-OCT-2013 06:39:09 Uptime 0 days 0 hr. 19 min. 18 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/10.2/db_1/network/admin/listener.ora Listener Log File /u01/app/oracle/product/10.2/db_1/network/log/listener.log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db01)(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 "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orcl_XPT" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "test01" has 1 instance(s). Instance "orcl", status UNKNOWN, has 1 handler(s) for this service... =>实例orcl的状态为unknown The command completed successfully 此时当用户通过客户端连接数据库时: SQL> conn system/hat@test01
已连接。
2、关闭状态:
[oracle@db01 admin]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 16-OCT-2013 06:54:44
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db01)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 16-OCT-2013 06:39:09
Uptime 0 days 0 hr. 15 min. 35 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/10.2/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/10.2/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db01)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...