You are on page 1of 4

4/10/2017 Document 2060572.

How To Failover and Flashback a Physical Standby for testing without recreating broker
configuration and database (Doc ID 2060572.1)

In this Document

Goal
Solution
References

APPLIES TO:

Oracle Database - Enterprise Edition - Version 11.2.0.1 to 11.2.0.4 [Release 11.2]


Information in this document applies to any platform.

GOAL

For testing purpose it may be needed to execute a failover to a physical standby in a data guard environment.
This may be required, for example, to test the disaster recovery procedure so it should be as similar as possible to a real
situation.
After failover via dg broker the standby database, promoted to a read write primary, will be used to test applications.
After all the testing, the activated standby should be recreated from the "real" primary.
Since it may be time consuming and some work may be avoided, these steps may be used to recreate the DR enviroment.
It's fundamental that primary and standby site are isolated during test.
For a similar scenario without dg broker note 805438.1 may be used.

There are also two alternative ways to test a failover:


The reinstate option to convert the old primary to standby and in case switch back roles
Add an additional Physical Standby Database for Failover Tests to ensure DR at any Time

SOLUTION

The following test enviroment was used:

DGMGRL> show configuration

Configuration - V112CONF

Protection Mode: MaxPerformance


Databases:
V112NEW - Primary database
V112 - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

All connections via sqlplus are executed as : sqlplus /as sysdba


All connections via broker are executed as : dgmgrl /

The basic steps are:

V112 and V112NEW will be isolated


V112 will be converted to primary using failover command
V112 will be used for testing
V112 will be converted back to physical standby
Connectivity between V112 and V112NEW will be re-established

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=ooymh0edf_297&id=2060572.1 1/4
4/10/2017 Document 2060572.1

V112 will be re-added as Physical standby to DG Broker configuration

Step 1 - In Standby database


-----------------------------------
A) Set up a flash recovery area.
If it's not configured in the standby then enable it and make sure to give enough space for to FRA:

SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE=5G;


SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST='/u01/oracle/flashback';

B) Cancel Redo Apply and create a guarantee restore point:

DGMGRL> edit database 'V112' set state='APPLY-OFF';


SQL> create restore point pre_fail guarantee flashback database;
SQL> select * from v$restore_point;
DGMGRL> edit database 'V112' set state='APPLY-ON';

C) Change CommunicationTimeout (default 180 sec)


This step is optional and is only needed to reduce waits while primary and standby are isolated.
Check its value before changing it.

DGMGRL> EDIT CONFIGURATION SET PROPERTY 'CommunicationTimeout'='20';

Step 2 - In Primary Database


-----------------------------------
A) On the primary database, switch logs so the SCN of the restore point will be archived on the physical standby database.
When using standby redo log files, this step is essential to ensure the database can be properly flashed back to the
restore point.

SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;

Step 3 - In Standby database


-----------------------------------
A) Isolate standby/primary and primary/standby
For example bring down server nics on DR site:

ifconfig eth0 down


ifconfig eth1 down

Step 4 - In Primary Database


-----------------------------------
A) From dgmgrl disable standby database:

DGMGRL> disable database 'V112'

Step 5 - In Standby database


-----------------------------------
A) Take a backup of parameter file before failover.
Executing the failover, the dgmgrl utility will change parameters in spfile. The copy
of spfile is needed to have the same configuration file when the database V112 will be
converted back to physical standby.

SQL> create pfile='/u01/app/oracle/product/11.2.0/dbs/prefail.txt' from spfile;

B) Execute failover:
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=ooymh0edf_297&id=2060572.1 2/4
4/10/2017 Document 2060572.1

DGMGRL> failover to 'V112'

C) Open and execute tests on standby database just converted to primary:

For example create a table:

SQL> create table fail as select * from all_objects;

D) Once tests are ended, revert the active standby database back to Physical standby database:

SQL> shut abort

E) Remove broker configuration files (dg_broker_config_file1 and dg_broker_config_file2) at OS level


These files will be automatically recreated when the standby database will be enabled.

For example :

rm /u02/data/V112/dr1mfg.dat
rm /u02/data/V112/dr2mfg.dat

F) Recreate saved spfile and flashback the standby database:

SQL> startup mount pfile='/u01/app/oracle/product/11.2.0/dbs/prefail.txt'


SQL> create spfile from pfile='/u01/app/oracle/product/11.2.0/dbs/prefail.txt';

If pfile is placed on an ASM Disk Group, consider these steps to modify new spfile location:
SQL> create spfile='+DATA' from pfile ='/u01/app/oracle/product/11.2.0/dbs/prefail.txt';
srvctl modify database -d V112 -p +DATA/V112/PARAMETERFILE/spfile.XXX.YYYYYYYYY
srvctl config database -d V112
If present, modify init<SID>.ora (initV112.ora) under OH/dbs/ to point to new spfile.

SQL> startup mount force


SQL> alter system set dg_broker_start=false;
SQL> flashback database to restore point pre_fail;

G) Convert to Standby database

SQL> alter database convert to physical standby;


SQL> startup mount force

H) Re-enable connectivity between standby/primary and primary/standby

ifconfig eth0 up
ifconfig eth1 up

I) Re-enable broker and drop restore point

SQL> alter system set dg_broker_start=true;


SQL> drop RESTORE POINT pre_fail;

Step 6 - In Primary Database


-----------------------------------
A) Re-enable the standby database

DGMGRL> enable database 'V112'


https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=ooymh0edf_297&id=2060572.1 3/4
4/10/2017 Document 2060572.1

Enabling the database through the broker will force the recreation of broker configuration files on
the standby site. Only dg_broker_config_file1 may be created.
Execute the following step B, even if the CommunicationTimeout wasn't changed. This will force a configuration change
and the second broker configuration file (/u02/data/V112/dr2mfg.dat) will be recreated on standby site.

B) Restore CommunicationTimeout to previous value:

DGMGRL> EDIT CONFIGURATION SET PROPERTY 'CommunicationTimeout'='180';

For RAC databases additional steps are to be considered.


For example only one instance must be up during flashback or convert commands.

REFERENCES

NOTE:805438.1 - How To Open Physical Standby For Read Write Testing and Flashback
NOTE:838249.1 - Physical Standby Read/Write Testing With Belated Flashback Database
Didn't find what you are looking for?

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=ooymh0edf_297&id=2060572.1 4/4

You might also like