Oralce数据库SCN增量备份恢复

参考链接:

  1. RMAN-06094
  2. ORA-17503
  3. ORA-10459

一、 恢复原因

Oralce数据库主库少了一个sequence为46502的归档日志文件,导致备库和容灾库因缺少此归档日志文件而无法同步,此时又无此归档日志文件的备份,故采用增量备份恢复。

二、 恢复原理

Oracle数据库的每一个数据块都记录有一个SCN,通过比较数据块的SCN和增量备份给定的SCN大小,就可以判断出数据块是否在给定的SCN之后有过修改。

三、 恢复步骤

1. 查看备库当前的scn
SELECT Min(fhscn)
FROM   x$kcvfh;

输出结果:

MIN(FHSCN)
----------------
11986362701216
2. 增量备份主库数据

在主库下创建/oracle/tmp_prod目录,注意给对应的数据库用户权限

Run
{
Allocate channel aux0 device type disk format='/oracle/tmp_prod/DB_%d_%T_S%s_P%p';
Allocate channel aux1 device type disk format='/oracle/tmp_prod/DB_%d_%T_S%s_P%p';
Allocate channel aux2 device type disk format='/oracle/tmp_prod/DB_%d_%T_S%s_P%p';
Allocate channel aux3 device type disk format='/oracle/tmp_prod/DB_%d_%T_S%s_P%p';
Allocate channel aux4 device type disk format='/oracle/tmp_prod/DB_%d_%T_S%s_P%p';
Allocate channel aux5 device type disk format='/oracle/tmp_prod/DB_%d_%T_S%s_P%p';
Allocate channel aux6 device type disk format='/oracle/tmp_prod/DB_%d_%T_S%s_P%p';
Allocate channel aux7 device type disk format='/oracle/tmp_prod/DB_%d_%T_S%s_P%p';
Allocate channel aux8 device type disk format='/oracle/tmp_prod/DB_%d_%T_S%s_P%p';
Allocate channel aux9 device type disk format='/oracle/tmp_prod/DB_%d_%T_S%s_P%p';
Backup incremental from scn 11986362701216 database;
release channel aux0;
release channel aux1;
release channel aux2;
release channel aux3;
release channel aux4;
release channel aux5;
release channel aux6;
release channel aux7;
release channel aux8;
release channel aux9;
}

增量备份完成后,将/oracle/tmp_prod目录下生成的文件拷贝至待恢复的备库,注意文件权限。

3. 恢复控制文件

进主库:

alter database create standby controlfile as '/tmp/std.ctl';

将主库机器上的/tmp/std.ctl文件scp至备库,进nomount状态备库rman:

restore standby controlfile from '/tmp/std.ctl';
4. 恢复备库数据

进入mount状态备库RMAN:

catalog start with '/oracle/tmp_prod';
catalog start with '+data01';
switch database to copy;
recover database;

四、 问题总结

  1. 采取这种方式恢复,刚开始时查看日志会报ORA-17503错误,不过没关系,oracle会自己clear在线日志文件,过一会就正常了。
  2. 一个实例起到open状态,另一个实例处于mount状态,起MRP进程会失败,查看日志报ORA-10459错误,将两个实例状态一致就可正常拉起MRP进程
  3. 如果在switch database to copy时报rman-06571: datafile n does not have a recoverable copy:
a.switch 现有datafile
SELECT 'switch datafile '||(listagg(file#, ',') within GROUP (ORDER BY file#))||' to copy;'
FROM   v$backup_copy_details
WHERE  rownum <= 600;
b.增加文件n
SELECT 'alter database create datafile '
       || file#
       || ' as new;'
FROM   v$datafile
WHERE  name LIKE '+data01/hssds/datafile%';

alter system set standby_file_management=manual;
alter database create datafile n as new;
alter system set standby_file_management=auto;

######c. 重新生成logfile
``` sql
SELECT 'alter database clear logfile group '
       || group#
       || ';'
FROM   v$logfile;

你可能感兴趣的:(Oralce数据库SCN增量备份恢复)