SCAN (single client access name) is the virtual hostname for all clients to connect to the cluster. SCAN is a domain name registered to at least one and upto three IP addresses. SCAN can be setup using either DNS or GNS. Thus client sends a connection request with a scan name, which first hits the DNS server. SCAN listeners are simply used for redirecting requests from the client to the local listeners. This is a lightweight process as compared to the functioning of NODE VIP listeners which fork a new process to establish a database connection. DNS server resolves this SCAN name to the first available IP and port whose default name is LISTENER_SCAN1. Since all cluster services and DB instances are registered by PMON with the SCAN listener and the local listener on each node, the listener SCAN1 uses details from the load balancing advisory (LBA) to identify the least loaded node which can provide the required service to the client, and thus redirects the client request to the local listener on that node which spawns a process to establish a connection between the client and the node.
By default the name used by the SCAN is the same as the name used for the cluster and must be unique. For the installation to succeed, the SCAN must resolve to at least one IP address. There can be a maximum of 3 IP addresses that can be used for a SCAN.
The SCAN VIP must be on the same sub net as the virtual IP address and the public IP address.
SCAN IP addresses and SCAN listeners are managed as resources in Oracle clusterware. For high availability and scalability oracle recommends you use 3 SCAN IP addresses in a round robin manner.
SCAN listeners are started from the GRID ORACLE HOME and not the Database ORACLE HOME.
Prior to Oracle 11g, the details of each node would be added to the tnsnames.ora. So when a client makes a database connection request, the request would be sent to any one of the host names in the ADDRESS_LIST parameter.
Sample tnsnames.ora file for RAC prior to Oracle 11g
orac =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = host1-vip.localhost.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = host2-vip.localhost.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = host3-vip.localhost.com)(PORT = 1521))
(LOAD_BALANCE = yes)
)
(CONNECT_DATA =
(SID = orac)
)
)
The host name is resolved either from the hosts file or the DNS server file.
Once the VIP of the host is known, the request is sent to the local listener on that host which forks a new connection. In this method, each time a node is added/deleted, both the tnsnames.ora file and the hosts file on each client has to be modified which is a cumbersome process.orac =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = scan.localhost.com)(PORT = 1521))
(LOAD_BALANCE = yes)
)
(CONNECT_DATA =
(SID = orac)
)
)
The host in ADDRESS_LIST is resolved to any of 3 ip addresses. (in DNS or hosts file) with which the SCAN listeners are registered. These ips are selected in a round robin manner.
In all there are 3 SCAN listeners running on any of the nodes in the cluster. So in a 2 node system 2 listeners will be running on one node and 1 listener on the second node.
Some useful commands related to SCAN are given below
$nslookup scan.localhost.com
Output of this will give the 3 vip addresses registered with SCAN.
SQL>show parameter local_listener
SQL>show parameter remote_listener
$srvctl config scan
gives the scan names and vip related information
$srvctl config scan_listener
gives the listener scan names and ips
$crsctl stat res -w "TYPE=ora.scan_listener.type"
gives the name, type and status of each SCAN listener.
$ps -ef | grep tnsl
gives the background processes associated with both the local LISTENER and the SCAN LISTENER.
If multiple scan listeners are running on that node both will get displayed.
$lsnrctl status LISTENER_SCAN1
Benefits
No comments:
Post a Comment