Oracle RAC Database Connections Using SCANs

Oracle recommends Using SCANs to connect Oracle RAC database

The SCAN is a domain name registered to at least one and up to three IP addresses, either in domain name service (DNS) or in Grid Naming Service (GNS).

During the installation of Oracle Grid Infrastructure, several Oracle Clusterware resources are created for the SCAN.

  • A SCAN virtual IP (VIP) is created for each IP address that Oracle Single Client Access Name (SCAN) resolves to
  • A SCAN listener is created for each SCAN VIP
  • A dependency on the SCAN VIP is configured for the SCAN listener

SCANs are defined using one of two options:

  • The SCAN is defined in DNSIf you configure a SCAN manually, and use DNS for name resolution, then your network administrator should create a single name for the SCAN that resolves to three IP addresses on the same network as the public network for the cluster. The SCAN name must be resolvable without the domain suffix (for example, the address sales1-scan.example.com must be resolvable using sales1-scan). The SCAN must not be assigned to a network interface, because Oracle Clusterware resolves the SCAN.The default SCAN is cluster_name-scan.domain_name. For example, in a cluster that does not use GNS, if your cluster name is sales1, and your domain is example.com, then the default SCAN address is sales1-scan.example.com:1521.
  • The SCAN is defined in GNSWhen using GNS and DHCP, Oracle Clusterware configures the VIP addresses for the SCAN name that is provided during cluster configuration. The node VIP and the three SCAN VIPs are obtained from the DHCP server when using GNS. If a new server joins the cluster, then Oracle Clusterware dynamically obtains the required VIP address from the DHCP server, updates the cluster resource, and makes the server accessible through GNS.

Connecting to an Oracle RAC Database Using SCANs

Oracle Database 19c database clients use SCAN to connect to the database. Oracle recommends against using the easy connect method with SCAN because the easy connect method does not have the ability to specify timeouts and retries for connection establishment. Instead, applications must use an Oracle Net connect descriptor with the following format:

(DESCRIPTION =
      (CONNECT_TIMEOUT=90) (RETRY_COUNT=20)(RETRY_DELAY=3) (TRANSPORT_CONNECT_TIMEOUT=3)
                   ( ADDRESS = (PROTOCOL = TCP)(HOST=scan)(PORT=1521))
                      (CONNECT_DATA=(SERVICE_NAME=service_name)))

scan represents the SCAN for your cluster. If you do not specify a port number, then the default value of 1521 is used for the TCP port identifier. The service_name is the name of a dynamic database service.

The client then uses one of the returned SCAN VIP addresses to contact a SCAN listener. When a SCAN listener receives a connection request from a client, the SCAN listener identifies the least loaded instance in the cluster that provides the requested service. It then redirects the connection request to the local listener on the node where the least loaded instance is running, and the client is given the local listener address. The local listener then creates the connection to the database instance.

Connecting to Oracle RAC Using an Oracle Net Connect Descriptor

If the Oracle RAC database runs on a cluster for which the SCAN is sales1-scan.mycluster.example.com, then you can submit a connection request for the database service oltp.example.com by using a connect descriptor similar to the following:

(DESCRIPTION =
      (CONNECT_TIMEOUT=90) (RETRY_COUNT=20)(RETRY_DELAY=3) (TRANSPORT_CONNECT_TIMEOUT=3)
                 ( ADDRESS = (PROTOCOL = TCP)(HOST=sales1-scan.mycluster.example.com)(PORT=1521))
                           (CONNECT_DATA=(SERVICE_NAME=oltp.example.com)))

If the SCAN is resolved by DNS, then DNS returns all three SCAN VIP addresses to the client. If the SCAN is resolved by GNS, then DNS zone delegation sends the lookup request to GNS, which then returns all three SCAN VIP addresses to the client. The client then uses one of the returned SCAN VIP addresses to contact a SCAN listener.

When a SCAN listener receives a connection request from a client, the SCAN listener identifies the least loaded instance in the cluster that provides the requested service. It then redirects the connection request to the local listener on the node where the least loaded instance is running, and the client is given the local listener address. The local listener then creates the connection to the database instance.

Database Connections are Created When Using SCANs

Based on the environment, the following actions occur when you use a SCAN to connect to an Oracle RAC database using a service name.

The numbered actions correspond to the arrows shown in Load Balancing Actions for Oracle RAC Connections That Use SCAN:

  1. The LREG process of each instance registers the database services with the default listener on the local node and with each SCAN listener, which is specified by the REMOTE_LISTENER database parameter. The listeners are dynamically updated on the amount of work being handled by the instances and dispatchers.
  2. The client issues a database connection request using a connect descriptor of the form:
    • orausr/@scan_name:1521/webapp
    • If you use the Easy Connect naming method, then ensure that the sqlnet.ora file on the client contains EZCONNECT in the list of naming methods specified by the NAMES.DIRECTORY_PATH parameter.
  3. The client uses DNS to resolve scan_name. After DNS returns the three addresses assigned to the SCAN, the client sends a connect request to the first IP address. If the connect request fails, then the client attempts to connect using the next IP address.
  4. When the connect request is successful, the client connects to a SCAN listener for the cluster that hosts the sales database and has an instance offering the webapp service, which in this example is sales1 and sales2. The SCAN listener compares the workload of the instances sales1 and sales2 and the workload of the nodes on which they run. If the SCAN listener determines that node2 is less loaded than node1, then the SCAN listener selects node2 and sends the address for the local listener on that node back to the client.
  5. The client connects to the local listener on node2. The local listener starts a dedicated server process for the connection to the database.
  6. The client connects directly to the dedicated server process on node2 and accesses the sales2 database instance.

Load Balancing Actions for Oracle RAC Connections That Use SCANDescription of Figure 6-1 follows

Also See:

Oracle RAC

Understanding SCANs