Rolling Forward Physical Standby Database Using Recover From Service Command

From 12C onwards Oracle has introduced a new way of rolling forward a physical standby database by using recover from service commands.

There could be a scenario where we need to roll forward a standby database from an archive log gap where the standby lags behind the primary. Our aim is to remain the standby database in sync with the primary database.

From 12C onwards we can use recover from service commands, which does the following –

  • Takes an incremental backup including all the changes to the primary database from the last SCN of the standby database.   
  • Transfers the incremental backup to the physical standby database and applies it.

For this article we will use following environments –

Primary Database:

DB_UNIQUE_NAME: TEST_PRIMARY (net service name ‘PRIM’)

Standby Database:

DB_UNIQUE_NAME: TEST_CLONE (net service name ‘CLONE’)

I am assuming the below-mentioned points are already present to the current infrastructure.

  1. There should be an entry in the tnsnames.ora file for the primary and standby to the corresponding tns files.
  2. The password file is the same as primary.
  3. The compatible parameter should be set to 12.0 at least.
  4. Standby database is in mount mode.

Stop the managed recovery processes on the physical standby database –

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Please note down the current SCN of physical standby database –

SQL> SELECT CURRENT_SCN FROM V$DATABASE;

The RECOVER … FROM SERVICE command refreshes the standby data files and rolls them forward to the same point-in-time as the primary.

$ rman target SYS/<Password>
Recovery Manager: Release 12.1.0.1.0 - Production on Wed Mar 9 18:22:52 2022
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRIM (DBID=1756755399, not open)

RMAN> recover database from service PRIM noredo using compressed backupset;

Shut down the standby database and then start it in NOMOUNT mode –

SQL> SHUTDOWN IMMEDIATE; 
SQL> STARTUP NOMOUNT;

Now restore the standby control file by using service –

RMAN> restore standby controlfile from service PRIM;

 After the successful restoration of control file, mount the database –

RMAN> alter database mount;

After that please clear the standby log files and start the MRP process in the physical standby database.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Hope this step by step approach will help you to roll forward the physical standby database using recover from service command. 


Leave a Comment

Your email address will not be published. Required fields are marked *