记得之前Oracle原厂的工程师在例行检查时发现一台Oracle数据库服务器的上启动了两个监听,分别监听的是1521和1581端口,而且两个端口都在用,当时当作一个比较奇怪的现象,没有能理解原因是什么。最近几天在看Oracle网络配置的文档,无意间在虚拟机上启动了两个监听,就又想起了之前的问题。到底是因为什么原因呢?
下面先来还原一下整个过程。
当时是在做配置静态监听的练习,在listener.ora中配置了一个静态监听:
ORCL =
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.2)(PORT=1581))
SID_LIST_ORCL=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=orcl)
(ORACLE_HOME=/u02/app/oracle/product/11.2.4/db1)
(SID_NAME=orcl)))
启动正常:
[oracle@rhel6 admin]$ lsnrctl start orcl
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 03-JUN-2017 16:22:41
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u02/app/oracle/product/11.2.4/db1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora
Log messages written to /u02/app/oracle/diag/tnslsnr/rhel6/orcl/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.2)(PORT=1581)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.2)(PORT=1581)))
STATUS of the LISTENER
------------------------
Alias orcl
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 03-JUN-2017 16:22:41
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora
Listener Log File /u02/app/oracle/diag/tnslsnr/rhel6/orcl/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.2)(PORT=1581)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
远程测试连接成功
这时不小时敲了lsnrctl start命令,“神奇”的事情发生了,又一个监听起来了:
使用netstat -nltp查端口,两个端口都是被监听的状态:
那么现在问题就来了,为什么可以启动两个监听,而两个监听都可以用呢?而且我在listener.ora中并没有配置1521端口的监听,为什么可以启动1521的监听呢?
先来看第二个问题,为什么会启动对1521端口的监听,从官方文档中找到这样一名话: