Steps to convert Physical Standby database to Snapshot Standby database in oracle 12c
What is snapshot standby and its Benefits?
A snapshot standby database is a fully updatable standby database that is created by converting a physical standby database into a snapshot standby database. A snapshot standby database receives and archives, but does not apply, redo data from a primary database. Redo data received from the primary database is applied when a snapshot standby database is converted back into a physical standby database, after discarding all local updates to the snapshot standby database.
A snapshot standby database typically diverges from its primary database over time because redo data from the primary database is not applied as it is received. Local updates to the snapshot standby database will cause additional divergence. The data in the primary database is fully protected, however, because a snapshot standby can be converted back into a physical standby database at any time, and the redo data received from the primary will then be applied.
A snapshot standby database provides disaster recovery and data protection benefits that are similar to those of a physical standby database. Snapshot standby databases are best used in scenarios where the benefit of having a temporary, updatable snapshot of the primary database justifies additional administrative complexity and increased time to recover from primary database failures.
Steps to perform Snapshot database conversion.
Step-1: Validate the standby database health.
Step-2: Convert from physical to snapshot standby.
Step-3: Handover the database to the Application team to test the functionality.
Step-4: Convert from snapshot to physical standby.
Step-5: Post converts to physical standby steps.
Step-1: Validate the standby lag status if any
====last log applied and received along with log time on Standby database===
SELECT 'Last Applied : ' Logs,
TO_CHAR (next_time, 'DD-MON-YY:HH24:MI:SS') Time
FROM gv$archived_log
WHERE sequence# = (SELECT MAX (sequence#)
FROM v$archived_log
WHERE applied = 'YES')
UNION
SELECT 'Last Received : ' Logs,
TO_CHAR (next_time, 'DD-MON-YY:HH24:MI:SS') Time
FROM gv$archived_log
WHERE sequence# = (SELECT MAX (sequence#) FROM v$archived_log);
===== Last sequence # received and applied on the standby database =====
SELECT al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
FROM ( SELECT thread# thrd, MAX (sequence#) almax
FROM gv$archived_log
WHERE resetlogs_change# = ( SELECT resetlogs_change# FROM v$database)
GROUP BY thread#) al,
( SELECT thread# thrd, MAX (sequence#) lhmax
FROM gv$log_history
WHERE first_time = ( SELECT MAX (first_time) FROM v$log_history)
GROUP BY thread#) lh
WHERE al.thrd = lh.thrd;
=== Validate the standby instances status =====
$ srvctl status database -d STND12 -v
Step-2: Convert from physical to snapshot standby
Shutdown the physical standby and startup in the mount to convert it to snapshot standby
$srvctl stop database -d STND12
$srvctl start database -d STND12 -o mount
== Validating the status of the standby database ==
srvctl status database -d STND12 -v
== Run the command to convert the physical to snapshot standby ==
Sqlplus / as sysdba
SYS@STND121 > alter database convert to snapshot standby;
Database altered.
SYS@STND121 > alter database open;
Database altered.
SYS@STND121 > select database_role,open_mode from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
SNAPSHOT STANDBY READ WRITE
Note: Make sure you should OPEN the other all instances in READ-WRITE mode either by shutting down the standby database using SRVCTL
You could additionally validate the restore point that oracle has automatically created during the snapshot standby database conversion.
SYS@STND121 > select NAME,GUARANTEE_FLASHBACK_DATABASE from v$restore_point;
Step-3: Handover the database to Application team to test the functionality
Step-4: Convert from snapshot to physical standby
== Shutdown the snapshot standby and startup in the mount to convert it to physical standby==
$srvctl stop database -d STND12
$srvctl start instance -i STND121 -d STND12 -o mount
Note: Please start only instance-1 to avoid the error “ORA-38777: database must not be started in any other instance”
Validating the status of the snapshot standby database to make sure only one instance is currently running
$ srvctl status database -d STND12
== Run the command to convert Snapshot to Physical standby database ==
SYS@STND121 > alter database convert to physical standby;
Database altered.
SYS@STND121 > select database_role from v$database;
DATABASE_ROLE
-------------------------
PHYSICAL STANDBY
Stop and startup the physical standby database into Active standby database role (ReadOnly)
$srvctl stop database -d STND12
$srvctl start database -d STND12
SYS@STND121 > alter database recover managed standby database disconnect nodelay;
Database altered.
Validate logs are applying on the standby database
====last log applied and received along with log time on Standby database===
SELECT 'Last Applied : ' Logs,
TO_CHAR (next_time, 'DD-MON-YY:HH24:MI:SS') Time
FROM gv$archived_log
WHERE sequence# = (SELECT MAX (sequence#)
FROM v$archived_log
WHERE applied = 'YES')
UNION
SELECT 'Last Received : ' Logs,
TO_CHAR (next_time, 'DD-MON-YY:HH24:MI:SS') Time
FROM gv$archived_log
WHERE sequence# = (SELECT MAX (sequence#) FROM v$archived_log);
==== Last sequence # received and applied on the standby database ===
SELECT al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
FROM ( SELECT thread# thrd, MAX (sequence#) almax
FROM gv$archived_log
WHERE resetlogs_change# = ( SELECT resetlogs_change# FROM v$database)
GROUP BY thread#) al,
( SELECT thread# thrd, MAX (sequence#) lhmax
FROM gv$log_history
WHERE first_time = ( SELECT MAX (first_time) FROM v$log_history)
GROUP BY thread#) lh
WHERE al.thrd = lh.thrd;
Step-5: Post convert to physical standby steps
=== Disable Flashback on the standby database ===
SYS@STND121 > alter database flashback off;
Database altered.
== Validate the database alert log files on both the primary and standby databases if any errors ==
Additional consideration before converting a Physical standby database to the Snapshot database.
1. Consider disabling archive log deletion jobs on Primary and Standby
2. Consider disabling backup jobs running on the standby database
3. disable the alerting on the standby database to avoid any incidents
Comments
Post a Comment