Skip to content
Home » Oracle Database » How Srvctl Add Listener to Default Network

How Srvctl Add Listener to Default Network

Cluster listeners have a very special feature that can generate endpoint listeners dynamically on all nodes, one for each, to establish the connections either from the public or virtual IP of its node.

If you planned to add a cluster listener in the same network, you have to choose a different port to listen to. In this case, we picked port 1522.

Let's see current configuration of all cluster listeners. There's only one default cluster listener LISTENER.

[grid@primary01 ~]$ srvctl config listener
Name: LISTENER
Type: Database Listener
Network: 1, Owner: grid
Home: <CRS home>
End points: TCP:1521
Listener is enabled.
Listener is individually enabled on nodes:
Listener is individually disabled on nodes:

srvctl add listener

Then, we added a cluster listener named LISTENER2 on port 1522 with current network.

[grid@primary01 ~]$ srvctl add listener -l listener2 -p 1522 -k 1

I added -k 1 to indicate that we want this listener to work in network 1 which is the default cluster network. Of course, you can skip the option.

srvctl config listener

Check all listeners' configuration again.

[grid@primary01 ~]$ srvctl config listener
Name: LISTENER
Type: Database Listener
Network: 1, Owner: grid
Home: <CRS home>
End points: TCP:1521
Listener is enabled.
Listener is individually enabled on nodes:
Listener is individually disabled on nodes:
Name: LISTENER2
Type: Database Listener
Network: 1, Owner: grid
Home: <CRS home>
End points: TCP:1522
Listener is enabled.
Listener is individually enabled on nodes:
Listener is individually disabled on nodes:

srvctl status listener

To check whether the listener is running or not, we should see its status.

[grid@primary01 ~]$ srvctl status listener -l listener2
Listener LISTENER2 is enabled
Listener LISTENER2 is not running

We should start the newly added listener.

srvctl start listener

Startup the new listener. If it was planned to run on node 1 only, we can specify the node at startup.

[grid@primary01 ~]$ srvctl start listener -l listener2 -n primary01
[grid@primary01 ~]$ srvctl status listener -l listener2
Listener LISTENER2 is enabled
Listener LISTENER2 is running on node(s): primary01

Since we specify the node option in the command, so LISTENER2 was started only at node 1. If you want it to be started at all nodes, don't specify the node option.

Next, we should take care about the initialization parameters related to listener.

Alter System Set LOCAL_LISTENER

Normally, you don't have to set listener parameters, neither LOCAL_LISTENER nor REMOTE_LISTENER and you should keep them null. This is because the background process LREG will register services with the default local and remote listener automatically. Once you changed the subnet of cluster network, you don't have to worry about the settings of databases.

But with a different port 1522 which is not the default one, you should set LOCAL_LISTENER for this node to point to the new addresses with specifying SID.

SQL> alter system set local_listener='(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=primary01)(PORT=1522))(ADDRESS=(PROTOCOL=TCP)(HOST=primary01-vip)(PORT=1522)))' sid='primdb1' scope=both;

System altered.

If you want the database to register services on all nodes, you should specify SID='*'.

SQL> show parameter local_listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      (ADDRESS_LIST=(ADDRESS=(PROTOC
                                                 OL=TCP)(HOST=primary01)(PORT=1
                                                 522))(ADDRESS=(PROTOCOL=TCP)(H
                                                 OST=primary01-vip)(PORT=1522))
                                                 )

Let's see what services registered with this listener.

[grid@primary01 ~]$ lsnrctl status listener2

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on X

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER2)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER2
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                X
Uptime                    0 days 0 hr. 0 min. 9 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/12.1.0/grid/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/primary01/listener2/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER2)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.0.0.11)(PORT=1522)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.0.0.111)(PORT=1522)))
Services Summary...
Service "-MGMTDBXDB" has 1 instance(s).
  Instance "-MGMTDB", status READY, has 1 handler(s) for this service...
Service "_mgmtdb" has 1 instance(s).
  Instance "-MGMTDB", status READY, has 1 handler(s) for this service...
Service "compdb.example.com" has 1 instance(s).
  Instance "primdb1", status READY, has 1 handler(s) for this service...

Service "primary_cluster" has 1 instance(s).
  Instance "-MGMTDB", status READY, has 1 handler(s) for this service...
Service "primdbXDB.example.com" has 1 instance(s).
  Instance "primdb1", status READY, has 1 handler(s) for this service...
The command completed successfully

Good, the instance is registered with the new listener now.

4 thoughts on “How Srvctl Add Listener to Default Network”

  1. Very nice article. If I could suggest one change in the article, that would be to configure the Oracle listener on all nodes. Starting and managing the Oracle listener on only one node in the RAC would be a special case. In nearly all cases, you want to access the new port available from all nodes, not just primary01 as shown in your example. Why I mention this is because it would change how you modify the local_listener and remote_listener instance parameters. This makes the article somewhat incomplete. Additionally, wouldn’t you have to modify the remote_listener instance parameter?

    SQL> show parameter _listener

    NAME TYPE VALUE
    ———————————— ———– ——————————
    local_listener string (ADDRESS=(PROTOCOL=TCP)(HOST=1
    92.168.1.251)(PORT=1521)), (AD
    DRESS=(PROTOCOL=TCPS)(HOST=192
    .168.1.251)(PORT=2484))
    remote_listener string racnode:1521

    I do appreciate the work you put into providing this article. ~jeff

  2. i have added listener using srvctl add listener –, but this newly created listener entry is not added in listener.ora file, caused not allow me to start my listener. says listener entry not found in listener.ora file.

Leave a Reply

Your email address will not be published. Required fields are marked *