恢复之前做一个备份,下面是笔者自己写的全备份脚本:

run {

configure controlfile autobackup on;

configure controlfile autobackup format for device type disk to '/home/oracle/%F';

backup format '/home/oracle/data_%U' database

plus archivelog

delete all input;

}

 

oracle@orazhang dbs]$ rman target / --不要在sqlplus里startup ,去rman 里 startup 到nomount

RMAN> startup nomount

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file ‘/u01/app/oracle/product/10.2.0/db_1/dbs/initorcl.ora’

starting Oracle instance without parameter file for retrival of spfile
Oracle instance started

方法一:

RMAN> restore spfile from autobackup;

Starting restore at 22-2月 -11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 02/22/2011 10:43:06
RMAN-06495: must explicitly specify DBID with SET DBID command

提示如果要用 autobackup,就要指定dbid, 要先在 rman 中set dbid=xxxx,dbid在rman备份时会显示,也可以在数据库状态打开时,用

SQL> select dbid from  v$database;

DBID 
———-
1246063822

如果知道dbid就可以

在备份的controlfile spfile的文件名中有dbid。

RMAN> startup nomount

Oracle instance started

Total System Global Area     562036736 bytes

Fixed Size                     1220556 bytes
Variable Size                176160820 bytes
Database Buffers             377487360 bytes
Redo Buffers                   7168000 bytes

RMAN> set dbid=1246063822

executing command: SET DBID

RMAN> restore spfile from autobackup;

方法二:

现在是假如我dbid不知道怎么办?直接指定备份的控制文件

RMAN> restore spfile from ‘/home/oracle/c-1246063822-20110221-01.ctl’;

Starting restore at 22-2月 -11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=39 devtype=DISK

channel ORA_DISK_1: autobackup found: /home/oracle/c-1246063822-20110221-01.ctl
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 22-2月 -11

RMAN> shutdown immediate

using target database control file instead of recovery catalog
Oracle instance shut down

RMAN> startup

connected to target database (not started)
Oracle instance started
database mounted
database opened

Total System Global Area     562036736 bytes

Fixed Size                     1220556 bytes
Variable Size                176160820 bytes
Database Buffers             377487360 bytes
Redo Buffers                   7168000 bytes

好,spfile恢复成功了

controlfile的恢复也一样。