说明:
adg出现故障需要重建adg时使用
记录:
源库:
备份数据库
rman target / << EOF
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup AS COMPRESSED BACKUPSET database format '/ora_bak/full_%d_%T_%s_%p';
sql "alter system archive log current";
backup AS COMPRESSED BACKUPSET archivelog all format '/ora_bak/arch_%d_%T_%s_%p';
backup current controlfile format '/ora_bak/ctl_%d_%T_%s_%p';
}
EOF
将备份拷贝至灾备库
灾备库:
启动至nomount
startup nomount
恢复控制文件
restore standby controlfile to '+DATADG/CONTROLFILE/current.306.994095609' from '/tmp/tmp_bak/ctl_20200730_9502_1';
restore standby controlfile to '+RECDG/CONTROLFILE/current.346.994095611' from '/tmp/tmp_bak/ctl_20200730_9502_1';
启动到mount
shutdown immediate;
startup nomount;
alter database mount standby database;
注册备份信息
CROSSCHECK BACKUP;
DELETE NOPROMPT EXPIRED BACKUP;
catalog start with '/tmp/tmp_bak';
恢复数据库
rman target / <<EOF
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
set newname for datafile 1 to '+DATADG';
set newname for datafile 2 to '+DATADG';
set newname for datafile 3 to '+DATADG';
set newname for datafile 4 to '+DATADG';
set newname for datafile 5 to '+DATADG';
set newname for datafile 6 to '+DATADG';
set newname for datafile 7 to '+DATADG';
set newname for datafile 8 to '+DATADG';
set newname for datafile 9 to '+DATADG';
set newname for datafile 10 to '+DATADG';
set newname for datafile 11 to '+DATADG';
set newname for datafile 12 to '+DATADG';
set newname for datafile 13 to '+DATADG';
set newname for datafile 14 to '+DATADG';
set newname for datafile 15 to '+DATADG';
set newname for datafile 16 to '+DATADG';
set newname for datafile 17 to '+DATADG';
set newname for datafile 18 to '+DATADG';
set newname for datafile 19 to '+DATADG';
set newname for datafile 20 to '+DATADG';
set newname for datafile 21 to '+DATADG';
set newname for datafile 22 to '+DATADG';
set newname for datafile 23 to '+DATADG';
set newname for datafile 24 to '+DATADG';
set newname for datafile 25 to '+DATADG';
set newname for datafile 26 to '+DATADG';
set newname for datafile 27 to '+DATADG';
set newname for datafile 28 to '+DATADG';
set newname for tempfile 1 to '+DATADG';
set newname for tempfile 2 to '+DATADG';
set newname for tempfile 3 to '+DATADG';
restore database;
switch datafile all;
switch tempfile all;
recover database;
}
EOF
恢复同步
recover managed standby database disconnect from session;
启动ADG
shutdown immediate
startup
recover managed standby database using current logfile disconnect from session;