Practice Implement Client Failover
Practice Implement Client Failover
Practice Implement Client Failover
Purpose In this practice we will enable the automatic client failover on a SQL*Plus
client session.
1. Make a copy of the folder “Practice 8 Fast-Start Failover”. Give the new folder the name “Practice
10 Client Failover”.
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
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
#srv2
srvctl add service -db oradb_s2 -service oradbsrvc -role PRIMARY -notification TRUE -
failovermethod BASIC -failoverdelay 3 -failoverretry 120 -failovertype SELECT
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))
)
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
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;
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
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 ;
Notes
• Perform the following to shutdown the databases and the appliances:
• Those appliances will not be needed anymore for the incoming lectures.