Transparent Application Fail over in Oracle RAC Environment

Transparent Application Fail over in Oracle RAC Environment

TAF support application to automatically reconnect for established session to the service if connection failed.
Suppose if select statement is running on instance 1 then instance 1 failed then TAF establish connection with another instance 2 and provide output to user with some delay. User donot know about anything happened in background.
Note: When FAN (Fast Application) is used, then no need to configure TAF.

TAF is having two Failover Methods:
Basic :- In Basic, Connection is established with instance 1, if instance 1 failed then Net Services reconnect the current application session to another available instance 2.
If any transaction is running on instance 1 then its rollback and select query transfer to on another instance 2 without the knowledge to end user. But in this end user may feel delayed due to connection re established.

PRECONNECT :- In Preconneect method, TAF make two connection for each session, one as primary & second is backup connection also called shadow connection.
If primary instance failed then application session connected with instance 2. If select is running on instance 1 then it failed, then select query is run on instance 2. without the knowledge of end user. In this no delay because connection is already established. It only switch to secondary connection.

TAF configured by two ways:
1. Client side in tnsnames.ora
2. Server side using srvctl utility

BASIC Method
In case connection failed then new connection is established with other available instance then SELECT statement is executed to another instance, customer faced some delay in output.
Server Side Configuration for BASIC Method

srvctl add service -db orcl -service AP -failovermethod BASIC -failovertype SELECT -failoverretry 20 -failoverdelay 5 -preferred ORCL1 -available ORCL2

2. Check the service configuration

srvctl config service -db orcl -service AP

3. Make an entry of Service AP in tnsnames.ora

AP = (DESCRIPTION =
(ADDRESS=(PROTOCOL=tcp)(HOST=rac-scan.oracle.com)(port=1521))
(connect_data=
(SERVICE_NAME=ap)))

Client Side Configuration for BASIC Method:
For configure at client Side, Need to make an entry in tnsnames.ora file as follows:

ORCL_TAF=
(DESCRIPTION =(FAILOVER=ON)(LOAD_BALANCE=ON)
(ADDRESS=(PROTOCOL=tcp)(HOST=rac-scan.oracle.com)(port=1521))
(connect_data=
(SERVICE_NAME=ORCL)
(FAILOVER_MODE=(TYPE=SESSION)
(METHOD=BASIC)
(RETRIES=20)
(DELAY=5))
))

Note: Failover is two value: SELECT / SESSION. Check the bold parameter carefully.
 
Verify the session from GV$session:

select inst_id,username,machine,failover_method,failover_type,failed_over,Service_name
from gv$session where username='SCOTT';

PRECONNECT Method
Established connection with primary instance and second connection automatic established with backup instance. It is configured with client side only.
In this we need to configure the two services
Client Side Configuration
In this we need to configure the two services, one with preferred
node as primary node and available as backup node and in second service we make opposite
preferred node as backup node and available as primary node in step 1.
1. Step add two services:

srvctl add service -db orcl -service AP -preferred orcl1 -available orcl2
srvclt add service -db orcl -service AP_PRECONNECT -preferred orcl2 -available orcl1

2. Start the services:

srvctl start service -db orcl -service AP
srvclt start service -db orcl -service AP_PRECONNECT

3. Status of the service

srvctl status service -db orcl -service AP
srvclt status service -db orcl -service AP_PRECONNECT

4. In TNSNAMES.ORA make the following two entries and mention BACKUP parameter or making second connection at same time when end user tried to make connection. Two connection is established on one request One is primary and second is shadow of first one.

AP =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=rac-scan.oracle.com)(port=1521))
(CONNECT_DATA=
(SERVICE_NAME=ap.oracle.com)
(FAILOVER_MODE=(BACKUP=AP_PRECONNECT)(TYPE=SELECT)(METHOD=PRECONNECT))
)
)

AP_PRECONNECT =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=rac-scan.oracle.com)(port=1521))
(CONNECT_DATA=
(SERVICE_NAME=ap_preconnect.oracle.com)
(FAILOVER_MODE=(BACKUP=AP)(TYPE=SELECT)(METHOD=PRECONNECT))
)
)

Note: Check bold parameter carefully.
 
Verify the session from GV$session:

select inst_id,username,machine,failover_method,failover_type,failed_over,Service_name
from gv$session where username='SCOTT';

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.