Single Client Access Name (SCAN)
SCAN Concepts :
1) Beginning with Oracle 11g R2 a maximum of three additional IP addresses in a round-robin fashion are needed for a Single Client Access Name (SCAN). Unlike the other three IP (Public, Private, and VIP) addresses and hostnames, the SCAN must be assigned a unique name across all nodes and it must remain on the same subnet as a public and VIP address.
2) In Oracle 11g R2, when the server-side load balancing is set, it is the SCAN listener that uses the load balancing advisory and directs a connection to the best instance
currently providing the service.
3) BENEFITS
A) One of the maintenance challenges with RAC is maintaining all of the client connection files (TNSNAMES.ora) every time a change is made to a cluster database configuration. A new feature of Oracle Database 11g RAC databases, and a primary benefit, is the Single Client Access Name (SCAN). SCAN, which is new in Oracle 11g R2, is the hostname that enables all clients to connect to the cluster, eliminating the need to modify clients when nodes are added or removed from the cluster. Typically, the SCAN name is the same as the cluster name. Make sure the SCAN name has three IP addresses specified either in the DNS or in the Grid Naming Service (GNS).
B) Clients use a simple EZconnect string and JDBC connections can use a JDBC thin URL to access the database, which is done independently of the physical hosts that the database instances are running on.
C) Additionally, SCAN automatically provides both failover and load balancing of connects, where the new connection will be directed to the least busy instance in the cluster by default.
4) SCAN Listener is Listener for single client access name, listening on SCAN VIP
5) The SCAN is a domain name registered to at least one and up to three IP addresses, either in the domain name service (DNS) or the Grid Naming Service (GNS). SCAN works by replacing a hostname or IP list with virtual IP addresses (VIP).
6) The default value for the SCAN is based on the local node name. If you change the SCAN from the default, then the name that you use must be globally unique throughout your enterprise.
7) The purpose of using two layers of listeners (SCAN listeners and node listeners) is to separate the two functions of listeners in a RAC: to load balance connections, and to spawn-and-bequeath sessions. The SCAN listeners will receive connection requests from clients, randomly distributed by the GNS. The SCAN listener will then use load balancing metrics to redirect the request intelligently to the node listener on the node best able to offer the requested service. Database instances register with the SCAN listeners as remote listeners, and with the node listeners as local listeners.
The client needs nothing more than a TNS names entry such as this:
s1=(description=(address=(protocol=tcp)(host=cluster1-scan.cluster1.example.com)(port=1521)) (connect_data=(service_name=s1)))
and the Grid will do the rest.
8) The combination of GNS and SCAN, implemented using VIPs and DHCP, makes the Grid almost completely independent of network resources administered by third parties. Adding and removing nodes, or relocating services, requires no network configuration at all.
9) RAC Instances register the SCAN listeners as remote listeners.
10) SCAN health check
Check we have SCAN listener configured
[oracle@rac1]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1521
Check status of SCAN listeners
[oracle@rac1]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node rac1
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is running on node rac2
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is running on node rac2
[oracle@rac1]$ ps -aef | grep -i SCAN
oragrid 20168 1 0 Jan11 ? 00:00:12 /u01/app/11.2.0/grid/bin/tnslsnr LISTENER_SCAN2 -inherit
oragrid 20179 1 0 Jan11 ? 00:00:11 /u01/app/11.2.0/grid/bin/tnslsnr LISTENER_SCAN3 -inherit
Finally verify that the service that are required to connect to existed on the SCAN listener
[oracle@auw2k3 ~]$ lsnrctl services LISTENER_SCAN2
11) It's highly recommended that the clients are Oracle 11g R2 clients, to allow them to fully take advantage of the failover with the SCAN settings.
The TNSNAMES.ora file would now reference the SCAN rather than the VIPs as has been done in previous versions. This is what a TNSNAMES entry would be:
MYDB (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=mydb-scan.ORACLE.COM)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=myservice.ORACLE.COM)))