Configure listener Oracle 19c

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:

  1. reconfiguring the listener.
  2. reconfiguring the database instance[s] to register to the listener on the new, non-default port.
Note: 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.

There are two ways to achieve this:

  1. Through the configuration tools
  2. by manually adjusting the appropriate configuration files.

The preferred way is to use the configuration tools.

Using Configuration Tools

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:

$ netmgr
  • Select Local / Listeners / LISTENER in the left pane.
  • Select Listening Locations in the right pane upper selection button.
  • Browse through the AddressX tabs and choose the one with Protocol TCP/IP.
  • Change the value in the Port: field to your desired port number.
  • In the left pane select Local / Service Naming.
  • Create a new Net Service Name:
    1. Click the green plus [+] icon on the leftmost toolbar; dialog will appear.
    2. Type a name for the new Service Name [e.g. MYLISTENER]; press Next.
    3. Select TCP/IP [Internet Protocol]; press Next.
    4. Type your hostname in Hostname: field and the same port number you chose in the previous steps in the Port Number: field; press Next
    5. Type the name of an existent database [e.g. ORCL]; press Next
    6. Optionally you may Test the new connection.
    7. Press Finish.
  • Select from menus File / Save Network Configuration and close the Net Manager

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.

Using Configuration Files

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:

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:

  1. creating a alias name for the new listener.
  2. 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:

SQL> ALTER SYSTEM SET LOCAL_LISTENER='MYLISTENER' SCOPE=BOTH;

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='[db_sid] argument if you employ a common spfile for many instances.

Note: You may need to run this command for each Oracle database you have or which you will create on the server.
How to change the SCAN IP address [SCAN VIP resources] in 11gR2 Grid [CRS] environment
Next Read: Oracle 12.2 : RMAN Cross-Platform Transport of PDB into Destination CDB »

Video liên quan

Chủ Đề