What is Single Client Access Name (SCAN) in Oracle
It is a new Oracle Real Application Clusters (RAC) 11g Release 2 feature that provides a single name for clients to access Oracle Databases running in a cluster. The benefit is that the client’s connect information does not need to change if you add or remove nodes in the cluster. Having a single name to access the cluster allows clients to use the EZConnect client and the simple JDBC thin URL to access any database running in the cluster, independently of which server(s) in the cluster the database is active. SCAN provides load balancing and failover for client connections to the database. The SCAN works as a cluster alias for databases in the cluster.
How to configure the Single Client Access Name (SCAN)
The SCAN is configured during the installation of Oracle Grid Infrastructure that is distributed with Oracle Database 11g Release 2. Oracle Grid Infrastructure is a single Oracle Home that contains Oracle Clusterware and Oracle Automatic Storage Management. You must install Oracle Grid Infrastructure first in order to use Oracle RAC 11g Release 2. During the installation phase of the Oracle Grid Infrastructure installation, you will be prompted to provide a SCAN name.
you must ask your network administrator to create a single name that resolves to 3 IP addresses using a round-robin algorithm. Three IP addresses are recommended considering load balancing and high availability requirements regardless of the number of servers in the cluster. The IP addresses must be on the same subnet as your public network in the cluster. The name must be 15 characters or less in length, not including the domain, and must be resolvable without the domain suffix . The IPs must not be assigned to a network interface (on the cluster), since Oracle Clusterware will take care of it
nslookup tech-scan Server: 220.127.116.11 Address: 18.104.22.168#53 Non-authoritative answer: Name: tech-scan.localdomain Address: 22.214.171.124 Name: tech-scan.localdomain Address: 126.96.36.199 Name: tech-scan.localdomain Address: 188.8.131.52
How Single Client Access Name (SCAN) works
During cluster configuration, several resources are created in the cluster for SCAN. For each of the 3 IP addresses that the SCAN resolves to, a SCAN VIP resource is created and a SCAN Listener is created. The SCAN Listener is dependent on the SCAN VIP and the 3 SCAN VIPs (along with their associated listeners) will be dispersed across the cluster. This means, each pair of resources (SCAN VIP + Listener) will be started on a different server in the cluster,assuming the cluster consists of three or more nodes.In case, a 2-node-cluster is used (for which 3 IPs are still recommended for simplification reasons), one server in the cluster will host two sets of SCAN resources under normal operations. If the node where a SCAN VIP is running fails,the SCAN VIP and its associated listener will failover to another node in the cluster. If by means of such a failure the number of available servers in the cluster becomes less than three, one server would again host two sets of SCAN resources. If a node becomes available in the cluster again, the formerly mentioned dispersion will take effect and relocate one set accordingly.
How Connection Load Balancing Works Using the SCAN
For clients connecting using Oracle SQL*Net, three IP addresses are received by the client by resolving the SCAN name through DNS. The client then goes through the list that it receives from the DNS and tries connecting through one of the IP addresses in the list. If the client receives an error, then it tries connecting to the other addresses before returning an error to the user or application. This is similar to how client connection failover works in earlier Database releases, when an address list is provided in the client connection string.
When a SCAN Listener receives a connection request, the SCAN Listener checks for the least loaded instance providing the requested service. It then re-directs the connection request to the local listener on the node where the least loaded instance is running. Subsequently, the client is given the address of the local listener. The local listener then finally creates the connection to the Database instance.
TNS Before SCAN TECH= (DESCRIPTION = (ADDRESS_LIST = (LOAD_BALANCE = ON) (FAILOVER = ON) (ADDRESS = (PROTOCOL = tcp)(HOST = tech1-vip.localdomain)(PORT =1521)) (ADDRESS = (PROTOCOL = tcp)(HOST = tech2-vip.localdomain)(PORT =1521)) (ADDRESS = (PROTOCOL = tcp)(HOST = tech3-vip.localdomain)(PORT =1521)) (ADDRESS = (PROTOCOL = tcp)(HOST = tech4-vip.localdomain)(PORT =1521)) ) (CONNECT_DATA = (SERVICE_NAME = TECH) ) ) TNS AFTER SCAN TECH= (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = tcp)(HOST = tech-scan.localdomain)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = TECH) ) )
How Database need to be configured to make use of SCAN
Set local_listener to the Node VIP and Remote_listener to the SCAN l
LOCAL_LISTENER = (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))))