Enabling Clients for Oracle RAC
Learn how FAN is integrated with Oracle Clients, and how to enable FAN events for the several specific client development environments.
Oracle has integrated FAN with many of the common client application environments used to connect to Oracle Real Application Clusters (Oracle RAC). The easiest way to use FAN is to use an integrated Oracle Client.
Overview of Oracle Integrated Clients and FAN
The overall goals of FAN are to enable end-to-end, lights-out recovery of applications and load balancing based on real transaction performance.
Applications use the FAN high availability (HA) events to achieve very fast detection of failures, balancing of connection pools following failures, and distribution of connections again when the failed components are repaired.
The FAN events carrying load balancing advice help connection pools consistently deliver connections to available instances that provide the best service. FAN HA is integrated with the JDBC-thin and OCI drivers. FAN HA and FAN load balancing are both integrated with the JDBC Universal Connection Pool (and the deprecated Implicit Connection Cache), the OCI session pools, the ODP.NET connection pool, and Oracle WebLogic Server Active GridLink for Oracle RAC.
Due to the integration with FAN, Oracle integrated clients are more aware of the current status of an Oracle RAC cluster. This prevents client connections from waiting or trying to connect to instances or services that are no longer available. When instances start, Oracle RAC uses FAN to notify the connection pool so that the connection pool can create connections to the recently started instance and take advantage of the additional resources that this instance provides.
Oracle client drivers that are integrated with FAN can:
- Remove terminated connections immediately when a service is declared
DOWNat an instance, and immediately when nodes are declaredDOWN - Report errors to clients immediately when Oracle AI Database detects the
NOT RESTARTINGstate, instead of making the client wait while the service repeatedly attempts to restart
Oracle connection pools that are integrated with FAN can:
- Balance connections across all of the Oracle RAC instances when a service starts; this is preferable to directing the sessions that are defined for the connection pool to the first Oracle RAC instance that supports the service
- Balance work requests at run time using load balancing advisory events
The use of client drivers or connection pools and FAN requires that you properly configure the Oracle Notification Service to deliver the FAN events to the clients. In addition, for load balancing, configure database connection load balancing across all of the instances that provide the services used by the connection pool. Oracle recommends that you configure both client-side and server-side load balancing with Oracle Net Services. If you use Oracle DBCA to create your database, then both client-side and server-side load balancing are configured by default.
Related Topics
Enabling JDBC-Thin Clients for Fast Connection Failover
Enabling Fast Connection Failover (FCF) for Universal Connection Pool and Oracle WebLogic Server Active GridLink for Oracle RAC enables the use of FAN HA and load balancing advisory events.
About Fast Connection Failover and JDBC-Thin Clients
Learn how Oracle Real Application Clusters (Oracle RAC) FAN APIs enable application code to receive and respond to FAN event notifications.
For Universal Connection Pool to use Oracle RAC Fast Application Notification (FAN), your application can use the Java Database Connectivity (JDBC) development environment for either JDBC OCI or JDBC Thin clients. The Java Database Connectivity Oracle Call Interface (JDBC/OCI) driver connection pooling functionality is part of the JDBC-thin client. This functionality is provided by the OracleOCIConnectionPool class.
To enable FCF for the JDBC-thin client, call the method setFastConnectionFailoverEnabled(true) of the OracleDataSource class in the oracle.jdbc.pool package before making the first getConnection() request. When you enable FCF for the JDBC-thin client, the failover property applies to every connection in the connection pool. Enabling FCF with JDBC-thin driver or JDBC/OCI clients enables the connection pool to receive and react to all FAN events.
JDBC application developers can programmatically integrate with FAN by using a set of APIs. The Oracle RAC FAN APIs enable application code to receive and respond to FAN event notifications sent by Oracle RAC in the following ways:
- Listening for Oracle RAC service down, service up, and node down events
- Listening for load balancing advisory events and responding to them
Related Topics
Oracle Notification Service for JDBC-Thin Clients
Learn about the benefits of using Remote Oracle Notification Service subscription with your Oracle Real Application Clusters (Oracle RAC) database.
FCF relies on Oracle Notification Service to propagate database events between the connection pool and the Oracle RAC database. At run time, the connection pool must be able to setup an Oracle Notification Service environment. Oracle Notification Service (ons.jar) is included as part of the Oracle Client software. Oracle Notification Service can be configured using either remote configuration or client-side Oracle Notification Service daemon configuration. Remote Oracle Notification Service subscription offers the following advantages:
- Support for an All Java mid-tier software
- An Oracle Notification Service daemon is not necessary on the client system, so you do not have to manage this process
- Configuration by way of a
DataSourceproperty
Configuring FCF for JDBC/OCI and JDBC-Thin Driver Clients
You can enable FCF for Universal Connection Pool or Implicit Connection Cache.
Oracle recommends using the Universal Connection Pool for Java because the Implicit Connection Cache is deprecated. You can also use Oracle WebLogic Server Active GridLink for Oracle RAC.
This procedure explains how to enable FCF for JDBC. You can also configure Application Continuity and Transaction Guard.
To enable FCF, you must first enable the Universal Connection Pool, as described in the following procedure:
Create the connection pool and set
setFastConnectionFailoverEnabled(true).The following example creates a connection pool and enables FCF. The
ucp.jarlibrary must be included in the classpath of an application to use this example.PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource(); pds.setFastConnectionFailoverEnabled(true);Determine the ports to use for Oracle Notification Service remote subscriptions.
Use the following command to view the Oracle Notification Service configuration on each node that is running Oracle Clusterware as in the following example:
srvctl config nodeapps -onsonlyThe output of this command lists the local and remote ports configured for Oracle Notification Service.
Note:
Oracle Notification Service configuration should have been automatically completed during the Oracle Grid Infrastructure installation.
Configure the remote Oracle Notification Service subscription.
When using the Universal Connection Pool, an application calls
setONSConfigurationfor anOracleDataSourceinstance and specifies the nodes and port numbers to use. The port numbers used for each node are the same as the remote port displayed for each node in Step 2, as shown in the following example. Theons.jarlibrary must be included in the classpath of an application to use this example.pds.setONSConfiguration("nodes=racnode1:6200,racnode2:6200");Applications that use remote Oracle Notification Service configuration must set the
oracle.ons.oraclehomesystem property to the location ofORACLE_HOMEbefore starting the application, for example:java -Doracle.ons.oraclehome=$ORACLE_HOME ...Configure the connection URL.
A connection factory's connection URL must use the service name syntax when using FCF. The service name is used to map the connection pool to the service. The following example demonstrates configuring the connection URL:
pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource"); pds.setURL("jdbc:oracle:thin@//SCAN_name:service_name");...
Related Topics
Enabling JDBC Clients for Run-time Connection Load Balancing
Run-time connection load balancing requires the use of an Oracle JDBC driver and an Oracle RAC database.
Oracle JDBC Universal Connection Pool and Oracle WebLogic Server Active GridLink for Oracle RAC leverage the load balancing functionality provided by an Oracle RAC database.
The Universal Connection Pool and Oracle WebLogic Server Active GridLink for Oracle RAC are integrated to take advantage of Load Balancing Advisory information.
Run-time connection load balancing requires that FCF is enabled and configured properly. In addition, the Oracle RAC load balancing advisory must be configured with service-level goals for each service used by the connection pool.
srvctl modify service -db db_unique_name -service service_name
-rlbgoal SERVICE_TIME -clbgoal LONG
Related Topics
Configuring JDBC-Thin Clients for Application Continuity for Java
This oracle.jdbc.datasource.impl.OracleDataSource data source is a JDBC-thin data source that Application Continuity requires for Java.
This data source serves as the connection factory that produces new physical JDBC connections, for both Universal Connection Pool and Oracle WebLogic Server Active GridLink for Oracle RAC data sources. The JDBC replay driver maintains a history of calls during a client conversation with Oracle AI Database. Following any outage of the session caused by a loss of database service, planned or unplanned, under the direction of the database, the JDBC replay driver attempts to rebuild the non-transactional and transactional database session states, so that the outage appears as a delayed processing.
Application Continuity for Java is supported in the following configurations:
- JDBC applications using Oracle JDBC data source and using neither Universal Connection Pool or Oracle WebLogic Server Active GridLink-typical third-party, JDBC-based connection pools
- JDBC applications using Universal Connection Pool data sources-standalone or third-party application servers configured to use a Universal Connection Pool data source
- JDBC applications using only Oracle WebLogic Server Active GridLink but not Universal Connection Pool data sources-typical Oracle WebLogic Server J2EE cases
To configure JDBC-thin clients to use the JDBC Replay Driver:
- Ensure that you are using an application that is certified for replay.
- Use SRVCTL to create a service for use by the application, if one does not already exist. Set the
-failovertypeparameter toTRANSACTIONand the-commit_outcomeparameter toTRUEfor this service. Configure the connection element using the
PoolDataSourceobject, as shown in the following example:PoolDataSource rds = PoolDataSourceFactory.getPoolDataSource(); rds.setConnnectionPoolName("replayExample"); rds.setONSConfiguration("nodes=racnode1:4200,racnode2:4200"); rds.setFastConnectionFailoverEnabled(true); rds.setConnectionFactoryClassName("oracle.jdbc.datasource.impl.OracleDataSource"); Connection conn = rds.getConnection();- When connecting to the database, use a URL that can access all instances offering the service.
Related Topics
- About Application Continuity
- Creating Services for Application Continuity and Transaction Guard
- Oracle AI Database JDBC Developer's Guide
- Oracle Universal Connection Pool Developer's Guide
See also
Oracle AI Database JDBC Developer's Guide for information about configuring Transaction Guard without enabling Application Continuity
Configuring JDBC-Thin Clients for Transaction Guard
Transaction Guard provides a protocol and a generic tool for applications to use for at-most-once processing in case of planned and unplanned outages.
Applications use the logical transaction ID to determine the outcome of the last transaction open in a database session following an outage. Without Transaction Guard, end users or applications that attempt to retry operations following outages can cause logical corruption by committing duplicate transactions or committing transactions out of order.
Related Topics
- Oracle AI Database JDBC Developer's Guide
- Oracle AI Database Development Guide
- Oracle Call Interface Developer's Guide
Enabling OCI Clients for Fast Connection Failover
Complete the procedure that enables Fast Connection Failover (FCF) by registering to receive notifications for Oracle RAC high availability Fast Application Notification (FAN) events.
Oracle Call Interface (OCI) clients can enable FCF by registering to receive notifications for Oracle Real Application Clusters (Oracle RAC) high availability FAN events and responding when events occur. Using FCF improves the session failover response time in OCI applications and also removes connections to nonfunctioning instances from connection and session pools. FCF can be used in OCI applications that also use TAF, OCI drivers (including your own connection pools), OCI connection pool, and OCI session pools. FAN is posted over the Oracle Notification Service for both high availability and load balancing events.
To use FCF, you must use a service with FAN enabled. FAN is published over Oracle Notification Service. Client applications can also register callbacks that are used whenever an event occurs. This reduces the time that it takes to detect a connection failure.
During DOWN event processing, OCI:
- Terminates affected connections at the client and returns an error
- Removes connections from the OCI connection pool and the OCI session pool-the session pool maps each session to a physical connection in the connection pool, and there can be multiple sessions for each connection
- Fails over the connection if you have configured TAF. If TAF is not configured, then the client only receives an error if the instance it is connected to fails.
If your application is using TAF, then you must enable the TAF properties for the service using SRVCTL or Oracle Enterprise Manager. Configure your OCI client applications to connect to an Oracle RAC database using the configured service.
Note:
OCI does not manage UP events.
Example: Configuring FCF for OCI Clients
OCI applications must connect to an Oracle RAC instance to enable HA event notification. Furthermore, these applications must perform the following steps to configure FCF for an OCI client:
Configure the service for your OCI connection pool to enable FAN, connection load balancing, and run-time connection load balancing, as shown in the following example:
$ srvctl modify service -db crm -service ociapp.example.com -notification TRUE- Link the application with a thread library.
- After linking with the thread library, the applications can register a callback that is invoked whenever a FAN event occurs.
Related Topics
Enabling OCI Clients for Run-time Connection Load Balancing
Oracle Call Interface (OCI) session pooling enables multiple threads of an application to use a dynamically managed set of pre-created database sessions.
In connection pooling, the pool element is a connection, but in session pooling, the pool element is a session. Oracle AI Database continually reuses the sessions in the session pool to form nearly permanent channels to the instances, thus saving the overhead of creating and closing sessions every time applications need them.
Run-time connection load balancing is enabled by default in Oracle AI Database. For Oracle RAC environments, session pools use service metrics received from the Oracle RAC load balancing advisory through Fast Application Notification (FAN) events to balance application session requests. The work requests coming into the session pool can be distributed across the instances of Oracle RAC offering a service, using the current service performance.
Note:
Run-time connection load balancing is basically routing work requests to sessions in a session pool that can best serve the work. It comes into effect when selecting a session from an existing session pool. Thus, run-time connection load balancing is a very frequent activity.
Example: Configuring OCI Clients to Receive Load Balancing Advisory FAN Events
For Oracle RAC environments, session pools use service metrics received from the Oracle RAC load balancing advisory through Fast Application Notification (FAN) events to balance application session requests. To enable your application to receive the service metrics based on the service time, ensure that you configure FAN, the load balancing advisory goal (-rlbgoal parameter), and the connection load balancing goal (-clbgoal parameter) for a service that is used by the session pool, as shown in the following example:
$ srvctl modify service -db crm -service ociapp.example.com -rlbgoal SERVICE_TIME
-clbgoal LONG -notification TRUE
Related Topics
Configuring OCI Clients to use Transaction Guard
OCI supports FAN messages and Transaction Guard. FAN is designed to quickly notify an OCI-based application of outages at the node, database, instance, service, and public network levels.
Once notified of the failure, an application can leverage Transaction Guard to reliably determine the outcome of the last in-flight transaction.
Transaction Guard avoids the costs of ambiguous errors that lead to user frustration, customer support calls, and lost opportunities. Transaction Guard is safer and performs better, with lower overheads, than home grown solutions for a known outcome.
Related Topics
Enabling ODP.NET Clients to Receive FAN High Availability Events
ODP.NET connection pools can subscribe to FAN HA notifications that indicate when nodes, services, and service members are down.
After a DOWN event, Oracle AI Database cleans up sessions in the connection pool that go to the instance and ODP.NET proactively removes connections that are no longer valid. ODP.NET establishes additional connections to existing Oracle RAC instances if the removal of invalid connections reduces the total number of connections to below the value for the Min Pool Size parameter.
When connecting to Oracle AI Database, ODP.NET uses Oracle Notification Service, rather than Advanced Queuing.
Enable Fast Connection Failover for ODP.NET connection pools by subscribing to FAN high availability events. To enable Fast Connection Failover, include "HA Events=true" and "pooling=true" (the default value) in the connection string, as shown in the following example where user_name is the name of the database user and password is the password for that user:
con.ConnectionString =
"User Id=user_name;Password=password;Data Source=odpnet;" +
"Min Pool Size=10;Connection Lifetime=120;Connection Timeout=60;" +
"HA Events=true;Incr Pool Size=5;Decr Pool Size=2";
Related Topics
Enabling ODP.NET Clients to Receive FAN Load Balancing Advisory Events
When connecting to Oracle AI Database, ODP.NET uses Oracle Notification Service, rather than Advanced Queuing.
Use the following procedure to enable ODP.NET clients or applications to receive FAN load balancing advisory events:
Enable Oracle Notification Service notifications by using SRVCTL, and set the run-time load balancing goal, as shown in the following example:
$ srvctl modify service -db crm -service odpapp.example.com -notification TRUE -clbgoal LONG -rlbgoal SERVICE_TIME- Ensure Oracle Notification Service (ONS) is configured for FAN events including run-time load balancing advice.
To take advantage of load balancing events with ODP.NET connection pools, set the load balancing attribute in the ConnectionString to
TRUE(the default isFALSE). You can do this at connect time. This only works if you are using connection pools, or when the pooling attribute is set toTRUEwhich is the default.The following example demonstrates how to configure the ConnectionString to enable load balancing, where
user_nameis the name of the user andpasswordis the password:con.ConnectionString = "User Id=user_name;Password=password;Data Source=odpapp;" + "Min Pool Size=10;Connection Lifetime=120;Connection Timeout=60;" + "Load Balancing=true;Incr Pool Size=5;Decr Pool Size=2";
Note:
ODP.NET does not support connection redistribution when a node starts (UP events). However, if you have enabled failover on the server-side, then ODP.NET can migrate connections to newly available instances.
Related Topics
- srvctl modify service
- Oracle Data Provider for .NET Developer's Guide
- Fast Application Notification (FAN)
Configuring ODP.NET Clients to use Transaction Guard
ODP.NET supports FAN messages and Transaction Guard. FAN is designed to quickly notify an ODP.NET-based application of outages at the node, database, instance, service, and public network levels.
Once notified of the failure, an application can leverage Transaction Guard to reliably determine the outcome of the last in-flight transaction.
Transaction Guard avoids the costs of ambiguous errors that lead to user frustration, customer support calls, and lost opportunities. Transaction Guard is safer and performs better, with lower overheads, than home grown solutions for a known outcome.
Related Topics