NEED FOR VIP IN RAC

In this post, I will demonstrate why do we need VIPs in RAC for failover.If the client request for connection goes to Physical IP of a node and the node is down, client will get notified about after network time out only (which could be as long as 10 minutes). After the client gets this information, he tries to connect to the alternative address. Alternatively, if the client request goes to Virtual IP of the node (VIP) and the node is down, VIP will automatically failover to one of the surviving nodes without waitinig for the network timeout. The listener on the new node listens only to the native VIP on that node and not to the relocated VIP. Any connection request to the relocated VIP receives ORA-12541 No listener error. On receiving the error, the client will try the next address to connect to the database. Hence, VIPs are needed in a RAC for quick failover of client connection requests.
Let’s demonstrate :
Current Scenario:
Two node setup
Nodes : host01, host02
RAC database : orcl

Overview :
— Find out VIPs of both the nodes
— Add entries in tnsnames.ora for two aliases : SIP and SVIP
SIP sends request to physical IP’s of the nodes
SVIP sends request to virtual IP’s (VIP’s) of the nodes
— Shutdown host02

— Try to connect using SIP – waits for network timeout before connecting to host01

– Try to connect using SVIP –  connects to host01 immediately without waiting  for network timeout

Implementation:

- Find out VIPs of both the nodes
[grid@host01 ~]$ srvctl config vip -n host01

VIP exists.:host01
VIP exists.: /192.9.201.254/192.9.201.254/255.255.255.0/eth0

[grid@host01 ~]$ srvctl config vip -n host02

VIP exists.:host02
VIP exists.: /192.9.201.250/192.9.201.250/255.255.255.0/eth0

– Add entries in tnsnames.ora for

– SVIP : An alias for orcl service using which, the client will try to
.  connect to  host02-vip (192.9.201.250 ) first.
. If host02 is down, host02-vip will failover to the other host (host01)
and on receiving No listener error, client will get try connecting to host01

– SIP : An alias for orcl service using which, the client will try to
.  connect to  host02 (Physical IP) first.
. If host02 is down, client gets notified after network time out
. Client tries and gets connected to host01 (Physical IP)

[grid@host01 admin]$ vi /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

SVIP =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.9.201.250 )(PORT = 1521)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.9.201.254 )(PORT = 1521)
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)

SIP =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = host02)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = host01)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)

– Shutdown node host02

[root@host02]#init 0

- Try to connect to the database using service sip
— Note that as host02 is down, client waits for network timeout before trying  connection to host01 and time taken to connect to host01 is 25 seconds (23:42:57  – 23:42:32 )

SQL> set time on
 23:42:32 SQL>  conn system/sys@sip
 Connected.
 23:42:57 SQL>

– Try to connect to the database using service svip
— Note that as host02 is down, host02 VIP immediately fails over to host01 and time taken to connect to host01 is of the order of milliseconds (23:43:38  – 23:43:38 )

23:43:38 SQL> conn system/sys@svip
 Connected.
 23:43:38 SQL>

I hope this demonstration was useful.
Your comments and suggestions are always welcome !!!

References:

Oracle RAC VIP and ARP Primer

—————————————————————————————

 

15 thoughts on “NEED FOR VIP IN RAC

  1. Hi Anju,

    Your blog is very good and its explains lots to physical dbas. Thanks for your effort.
    Have one doubt, in a 4-node/more cluster configuration, how many SCAN VIP and SCAN LISTENERS will be required and also how they will work and failover.

    Thanks
    – Anuradha

  2. Hi Anju,

    I have a query with regards to using VIP on client side tnsnames.ora

    We have a two node RAC instance, where the crs stack is down on node 1 (fht-pas-dbs-p01)
    The vip of node 1 has failed over to node 2 ie crsctl stat res -t on node 2(fht-pas-dbs-p02) gives:

    ora.fht-pas-dbs-p01.vip
    1 ONLINE INTERMEDIATE fht-pas-dbs-p02 FAILED OVER

    Now, if my tnsnames.ora is having entry like :

    vip1 =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =fht-pas-dbs-p01-vip)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = OASLIVE)
    )
    )

    Even though the tnsnames.ora entry does not have entry for vip2 of second node, the client should still be able to connect to node 2, as the node 1 vip has failed over to node 2.

    However, I am not able to connect using the vip1 tnsnames.ora entry as it gives error : TNS:no listener.

    Can you please comment on it?

    fht-pas-dbs-p01:oracle@OASLIVE1 > tnsping vip1
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =fht-pas-dbs-p01-vip)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = OASLIVE)))
    TNS-12541: TNS:no listener

Your comments and suggestions are welcome!