rman target / startup nomount;
run{ allocate channel ch00 type 'SBT_TAPE'; send 'nb_ora_serv=nbumaster01'; send 'nb_ora_client=zhnsdfp'; restore controlfile from 'cntrl_984_1_946173555'; release channel ch00; } alter database mount; run{ allocate channel ch00 type 'SBT_TAPE'; allocate channel ch01 type 'SBT_TAPE'; send 'nb_ora_serv=nbumaster01'; send 'nb_ora_client=zhnsdfp'; restore database until time "to_date('2017/06/07 11:16:41','yyyy/mm/dd hh24:mi:ss')"; release channel ch00; release channel ch01; }
-------------------------------- sqlplus / as sysdba alter session set nls_date_format='YYYYMMDD HH24:MI:SS'; set linesize 160; set pagesize; select THREAD#,SEQUENCE#,FIRST_TIME,COMPLETION_TIME from v$archived_log where COMPLETION_TIME>to_date('20170602 23:00:00','yyyymmdd hh24:mi:ss') and COMPLETION_TIME<to_date('20170607 20:00:00','yyyymmdd hh24:mi:ss') order by SEQUENCE#; 68305-68827 rman target / 恢复脚本 run{ allocate channel ch0 type 'SBT_TAPE'; allocate channel ch1 type 'SBT_TAPE'; send 'NB_ORA_CLIENT=zhnsdfp'; send 'nb_ora_serv=nbumaster01'; restore archivelog sequence between 68305 and 68827; release channel ch0; release channel ch1; } -----------------------
sqlplus / as sysdba alter session set nls_date_format='YYYY/MM/DD HH24:MI:SS'; recover database until time '2017/06/07 11:16:41' using backup controlfile; alter database open resetlogs;
二、基于差异备份恢复6月7日11:35分数据
1.查询所需要的归档日志
bplist -C zhnsdfp -s 2017-6-7 -e 2017-6-9 -k oracle_zhnsdfp_0_97_seineebs_arch -t 4 -R -b -l / |findstr "cnt"
2.shutdown immediate 后删除数据库文件和归档日志文件。
删除C:\app\fast_recovery_area\SEINEEBS\control02.ctl和C:\app\fast_recovery_area\SEINEEBS\ARCHIVELOG\2017_06_20
3.开始还原控制文件
rman target /
startup nomount;
run{
allocate channel ch00 type 'SBT_TAPE';
send 'nb_ora_serv=nbumaster01';
send 'nb_ora_client=zhnsdfp';
restore controlfile from 'cntrl_984_1_946173555';
release channel ch00;
}
4.还原数据文件
alter database mount;
run{
allocate channel ch00 type 'SBT_TAPE';
allocate channel ch01 type 'SBT_TAPE';
send 'nb_ora_serv=nbumaster01';
send 'nb_ora_client=zhnsdfp';
restore database
until time "to_date('2017/06/07 11:16:41','yyyy/mm/dd hh24:mi:ss')";
release channel ch00;
release channel ch01;
}
5.查询SCN号 还原归档日志
-------------------------------- sqlplus / as sysdba alter session set nls_date_format='YYYYMMDD HH24:MI:SS'; set linesize 160; set pagesize; select THREAD#,SEQUENCE#,FIRST_TIME,COMPLETION_TIME from v$archived_log where COMPLETION_TIME>to_date('20170602 23:00:00','yyyymmdd hh24:mi:ss') and COMPLETION_TIME<to_date('20170607 20:00:00','yyyymmdd hh24:mi:ss') order by SEQUENCE#; ---68305-68827 rman target / 恢复脚本 run{ allocate channel ch0 type 'SBT_TAPE'; allocate channel ch1 type 'SBT_TAPE'; send 'NB_ORA_CLIENT=zhnsdfp'; send 'nb_ora_serv=nbumaster01'; restore archivelog sequence between 68305 and 68827; release channel ch0; release channel ch1; } -----------------------
6.恢复数据库
----------------------- sqlplus / as sysdba alter session set nls_date_format='YYYY/MM/DD HH24:MI:SS'; recover database until time '2017/06/07 11:35:00' using backup controlfile; alter database open resetlogs;
三、基于全备(利用全备文件恢复数据库,还原7.22号的数据)
7.22凌晨进行全备,现需还原7.22号全备后的数据
1.查询所需要的归档日志,shutdown immediate 后删除以下文件:
bplist -C zhnsdfp -s 2017-7-21 -e 2017-7-23 -k oracle_zhnsdfp_0_97_seineebs_full -t 4 -R -b -l / |findstr "cnt"
2.利用备份文件进行控制文件还原,
rman target / startup nomount; run{ allocate channel ch00 type 'SBT_TAPE'; send 'nb_ora_serv=nbumaster01'; send 'nb_ora_client=zhnsdfp'; restore controlfile from 'full_cntrl_1800_1_949971276'; release channel ch00; }
3.进行数据库还原
alter database mount; run{ allocate channel ch00 type 'SBT_TAPE'; allocate channel ch01 type 'SBT_TAPE'; send 'nb_ora_serv=nbumaster01'; send 'nb_ora_client=zhnsdfp'; restore database; release channel ch00; release channel ch01; }
4,进行数据库恢复
run{ allocate channel ch00 type 'SBT_TAPE'; allocate channel ch01 type 'SBT_TAPE'; send 'nb_ora_serv=nbumaster01'; send 'nb_ora_client=zhnsdfp'; recover database release channel ch00; release channel ch01; }
解决如下:
还原到最后报错,这是因为没有还原到数据库当前日志,可以根据指定的SCN号打开数据库
5.最后用resetlogs模式打开数据库。进行数据验证
alter database open resetlogs;