监听配置概览
一个监听配置一个或多个监听协议地址,信息包含支持的服务,控制它运行时的参数,监听的配置保持在listener.ora文件中。因为监听的参数都有默认值,所有你可以不用配置就启动和使用监听,默认的监听名字叫listener,启动时不支持服务,在下面的协议地址上监听
(ADDRESS=(PROTOCOL=tcp)(HOST=host_name)(PORT=1521))
支持的服务,也就是监听转发客户请求的服务,可以配置在listener.ora中,或者这个信息可以动态注册。这个动态注册叫做服务注册。注册的动作时pmon进程来操作的。动态注册不需要listener.ora文件的任何配置。服务注册提供下面的好处:
1简化配置
2连接时故障转移
因为监听总是知道实例的状态,服务注册有助于自动故障转移,在一个实例当掉下将客户端连接请求道别的实例上。
在静态配置模型中,监听会在接受到客户端请求的时候启动专用server,server发现实例不启动的时候,会发出 "Oracle not available
"的信息。
3运行时连接负载均衡
服务注册能让监听发送客户连接请求道最小负载的实例上,服务注册在service 处理器和节点中均衡负载。
在安装过程中的监听配置
netca自动配置一个叫listener的监听,另外,一个为了外部存储过程的ipc协议地址也自动被配置。netca也自动为外部存储过程配置服务信息。
下面的例子,listener条目定义了监听的协议地址,sid_lis_listener条目定义了监听静态支持的服务信息
LISTENER=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))))
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=plsextproc)
(ORACLE_HOME=/oracle10g)
(PROGRAM=extproc)))
如果你使用了ipc协议,你以通过指定最大的并发ipc连接来提高性能,例如
listener_name=(description=(address=(protocol=ipc)(key=listener0)(queuesize=50)))
处理大量的并发连接请求
如果你想监听器处理大量的并发连接请求,你可以为tcp/ip或ipc指定一个监听器队列。为了指定队列大小,要制定queuesize参数,如下
LISTENER=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521)(QUEUESIZE=20)))
下面是不同平台的默认值
Solaris Operating System: 5
Windows NT 4.0 Workstation: 5
Windows NT 4.0 Server: 50
配置静态信息
在listener.ora中的静态服务设置
Oracle Net Manager Field | listener.ora File Parameter | Description |
---|---|---|
SID |
|
Specifies the Oracle System Identifier (SID) of the instance. You can obtain the SID value from the |
Service Name |
|
Identifies the database service. Can the following paragraph be removed? It seems to be relevant only to Oracle8 While processing a client connection request, the listener tries to match the value of this parameter with the value of the The value for this parameter is typically obtained from the combination of the |
Oracle Home Directory |
|
On UNIX, this setting is optional. Use it to specify the Oracle home location of the instance. Without this setting, the listener assumes its Oracle home for the instance. On Windows, this setting is ignored. The Oracle home specified by the |
下面是一个静态配置 数据库服务的例子
listener.ora
file statically configured for a database service calledsales.us.acme.com
:SID_LIST_listener= (SID_LIST= (SID_DESC= (GLOBAL_DBNAME=sales.us.acme.com) (SID_NAME=sales) (ORACLE_HOME=/u01/app/oracle/10g)))
INSTANCE_NAME
for the instance name
使用默认的,本地监听注册服务
默认的,pmon进程使用本地监听,子默认的本地地址上注册服务信息。只要监听配置和数据库配置同步,pmon可以使用非默认本地监听或远程监听注册服务。
用非默认监听注册
如果想要用pmon来注册本地监听,不适用tcp/ip,1521端口,在参数文件中配置local_listener参数来定位本地监听。
Set the LOCAL_LISTENER
parameter as follows:
local_listener=listener_alias
listener_alias通过命名方法来解析监听协议地址。
用远程监听来注册信息
注册到远程监听,像是使用rac。需要配置remote_listener参数来定位远程监听,例如,如果监听配置在sales1-server和sales2-server的机器上,你可以设置remote_listener参数在sales1-server上如下:
REMOTE_LISTENER=listener_sales2
在sales1-sever上的tnsnames.ora文件中解析listener_sales2
listener_sales2=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=sales2-server)(PORT=1521)))
监听的启动停止
lsnrctl STOP [listener_name]
lsnrctlSTART [listener_name]
lsnrctl STATUS [listener_name]
关闭监听的日志
1 参数 lsnrctl>set log_status off
2 在listener.ora文件中增加“LOGGING_LISTENER=OFF”
监控监听的服务
使用service命令
Example 10-4 Listener Control Utility's SERVICES Command Output
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=net))) Services Summary... Service "sales.us.acme.com" has 1 instance(s). Instance "sales", status READY, has 3 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER "D000" established:0 refused:0 current:0 max:10000 state:ready DISPATCHER <machine: sales-server, pid: 1689> (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=52414)) "D001" established:0 refused:0 current:0 max:10000 state:ready DISPATCHER <machine: sales-server, pid: 1691> (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=52415)) Service "hr.us.acme.com" has 1 instance(s). Instance "hr", status READY, has 2 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER "D000" established:0 refused:0 current:0 max:10000 state:ready DISPATCHER <machine: sales-server, pid: 11326> (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=58361)) The command completed successfully
This output shows that two database services, sales.us.acme.com
andhr.us.acme.com
, are registered with the listener.
Client connection requests to sales.us.acme.com
are handled by two dispatchers namedD000
and D001
and one dedicated server. All handlers have a status ofready
, indicating that they are ready to receive connections.
Client connection requests to hr.us.acme.com
are handled by one dispatcher namedD001
and one dedicated server.