公司每年会恢复nbu磁带数据,验证数据有效性,公司目前是用NBU进行rman备份恢复到特定时间。
恢复原理就是通过恢复控制文件到rman全备的点,然后控制数据文件恢复的时间,不过因为我们恢复的rac是要到单机,所以需要手动修改目录
恢复过程是:1.恢复控制文件——2.恢复数据文件——3.恢复归档日志
恢复前的准备:①确认控制文件名(步骤1)②确认恢复的磁带/磁盘是否还有当天数据这个用过NBU的都懂在catalog上面查即可
1.查看现有的NBU磁带上面的记录
在恢复服务器执行以下命令:
/usr/openv/netbackup/bin/bplist -C oracleSID -t 4 -R -l /
需要注意的是这个oracleSID是你们公司的RAC数据库(既数据源的SID可以通过echo $ORACLE_SID查看)
得到结果如下图(cntrl_34057_1_1060827624 这个文件就是我们要的1月3日的控制文件)
2.恢复控制文件
先将数据库修改为nomount模式
进入数据库:
su -oraclesqlplus / as sysdbaalter database mount
然后退出进入rman
rman target /
输入如下命令SID不用说还是自己公司的SID,controlfile就是上面获取的名称
run
{
ALLOCATE CHANNEL CH00 TYPE 'SBT_TAPE';
SEND 'NB_ORA_CLIENT=oracleSID';
restore controlfile from 'cntrl_34057_1_1060827624';
release CHANNEL CH00;
}
NBU上面可以看到恢复完成,恢复完成后数据库修改为mount模式验证是否正常
3.然后到源库(RAC库上面)确认库的路径,并修改目标数据库的地址
select group#,member from v$logfile;
select file#,name from v$datafile;
select name from v$tempfile;
在源库执行以上3个查找到对应的日志,数据文件,temp等目录
①这个是RAC的日志路径
select group#,member from v$logfile;
②这个是数据文件
select file#,name from v$datafile;
③
select name from v$tempfile;
查完以后在目标库执行将RAC日志修改为本地
alter database rename file '+DATA/prod/onlinelog/group_1.283.983976601' to '/opt/oracle/oradata/prod/group_1.log';
alter database rename file '+DATA/prod/onlinelog/group_2.284.983976601' to '/opt/oracle/oradata/prod/group_2.log';
alter database rename file '+DATA/prod/onlinelog/group_3.285.983976603' to '/opt/oracle/oradata/prod/group_3.log';
alter database rename file '+DATA/prod/onlinelog/group_4.286.983976603' to '/opt/oracle/oradata/prod/group_4.log';
alter database rename file '+DATA/prod/onlinelog/group_5.287.983976603' to '/opt/oracle/oradata/prod/group_5.log';
alter database rename file '+DATA/prod/onlinelog/group_6.289.983977735' to '/opt/oracle/oradata/prod/group_6.log';
alter database rename file '+DATA/prod/onlinelog/group_7.290.983977735' to '/opt/oracle/oradata/prod/group_7.log';
alter database rename file '+DATA/prod/onlinelog/group_8.291.983977737' to '/opt/oracle/oradata/prod/group_8.log';
alter database rename file '+DATA/prod/onlinelog/group_9.292.983977737' to '/opt/oracle/oradata/prod/group_9.log';
alter database rename file '+DATA/prod/onlinelog/group_10.293.983977737' to '/opt/oracle/oradata/prod/group_10.log';
4.回到rman执行以下命令(SET NEWNAME FOR DATAFILE 这个就是数据库的文件名)
run {
allocate channel ch00 type 'sbt_tape';
allocate channel ch01 type 'sbt_tape';
SEND 'NB_ORA_CLIENT=oracleSID';
set newname for datafile 1 to '/opt/oracle/oradata/prod/system.256.882140617';
set newname for datafile 2 to '/opt/oracle/oradata/prod/sysaux.257.882140617';
set newname for datafile 3 to '/opt/oracle/oradata/prod/sysaux.258.989572457';
set newname for datafile 4 to '/opt/oracle/oradata/prod/users.259.882140617';
set newname for datafile 5 to '/opt/oracle/oradata/prod/undotbs4.261.983977701';
set newname for datafile 6 to '/opt/oracle/oradata/prod/coredata.265.882208237';
set newname for datafile 7 to '/opt/oracle/oradata/prod/coredata.266.882208241';
set newname for datafile 8 to '/opt/oracle/oradata/prod/coredata.267.882208247';
set newname for datafile 9 to '/opt/oracle/oradata/prod/coredata.268.882208251';
set newname for datafile 10 to '/opt/oracle/oradata/prod/coredata.269.882208255';
set newname for datafile 11 to '/opt/oracle/oradata/prod/coreindex.270.882208273';
set newname for datafile 12 to '/opt/oracle/oradata/prod/coreindex.271.882208289';
set newname for datafile 13 to '/opt/oracle/oradata/prod/coreindex.275.882240665';
set newname for datafile 14 to '/opt/oracle/oradata/prod/jlprebak';
set newname for datafile 15 to '/opt/oracle/oradata/prod/undotbs3.282.983976569';
set newname for datafile 16 to '/opt/oracle/oradata/prod/coredata.256.996609299';
set newname for datafile 17 to '/opt/oracle/oradata/prod/coredata.257.996609309';
set newname for datafile 18 to '/opt/oracle/oradata/prod/coreindex.258.1008326627';
set newname for datafile 19 to '/opt/oracle/oradata/prod/coreindex.259.1008326663';
set newname for datafile 20 to '/opt/oracle/oradata/prod/sysaux.260.1015675111';
set newname for datafile 21 to '/opt/oracle/oradata/prod/sysaux.261.1015675137';
SET NEWNAME FOR TEMPFILE 1 to '/opt/oracle/oradata/prod/temp.260.882140683';
restore database;
recover database;
release channel ch00;
release channel ch01;
}
最后等待数据恢复完成。
完成以后执行最后一步数据库
alter database open resetlogs;