本文档讨论监听的动态注册和静态注册的问题
1.静态注册,由ORACLE PMON进程自动注册ORACLE 实例
查看$ORACLE_HOME/network/admin/listener.ora文件内容
oracle@RHEL5.4:/u01/app/oracle/products/10.2.0/db_1/network/admin>cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/products/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/products/10.2.0/db_1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = RHEL5.4)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
来看一个静态注册监听反馈出来的信息
SQL> select instance_name,status from v$Instance;
INSTANCE_NAME STATUS
---------------- ------------
macdb MOUNTED
oracle@RHEL5.4:/home/oracle>lsnrctl status
LSNRCTL for Linux: Version 10.2.0.3.0 - Production on 07-MAY-2013 21:10:46
Copyright (c) 1991, 2006, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=RHEL5.4)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.3.0 - Production
Start Date 07-MAY-2013 21:10:23
Uptime 0 days 0 hr. 0 min. 23 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/products/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/products/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=RHEL5.4)(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 "macdb" has 1 instance(s).
Instance "macdb", status READY, has 1 handler(s) for this service...
Service "macdb_XPT" has 1 instance(s).
Instance "macdb", status READY, has 1 handler(s) for this service...
The command completed successfully
Service的值默认为service_names的值
当关闭掉实例之后监听里面就没有任何实例的信息了
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> !lsnrctl status
LSNRCTL for Linux: Version 10.2.0.3.0 - Production on 07-MAY-2013 21:13:11
Copyright (c) 1991, 2006, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=RHEL5.4)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.3.0 - Production
Start Date 07-MAY-2013 21:10:23
Uptime 0 days 0 hr. 2 min. 48 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/products/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/products/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=RHEL5.4)(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...
The command completed successfully
需要注意的是ORACLE PMON只能动态注册1521端口的监听,如果你用其他的端口,PMON不能完成静态注册。
修改监听的端口号为1531,则PMON不能自动注册
oracle@RHEL5.4:/u01/app/oracle/products/10.2.0/db_1/network/admin>cat listener.ora
#listener.ora Network Configuration File: /u01/app/oracle/products/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/products/10.2.0/db_1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = RHEL5.4)(PORT = 1531))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
启动监听查看状态
oracle@RHEL5.4:/u01/app/oracle/products/10.2.0/db_1/network/admin>lsnrctl status
LSNRCTL for Linux: Version 10.2.0.3.0 - Production on 07-MAY-2013 21:37:36
Copyright (c) 1991, 2006, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=RHEL5.4)(PORT=1531)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.3.0 - Production
Start Date 07-MAY-2013 21:28:25
Uptime 0 days 0 hr. 9 min. 11 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/products/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/products/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=RHEL5.4)(PORT=1531)))
(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...
The command completed successfully
这个时候需要对参数LOCAL_LISTENER做一些设置
我们先来看看这个参数官方是怎么说的
LOCAL_LISTENER specifies a network name that resolves to an address or address list
of Oracle Net local listeners (that is, listeners that are running on the same machine as
this instance). The address or address list is specified in the TNSNAMES.ORA file or
other address repository as configured for your system.
说的比较清楚了,这个参数是用来指定一个网络的名称这个名称必须在TNSNAME.ORA文件中存在。
oracle@RHEL5.4:/u01/app/oracle/products/10.2.0/db_1/network/admin>cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/products/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
MACDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = RHEL5.4)(PORT = 1531))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = macdb)
)
)
设置LOCAL_LISTENER参数
SQL> show parameter local_listener
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string
SQL> alter system set local_listener='macdb' scope=both;
System altered.
SQL> show parameter local_listener
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string macdb
查看监听状态
oracle@RHEL5.4:/u01/app/oracle/products/10.2.0/db_1/network/admin>lsnrctl status
LSNRCTL for Linux: Version 10.2.0.3.0 - Production on 07-MAY-2013 21:47:36
Copyright (c) 1991, 2006, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=RHEL5.4)(PORT=1531)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.3.0 - Production
Start Date 07-MAY-2013 21:28:25
Uptime 0 days 0 hr. 19 min. 11 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/products/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/products/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=RHEL5.4)(PORT=1531)))
(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 "macdb" has 1 instance(s).
Instance "macdb", status READY, has 1 handler(s) for this service...
Service "macdbXDB" has 1 instance(s).
Instance "macdb", status READY, has 1 handler(s) for this service...
Service "macdb_XPT" has 1 instance(s).
Instance "macdb", status READY, has 1 handler(s) for this service...
The command completed successfully
还原LOCAL_LISTENER参数
SQL> ALTER SYSTEM RESET LOCAL_LISTENER SCOPE=SPFILE SID='*';
System altered.
SQL> show parameter local_listener
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string macdb
oracle@RHEL5.4:/u01/app/oracle/products/10.2.0/db_1/network/admin>lsnrctl status
LSNRCTL for Linux: Version 10.2.0.3.0 - Production on 07-MAY-2013 21:55:18
Copyright (c) 1991, 2006, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=RHEL5.4)(PORT=1531)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.3.0 - Production
Start Date 07-MAY-2013 21:28:25
Uptime 0 days 0 hr. 26 min. 53 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/products/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/products/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=RHEL5.4)(PORT=1531)))
(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 "macdb" has 1 instance(s).
Instance "macdb", status READY, has 1 handler(s) for this service...
Service "macdbXDB" has 1 instance(s).
Instance "macdb", status READY, has 1 handler(s) for this service...
Service "macdb_XPT" has 1 instance(s).
Instance "macdb", status READY, has 1 handler(s) for this service...
The command completed successfully
注册的监听并没有被收回,重启监听失效
2.动态注册
查看监听文件发现有些不一样的地方
oracle@RHEL5.4:/u01/app/oracle/products/10.2.0/db_1/network/admin>cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/products/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/products/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = macdb)
(ORACLE_HOME = /u01/app/oracle/products/10.2.0/db_1)
(SID_NAME = macdb)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = RHEL5.4)(PORT = 1531))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
当实例没有启动的时候监听里面也能看到相关注册实例的信息
oracle@RHEL5.4:/u01/app/oracle/products/10.2.0/db_1/network/admin>ps -ef | grep oracle
oracle 2747 1 0 21:08 ? 00:00:02 /u01/app/oracle/products/10.2.0/db_1/bin/ocssd.bin
root 3158 3124 0 21:10 pts/1 00:00:00 su - oracle
oracle 3159 3158 0 21:10 pts/1 00:00:00 -bash
oracle 3547 1 0 22:08 ? 00:00:00 /u01/app/oracle/products/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
oracle 3552 3159 0 22:08 pts/1 00:00:00 ps -ef
oracle 3553 3159 0 22:08 pts/1 00:00:00 grep oracle
oracle@RHEL5.4:/u01/app/oracle/products/10.2.0/db_1/network/admin>lsnrctl status
LSNRCTL for Linux: Version 10.2.0.3.0 - Production on 07-MAY-2013 22:09:05
Copyright (c) 1991, 2006, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=RHEL5.4)(PORT=1531)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.3.0 - Production
Start Date 07-MAY-2013 22:08:05
Uptime 0 days 0 hr. 0 min. 59 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/products/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/products/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=RHEL5.4)(PORT=1531)))
(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 "macdb" has 1 instance(s).
Instance "macdb", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26169542/viewspace-765911/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26169542/viewspace-765911/