domingo, 22 de marzo de 2020

How to Create a Second SCAN in Oracle RAC

In this article I will show how to create a Second SCAN that can be used for a dedicated and isolated purpose.

The initial configuration in the RAC that I  am using for this example is the following:

[root@rac1 ~]# srvctl config network
Network 1 exists
Subnet IPv4: 192.168.1.0/255.255.255.0/, static
Subnet IPv6:
Ping Targets:
Network is enabled
Network is individually enabled on nodes:
Network is individually disabled on nodes:
[root@rac1 ~]#

[root@rac1 ~]# srvctl config scan -all
SCAN name: rac-scan, Network: 1
Subnet IPv4: 192.168.1.0/255.255.255.0/, static
Subnet IPv6:
SCAN 1 IPv4 VIP: 192.168.1.15
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes:
SCAN VIP is individually disabled on nodes:
[root@rac1 ~]#

[root@rac1 ~]# srvctl config scan_listener -all
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
Registration invited nodes:
Registration invited subnets:
SCAN Listener is enabled.
SCAN Listener is individually enabled on nodes:
SCAN Listener is individually disabled on nodes:
[root@rac1 ~]#

[root@rac1 ~]# srvctl config listener -all
Name: LISTENER
Type: Database Listener
Network: 1, Owner: oracle
Home: <CRS home>
  /u01/app/12.2.0.1/grid on node(s) rac2,rac1
End points: TCP:1521
Listener is enabled.
Listener is individually enabled on nodes:
Listener is individually disabled on nodes:
[root@rac1 ~]#

For this example, I am using /etc/hosts for all IPs, but you can adapt it to use DNS. The /etc/hosts has already the IPs for the Second SCAN:

[root@rac1 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.16 rac2
192.168.1.14 rac2-vip
192.178.2.15 rac2-priv
192.168.1.15 rac-scan
192.178.5.35 rac-scan2
192.178.5.36 rac-scan2

192.168.1.17 rac1
192.168.1.19 rac1-vip
192.178.2.18 rac1-priv


The first step is to create a new network:

[root@rac1 ~]# srvctl add network -netnum 2 -subnet 192.178.0.0/255.255.0.0
[root@rac1 ~]#  srvctl config network
Network 1 exists
Subnet IPv4: 192.168.1.0/255.255.255.0/, static
Subnet IPv6:
Ping Targets:
Network is enabled
Network is individually enabled on nodes:
Network is individually disabled on nodes:
Network 2 exists
Subnet IPv4: 192.178.0.0/255.255.0.0/, static
Subnet IPv6:
Ping Targets:
Network is enabled
Network is individually enabled on nodes:
Network is individually disabled on nodes:
[root@rac1 ~]#

Adding a second SCAN:

[root@rac1 ~]#  srvctl add scan -scanname rac-scan2 -netnum 2
[root@rac1 ~]# srvctl config scan -all
SCAN name: rac-scan, Network: 1
Subnet IPv4: 192.168.1.0/255.255.255.0/, static
Subnet IPv6:
SCAN 1 IPv4 VIP: 192.168.1.15
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes:
SCAN VIP is individually disabled on nodes:
SCAN name: rac-scan2, Network: 2
Subnet IPv4: 192.178.0.0/255.255.0.0/, static
Subnet IPv6:
SCAN 1 IPv4 VIP: 192.178.5.35
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes:
SCAN VIP is individually disabled on nodes:
SCAN 2 IPv4 VIP: 192.178.5.36
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes:
SCAN VIP is individually disabled on nodes:
[root@rac1 ~]#

Adding scan_listener:

[root@rac1 ~]# srvctl add scan_listener -listener LISTENER2 -netnum 2 -endpoints TCP:1522
[root@rac1 ~]# srvctl config scan_listener -all
SCAN Listener LISTENER2_SCAN1_NET2 exists. Port: TCP:1522
Registration invited nodes:
Registration invited subnets:
SCAN Listener is enabled.
SCAN Listener is individually enabled on nodes:
SCAN Listener is individually disabled on nodes:
SCAN Listener LISTENER2_SCAN2_NET2 exists. Port: TCP:1522
Registration invited nodes:
Registration invited subnets:
SCAN Listener is enabled.
SCAN Listener is individually enabled on nodes:
SCAN Listener is individually disabled on nodes:
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
Registration invited nodes:
Registration invited subnets:
SCAN Listener is enabled.
SCAN Listener is individually enabled on nodes:
SCAN Listener is individually disabled on nodes:
[root@rac1 ~]#

Starting the scan_listener:

[root@rac1 ~]# srvctl start scan -netnum 2
[root@rac1 ~]# srvctl start scan_listener -netnum 2
[root@rac1 ~]# srvctl status scan -all
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node rac1
SCAN VIP scan1_net2 is enabled
SCAN VIP scan1_net2 is running on node rac2
SCAN VIP scan2_net2 is enabled
SCAN VIP scan2_net2 is running on node rac1
[root@rac1 ~]#
[root@rac1 ~]# srvctl status scan_listener -all
SCAN Listener LISTENER2_SCAN1_NET2 is enabled
SCAN listener LISTENER2_SCAN1_NET2 is running on node rac1
SCAN Listener LISTENER2_SCAN2_NET2 is enabled
SCAN listener LISTENER2_SCAN2_NET2 is running on node rac1
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node rac2
[root@rac1 ~]#

The second SCAN was created. Now I will create a new Local Listener, so that the database can balance the connections between the network 1 (scan 1) and the network 2 (scan 2) across the two instances of the RAC. To do so we have to create two more VIPs, one per node and then the new listener will be created:


[root@rac1 ~]#  srvctl add vip -node rac1 -address 192.178.5.38/255.255.0.0 -netnum 2
[root@rac1 ~]# srvctl add vip -node rac2 -address 192.178.5.39/255.255.0.0 -netnum 2
[root@rac1 ~]# srvctl add listener -listener LISTENER2 -netnum 2 -user oracle -endpoints TCP:1522
[root@rac1 ~]# srvctl start listener  -listener LISTENER2

[root@rac1 ~]# srvctl start listener  -listener LISTENER2
[root@rac1 ~]#


[root@rac1 ~]# srvctl config listener -all
Name: LISTENER
Type: Database Listener
Network: 1, Owner: oracle
Home: <CRS home>
  /u01/app/12.2.0.1/grid on node(s) rac2,rac1
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: oracle
Home: <CRS home>
  /u01/app/12.2.0.1/grid on node(s) rac2,rac1
End points: TCP:1522
Listener is enabled.
Listener is individually enabled on nodes:
Listener is individually disabled on nodes:

[root@rac1 ~]# srvctl status listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): rac1,rac2
Listener LISTENER2 is enabled
Listener LISTENER2 is running on node(s): rac1,rac2
[root@rac1 ~]#


Finally the database instance have to be configured to listener the connections in SCAN1 and SCAN2 and redirect the connections to the proper local listener:

ALTER SYSTEM SET local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=rac1-vip)(PORT=1521))' SCOPE=BOTH SID='orcl1';

