rman全库备份,恢复过程

最近一直在忙于写shell脚本,忽略了oracle的基础的回顾,正好做了个rman的恢复,记录一下加深印象!

oracle全库备份的理想状态下在mount时做全备,这样不需要去做考虑一致性问题。仅仅是理想而已。

将数据库开为归档模式下,进行全备,脚本如下

log_file=/paic/hq/bk/restore/home/op11202/xionglang/investdw/full_backup_${ORACLE_SID}_`date '+%Y%m%d_%H%M%S'`.log
export log_file
rman target / << EOF > ${log_file} 2>&1
sql 'alter system switch logfile';
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;
BACKUP as compressed backupset full DATABASE plus archivelog FORMAT '/paic/hq/bk/restore/home/op11202/xionglang/investdw/full_%T-%d-%u-%p'  filesperset=10;
backup as copy current controlfile format '/paic/hq/bk/restore/home/op11202/xionglang/investdw/ctrl_%t-%s-%p.f';
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 "Backup finished at `date '+%Y%m%d_%H%M%S'`" >> ${log_file}

1.生成一份原开发/测试库的pfile 
2.利用步骤1中的pfile,启动到nomount
3.rman target /
RMAN>  Restore controlfile from  ‘/xxxx/xxxx/*****.f’;   /xxxx/xxxx/*****.f为生产dg库的controlfile的备份
RMAN> Alter database mount;
RMAN>  Catalog start with ‘/xxxx/xxxx/’;  注册备份片到恢复出来的控制文件里

4.后台执行如下restore脚本。如果恢复出来了归档日志restore database之后需要recover database;
(注意incarnation相关报错)
5.恢复完成以后,shutdown实例,修改pfile里的db_name为原测试库SID  启动到nomount
6.使用create controlfile set database 命令重建控制文件
7.alter database open resetlogs;
8.添加临时文件


恢复脚本:

log_file=/paic/dev/oracle/11g/odsz11g/xionglang/xionglang/d1gccrep/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

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值