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
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,....;
}
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