Oracle FAN with Oracle Data Guard but without using Oracle Grid/ RAC

1.2k views Asked by At

Is it possible for a JDBC application to receive Fast Application Notification (FAN) from an Oracle Data Guard broker when a SWITCHOVER happens from a primary to a secondary database, so that the application can reconnect without Oracle RAC/ cluster? That is, I have just got a single instance database on the primary site and a similar setup on the secondary site, and I want my Java based application to detect and reconnect in case of FAILOVER/ SWITCHOVER.

Based on what I know about FAN, it depends on Oracle Notification Service, which indirectly means Oracle RAC/ Grid. Is this understanding correct? Oracle Data Guard, by itself, doesn't require either Oracle RAC or Oracle Grid.

If FAN is not available, what are the options for an application to get the connection to the new primary without requiring a restart?

1

There are 1 answers

0
Jaywalker On BEST ANSWER

You need either Oracle Grid or Oracle RAC. It cannot be configured with a simple Oracle Data Guard set up with single instance non-RAC databases.

Client failover

There are two things that we need to consider for client failover:

  1. Detecting database failover
  2. Reconnecting with the new primary

Detecting database failover

FAN mainly helps with the first point. Without FAN, the application would have to rely on database connection errors to detect that the database has failed (or no longer the primary database). This could happen in three different ways:

  1. While establishing a new connection, the application would fail to connect with a failed database. If it was a SWITCHOVER, the application will also fail to establish a connection with a standby database with (plain) Oracle Data Guard. For Active Oracle Data Guard, it will fail to open up a connection unless its in read-only mode.

  2. An existing connection which is already closed from the database side would throw an error. The application needs to catch this error and respond accordingly.

  3. If the connection is still valid (for some reason), and the database is no longer available to respond (as it has failed), the application has to rely on TCP/ IP timeouts and OS level handling of sockets. For this, Oracle recommends that you tune the timeouts at the kernel level.

Once you detect connection failure, your application should be capable of creating a new connection to the database. This connection should be established with the new primary, as explained next.

Reconnecting with the new primary

Whether you use FAN or not, you can specify an address list (instead of a single database) in your connection string. This allows you to use a single connection string for multiple databases and can help you with Oracle Data Guard failover scenarios as well. A sample connection string for JDBC with multiple addresses is given below:

jdbc:oracle:thin:<userid>/<pwd>@(DESCRIPTION_LIST=
(LOAD_BALANCE=off)(FAILOVER=on)
(DESCRIPTION=
   (CONNECT_TIMEOUT=6)(TRANSPORT_CONNECT_TIMEOUT=3)(RETRY_COUNT=2)
   (ADDRESS_LIST=   
      (LOAD_BALANCE=on)
      (ADDRESS=(PROTOCOL=TCP)(HOST=<primary-host-name>)(PORT=<port>))
   )
   (CONNECT_DATA=(SERVICE_NAME=<dbServiceNameOnPrimary>))
)
(DESCRIPTION=
   (CONNECT_TIMEOUT=6)(TRANSPORT_CONNECT_TIMEOUT=3)(RETRY_COUNT=2)
   (ADDRESS_LIST=
   (LOAD_BALANCE=on)
      (ADDRESS=(PROTOCOL=TCP)(HOST=<standby-host-name>)(PORT=<port>))
   )
   (CONNECT_DATA=(SERVICE_NAME=<dbServiceNameOnStandby>))
))

Source: Client Failover Best Practices for Highly Available Oracle Databases (pdf)