如何增量备份恢复dataguard中standby端的数据

32次阅读
没有评论

共计 3656 个字符,预计需要花费 10 分钟才能阅读完成。

这篇文章主要讲解了“如何增量备份恢复 dataguard 中 standby 端的数据”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着丸趣 TV 小编的思路慢慢深入,一起来研究和学习“如何增量备份恢复 dataguard 中 standby 端的数据”吧!

很多正在使用 dataguard 的客户,都会遇到一个棘手的问题:在备份端与主库同步的过程中由于网络原因或磁盘问题导致一个或多个归档日志丢失,进而 dataguard 同步无法继续。很多客户都选择了重新全库恢复,并重新搭建 dataguard。如果我们的源数据库非常大(超过 100G 的数据量),其实可以选择一种更简便并高效的恢复方法 – 通过 rman 的增量备份恢复 dataguard 中 standby 端的数据。

具体恢复过程如下:
1) Stop the managed recovery process (MRP) on the STANDBY database
SQL ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
2) Determine the SCN of the STANDBY database.
SQL SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
————–
3164433
SQL select min(checkpoint_change#) from v$datafile_header
where file# not in (select file# from v$datafile where enabled = READ ONLY
MIN(F.FHSCN)
—————-
3162298
comment: 上面一个为控制文件中记录的 SCN 号,另一个为数据文件头记录的 SCN 号,我们需要选择较小 SCN 号(3162298)的来备份。
3) Take an incremental backup of the PRIMARY database
RMAN BACKUP INCREMENTAL FROM SCN 3162298 DATABASE FORMAT /tmp/ForStandby_%U tag FORSTANDBY
4) Transfer all backup sets to STANDBY server
scp /tmp/ForStandby_* standby:/tmp
5) Catalog the backups in STANDBY controlfile.
RMAN CATALOG START WITH /tmp/ForStandby  
6) Recover the STANDBY database with the cataloged incremental backup:
RMAN RECOVER DATABASE NOREDO; 
7) In RMAN, connect to the PRIMARY database and create a standby control file backup:
RMAN BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT /tmp/ForStandbyCTRL.bck
8) Copy the standby control file backup to the STANDBY system. 
9) Capture datafile information in STANDBY database.
We now need to refresh the standby controlfile from primary controlfile (for standby) backup. However, since the datafile names are likely different than primary, let s save the name of datafiles on standby first, which we can refer after restoring controlfile from primary backup to verify if there is any discrepancy. Run below query from Standby and save results for further use.
10) From RMAN, connect to STANDBY database and restore the standby control file:
RMAN SHUTDOWN IMMEDIATE ;
RMAN STARTUP NOMOUNT;
RMAN RESTORE STANDBY CONTROLFILE FROM /tmp/ForStandbyCTRL.bck
11) Shut down the STANDBY database and startup mount:
RMAN SHUTDOWN;
RMAN STARTUP MOUNT;
scp /tmp/ForStandbyCTRL.bck standby:/tmp
12) Catalog datafiles in STANDBY if location/name of datafiles is different
Since the controlfile is restored from PRIMARY the datafile locations in STANDBY controlfile will be same as PRIMARY database, if the directory structure is different between the standby and primary or you are using Oracle managed file names, catalog the datafiles in STANDBY will do the necessary rename operations. If the primary and standby have identical structure and datafile names, this step can be skipped.
Perform the below step in STANDBY for each diskgroup where the datafile directory structure between primary and standby are different.
RMAN CATALOG START WITH +DATA/mystd/datafile/
To determine if any files have been added to Primary since the standby current scn:
SQL SELECT FILE#, NAME FROM V$DATAFILE WHERE CREATION_CHANGE# 3162298
If the above query returns with 0 zero rows, you can switch the datafiles. This will rename the datafiles to its correct name at the standby site:
RMAN SWITCH DATABASE TO COPY;
datafile 1 switched to datafile copy +DATA/mystd/datafile/system.297.688213333
datafile 2 switched to datafile copy +DATA/mystd/datafile/undotbs1.268.688213335
datafile 3 switched to datafile copy +DATA/mystd/datafile/sysaux.267.688213333
13) Configure the STANDBY database to use flashback (optional)
SQL ALTER DATABASE FLASHBACK OFF; 
SQL ALTER DATABASE FLASHBACK ON;
14) On STANDBY database, clear all standby redo log groups:
SQL ALTER DATABASE CLEAR LOGFILE GROUP 1;
SQL ALTER DATABASE CLEAR LOGFILE GROUP 2;
SQL ALTER DATABASE CLEAR LOGFILE GROUP 3;
….
15) On the STANDBY database, start the MRP
SQL ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
For more detailed info:
Steps to perform for Rolling Forward a Physical Standby Database using RMAN Incremental Backup. (Doc ID 836986.1)

感谢各位的阅读,以上就是“如何增量备份恢复 dataguard 中 standby 端的数据”的内容了,经过本文的学习后,相信大家对如何增量备份恢复 dataguard 中 standby 端的数据这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是丸趣 TV,丸趣 TV 小编将为大家推送更多相关知识点的文章,欢迎关注!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-01发表,共计3656字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)