Skip to main content

Converting a Physical Standby Database to a Snapshot Standby: A Step-by-Step Guide

 

Converting a Physical Standby Database to a Snapshot Standby: A Step-by-Step Guide

A snapshot standby database is a powerful feature in Oracle Data Guard that allows you to temporarily convert a physical standby database into a read-write database for testing or development purposes, while preserving the ability to revert back to a synchronized physical standby later. This blog post demonstrates the step-by-step process of converting a physical standby database to a snapshot standby.

Prerequisites

  • Primary database (testpri) and physical standby database (testsby) are properly configured with Data Guard
  • Appropriate privileges to perform administrative commands
  • Log archiving is properly configured between primary and standby

The Conversion Process

Step 1: Defer Log Shipping from Primary Database

Before converting the standby database to a snapshot standby, it's a good practice to temporarily defer log shipping from the primary to avoid conflicts during the conversion process.

On the primary database (testpri):

First, check the current archive log destination configuration:

SQL> show parameter log_archive_dest_2

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2                   string      service=testsby ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testsby
SQL> show parameter log_archive_dest_state_2

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_2             string      ENABLE

Now, defer the log shipping to the standby:

SQL> alter system set log_archive_dest_state_2=DEFER;

System altered.

Step 2: Check Status and Cancel Recovery on Standby Database

On the standby database (testsby):

First, verify the current status of the standby database:

SQL> select name, open_mode, log_mode, database_role from v$database;

NAME      OPEN_MODE            LOG_MODE     DATABASE_ROLE
--------- -------------------- ------------ ----------------
TESTSBY   MOUNTED              ARCHIVELOG   PHYSICAL STANDBY
$ hostname
testsby-server

Cancel the managed standby recovery:

SQL> alter database recover managed standby database cancel;

Database altered.

Verify that recovery has been canceled:

SQL> select name, open_mode, log_mode, database_role from v$database;

NAME      OPEN_MODE            LOG_MODE     DATABASE_ROLE
--------- -------------------- ------------ ----------------
TESTSBY   MOUNTED              ARCHIVELOG   PHYSICAL STANDBY

Step 3: Convert to Snapshot Standby

Now, convert the physical standby database to a snapshot standby:

SQL> alter database convert to snapshot standby;

Database altered.

Step 4: Restart the Database

After conversion, restart the database to open it in read-write mode:

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup;
ORACLE instance started.
Database mounted.
Database opened.

Step 5: Verify Snapshot Standby Status

Confirm that the conversion to snapshot standby was successful:

SQL> select name, open_mode, log_mode, database_role from v$database;

NAME      OPEN_MODE            LOG_MODE     DATABASE_ROLE
--------- -------------------- ------------ ----------------
TESTSBY   READ WRITE           ARCHIVELOG   SNAPSHOT STANDBY

What Happens Behind the Scenes

When you convert a physical standby to a snapshot standby:

  1. Oracle creates a guaranteed restore point to mark the current state of the physical standby
  2. The database role changes from PHYSICAL STANDBY to SNAPSHOT STANDBY
  3. The database is opened in READ WRITE mode
  4. Archive logs from the primary continue to be received but are not applied
  5. When you convert back to a physical standby, Oracle will use the guaranteed restore point to flashback the database and then apply the accumulated archive logs

Benefits of Using a Snapshot Standby

  • Provides a temporary read-write copy of the production database for testing or development
  • Maintains synchronization with the primary database in the long term
  • Offers flexibility to switch between physical standby and snapshot standby as needed
  • Preserves the disaster recovery capabilities of Data Guard

Converting Back to Physical Standby

When you're ready to convert back to a physical standby:

SQL> alter database convert to physical standby;
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database recover managed standby database using current logfile disconnect;

Conclusion

Converting a physical standby database to a snapshot standby provides significant flexibility in database management, allowing for testing and development while maintaining the ability to easily return to a synchronized physical standby. By following the steps outlined in this blog post, you can effectively leverage this powerful feature of Oracle Data Guard.


Comments

Popular posts from this blog

🚀 Automating Oracle Database Patching with Ansible: A Complete Guide

Oracle database patching has long been the bane of DBAs everywhere. It's a critical task that requires precision, expertise, and often results in extended maintenance windows. What if I told you that you could automate this entire process, reducing both risk and downtime while ensuring consistency across your Oracle estate? 💡 In this comprehensive guide, I'll walk you through a production-ready Ansible playbook that completely automates Oracle patch application using OPatch. Whether you're managing a single Oracle instance or hundreds of databases across your enterprise, this solution will transform your patch management strategy! 🎯 🔥 The Challenge: Why Oracle Patching is Complex Before diving into the solution, let's understand why Oracle patching is so challenging: 🔗 Multiple dependencies : OPatch versions, Oracle Home configurations, running processes ⚠️ Risk of corruption : Incorrect patch application can render databases unusable ⏰ Downtime requirements : Da...

Oracle RAC Switchover & Switchback: Step-by-Step Guide

 Ensuring business continuity requires regular Disaster Recovery (DR) drills. This guide covers the Switchover and Switchback process between Primary (DC) and Standby (DR) databases . Pre-checks Before Performing Switchover Before starting the activity, ensure there are no active sessions in the database. If any are found, share the session details with the application team, get their confirmation, and terminate the sessions. Primary Database Name: PRIMARY Standby Database Name: STANDBY  Identify Active Sessions set lines 999 pages 999 col machine for a30 col username for a30 col program for a30 compute sum of count on report break on report select inst_id,username,osuser,machine,program,status,count(1) "count" from gv$session where inst_id=1 and program like 'JDBC%' group by inst_id,username,osuser,machine,program,status order by 1,2; select inst_id,username,osuser,machine,program,status,count(1) "count" from gv$session where inst_id=2 and program lik...

Mastering Oracle RAC with SRVCTL Commands

Oracle Real Application Clusters (RAC) provide high availability, scalability, and manageability for databases. One of the most powerful tools for managing RAC databases is srvctl , a command-line utility that allows administrators to control various database services. This blog explores essential srvctl commands to help you efficiently manage Oracle RAC environments. 1. Checking Database Configuration and Status  List all available databases on the host:                  srvctl config database   Check the status of a specific database and its instances:                    srvctl status database -d <database_name>   Retrieve detailed status information about a database, including its instances and states:                    srvctl status database -d <database_name> -v 2. Stopping and Starting Databases   ...