Rolling forward a standby database using RMAN Incremental Backup.
模拟归档丢失的情况
一 主库操作:
查看当前归档
停用归档传输
alter system set log_archive_dest_state_2=defer;
切换归档
alter system switch logfile;
alter system switch logfile;
模拟丢失归档
RMAN> delete archivelog low sequence 3821 high sequence 3823;
RMAN> delete force archivelog low sequence 3821 high sequence 3823; ------11G需要添加force
恢复归档传输
alter system set log_archive_dest_state_2=enable;
备库警告日志错误
FAL[client]: Failed to request gap sequence
GAP - thread 1 sequence 79-81
DBID 2144245355 branch 846098926
FAL[client]: All defined FAL servers have been attempted.
-------------------------------------------------------------
Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization
parameter is defined to a value that is sufficiently large
enough to maintain adequate log switch information to resolve
archivelog gaps.
-------------------------------------------------------------
Tue Apr 29 18:54:21 2014
二 备库操作
用增量备份解决断档
备库查询当前scn号
–停止mrp应用
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
–查询scn取最小值(取当前scn和最小scn的中的最小值)
SELECT CURRENT_SCN FROM V$DATABASE;
SELECT to_char(CURRENT_SCN) FROM V$DATABASE;
CURRENT_SCN
570778
select min(fhscn) from x$kcvfh;
MIN(FHSCN)
570778
三 增量备份
主库进行增量备份并创建controlfile
RMAN>BACKUP INCREMENTAL FROM SCN 570778 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY';
scp ForStandby_* node2:/oracle/arch/
ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/tmp/control01.ctl';
scp control01.ctl node2:/oracle/oradata/test/control01.ctl
在主库增量备份的过程中,可使用以下语句查询进度
SELECT inst_id,
sid,
serial#,
opname,
ROUND(SOFAR / TOTALWORK * 100, 2) "%_COMPLETE"
FROM gV$SESSION_LONGOPS
WHERE OPNAME LIKE 'RMAN%'
AND OPNAME NOT LIKE '%aggregate%'
AND TOTALWORK != 0
AND SOFAR <> TOTALWORK;
最后确定主库在此scn后是否添加过数据文件
SQL> select FILE#,name from v$datafile where CREATION_CHANGE#> =570778;
如果有添加过数据文件,确保standby_file_management=auto,则后续可以restore进行恢复
如果不使用restore进行恢复,则使用以下步骤进行创建数据文件(待验证)
select file#,name from v$datafile;
alter database create datafile '/oracle/app/product/11.2.0/db_1/dbs/UNNAMED00011' as '/oradata/ddd01.dbf'
备库端操作
关闭数据库用新的controlfile打开到mount状态并注册备份信息
恢复数据文件:
alter database mount;
RMAN>CATALOG BACKUPPIECE '/oracle/arch/ForStandby_04p6vfe9_1_1';
RMAN>CATALOG BACKUPPIECE '/oracle/arch/ForStandby_03p6vfdg_1_1';
或
RMAN> catalog start with '/oracle/arch';
恢复数据文件:(如果有增加过数据文件,执行这步,没有跳到下一步)
RMAN> restore datafile 10;数据文件号为在主库scn添加过的数据文件号
恢复
RMAN> RECOVER DATABASE NOREDO;
备库开启mrp
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
关闭mrp
alter database recover managed standby database cancel;
开启数据库
alter database open
四 补充
若主库的部分归档由于某些原因没有传至备库,则可通过以下方法解决:
1 主库scp 备库丢失的归档 备库
2 备库应用归档:
alter database register logfile ‘/data/archlog /1_324_966768650.dbf’;
3 观察alert日志