Sunday, April 20, 2014

Difference between SCAN and VIP in RAC


http://satya-racdba.blogspot.com/2012/09/scan-in-oracle-rac-11g-r2.html

If you have ever been tasked with extending an Oracle RAC cluster by adding a new node (or shrinking a RAC cluster by removing a node), then you know the pain of going through a list of all clients and updating their SQL*Net or JDBC configuration to reflect the new or deleted node. To address this problem, Oracle 11g Release 2 introduced a new feature known as Single Client Access Name or SCAN for short. SCAN is a new feature that provides a single host name for clients to access an Oracle Database running in a cluster. Clients using SCAN do not need to change their TNS configuration if you add or remove nodes in the cluster. The SCAN resource and its associated IP address(s) provide a stable name for clients to use for connections, independent of the nodes that make up the cluster. You will be asked to provide the host name (also called the SCAN name in this document) and up to three IP addresses to be used for the SCAN resource during the interview phase of the Oracle Grid Infrastructure installation. For high availability and scalability, Oracle recommends that you configure the SCAN name for round-robin resolution to three IP addresses. At a minimum, the SCAN must resolve to at least one address.

The SCAN virtual IP name is similar to the names used for a node's virtual IP address, such as racnode1-vip. However, unlike a virtual IP, the SCAN is associated with the entire cluster, rather than an individual node, and can be associated with multiple IP addresses, not just one address.

During installation of the Oracle Grid Infrastructure, a listener is created for each of the SCAN addresses. Clients that access the Oracle RAC database should use the SCAN or SCAN address, not the VIP name or address. If an application uses a SCAN to connect to the cluster database, the network configuration files on the client computer do not need to be modified when nodes are added to or removed from the cluster. Note that SCAN addresses, virtual IP addresses, and public IP addresses must all be on the same subnet.

The SCAN should be configured so that it is resolvable either by using Grid Naming Service (GNS) within the cluster or by using the traditional method of assigning static IP addresses using Domain Name Service (DNS) resolution.

In this article, I will configure SCAN for round-robin resolution to three, manually configured static IP address using the DNS method.


racnode-cluster-scan IN A 192.168.1.187 
racnode-cluster-scan IN A 192.168.1.188 
racnode-cluster-scan IN A 192.168.1.189

Further details regarding the configuration of SCAN will be provided in the section "Verify SCAN Configuration" during the network configuration phase of this guide..



FAQ :

Que#1: Will three SCAN listeners have same same port to listen? 
ANS: Yes all three Scan Listeners will have same port and you can choose the port and the port will be different than the port used for VIP listeners. :-) Can't Share the port# which i used in my production. 

Que#2: Three SCAN listeners take the request parallel? 
ANS: Yes three Scan listeners will run in parallel and accept requests, DNS will route request to one of the SCAN Listener. 

Que#3: So from 11.2 onwards we are not using VIP? 
ANS: VIPs still exists on each node, But we dont use VIPs in our client connection string instead we we use one SCAN-Name. 

Que#4: It does seem VIPs are redudent in that case? 
ANS: There is difference between VIP and SCAN Listener, Let me try to explain and hope the example at the end will help to understand in more detail, First difference is VIP is always bound to a node and each node will specifically have one VIP Listener Where as Grid Services will start the SCAN Listener on any node e.g if you have three SCAN Listener and 2/3 RAC Nodes then it may be the case that 2 SCAN Listeners in one node and 1 SCAN Listerner on second node where as third node doesn't have any SCAN Listerner. For VIPs if a certain node is offline then that VIP will not be available in Cluster where as if certain node is offline then Cluster will relocate the SCAN to other surviving nodes. 
Advantage of SCAN: Previously we specified all the VIPs in our client connections but now you need to specify only one "SCAN Name" in your client address. If you Add/Remove Nodes in your RAC then you dont need to update your client connection strings, The only change will be done in DNS.

====

******************************Example Eleboration*********************** 
#######################Configuration Before SCAN######################### 
Number of RAC Nodes: 8 
Physical IPs: 8, One for each node 
Private IPs: atleast 8, One for each node (You can have two for each for redudency) 
Virtual IPs: 8, One assigned to each node ... Word "assigned" is important 
Number of VIP Listeners: 8, Each Bound to certain Node ... word "bound"/"assigned" 

Client Connection String: Mentioning address of all 8 VIP Listeners (Failover etc) 

Simplest Event: Add 4 new Nodes or Remove 4 Nodes 
Required Action: Update the Client connection string on all clients 
Connection Establishment: Client sends request to one of VIP Listeners mentioned in client connection string, if failed then client will send request on another VIP address until the connection is successful. So client sending requests directly to VIP listeners specific/bound to VIP on each node. 

#######################Configuration After SCAN########################## 
**********************************Understanding SCAN**************************************** 
SCAN: Single Client Access Name -- Allowing client to access whole cluster/grid through one name, rather specifying all VIP addresses individually 
SCAN Requirement: To be able to get SCAN Functionality, We need some service through which one name is resolved to multiple IPs/hosts. This is what we often call "DNS", Domain name service or if you dont have DNS in your environment then you can use Oracle's "GNS (Grid Naming Service)" 

SCAN Implementation/Configuration: In Our DNS We defined a ScanName and assigned three Virtual IPs e.g (OraProdScan=X.X.X.5, X.X.X.6 and X.X.X.7), Now when you do nslookup OraProdScan from your client it will give you list of three IPs specified as above and important thing, everytime you do nslookup it will give you the IP addresses in round robin, So every request to resolve the OraProdScan name will give different IP every time. One kind of load balancing at first place to reach to SCAN Listener so requests will be distributed on available SCAN Listeners. 

SCAN Usage: During Oracle Grid Installation, Specify mentioned IPs, Each VIP Listener on each node will register itself will Every SCAN Listener on whatever node the SCAN Listener is running. 


Number of RAC Nodes: 8 
Physical IPs: 8, One for each node 
Private IPs: atleast 8, One for each node (You can have two for each for redudency) 
Virtual IPs: 8, One assigned to each node ... Word "assigned" is important 
Number of VIP Listeners: 8, Each Bound to certain Node ... word "bound"/"assigned" 
Number of SCAN Listeners: 3, Grid will decide which nodes SCAN Listeners will be Allocated 
Client Connection String: Mentioning the name of SCAN "OraProdScan" 

Simplest Event: Add 4 new Nodes or Remove 4 Nodes 
Required Action: No update required. 
Connection Establishment: Client sends request to DNS using SCAN Name "OraProdScan", DNS will return one of three IPs, Client Sends request on that IP to the SCAN Listener, the SCAN Listener will route the request to one of the VIP Listeners among 8 VIP listeners in this case because each VIP listener has already registered itself with every SCAN Listener. Finally direct connection is established between client and one of the VIP Listeners. 
You see flexibility, adding/removing as many nodes in Grid/RAC doesn't require any change. 
Hope i have answered all questions, it was long post, if i still have missed anything please let me know!