码迷,mamicode.com
首页 > 其他好文 > 详细

rman 增量恢复 dg gap后 主库添加新数据文件

时间:2015-01-31 17:56:39      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:



1) On the standby database, 关闭 (MRP)
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;


2) On the STANDBY DATABASE, 获取备库最小scn值,用作主库增量备份点 :
col MIN(CHECKPOINT_CHANGE#) for 999999999999999999
col CURRENT_SCN for 99999999999999999
SELECT CURRENT_SCN FROM V$DATABASE;


select min(checkpoint_change#) from v$datafile_header;
CHECKPOINT_CHANGE#
---------------------
3162298


col current_scn for 999999999999999
 SELECT CURRENT_SCN FROM V$DATABASE;
 
 select min(fhscn) from x$kcvfh;
 
 select min(f.fhscn) from x$kcvfh f, v$datafile d
      where f.hxfil =d.file# and d.enabled != ‘READ ONLY‘ ;


取最小scn


3)  在主库确定dg gap后新添加的数据文件(scn 基于备库的最小scn) :
SQL> SELECT FILE#, NAME FROM V$DATAFILE WHERE CREATION_CHANGE# > <SCN_NUMBER_FROM_STEP 2>;


4) 使用rman 创建相应数据文件备份,和全库基于scn 的增量备份,standb 控制文件:
RMAN> backup datafile #, #, #, # format ‘/tmp/ForStandby_%U‘ tag ‘FORSTANDBY‘;
RMAN> backup incremental from SCN 3162298 database format ‘/tmp/ForStandby_%U‘ tag ‘FORSTANDBY‘;
RMAN> backup current controlfile for standby format ‘/tmp/ForStandbyCTRL.bck‘;



 5) 把备份结果拷贝到备库
scp /tmp/ForStandby_* standby:/tmp


 6)恢复新生成的standby 控制文件,并注册拷过来的备份片:
RMAN> shutdown;
RMAN> startup nomount;
RMAN> restore standby controlfile from ‘/tmp/ForStandbyCTRL.bck‘;
RMAN> alter database mount;


-----注册拷过来的备份片
RMAN> CATALOG START WITH ‘/tmp/ForStandby‘; 

using target database control file instead of recovery catalog 
searching for all files that match the pattern /tmp/ForStandby 


List of Files Unknown to the Database 
===================================== 
File Name: /tmp/ForStandby_2llixora4_1_1 
File Name: /tmp/ForStandby_2mlixora8_1_1 


Do you really want to catalog the above files (enter YES or NO)? YES 
cataloging files... 
cataloging done 


List of Cataloged Files 
======================= 
File Name: /tmp/ForStandby_2llixora4_1_1 
File Name: /tmp/ForStandby_2mlixora8_1_1



 7) restore missing datafiles:
这里可能会有问题,当主库新添加的数据文件没有数据时,ramn 备份生成的是备份集只100多kb,貌似在使用


catalog start with 时oracle 没法识别到。
不过没关系,我们可以直接手工注册:
CATALOG BACKUPPIECE ‘/tmp/01dmsbj4_1_1.bcp’; 

run
{
set newname for datafile 9 to ‘+DISKGROUP‘;
set newname for datafile 8 to ‘+DISKGROUP‘;
set newname for datafile 11 to ‘+DISKGROUP‘;
#set newname for datafile 12 to ‘/oradata/datafile/lixora.dbf‘;
restore datafile 9,8,11,....;
}



8)更新备库 stndby 控制文件中数据文件的路径 .
使用 catalog 命令更新数据文件路径(备库和主库数据文件名,路径不同的数据文件)


RMAN> CATALOG START WITH ‘+DATA/lixora/datafile/‘; 
or
RMAN> CATALOG START WITH ‘/oradata/lixora/datafile/‘; 

List of Files Unknown to the Database 
===================================== 
File Name: +data/lixora/DATAFILE/SYSTEM.309.685535773 
File Name: +data/lixora/DATAFILE/SYSAUX.301.685535773 
File Name: +data/lixora/DATAFILE/UNDOTBS1.302.685535775 
File Name: +data/lixora/DATAFILE/SYSTEM.297.688213333 
File Name: +data/lixora/DATAFILE/SYSAUX.267.688213333 
File Name: +data/lixora/DATAFILE/UNDOTBS1.268.688213335 

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/lixora/DATAFILE/SYSTEM.297.688213333 
File Name: +data/lixora/DATAFILE/SYSAUX.267.688213333 
File Name: +data/lixora/DATAFILE/UNDOTBS1.268.688213335




---这一步等效于 alert database datafile rename ,这一步才真正去更新standby 控制文件中的数据文件信息:
RMAN> SWITCH DATABASE TO COPY; 


datafile 1 switched to datafile copy "+DATA/lixora/datafile/system.297.688213333" 
datafile 2 switched to datafile copy "+DATA/lixora/datafile/undotbs1.268.688213335" 
datafile 3 switched to datafile copy "+DATA/lixora/datafile/sysaux.267.688213333"
 
9) 使用增量备份恢复 备库,noredo表示不应用redo or 归档:
RMAN> RECOVER DATABASE NOREDO; 

starting recover at 03-JUN-09 
allocated channel: ORA_DISK_1 
channel ORA_DISK_1: sid=28 devtype=DISK 
channel ORA_DISK_1: starting incremental datafile backupset restore 
channel ORA_DISK_1: specifying datafile(s) to restore from backup set 
destination for restore of datafile 00001: +DATA/lixora/datafile/system.297.688213333 
destination for restore of datafile 00002: +DATA/lixora/datafile/undotbs1.268.688213335 
destination for restore of datafile 00003: +DATA/lixora/datafile/sysaux.267.688213333 
channel ORA_DISK_1: reading from backup piece /tmp/ForStandby_2llixora4_1_1 
channel ORA_DISK_1: restored backup piece 1 
piece handle=/tmp/ForStandby_2llixora4_1_1 tag=FORSTANDBY 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 
Finished recover at 03-JUN-09


10) 【可选】配置闪回
If the STANDBY database needs to be configured for FLASHBACK use the below step to enable.
SQL> ALTER DATABASE FLASHBACK OFF; 
SQL> ALTER DATABASE FLASHBACK ON;


11) 清理所有的standby redolog ,建议清理


SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1; 
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 2; 
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 3;
....

12) On the STANDBY database, 启动MRP
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;


 This note assumes all files are at the same recovery scn or very close. 
If nologging operations have been made or files are at differnt or widely varying scns see the 

online documentation:
10.2:  http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/scenarios.htm#CIHIAADC
11.1:  http://download.oracle.com/docs/cd/B28359_01/server.111/b28294/rman.htm#SBYDB00759
11.2: http://download.oracle.com/docs/cd/E11882_01/server.112/e17022/rman.htm#CIHIAADC

rman 增量恢复 dg gap后 主库添加新数据文件

标签:

原文地址:http://blog.csdn.net/lixora/article/details/43342279

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!