前言
因为归档缺失,并且数据库较大,备库需要进行增量恢复快速恢复DG。
本文步骤适用于12c+版本。
18c+版本支持一条命令完成DG前滚,备库一个节点mount状态执行。(但本人并未探索到可以支持多通道并行的恢复方法,数据量较小时可以采用这个方法)
RMAN> RECOVER STANDBY DATABASE FROM SERVICE primary_connect_identifier;
复制
从Oracle Database 12c开始,可以使用远程数据库中的文件恢复数据库、数据文件、控制文件、表空间或spfile。RMAN连接到远程数据库,并使用备份集通过网络将所需的文件传输到目标数据库。这在Data Guard环境中非常有用。通过网络连接到备用数据库,可以恢复主数据库上的数据文件。还可以通过连接到主数据库来恢复备用数据库上的数据文件。
在通过网络从远程主机恢复文件时,必须使用from SERVICE指定从其获取文件的远程主机的服务名称。可选地,使用SECTION SIZE将源数据库中的文件恢复为多段备份集。也可以通过指定USING COMPRESSED BACKUPSET来压缩传输的文件。
1. 备库确认最小SCN
set num 15
select current_scn from v$database;
select min(f.checkpoint_change#) from v$datafile_header f,v$datafile d where f.file# =d.file# and d.enabled != 'READ ONLY';
复制
2. 主库确认备库没有新增数据文件
如有新增数据文件,则需要单独还原,执行还原新增的数据文件(按需)
select file# from v$datafile where creation_change# >=xxxx;
复制
3. 刷新备库控制文件
rman target /
startup nomount;
restore standby controlfile from service testdb;
alter database mount;
复制
4. 还原新增的数据文件(按需)
rman target /
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
set newname for database to '+DATA';
restore datafile xx,xx from service testdb USING COMPRESSED BACKUPSET;
}
复制
5. 刷新注册数据文件
rman target /
catalog start with '+DATA/TESTDBDG/DATAFILE';
switch database to copy;
复制
6. 备库清理datafilecopy
删除控制文件中不在需要的文件
rman target /
list datafilecopy all;
delete datafilecopy all;
复制
7. 备库清理日志文件
清理过程中,日志文件自动创建
SQL>
begin
for log_cur in ( select group# group_no from v$log )
loop
execute immediate 'alter database clear logfile group '||log_cur.group_no;
end loop;
end;
/
begin
for log_cur in ( select group# group_no from v$standby_log )
loop
execute immediate 'alter database clear logfile group '||log_cur.group_no;
end loop;
end;
/
复制
set lin 200 pages 99
col member for a80
col size for a10
select b.group#,b.THREAD#,to_char(bytes/1024/1024) || 'M' "size",b.status,member from v$logfile a,v$log b where a.group#=b.group# order by 2,1;
select b.group#,b.THREAD#,to_char(bytes/1024/1024) || 'M' "size",b.status,member from v$logfile a,v$standby_log b where a.group#=b.group# order by 2,1;
复制
8. 确认主库归档传输正常
alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE;
set lines 200
col error for a50
col RECOVERY_MODE for a30
select DEST_ID,STATUS,RECOVERY_MODE,DATABASE_MODE,ERROR from v$archive_dest_status where TYPE='PHYSICAL';
复制
9. 备库增量恢复
rman target sys/xxxx log=inc_recover_0727.log append <<EOF run { allocate channel c1 type disk connect '/@testdbdg'; allocate channel c2 type disk connect '/@testdbdg'; allocate channel c3 type disk connect '/@testdbdg'; allocate channel c4 type disk connect '/@testdbdg'; recover database from service 'testdb' using compressed backupset; }
复制
10. 一致性恢复
sqlplus / as sysdba recover automatic standby database until consistent;
复制
11. 打开备库,应用日志
alter database open;
alter database recover managed standby database disconnect from session;
复制
订阅号:DongDB手记
墨天轮:https://www.modb.pro/u/231198
最后修改时间:2023-08-23 10:01:53
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
文章被以下合辑收录
评论
目录