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 19c Database Deployment with Docker

Oracle 19c Database Deployment with Docker 🐳 Oracle 19c Database Deployment with Docker Welcome to this comprehensive guide on deploying, configuring, and managing Oracle 19c Database using Docker containers. This blog will walk you through the entire process from setup to production best practices with practical code examples. Docker provides an excellent way to run Oracle databases in isolated, portable containers, making it easy to deploy and manage Oracle 19c instances for development, testing, and production environments. This approach offers numerous benefits: πŸ”’ Isolation : Run Oracle in a containerized environment without affecting your host system 🚚 Portability : Easily move your database between different environments πŸ”„ Reproducibility : Quickly spin up identical database instances ⚡ Resource Efficiency : Use Docker's resource management capabilities to control CPU, memory, and stor...

Mastering Oracle RAC with CRSCTL commands

Mastering Oracle Clusterware Administration: Essential Commands & Best Practices Oracle Clusterware is a key component for managing cluster environments, ensuring high availability and resource management for Oracle databases. Below are essential commands for managing Oracle Clusterware effectively. What is crsctl? crsctl (Cluster Ready Services Control) is a command-line utility provided by Oracle to manage Oracle Clusterware. It allows administrators to start, stop, check, and configure various aspects of cluster services. With crsctl , DBAs can control cluster resources, manage voting disks, check the status of Oracle High Availability Services, and ensure the proper functioning of Oracle RAC environments. Starting and Stopping Oracle Clusterware On Local Node Stop Clusterware: crsctl stop cluster Start Clusterware: crsctl start cluster On RAC Standalone/Oracle Restart Stop Cluster: crsctl stop has Start Cluster: crsctl start has On All Nodes or All Hub Nodes Start Clusterware:...