If you don’t want to deal with missteps, I recommend that you test your standby database to facilitate the failover or switchover process.
This procedure is very useful when you have physical standby databases for testing and other purposes that require read-write access to the standby database. Also, it improves your checklist in the event of an error or disaster.
By using Snapshot standby databases, redo data is not applied until you convert the snapshot standby database back into a physical standby database, and after all local updates to the snapshot standby database are discarded.
Requirements
The following requirements need to be met in order to create a snapshot standby.
- The Data Guard environment (a primary and a physical standby) needs to be Oracle 10.2.0.1 version or higher.
- The Primary and Standby databases need to be in archivelog mode (this is a default requirement for Data Guard).
- Force logging should be set to
TRUE
(to avoid no-logging operations). - Flash Recovery Area (FRA) is required on the standby database to implement a Flashback database.
- The Primary and standby are in sync at the time of the test, or the gap between primary and physical standby is nominal.
Activation of the standby
On the standby database
- Stop dataguard brokers on standby:
SQL> alter system set dg_broker_start=FALSE;
- Get the SCN
SQL> select current_scn from v$database;
- Cancel the managed recovery:
SQL> alter database recover managed standby database cancel;
- Create the restore point.A restore point can be specified such that it guarantees the database can be recovered to a particular point-in-time and eliminates the need to manually record an SCN or timestamp to use with the Flashback database and Flashback table operations:
SQL> create restore point TEST_NEW_FEATURE guarantee flashback database;
- Now confirm the scn from restore point:
SQL> col name form a40; SQL> select scn, time, name from v$restore_point where name = 'TEST_NEW_FEATURE';
Prepare the primary
- Archive logsWhen using the standby redo logs, this step is essential to ensure that the database can be properly flashed back to the restore point.
SQL> alter system archive log current; SQL> alter system switch logfile; SQL> alter system switch logfile;
- Stop shipment of logs
SQL> alter system set log_archive_dest_state_2=DEFER
Activate the Physical Standby
- Activation of the standby:
SQL> alter database activate standby database; SQL> startup mount force; SQL> alter database set standby database to maximize performance; (This is used in case you have not set it before) SQL> alter database open;
- disable
log_archive_dest_2
(this will prevent archive logs being sent to primary):SQL> alter system set log_archive_dest_state_2=DISABLE;
Time for testing
Once the standby database has been activated, it is a full-blown production system. You may run reports, test new code, or create objects. Remember that any results stored in the activated database will be lost when the database is flashed back to before activation time.. If you need to save the results, they must be copied or exported out of the activated database before flashing it back.
Revert the snapshot database to physical standby
After testing is completed, you need to resynchronize the activated database with the primary database.
- Flashback to the restore point:
SQL> STARTUP MOUNT FORCE; SQL> FLASHBACK DATABASE TO RESTORE POINT TEST_NEW_FEATURE; SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY; SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE; SQL> STARTUP MOUNT FORCE;
- Re-enable log shipping on the primaryEnable shipment:
SQL> alter system set log_archive_dest_state_2=ENABLE
- To re-enable log shipping on the standby, enable this parameter:
SQL> alter system set log_archive_dest_state_2=ENABLE
- Check dgmgrl configurationDGMGRL> show configuration verbose;
Current status for “xxx”:
SUCCESS
DGMGRL> enable configuration (if not success)
A status of data guard configuration successful indicates the success of the procedures.
On Oracle Database 11g, you can use the Data Guard command-line interface (DGMGRL), Oracle Active Data Guard, and the OEM interface. In my next blog I’ll describe the equivalent procedures on 11g.
5 Comments. Leave new
Don’t forget to drop the restore point at the end, or your FRA will fill up as it continues flashback logging.
Thank you Don for the remind. It has to be done on the following step:
1. Flashback to the restore point:
SQL> STARTUP MOUNT FORCE;
SQL> FLASHBACK DATABASE TO RESTORE POINT TEST_NEW_FEATURE;
SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE;
SQL> STARTUP MOUNT FORCE;
SQL> DROP RESTORE POINT TEST_NEW_FEATURE;
Are you able to create the configuration as above in 11g with dgmgrl and can share
Great Work and excellent presentation to utilize the feature which otherwise people like me don’t realize it
@Sanhay:
In 11.1 and later you can use the snapshot standby to achieve the same without knowing about the details.
It has the added advantage that additional standby databases don’t start receiving archived logs from the newly activated standby.
Cheers,
Martin
Hi Sanhay and Martin.
Both options are valid for 11G and later. Just keep in mind that they require Enterprise Edition version.
“A snapshot standby database is a fully update-able standby database that is created by converting a physical standby database into a snapshot standby database.
A snapshot Standby is open in the read-write mode and hence it is possible to process transactions independently of the primary database. At the same time, it maintains protection by continuing to receive data from the production database, archiving it for later use.
Using a single command changes made while read-write mode can be discarded and quickly resynchronize the standby with the primary database.” Met.note [ID 443720.1]
I haven’t tested the snapshot standby. Will do and consider creating a blog about it.