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...

⚡ Automating Oracle 19c Database Patching on Windows Server with PowerShell

Applying Oracle patches on Windows often feels repetitive and error-prone — stopping services, updating OPatch, applying patches, running datapatch , and restarting services. To save time ⏱ and reduce mistakes ⚠, I created a PowerShell automation script that performs the patching process end-to-end 🚀. 🔹 Why Automate Oracle Patching? ⏱ Save time by automating repetitive steps ⚙ Avoid manual errors during patching 📜 Maintain logs for auditing and troubleshooting 🛡 Ensure consistent, reliable patching 🔹 Full PowerShell Script # --- CONFIGURATION --- $oracleHome = "c:\users\administrator\downloads\v982656-01" # Change if this is not your actual Oracle Home! $patchDir = "C:\Users\Administrator\Downloads\p37962957_190000_MSWIN-x86-64\37962957" #update the Patchfile directory $opatchDir = "$oracleHome\OPatch" $opatchZip = "C:\Users\Administrator\Downloads\p6880880_190000_MSWIN-x86-64.zip" #Based on your setup update Opatch di...

Installing pgBackRest on Linux (RHEL 9 / Rocky / AlmaLinux)

 When you work with PostgreSQL in real environments, one thing becomes very clear very quickly: Backups are not optional. It doesn’t matter how stable your database is — failures happen. Disks crash Files get corrupted Someone runs the wrong delete query A patch goes wrong A standby needs rebuilding. So having a proper backup strategy is not just good practice, it’s survival. That’s exactly why tools like pgBackRest are so widely used in PostgreSQL production systems. In this post, I’ll walk through a simple installation of pgBackRest on a Linux server (RHEL 9 / Rocky Linux / AlmaLinux). Why pgBackRest? PostgreSQL already provides tools like: pg_dump pg_basebackup And yes, they work. But once your database grows, or you start managing HA setups, these tools start feeling limited. pgBackRest is built for serious PostgreSQL backup requirements. Some of the reasons it stands out: Supports full, differential, and incremental backups Built-in compre...