SCAN NAME concept was introduced in Oracle 11g and it's still unsolved mystery for few of the Database Administrators. The main purpose for using SCAN NAME was to remove each Cluster Node entry from Tnsnames.ora file from client machine and to make it more dynamic. Though, Oracle successfully achieve his goal but make it complicated for newbies or sometimes for experienced DBA's as well. Each term SCAN NAME, SCAN VIP, SCAN Listener, Node VIP, Local_Listener and Remote_Listener has its own meaning and role to play in RAC environment.
In this post, I will explain meaning and use of each of above discussed Terms. Let's Start with SCAN NAME.
SCAN NAME: SCAN NAME was introduced in Oracle 11g R2 version. This a name which can resolve upto maximum three IP address and minimum one is required for Oracle 11g R2 Real Application Cluster installation. SCAN NAME must be unique in Entire Organization network, This name is used in Tnsname.ora file of client system, all database connection are made thorugh this name. DBA can use below commands to file SCAN NAME details.
[oracle@database bin]$ srvctl config scan SCAN name: orarac-scan, Network: 1/10.141.132.0/255.255.254.0/eth8 SCAN VIP name: scan1, IP: /orarac-scan/10.191.111.57 SCAN VIP name: scan2, IP: /orarac-scan/10.191.111.55 SCAN VIP name: scan3, IP: /orarac-scan/10.191.111.56 [oracle@database bin]$ nslookup orarac-scan Server: 126.96.36.199 Address: 188.8.131.52#53 Name: orarac-scan.oracle.com Address: 10.191.111.55 Name: orarac-scan.oracle.com Address: 10.191.111.56 Name: orarac-scan.oracle.com Address: 10.191.111.57
SCAN VIP: SCAN NAME resolves to one or more than one IP addresses, these IP address are called as SCAN VIP or SCAN IP. Each Scan VIP has a SCAN Listener generated corresponding to it. If there is one SCAN IP one SCAN Listener will be generated, if there are three SCAN IP's three SCAN Listeners will be generated. These SCAN Listener runs on any of three nodes on the RAC environment or it could be two SCAN Listener on one node if there are three SCAN Listener and only two nodes.
SCAN VIP and SCAN Listener works as a pair when SCAN VIP fails over to other node, the corresponding SCAN listener will also be failed over to the same node. Whenever SCAN VIP fails over happens, it will always select a node with least running SCAN VIP, i.e., if SCAN VIP runs on node1, node2 and node3 of a 4-node cluster, if node3 goes down, the SCAN VIP and corresponding SCAN listener will be failed over to node4 as the other two nodes already have one SCAN VIP running on each node.
Database Administrator can use below command to find SCAN Listener running on a node and SCAN VIP corresponding to it.
[oracle@database ~]$ ps -ef | grep tnslsnr oracle 18181 10705 0 15:07 pts/0 00:00:00 grep tnslsnr grid 22438 1 0 Jul24 ? 00:00:39 /u01/app/184.108.40.206/grid/bin/tnslsnr LISTENER_SCAN2 -inherit grid 25927 1 0 Jul24 ? 00:01:31 /u01/app/220.127.116.11/grid/bin/tnslsnr LISTENER -inherit grid 29211 1 0 Jul28 ? 00:00:27 /u01/app/18.104.22.168/grid/bin/tnslsnr LISTENER_SCAN3 -inherit [oracle@database bin]$ lsnrctl status LISTENER_SCAN3 LSNRCTL for Linux: Version 22.214.171.124.0 - Production on 06-AUG-2013 16:16:22 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN3))) STATUS of the LISTENER ------------------------ Alias LISTENER_SCAN3 Version TNSLSNR for Linux: Version 126.96.36.199.0 - Production Start Date 28-JUL-2013 08:38:01 Uptime 9 days 7 hr. 38 min. 21 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/188.8.131.52/grid/network/admin/listener.ora Listener Log File /u01/app/184.108.40.206/grid/log/diag/tnslsnr/node2/listener_scan3/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN3))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.191.111.57)(PORT=1521))) Services Summary... Service "newdb" has 2 instance(s). Instance "newdb1", status READY, has 1 handler(s) for this service... Instance "newdb2", status READY, has 1 handler(s) for this service... Service "newdbXDB" has 2 instance(s). Instance "newdb1", status READY, has 1 handler(s) for this service... Instance "newdb2", status READY, has 1 handler(s) for this service... The command completed successfully
From the above grep command DBA can see, this system has two SCAN Listener running at this moment. SCAN Listener having name LISTENER_SCAN3 is running on SCAN VIP 10.191.111.57 as shown in HOST parameter of lsnrctl status output.
SCAN Listener: As explained above Each SCAN VIP has SCAN Listener associated with each other and both works as a pair. One SCAN Listener is created corresponding to one SCAN VIP.
SCAN Listener used to run on database nodes. At max there could be three SCAN Listeners in the whole cluster. To file where all these SCAN Listeners are running use
[oracle@database ~]$ srvctl status scan_listener SCAN Listener LISTENER_SCAN1 is enabled SCAN listener LISTENER_SCAN1 is running on node node1 SCAN Listener LISTENER_SCAN2 is enabled SCAN listener LISTENER_SCAN2 is running on node node2 SCAN Listener LISTENER_SCAN3 is enabled SCAN listener LISTENER_SCAN3 is running on node node2
In this example, This is a two node RAC having three SCAN Listeners, Node1 has LISTENER_SCAN1 running while Node2 has LISTENER_SCAN2 and LISTENER_SCAN3 running.
Node VIP: Each Database node in Real Application cluster environment has one node IP and one Node VIP address, The main difference between these two is Node VIP can move to any other system in case if current owning system is down but Node IP can't do that. When ever a new connection request is made the SCAN listener listening on a SCAN IP address and the SCAN port is contracted on a client's behalf. Because all services on the cluster are registered with the SCAN listener, the SCAN listener replies with the address of the local listener as Node VIP address on the least-loaded node (Each scan listener keeps updated cluster load statistics) and connection is routed to that node.
Local Listener on the Database server is registered with Node VIP and Node IP address.
[oracle@database ~]$ lsnrctl status listener LSNRCTL for Linux: Version 220.127.116.11.0 - Production on 07-AUG-2013 05:12:02 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 18.104.22.168.0 - Production Start Date 24-JUL-2013 07:14:10 Uptime 13 days 21 hr. 57 min. 52 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/22.214.171.124/grid/network/admin/listener.ora Listener Log File /u01/app/grid/diag/tnslsnr/node2/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.141.21.360)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.141.21.366)(PORT=1521))) Services Summary... Service "+ASM" has 1 instance(s). Instance "+ASM2", status READY, has 1 handler(s) for this service... Service "newdb" has 1 instance(s). Instance "newdb2", status READY, has 1 handler(s) for this service... Service "newdbXDB" has 1 instance(s). Instance "newdb2", status READY, has 1 handler(s) for this service... The command completed successfully
Here, DBA can see Listner is registered with two IP addresses 10.141.21.360 is Node IP address and 10.141.21.366 is node VIP address.
Local_Listener: This is a database parameter which is used to provide detail of local listener running on database node itself. In Real Application Cluster environment this has Node VIP address as value.
SQL> show parameter local_listener NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ local_listener string (DESCRIPTION=(ADDRESS_LIST=(A DDRESS=(PROTOCOL=TCP)(HOST=10. 141.21.366)(PORT=1521))))
When a new connection request is made my SCAN Listener, This address is returned to the SCAN Listener and then connection is made to database local listener. The difference between SCAN Listener and Local Listener is SCAN listener runs corosponding to SCAN VIP's while Local Listener runs with Node VIP or Node IP address.SCAN Listener can move to another database node in case of node failure but local Listener doesn't have this kind of behavior.
Remote_Listener: Each database instance has this parameter set to SCAN NAME of the cluster environment. SCAN NAME in turn has one or more IP address further called SCAN VIP and each SCAN VIP has SCAN Listener running on it, so finally each database instance register itself with all SCAN Listeners running across the clusterware.
SQL> show parameter remote_listener NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ remote_listener string orarac-scan:1521
The solo purpose of remote_listener parameter is to register each database instance with all SCAN Listeners in RAC. This provide information on what services are being provided by the instance,the current load, and a recommendation on how many incoming connections should be directed to the instance.
Step by step Database Connection Process In Oracle 11g R2 RAC environment
1. SCAN Name is used in tnsname.ora file of client machine, So for new connection DNS server return to one of the IP address of SCAN Name to client machine called SCAN VIP.
2. SCAN VIP must be using by a Database Node and a SCAN Listener should be running on this SCAN VIP on that node.
3. SCAN Listener has all database instances registered with it, it check internally about load and availability and return Node VIP address to connect for.
4. Each Node VIP has a Local Listener running on database node for it and has a Node IP as well. This returns listener detail and database connection is made with the Local database listener.
In conclusion, This is a complicated process but each and every part has it's own role to play which make it complete. Please share your thoughts about this article.