ITPub博客

首页 > Linux操作系统 > Linux操作系统 > restore.ksh

restore.ksh

原创 Linux操作系统 作者:debug200 时间:2012-11-06 16:22:07 0 删除 编辑

恢复步骤:

0,在sit环境修改原库的db_name为dm环境db_name,数据文件路径。

 

把备份文件放到'/stg/oracle/ot11g/ot11g/yhw

 

1, 启到nomount状态,恢复控制文件:

 

catalog start with '/stg/oracle/ot11g/ot11g/yhw';

 

rman target /

restore controlfile from '备份路径/rman备份的控制文件';

 

sql 'alter database mount';

 

 

2,以下是恢复脚本,如果db比较小,可以直接用4个channel

因为是异机恢复,必须使用set newname来替换本机

 

在源库执行

select 'set newname for datafile '||file# || ' to '||''''||&1||'/'||substr(name,instr(name,'/',-1)+1)||''''||';' from  v$datafile_header;

输入目标库的DG:直接输入’'+TESTDATA_DG'

 

例子如下

 

z4ci1011:fcrtest1 > cat  restore.sh

export log_file=/paic/app/oracle/fcrrman/fcrtest_rman/fcr_rman_backup_20120710/restore_${ORACLE_SID}_`date '+%Y%m%d_%H%M%S'`.log

rman target / << EOF > ${log_file} 2>&1

run

{

allocate channel c1 type disk ;

allocate channel c2 type disk ;

allocate channel c3 type disk ;

allocate channel c4 type disk ;

allocate channel c5 type disk ;

allocate channel c6 type disk ;

allocate channel c7 type disk ;

allocate channel c8 type disk ;

allocate channel c9 type disk ;

allocate channel c10 type disk ;

allocate channel c11 type disk ;

allocate channel c12 type disk ;

set newname for datafile  1 to '+TESTDATA_DG';

set newname for datafile  2 to '+TESTDATA_DG';

set newname for datafile  3 to '+TESTDATA_DG';

set newname for datafile  5 to '+TESTDATA_DG';

set newname for datafile  6 to '+TESTDATA_DG';

set newname for datafile  7 to '+TESTDATA_DG';

set newname for datafile  8 to '+TESTDATA_DG';

set newname for datafile  9 to '+TESTDATA_DG';

set newname for datafile 10 to '+TESTDATA_DG';

set newname for datafile 11 to '+TESTDATA_DG';

set newname for datafile 12 to '+TESTDATA_DG';

set newname for datafile 13 to '+TESTDATA_DG';

set newname for datafile 14 to '+TESTDATA_DG';

set newname for datafile 15 to '+TESTDATA_DG';

set newname for datafile 16 to '+TESTDATA_DG';

set newname for datafile 17 to '+TESTDATA_DG';

set newname for datafile 18 to '+TESTDATA_DG';

set newname for datafile 19 to '+TESTDATA_DG';

set newname for datafile 20 to '+TESTDATA_DG';

set newname for datafile 21 to '+TESTDATA_DG';

set newname for datafile 22 to '+TESTDATA_DG';

set newname for datafile 23 to '+TESTDATA_DG';

restore database;

switch datafile all;

recover database;

release channel c1;

release channel c2;

release channel c3;

release channel c4;

release channel c5 ;

release channel c6 ;

release channel c7 ;

release channel c8 ;

release channel c9 ;

release channel c10;

release channel c11;

release channel c12;

}

EOF

 

echo "Restore finished at `date '+%Y%m%d_%H%M%S'`" >> ${log_file}

z4ci1011:fcrtest1 >

 

 

3,恢复完成后,要做open read only验证

 

4, 就是启库流程了

 

 

 

 

 

 

 

 

log_file=/paic/bank/tmpsun/rman1/backup/DM7/dmbcmsm/restore_${ORACLE_SID}_`date '+%Y%m%d_%H%M%S'`.log
export log_file
rman target / << EOF > ${log_file} 2>&1
run
{
allocate channel c1 type disk ;
allocate channel c2 type disk ;
allocate channel c3 type disk ;
allocate channel c4 type disk ;
allocate channel c5 type disk ;
allocate channel c6 type disk ;
allocate channel c7 type disk ;
allocate channel c8 type disk ;
restore database;
switch datafile all;
recover database;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5 ;
release channel c6 ;
release channel c7 ;
release channel c8 ;
}
EOF
 
echo "Restore finished at `date '+%Y%m%d_%H%M%S'`" >> ${log_filei}

 

 

 

 

 

 

 

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/14385647/viewspace-748469/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-11-05

  • 博文量
    24
  • 访问量
    28073