Practice Implement Client Failover

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Practice 10: Implement Client Failover | page: 1

Practice Implement Client Failover


Title

Purpose In this practice we will enable the automatic client failover on a SQL*Plus
client session.

Software Oracle database version 12.1.0.2 on Oracle Linux 6.7 64-bit.


version

Document 1.1, Aug-2016


version

Required VirtualBox Appliance


Software
The practice has been implemented on an Oracle virtual appliances that have
/ Files
been in practice number 8. We named that practice “Practice 8 Enabling
Fast-Start Failover”.

Hardware About 85 GB is required for the appliances used in this practice.

Oracle 12c Data Guard Administration Course by Ahmed Baraka


Practice 10: Implement Client Failover | page: 2

Data Guard Configuration Specifications

Protection Mode Maximum Performance

fast-start failover Enabled

The management interface Broker

Standby Database Type Physical Standby

Standby Database Unique Name ORADB_S2

Standby Database Hostname srv2

Oracle 12c Data Guard Administration Course by Ahmed Baraka


Practice 10: Implement Client Failover | page: 3

The Practice Overview


The Practice Environment
• You will work on the appliances that was created in the “Practice 8 Fast-Start
Failover”.

Configure Client Failover


• Create a database service.
• Configure the client failover in tnsnames.ora and sqlnet.ora files

• Test the automatic failover in the SQL*Plus session

Oracle 12c Data Guard Administration Course by Ahmed Baraka


Practice 10: Implement Client Failover | page: 4

Enable TAF Configuration

Get the Environment Ready

1. Make a copy of the folder “Practice 8 Fast-Start Failover”. Give the new folder the name “Practice
10 Client Failover”.

2. In VirtualBox open the two appliances in the copied folder.

3. Start the appliances.

4. Make sure the databases in the two appliances are up and running.

5. For the standby database, it has been configured to get started in MOUNT mode by default. You need
to change that and configure it to start in Read-Write mode so that the Real-time Query will be
enabled by default when we start the Apply process.
# first make sure the database is up and running:
srvctl status database -d oradb_s2

# now, update its STARTUP mode:


srvctl update database -db ORADB_S2 -startoption OPEN

6. Start the redo apply


dgmgrl sys/oracle@oradb
edit database oradb_s2 set state=apply-on;

7. Start the Observer in the standby machine (SRV2).


# on srv2:
dgmgrl sys/oracle@oradb_s2
START OBSERVER FILE='/home/oracle/ORADBFSFO.dat';

8. Check on the Broker configuration health. Make sure the Real-Time Query is enabled.
show configuration
show database oradb
show database oradb_s2

9. Start monitoring sessions to the alert log files and the Broker logfile.
tail -f /u01/app/oracle/diag/rdbms/oradb/ORADB/trace/alert_ORADB.log
tail -f /u01/app/oracle/diag/rdbms/oradb/ORADB/trace/drcORADB.log

# on srv2
tail -f /u01/app/oracle/diag/rdbms/oradb_s2/ORADB_S2/trace/alert_ORADB_S2.log

Oracle 12c Data Guard Administration Course by Ahmed Baraka


Practice 10: Implement Client Failover | page: 5

Configure Client Failover

10. Create a database service of the primary and standby databases.


# srv1
srvctl add service -db oradb -service oradbsrvc -role PRIMARY -notification TRUE -failovermethod
BASIC -failoverdelay 3 -failoverretry 120 -failovertype SELECT
srvctl start service -service oradbsrvc -db oradb

#srv2
srvctl add service -db oradb_s2 -service oradbsrvc -role PRIMARY -notification TRUE -
failovermethod BASIC -failoverdelay 3 -failoverretry 120 -failovertype SELECT

11. Verify the created services.


sqlplus sys/oracle@oradb as sysdba
select name from dba_services ;

conn sys/oracle@oradb_s2 as sysdba


select name from dba_services ;

12. Configure the tnsnames.ora file of the client. I will use a SQL*Plus installed locally in the host
machine. If you do not have Oracle installed on the host machine, you can use the sqlplus utility in
srv2 as a client.
vi $TNS_ADMIN/tnsnames.ora
ORADB=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.124)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=ORADB.localdomain)))

ORADB_S2=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.125)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=ORADB_S2.localdomain)))

ORADBSRVC=
(DESCRIPTION=
(FAILOVER=on)
(CONNECT_TIMEOUT=5)(TRANSPORT_CONNECT_TIMEOUT=3)
(RETRY_COUNT=3)
(ADDRESS_LIST=
(LOAD_BALANCE=off)
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.124)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.125)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME= oradbsrvc.localdomain))
)

Oracle 12c Data Guard Administration Course by Ahmed Baraka


Practice 10: Implement Client Failover | page: 6

13. Test the new naming alias added to the tnsnames.ora file.
sqlplus system/oracle@oradbsrvc

14. In the client side, add the following line to the sqlnet.ora file
SQLNET.OUTBOUND_CONNECT_TIMEOUT=4

15. Verify which database the client is connected to.


SELECT INSTANCE_NAME FROM V$INSTANCE ;

Test the Automatic Client-Failover Configuration

16. Run a query in the client sqlplus window that will take minutes to retrieve all its rows. Following is an
example:
select x.employee_id from hr.employees x, hr.employees y, hr.employees z;

17. Login to the primary database and abort it


sqlplus sys/oracle@oradb as sysdba
shutdown abort

18. Notice that the client session keeps hanging, till the observer automatically fails over to the standby.

19. In the client session, after all the rows of the query is retrieved, observe the connected instance
name:
SELECT INSTANCE_NAME FROM V$INSTANCE ;

20. Bring the primary database back up. Wait till the Observer automatically reinstates the old primary
database.
# on primary database appliance (srv1):
sqlplus / as sysdba
startup

21. Switchover to ORADB


dgmgrl sys/oracle@oradb
switchover to ORADB

22. Re-run the same query in the client session. Observe that the client has been automatically re-
connected to the new primary database without receiving any error.
SELECT INSTANCE_NAME FROM V$INSTANCE ;

Oracle 12c Data Guard Administration Course by Ahmed Baraka


Practice 10: Implement Client Failover | page: 7

Notes
• Perform the following to shutdown the databases and the appliances:

1. Stop the observer


dgmgrl sys/oracle@oradb
stop observer

2. Stop the apply process


EDIT DATABASE oradb_s2 SET STATE=APPLY-OFF;

3. Shutdown the appliances

• Those appliances will not be needed anymore for the incoming lectures.

Oracle 12c Data Guard Administration Course by Ahmed Baraka

You might also like