ALTER SYSTEM SET local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=rac2-vip)(PORT=1521))' SCOPE=BOTH SID='orcl2';

ALTER SYSTEM SET remote_listener='rac-scan:1521' SCOPE=BOTH SID='*';
ALTER SYSTEM SET listener_networks='((NAME=network1)(LOCAL_LISTENER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.19)(PORT=1521))))(REMOTE_LISTENER=rac-scan:1521)), ((NAME=network2)(LOCAL_LISTENER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.178.5.38)(PORT=1522))))(REMOTE_LISTENER=rac-scan2:1522))' SCOPE=scope SID='orcl1';

ALTER SYSTEM SET listener_networks='((NAME=network1)(LOCAL_LISTENER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.14)(PORT=1521))))(REMOTE_LISTENER=rac-scan:1521))','((NAME=network2)(LOCAL_LISTENER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.178.5.39)(PORT=1522))))(REMOTE_LISTENER=rac-scan2:1522))' SCOPE=scope SID='orcl2';

If you receive an error saying that the string is too long, you can create entries in the tnsnames.ora file  in the ORACLE_HOME of the database:

In server 1:

LISTENER_SCAN1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = node1-net1-vip)(PORT = 1521))
    )

LISTENER_SCAN2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = node1-net2-vip)(PORT = 1522))
    )

In server 2:

LISTENER_SCAN1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = node2-net1-vip)(PORT = 1521))
    )

LISTENER_SCAN2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = node2-net2-vip)(PORT = 1522))
    )

And then:

ALTER SYSTEM SET local_listener='LISTENER_SCAN1' SCOPE=BOTH SID='*';

ALTER SYSTEM SET remote_listener='rac-scan:1521' SCOPE=BOTH SID='*';

ALTER SYSTEM SET listener_networks='((NAME=network1)(LOCAL_LISTENER=LISTENER_SCAN1)(REMOTE_LISTENER=rac-scan:1521))',' ((NAME=network2)(LOCAL_LISTENER=LISTENER_SCAN2)(REMOTE_LISTENER=rac-scan2:1522))' SCOPE=scope SID='orcl1';

Finally Let's test the configuration.

I will create some sessions using the SCAN1, all the session should be balanced across the two instances and redirected to the proper local listener (LISTENER for SCAN1 and LISTENER2 for SCAN2) , the two terminals in the top are for SCAN 1, left for the listener in instance 1, and the right for the listener in instance 2:

Creating some sessions :
[oracle@rac1 ~]$ sqlplus dgomez/dgomez@rac-scan:1521/orcl


As you can see, only the listener "LISTENER" received these sessions, and the sessions were correctly balanced.

Now let's test the SCAN 2. The last two terminals (bellow) are for listener "LISTENER2" which is linked to the SCAN2. Left for the LISTENER2 in instance 1 and the right for the LISTENER2 in the instance 2:




1 comentario:

  1. Oracle Notes From Guatemala: How To Create A Second Scan In Oracle Rac >>>>> Download Now

    >>>>> Download Full

    Oracle Notes From Guatemala: How To Create A Second Scan In Oracle Rac >>>>> Download LINK

    >>>>> Download Now

    Oracle Notes From Guatemala: How To Create A Second Scan In Oracle Rac >>>>> Download Full

    >>>>> Download LINK

    ResponderEliminar

Oracle ACE Director Award - Deiby Gómez

Thanks #OracleACE Program for this awesome certificate recognizing the work I have done in the community for the last year. Looking forwa...