I remember that engineers at Oracle's original factory found that two monitors were started on an Oracle database server during routine checks. They monitored ports 1521 and 1581 respectively, and both ports were in use. At that time, it was regarded as a strange phenomenon that they could not understand why. In recent days, after reading the Oracle network configuration documentation, I inadvertently started two listeners on the virtual machine, which reminded me of the previous problem. What is the reason?
Now let's restore the whole process.
At that time, I was doing the exercise of configuring static listening, and configuring a static listening in 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)))
Start normal:
[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
Successful remote test connection
At that time, I knocked the lsnrctl start command from time to time, and the "magic" thing happened. Another monitor sounded like:
Using netstat-nltp to look up ports, both ports are monitored:
Now the remote test connection can be successfully connected.
So now the question arises. Why can we start two listeners and both can be used? And I don't configure 1521 listening in listener.ora. Why can I start 1521 listening?
First, let's look at the second question. Why did you start listening on port 1521 and find such a statement from the official documents?
Because all of the configuration parameters have default values, it is possible to start
and use a listener with no configuration. This default listener has a name of LISTENER,
supports no services on startup, and listens on the following TCP/IP protocol address:
(ADDRESS=(PROTOCOL=tcp)(HOST=host_name)(PORT=1521))
This sentence can explain why listening on port 1521 is started. I also experimented with starting a listener called LISTENER to listen on port 1521 even in the absence of a listener.ora file.
Explain what the monitor sounds like. Let's look at the first question again. Why can both monitor be used?
First, learn about dynamic and static listening:
Dynamic listening is when the database is started, the PMON process registers service information to the local port, and by default registers to the 1521 port of the local address. However, the monitoring of port 1521 which was started earlier conforms to the default registration mode, so it can be registered successfully directly, and the database can also provide services to the outside world.
The purpose of static monitoring configuration is to replace the registration of PMON process and directly bind the service of database to the monitoring. Even if the database is not started, the service name of the database will be displayed in the monitoring.
Before understanding these, it is not difficult to understand why two listening ports can be used at the same time: the database is silently registered on the 1521 port of monitoring, while static listening forces the database to be bound to the 1581 port, so both listening ports are accessible.
So the reason for this is that when configuring static listening, the default port 1581 is used instead of the default port 1521, and the default listening is started. If 1521 port is used for static listening, this will not happen.
How can this be avoided when using non-default listening ports? You can configure the local_listener parameter in the database, referring in detail to the previous blog: http://hbxztc.blog.51cto.com/1587495/1890055
Official documents: http://docs.oracle.com/cd/E11882_01/network.112/e41945/listenercfg.htm#NETAG292