从Oracle8i版本开始,在oracle数据库当中,应用如果没有特殊需求的话,数据库监听不需要做出配置,oracle把这种方法称为动态注册。所谓动态注册,oracle通过PMON进程根据参数instance_name和service_names中的内容,把oracle数据库的信息注册到默认的1521端口的监听器上。不管服务器端有几个监听程序,oracle默认都是注册到1521端口的监听器,也就是说,对于其他端口的监听器来说,如果想要正常的识别远程客户端提供的信息,需要做出配置,也就是静态注册。在lsnrctl命令下,通过services命令可以观察到是静态注册还是动态注册。如果是静态注册的话,oracle显示的服务的状态是unknown,如果是动态注册的话,服务的状态显示是ready。不过,如果用户想要修改动态注册的端口,这也是可以实现的,可以通过设置数据库的local_listener参数来实现。
我们来看下面的一个例子,首先,在数据库默认情况下,local_listener参数为空,没有设置。
[oracle@ztj10 admin]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Apr 22 03:03:44 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> show parameter local_l
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
查看监听器注册的服务,READY表示动态注册。
[oracle@ztj10 admin]$ lsnrctl
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 22-APR-2012 03:04:03
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> services
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
Service "db01" has 1 instance(s).
Instance "db01", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
Service "db01XDB" has 1 instance(s).
Instance "db01", status READY, has 1 handler(s) for this service...
Handler(s):
"D000" established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER <machine: ztj10, pid: 21629>
(ADDRESS=(PROTOCOL=tcp)(HOST=ztj10)(PORT=46550))
Service "db01_XPT" has 1 instance(s).
Instance "db01", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
The command completed successfully
LSNRCTL> services listener1
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.100)(PORT=1530)))
Services Summary...
Service "dbtest" has 1 instance(s).
Instance "db01", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
The command completed successfully
LSNRCTL> exit
根据上面的信息我们可以看到,现在oracle动态注册到1521端口的监听器listener,而listener1是静态注册,监听器使用的端口是1530。接下来我们做出配置,让PMON进程动态注册到1530端口的监听器。
使用more命令,得到listener.ora文件里红色部分的内容
[oracle@ztj10 admin]$ more listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1530))
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0)
(PROGRAM = extproc)
)
)
SID_LIST_LISTENER1 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = dbtest)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0)
(SID_NAME = db01)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
本栏目更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/