Oracle DataGuard发生归档丢失增量备份恢复备库

1.确定增量恢复起点SCN

有如下方法:

  1. 备库查看丢失的归档序列号

    --备库查看丢失的归档号
    SELECT * FROM V$ARCHIVE_GAP;
    --主库执行,查看SCN,146为第一个缺失归档的序列号
    SELECT FIRST_CHANGE# FROM V$ARCHIVED_LOG WHERE SEQUENCE#=146;
    
  2. 备库查看当前的SCN

    SELECT TO_CHAR(CURRENT_SCN) FROM V$DATABASE;
    
  3. 备库查看文件的SCN

    SELECT DISTINCT CHECKPOINT_CHANGE# FROM V$DATAFILE_HEADER;
    

在测试环境中,以上CURRENT_SCN为5156981,其他两个都为5156982

2.增量备份

2.1.主库执行增量备份

run{
allocate channel d1 type disk;
allocate channel d2 type disk;
backup as compressed backupset incremental from SCN 5156981 database format ‘/archlog/backup/standby_%d_%T_%U.bak‘ tag ‘FOR STANDBY‘;
backup current controlfile for standby format ‘/archlog/backup/standby_%d_%T_%U_CTRL.bak‘;
release channel d1;
release channel d2;
}

2.2.传送到备库

scp * xxx.xxx.xxx.xxx:/archlog/backup/

3.备库恢复

3.1.恢复控制文件

数据库至nomount状态

alter database recover managed standby database cancel;
shutdown immediate;
startup nomount;

进入rman恢复

restore standby controlfile from ‘/archlog/backup/standby_DGTEST_20210621_0d01vmh7_1_1_CTRL.bak‘;

3.2.识别增量备份

数据库至mount状态

alter database mount;

识别备份

catalog start with ‘/archlog/backup‘;

3.3.查找新增的文件

如果没有新增文件,可以忽略此节

3.3.1.查找文件
SELECT * FROM V$DATAFILE_HEADER WHERE CREATION_CHANGE#>5156981;
3.3.2.修改备库参数
alter system set standby_file_management = manual;
3.3.3.新增对应的文件
SELECT ‘alter database create datafile ‘‘‘||name||‘‘‘;‘ FROM V$DATAFILE_HEADER WHERE CREATION_CHANGE#>5156981;
3.3.4.修改备库参数
alter system set standby_file_management = auto;

3.4.恢复备库

recover database noredo

4.开启数据库日志应用

alter database open read only;
alter database recover managed standby database disconnect;

5.测试并开启全备

主库新建一个表查看备库是否OK

Oracle DataGuard发生归档丢失增量备份恢复备库

上一篇:MYSQL Packets out of order. Expected 1 received 56. Packet size=3420216错误


下一篇:Oracle清理归档日志