How to Synchronize Physical Standby Database Using Service
Primary DB Unique Name: ORCL1PP
Standby DB Unique Name: ORCL1PS
Step1: Place the physical standby database in MOUNT mode
If Active Dataguard is Used
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
SQL> STARTUP MOUNT;
Step2: Stop Managed Recovery Process
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Or if Broker is configured
DGMGRL> edit database 'ORCL1PS' set STATE='APPLY-OFF' ;
Step3: Connect to Standby database over Service
rman target SYS/<password>@ORCL1PS
connected to target database: ORCL1PS (DBID=4165840403, not open)
connected to target database: ORCL1PS (DBID=4165840403, not open)
Step4: Recover From Primary Database Service
RMAN> recover database from service "ORCL1PP" noredo using compressed backupset;
Starting recover at 06-JUL-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=318 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=630 device type=DISK
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ORCL1PP
destination for restore of datafile 00001: /u01/oradata/ORCL1P/DBFILE/SYSTEM_01.DBF
channel ORA_DISK_2: starting incremental datafile backup set restore
channel ORA_DISK_2: using compressed network backup set from service ORCL1PP
destination for restore of datafile 00002: /u01/oradata/ORCL1P/DBFILE/PDBSEED/SYSTEM_01.DBF
channel ORA_DISK_2: restore complete, elapsed time: 00:00:08
.....................
.....................
.....................
channel ORA_DISK_1: using compressed network backup set from service ORCL1PP
destination for restore of datafile 00012: /u01/oradata/ORCL1P/DBFILE/PDB01/TOOLS_01.DBF
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_DISK_2: restore complete, elapsed time: 00:03:17
Finished recover at 06-JUL-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=318 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=630 device type=DISK
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ORCL1PP
destination for restore of datafile 00001: /u01/oradata/ORCL1P/DBFILE/SYSTEM_01.DBF
channel ORA_DISK_2: starting incremental datafile backup set restore
channel ORA_DISK_2: using compressed network backup set from service ORCL1PP
destination for restore of datafile 00002: /u01/oradata/ORCL1P/DBFILE/PDBSEED/SYSTEM_01.DBF
channel ORA_DISK_2: restore complete, elapsed time: 00:00:08
.....................
.....................
.....................
channel ORA_DISK_1: using compressed network backup set from service ORCL1PP
destination for restore of datafile 00012: /u01/oradata/ORCL1P/DBFILE/PDB01/TOOLS_01.DBF
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_DISK_2: restore complete, elapsed time: 00:03:17
Finished recover at 06-JUL-20
Step5: Compare Primary and Standby datafile SCN for each datafile
Execute below command on Primary as well as on standby and compare the SCN for each datafile.
SQL>set line 200
SQL>col SUBSTR(HXFNM,1,40) for a50
SQL>select HXFIL File_num,substr(HXFNM,1,40),fhscn from x$kcvfh;
SQL>col SUBSTR(HXFNM,1,40) for a50
SQL>select HXFIL File_num,substr(HXFNM,1,40),fhscn from x$kcvfh;
At this point the datafiles are synchronized and as we know standby control file still do not have this information and therefore it also has to be synchronized.
Step6: Refresh standby controlfile from the primary
rman target SYS/<password>@ORCL1PS
RMAN> shutdown immediate;
database dismounted
Oracle instance shut down
Oracle instance shut down
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Oracle instance started
Total System Global Area 3221225472 bytes
Fixed Size 3078416 bytes
Variable Size 654313200 bytes
Database Buffers 2558525440 bytes
Redo Buffers 5308416 bytes
Variable Size 654313200 bytes
Database Buffers 2558525440 bytes
Redo Buffers 5308416 bytes
RMAN> restore standby controlfile from service "ORCL1PP" ;
Starting restore at 06-JUL-20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=312 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=619 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: using network backup set from service ORCL1PP
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:08
output file name=/u01/oradata/ORCL1P/CONTROL/CONTROL_01.CTL
output file name=/u01/oradata/ORCL1P/CONTROL/CONTROL_02.CTL
output file name=/u01/oradata/ORCL1P/CONTROL/CONTROL_03.CTL
Finished restore at 06-JUL-20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=312 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=619 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: using network backup set from service ORCL1PP
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:08
output file name=/u01/oradata/ORCL1P/CONTROL/CONTROL_01.CTL
output file name=/u01/oradata/ORCL1P/CONTROL/CONTROL_02.CTL
output file name=/u01/oradata/ORCL1P/CONTROL/CONTROL_03.CTL
Finished restore at 06-JUL-20
RMAN> alter database mount;
Statement processed
released channel: ORA_DISK_1
released channel: ORA_DISK_2
Statement processed
released channel: ORA_DISK_1
released channel: ORA_DISK_2
Step7: Validate Datafile name
Since we have restored the controlfile from primary database, it got the datafile name from Primary only and if the directory structure between Primary and standby is different between the standby and primary databases or if you are using Oracle managed file names OMF, you need to rename it accordingly.
catalog the STANDBY datafiles with RMAN to execute the rename operation.
NOTE: If the primary and standby have identical structure and datafile names, this step can be skipped.
RMAN> report schema;
To keep the blog cleaner and readable I have omitted the output of the command
........
........
RMAN> catalog start with '/u01/oradata/ORCL1P';
Switch Datafile to Copy
Switch to the cataloged datafile copy.
RMAN> SWITCH DATABASE TO COPY;
Step8: Start Recovery
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Only If Oracle Active Data Guard in Use
SQL> ALTER DATABASE OPEN READ ONLY;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Optionally
On the primary database, switch the archived redo log files using the following command:
SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
Comments
Post a Comment