我是靠谱客的博主 积极铃铛,最近开发中收集的这篇文章主要介绍通过RMAN备份standby database成功恢复还原,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

前言: 为了提升系统安全,通常会在primary DB+standby  DB 之外再做一份备份。 但直接对 primary DB备份可能会带来性能问题,所以决定在standby DB(open_mode:READ ONLY WITH APPLY)跑RMAN备份。模拟primary DB+standby DB都挂掉,通过RMAN备份恢复DB
(Oracle 11.0.2.4)

操作步骤(实验证明是错误的!正确方法在后面)
standby中执行 backup database -> backup archivelog -> backup controlfile 
新恢复DB中执行 restore controlfile -> restore database -> recover database -> open (read only)

具体操作(错误)
standby中
RMAN> backup database format='/data/rmanbak/fd_%U_%T.bak';
RMAN> backup archivelog from time 'sysdate-0.5' format 'al_%U_%T.bak'
RMAN> backup current controlfile format '/data/rmanbak/cf_%U_%T.bak';
新恢复DB中
RMAN> startup nomount;
RMAN> restore controlfile from '/data/rmanbak/cf_drt2a0st_1_1_20180507.bak';
RMAN> restore database;
RMAN> alter database mount;
RMAN> recover database;
Starting recover at 07-MAY-18
using channel ORA_DISK_1
starting media recovery
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 05/07/2018 14:26:01
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of archived log for thread 1 with sequence 1129 and starting SCN of 11096139396 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 1128 and starting SCN of 11096132481 found to restore

SQL> alter database open;    --OPEN时报错data file 1需要恢复
alter database open
*
ERROR at line 1:
ORA-10458: standby database requires recovery
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/data/ind/system01.dbf'   

SQL> recover standby database;    --recover时要求新的archivelog恢复,但因为模拟的原primary+standby挂掉了,没法copy新的archivelog来应用
ORA-00279: change 11094270515 generated at 05/07/2018 09:30:53 needed for
thread 1
ORA-00289: suggestion : /data/ind/arch/1_1123_964343049.arc
ORA-00280: change 11094270515 for thread 1 is in sequence #1123
Specify log: {=suggested | filename | AUTO | CANCEL}

查看controlfile SCN( v$database.CURRENT_SCN) > datafile SCN( v$datafile_header.CHECKPOINT_CHANGE#) ,说明了上面需要archivelog恢复现象
SQL> select OPEN_MODE,CONTROLFILE_TYPE,DATABASE_ROLE,to_char(CURRENT_SCN)  from v$database;
OPEN_MODE            CONTROL DATABASE_ROLE  TO_CHAR(CURRENT_SCN)
-------------------- ------- ----------------  ----------------------------------------
MOUNTED              STANDBY PHYSICAL STANDBY  11096139395

SQL> select FILE#,to_char(CHECKPOINT_CHANGE#) SCN from v$datafile_header;
     FILE# SCN
---------- ----------------------------------------
         1  11094270515
         2 11094270515
         3 11094270515
         4 11094270515
         5 11094270515
         6 11094270515
         7 11094270515
         8 11094270515
         9 11094270515
        10 11094270515

准备用resetlogs方式open又报错
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01666: control file is for a standby database
至此,验证此方法不行。
------------------------------------------------------------------------------------------------------------------

正确方法 操作步骤
standby中执行 backup database -> backup controlfile -> backup archivelog
新恢复DB中执行 restore controlfile -> restore database ->catalog start with 'archivelog' -> recover database -> open (read only)
具体操作(正确)
standby中
RMAN> backup database format='/data/rmanbak/fd_%U_%T.bak';
RMAN> backup current controlfile format '/data/rmanbak/cf_%U_%T.bak';
RMAN> backup archivelog from time 'sysdate-0.5' format 'al_%U_%T.bak'
新恢复DB中
RMAN> startup nomount;
RMAN> restore controlfile from '/data/rmanbak/cf_drt2a0st_1_1_20180507.bak';
RMAN> restore database;
RMAN> alter database mount;
RMAN> CATALOG START WITH '/data/rmanbak/al_dst2a7mn_1_1_20180507.bak';
searching for all files that match the pattern /data/rmanbak/al_dst2a7mn_1_1_20180507.bak
List of Files Unknown to the Database
=====================================
File Name: /data/rmanbak/al_dst2a7mn_1_1_20180507.bak
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /data/rmanbak/al_dst2a7mn_1_1_20180507.bak
RMAN> recover database;
SQL> alter database open;  --可以正常open(read only),但然如需要切为主库,激活standby即可
Database altered.

查看controlfile SCN( v$database.CURRENT_SCN ) +1 = datafile SCN( v$datafile_header.CHECKPOINT_CHANGE# ) 达到此一致可以OPEN。
当然如果对standby备份时取消掉实时应用(alter database recover managed standby database cancel;) ,也可以达到一致性目前,并recover open成功



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25583515/viewspace-2154182/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25583515/viewspace-2154182/

最后

以上就是积极铃铛为你收集整理的通过RMAN备份standby database成功恢复还原的全部内容,希望文章能够帮你解决通过RMAN备份standby database成功恢复还原所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部