Listener

How to Add a Cluster Listener on Second Network to Grid

I assume that you have added the second network to the grid infrastructure. Let’s continue our work.

Make sure the second network is available in the grid infrastructure.
[grid@primary01 admin]$ srvctl config network -k 2
Network 2 exists
Subnet IPv4: 10.0.8.0/255.255.255.0/eth2, static
Subnet IPv6:
Ping Targets:
Network is enabled
Network is individually enabled on nodes:
Network is individually disabled on nodes:

Check the configuration of current listener.
[grid@primary01 admin]$ 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:

The default listener is LISTENER. Therefore, we called the new listener LISTENER2. In RAC, listener resource object is the endpoint listener. You may also call it local listener.
[grid@primary01 ~]$ srvctl add listener -l listener2 -k 2 -p 1521 -s
[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: 2, Owner: grid
Home: <CRS home>
End points: TCP:1521
Listener is enabled.
Listener is individually enabled on nodes:
Listener is individually disabled on nodes:

The new listener is added, but not running. Let’s start it.
[grid@primary01 ~]$ srvctl status listener -l listener2
Listener LISTENER2 is enabled
Listener LISTENER2 is not running
[grid@primary01 ~]$ srvctl start listener -l listener2
[grid@primary01 ~]$ srvctl status listener -l listener2
Listener LISTENER2 is enabled
Listener LISTENER2 is running on node(s): primary01,primary02

Now, we should add a scan_listener resource object on port 1521 of network 2, and it should redirect connections to the local listener LISTENER2. By the way, scan_listener is the remote listener for databases.
[grid@primary01 ~]$ srvctl add scan_listener -k 2 -l listener2 -p 1521 -s
[grid@primary01 ~]# srvctl status scan_listener -k 2
SCAN Listener LISTENER2_SCAN1_NET2 is enabled
SCAN listener LISTENER2_SCAN1_NET2 is not running
SCAN Listener LISTENER2_SCAN2_NET2 is enabled
SCAN listener LISTENER2_SCAN2_NET2 is not running
SCAN Listener LISTENER2_SCAN3_NET2 is enabled
SCAN listener LISTENER2_SCAN3_NET2 is not running
SCAN Listener LISTENER2_SCAN4_NET2 is enabled
SCAN listener LISTENER2_SCAN4_NET2 is not running

Start the new scan_listener.
[grid@primary01 ~]# srvctl start scan_listener -k 2
[grid@primary01 ~]$ srvctl status scan_listener -k 2
SCAN Listener LISTENER2_SCAN1_NET2 is enabled
SCAN listener LISTENER2_SCAN1_NET2 is running on node primary01
SCAN Listener LISTENER2_SCAN2_NET2 is enabled
SCAN listener LISTENER2_SCAN2_NET2 is running on node primary02
SCAN Listener LISTENER2_SCAN3_NET2 is enabled
SCAN listener LISTENER2_SCAN3_NET2 is running on node primary01
SCAN Listener LISTENER2_SCAN4_NET2 is enabled
SCAN listener LISTENER2_SCAN4_NET2 is running on node primary02

Check the processes to see what listeners are located in this node.
[grid@primary01 ~]$ ps -ef | grep lsnr
...
grid     36857     1  0 14:50 ?        00:00:00 /u01/app/12.1.0/grid/bin/tnslsnr LISTENER2 -no_crs_notify -inherit
grid     40045     1  0 15:00 ?        00:00:00 /u01/app/12.1.0/grid/bin/tnslsnr LISTENER2_SCAN1_NET2 -no_crs_notify -inherit
grid     40130     1  0 15:00 ?        00:00:00 /u01/app/12.1.0/grid/bin/tnslsnr LISTENER2_SCAN3_NET2 -no_crs_notify -inherit
grid     41313     1  0 11:28 ?        00:00:00 /u01/app/12.1.0/grid/bin/tnslsnr LISTENER -no_crs_notify -inherit
grid     41716     1  0 11:29 ?        00:00:01 /u01/app/12.1.0/grid/bin/tnslsnr LISTENER_SCAN2 -no_crs_notify -inherit
grid     41739     1  0 11:29 ?        00:00:01 /u01/app/12.1.0/grid/bin/tnslsnr LISTENER_SCAN3 -no_crs_notify -inherit
...

As we can see, two local listeners and four scan listeners (two for each network) are running on this node.

Let’s see the listener configuration of database.
SQL> show parameter listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
listener_networks                    string      (( NAME=net2)(LOCAL_LISTENER=(
                                                 DESCRIPTION=(ADDRESS=(PROTOCOL
                                                 =TCP)(HOST=10.0.8.111)(PO
                                                 RT=1521))))), ((NAME=net2)(REM
                                                 OTE_LISTENER=primary-cluster-s
                                                 can2:1521))
local_listener                       string       (ADDRESS=(PROTOCOL=TCP)(HOST=
                                                 192.168.15.111)(PORT=1521))
remote_listener                      string       primary-cluster-scan:1521

What? I have never set listener_networks before, I just do a restart on the database.

Don’t you ever forget LREG background process. It automatically added the second network to the databases which have registered with grid. You may check the plain text of parameter initialization file to find out more, there’s no listener_networks.
SQL> create pfile='?/dbs/initprimdb1.ora.20160102' from spfile;

File created.

Now, it’s your turn to modify clients’ tnsnames.ora to test the connections.

Leave a Reply

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