col name for a20
col value for a200
select name ,value from gv$parameter a where a.NAME like '%listener%';
(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.6)(PORT=1521)),(ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.6)(PORT=1522))
prod1-scan:1521
(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.7)(PORT=1521)),(ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.7)(PORT=1522))
prod1-scan:1521
(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.5)(PORT=1521)),(ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.5)(PORT=1522))
prod1-scan:1521
(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.6)(PORT=1623)), (ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.6)(PORT=1522)), (ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.6)(PORT=1622))
nonprod2-scan:1623
(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.7)(PORT=1623)), (ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.7)(PORT=1522)), (ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.7)(PORT=1622))
nonprod2-scan:1623
----
However, if you are changing the default listener port number, the database instances will not be able to register themselves with this new listener as the database will contact the listener(s) on the default port 1521.
lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 01-AUG-2023 18:08:42
Copyright (c) 1991, 2023, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
netstat -ntpu|grep 1521
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
How do you change the default port 1521 to another port for a RAC configuration?
To get the current settings of your listener on RAC issue the following command:
> srvctl config listener
The output should be similar to the following
Name: LISTENER
Network: 1, Owner: oracle
Home:
End points: TCP:1521
Points to bear in mind:
+ The ILOM server is independent of the listener and will require no changes. (Exadata)
+ Cell Servers do not have Oracle Listeners on them and will also require no changes (Exadata)
+ At some point you have to restart the listener on each node. Depending on how your services are set up you may 'drive' traffic to one node if there are many connections. For this reason these changes should be done during a quiet time.
Steps to achieve the changes
(1) Amend the ports used with a command similar to the following
> srvctl modify listener -l LISTENER -p "TCP:
srvctl modify scan_listener -p "TCP:1623/TCPS:1522/TCPS:1622"
This changes the entry in OCR, so that a listener restart will pick up the new values. Existing connections will remain connected.
(2) Modify the scan listener if applicable with
> srvctl modify scan_listener -p
(3) LOCAL_LISTENER should be changed manually
An example would be
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=
(4) Make similar changes to the REMOTE_LISTENER
(5) endpoints_listener.ora and local_listener.ora for each SID are only changed after the listener is stopped and restarted.
(6) Check the configuration afterwards with "srvctl config Listener".
How do we change the default listener (TCP) port number ?
By default, after installing Oracle Database Server, the Listener service will wait for and accept connections on TCP port 1521. However, it is possible to reconfigure the listener to use a different port. The procedure comprises two steps: reconfiguring the listener and reconfiguring the database instance(s) to register to the listener on the new, non-default port.
You may not use ports numbered lower than 1024 as these require special user privileges. The maximum value is around 65500. Oracle does not recommend using a port in the ephemeral range for the listener. Please see your specific OS documentation for information regarding the ephemeral port range. Please consult Oracle's Installation Guide for your OS and RDBMS version as well.
Before changing the listener configuration you should stop it run the following command: "lsnrctl stop".
Launch Oracle Net Manager (execute "netmgr" at the command line) and follow these steps:
Restart the listener by running the following commands at the command prompt: "lsnrctl start".
However, after you changed the default listener port number, the database instances will not be able to register themselves with this new listener as the database will contact the listener(s) on the default port 1521. To fix this problem you need to add/change the "local_listener" initialization parameter for each database.
Use Oracle Enterprise Manager to change the "local_listener" initialization parameter to have the value "MYLISTENER" for the database(s) you work with or create in the future. Make sure you make this change permanent by storing it in the SPFile, in which case you need to restart the database instance to take effect.
Before changing the listener configuration you should stop it by running the following command: "lsnrctl stop".
The Oracle Listener is configured through the LISTENER.ORA file, which, by default is located in ORACLE_HOME under the NETWORK / ADMIN subdirectory. Edit this file with you preferred text editor and change the (PORT=1521) from under the default LISTENER profile to your desired value. If you do not have this file then you may use the following sample:
LISTENER = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) (ADDRESS = (PROTOCOL = TCP)(HOST = myhostname)(PORT = myport)) )
Please replace "myhostname" with your system hostname and "myport" with your desired port number. After changing the LISTENER.ORA file you need to restart the listener. To do that run the following commands at the command prompt: "lsnrctl start".
However, if you are changing the default listener port number, the database instances will not be able to register themselves with this new listener as the database will contact the listener(s) on the default port 1521.
To fix this problem you need to add/change the "local_listener" initialization parameter for each database. This can be achieved in two steps: creating a alias name for the new listener and adjusting the LOCAL_LISTENER initialization parameter.
In the TNSNAMES.ORA file (in the same location as LISTENER.ORA) add the following entry:
MYLISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myserver )(PORT = myport)) )
Please replace the "myhostname" and "myport" with the values used for listener configuration in LISTENER.ORA.
Now adjust the LOCAL_LISTENER parameter — use the following SQL statement as SYSDBA:
ALTER SYSTEM SET LOCAL_LISTENER='MYLISTENER' SCOPE=BOTH
--可以直接写(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.7)(PORT=1623)), (ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.7)(PORT=1522)), (ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.7)(PORT=1622)) 不用修改tnsnames.ora 防止文件被删了
Please take into consideration the effect of the SCOPE argument (as shown above it will also save the change in the spfile); also you may want to restrict the change to a certain instance with the help of the SID='
Please note that you may need to run this command for each Oracle database you have or which you will create on the server.
For the reference documentation see Oracle Database Net Services Administrator's Guide, Chapter "Configuring and Administering the Listener".
For RAC and/or SCAN please see:
Changing Listener Ports On RAC/EXADATA (Doc ID 1473035.1)