---
title: "rman进行数据库的备份与恢复"
author: "lengyue"
date: "2011-08-31T23:29:51Z"
tags: []
categories: ["数据库"]
slug: "rman"
draft: false
lastmod: "2011-08-31T23:29:51Z"
id: 1162847
url: "https://lengyue.iteye.com/blog/1162847"
---

通过rman进行备份与恢复的基本步骤

1.进入rman target sys/密码  
2.编辑脚本，放在d:\\sql下命名为level0.sql  
run {

  configure controlfile autobackup on;

  configure controlfile autobackup format for device type disk to 'd:\\backup\\%F';

  allocate channel d1 type disk;

  allocate channel d2 type disk;

  backup incremental level=0 database format 'd:\\backup\\d\_%T\_%s.bak';

  release channel d1;

  release channel d2;

}  
level1.sql  
run {

  configure controlfile autobackup on;

  configure controlfile autobackup format for device type disk to 'd:\\backup1\\%F';

  allocate channel d1 type disk;

  allocate channel d2 type disk;

  backup incremental level=1 database format 'd:\\backup1\\d\_%T\_%s.bak';

  release channel d1;

  release channel d2;

}

3.RMAN&gt;@d:\\sql\\level0.sql  
4.RMAN&gt;@d:\\sql\\level1.sql  
备份完成  
5.通过rman还原数据库  
6.修改  
修改d:\\develop\\oracle\\product\\10.2.0\\orcl\\admin\\orcl\\pfile\\init.ora.12848886686 文件，添加参数：  
 \_allow\_resetlogs\_corruption=true  
7.在sqlplus下connect sys/密码  
8.SQL&gt;startup pfile="d:\\develop\\oracle\\product\\10.2.0\\orcl\\admin\\orcl\\pfile\\init.ora.12848886686" nomount;  
9.在RMAN下  
select dbid from v$database;

记住这个数，本例中dbid为：1276583931  
10.connect target sys/密码 ;  
11.set dbid=1276583931;  
12.restore controlfile from 'd:\\backup1\\c-1276583931-20110803-00’;  
13.restore spfile from 'd:\\backup1\\c-1276583931-20110803-00';  
14.alter database mount;  
15.restore database;  
16.Alter database open resetlogs;