D:\>rman target sys/system@orcl catalog rman/rman@rmancat
Recovery Manager: Release 10.2.0.3.0 - Production on Thu Sep 22 15:31:05 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1286153759)
connected to recovery catalog database
RMAN> catalog recovery area;
searching for all files in the recovery area
no files found to be unknown to the database
RMAN> run{
2> allocate channel ch1 device type disk;
3> allocate channel ch2 device type disk;
4>
5> backup database;
6>
7> release channel ch1;
8> release channel ch2;
9>
10> sql 'alter system archive log current';
11>
12> allocate channel ch1 device type disk;
13> allocate channel ch2 device type disk;
14>
15> backup archivelog all delete input filesperset 5;
16>
17> release channel ch1;
18> release channel ch2;
19> }
allocated channel: ch1
channel ch1: sid=132 devtype=DISK
allocated channel: ch2
channel ch2: sid=131 devtype=DISK
Starting backup at 22-SEP-11
channel ch1: starting full datafile backupset
channel ch1: specifying datafile(s) in backupset
input datafile fno=00001 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
input datafile fno=00004 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
channel ch1: starting piece 1 at 22-SEP-11
channel ch2: starting full datafile backupset
channel ch2: specifying datafile(s) in backupset
input datafile fno=00003 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
input datafile fno=00005 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF
input datafile fno=00002 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
channel ch2: starting piece 1 at 22-SEP-11
channel ch1: finished piece 1 at 22-SEP-11
piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2011_09
_22\O1_MF_NNNDF_TAG20110922T153158_77OS3H5P_.BKP tag=TAG20110922T153158 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:36
channel ch2: finished piece 1 at 22-SEP-11
piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2011_09
_22\O1_MF_NNNDF_TAG20110922T153158_77OS3L85_.BKP tag=TAG20110922T153158 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:36
Finished backup at 22-SEP-11
Starting Control File and SPFILE Autobackup at 22-SEP-11
piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2011_0
9_22\O1_MF_S_762535955_77OS4NFJ_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 22-SEP-11
released channel: ch1
released channel: ch2
sql statement: alter system archive log current
allocated channel: ch1
channel ch1: sid=132 devtype=DISK
allocated channel: ch2
channel ch2: sid=131 devtype=DISK
Starting backup at 22-SEP-11
current log archived
channel ch1: starting archive log backupset
channel ch1: specifying archive log(s) in backup set
input archive log thread=1 sequence=3 recid=50 stamp=762535964
channel ch1: starting piece 1 at 22-SEP-11
channel ch2: starting archive log backupset
channel ch2: specifying archive log(s) in backup set
input archive log thread=1 sequence=4 recid=51 stamp=762535966
channel ch2: starting piece 1 at 22-SEP-11
channel ch1: finished piece 1 at 22-SEP-11
piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2011_09
_22\O1_MF_ANNNN_TAG20110922T153247_77OS50JX_.BKP tag=TAG20110922T153247 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:02
channel ch1: deleting archive log(s)
archive log filename=D:\ORACLE\PRODUCT\10.2.0\ARCH\ORCL\ARC00003_0762515031.001
recid=50 stamp=762535964
channel ch2: finished piece 1 at 22-SEP-11
piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2011_09
_22\O1_MF_ANNNN_TAG20110922T153247_77OS50SP_.BKP tag=TAG20110922T153247 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:02
channel ch2: deleting archive log(s)
archive log filename=D:\ORACLE\PRODUCT\10.2.0\ARCH\ORCL\ARC00004_0762515031.001
recid=51 stamp=762535966
Finished backup at 22-SEP-11
Starting Control File and SPFILE Autobackup at 22-SEP-11
piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\AUTOBACKUP\2011_0
9_22\O1_MF_S_762535970_77OS53F0_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 22-SEP-11
released channel: ch1
released channel: ch2
从输出信息可以看出,当rman配置为自动备份controlfile时,spfile也会随之一起自动备份。
一 数据库处于打开状态,丢失spfile,pfile
模拟spfile丢失的情况,删除spfile,pfile
del D:\oracle\product\10.2.0\db_1\database\spfileorcl.ora
del D:\oracle\product\10.2.0\db_1\database\initorcl.ora
SQL> create pfile from spfile;
create pfile from spfile
*
ERROR at line 1:
ORA-27041: unable to open file
OSD-04002: 无法打开文件
O/S-Error: (OS 2) 系统找不到指定的文件。
从rman恢复spfile
D:\>rman target sys/system@orcl catalog rman/rman@rmancat
Recovery Manager: Release 10.2.0.3.0 - Production on Thu Sep 22 16:02:22 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1286153759)
connected to recovery catalog database
RMAN> restore spfile from autobackup;
Starting restore at 22-SEP-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=139 devtype=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 09/22/2011 16:02:36
RMAN-06564: must use the TO clause when the instance is started with SPFILE
RMAN> restore spfile to 'd:\spfile.ora' from autobackup;
Starting restore at 22-SEP-11
using channel ORA_DISK_1
recovery area destination: d:\oracle\product\10.2.0\flash_recovery_area
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AR
EA\ORCL\AUTOBACKUP\2011_09_22\O1_MF_S_762535970_77OS53F0_.BKP
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 22-SEP-11
把spfile.ora拷贝至database目录下
cp d:\spfile.ora D:\oracle\product\10.2.0\db_1\database\spfileorcl.ora
验证spfile可以正常使用。
SQL> create pfile from spfile;
File created.
二 数据库处于关闭状态,丢失spfile,pfile
del D:\oracle\product\10.2.0\db_1\database\spfileorcl.ora
del D:\oracle\product\10.2.0\db_1\database\initorcl.ora
启动数据库
SQL> startup;
ORA-01078: failure in processing system parameters
LRM-00109: couldn't open parameter file 'D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INITORCL.ORA'
SQL> startup nomount;
ORA-01078: failure in processing system parameters
LRM-00109: couldn't open parameter file 'D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INITORCL.ORA'
SQL> startup force nomount;
ORA-01078: failure in processing system parameters
LRM-00109: couldn't open parameter file 'D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INITORCL.ORA'
D:\>rman target /
Recovery Manager: Release 10.2.0.3.0 - Production on Thu Sep 22 16:15:08 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> restore spfile from autobackup;
Starting restore at 22-SEP-11
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 09/22/2011 16:17:15
RMAN-12010: automatic channel allocation initialization failed
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
RMAN> restore spfile from 'D:\oracle\product\10.2.0\flash_recovery_area\ORCL\AUT
OBACKUP\2011_09_22\O1_MF_S_762535970_77OS53F0_.BKP';
Starting restore at 22-SEP-11
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 09/22/2011 16:18:21
RMAN-12010: automatic channel allocation initialization failed
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
RMAN> startup force nomount;
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: couldn't open parameter file 'D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INITORCL.ORA'
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
Total System Global Area 159383552 bytes
Fixed Size 1289436 bytes
Variable Size 58721060 bytes
Database Buffers 92274688 bytes
Redo Buffers 7098368 bytes
RMAN> restore spfile from autobackup;
Starting restore at 22-SEP-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=37 devtype=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 09/22/2011 16:24:26
RMAN-06495: must explicitly specify DBID with SET DBID command
RMAN> set DBID=1286153759
executing command: SET DBID
RMAN> restore spfile from autobackup;
Starting restore at 22-SEP-11
using channel ORA_DISK_1
channel ORA_DISK_1: looking for autobackup on day: 20110922
channel ORA_DISK_1: looking for autobackup on day: 20110921
channel ORA_DISK_1: looking for autobackup on day: 20110920
channel ORA_DISK_1: looking for autobackup on day: 20110919
channel ORA_DISK_1: looking for autobackup on day: 20110918
channel ORA_DISK_1: looking for autobackup on day: 20110917
channel ORA_DISK_1: looking for autobackup on day: 20110916
channel ORA_DISK_1: no autobackup in 7 days found
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 09/22/2011 16:25:37
RMAN-06172: no autobackup found or specified handle is not a valid copy or piece
rman找不到自动备份的spfile,只能指定具体的备份文件,从备份中进行恢复了。
不明白为什么rman自己找不到备份的spfile呢?
RMAN> restore spfile from 'D:\oracle\product\10.2.0\flash_recovery_area\ORCL\AUT
OBACKUP\2011_09_22\O1_MF_S_762535970_77OS53F0_.BKP';
Starting restore at 22-SEP-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=37 devtype=DISK
channel ORA_DISK_1: autobackup found: D:\oracle\product\10.2.0\flash_recovery_ar
ea\ORCL\AUTOBACKUP\2011_09_22\O1_MF_S_762535970_77OS53F0_.BKP
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 22-SEP-11
RMAN> shutdown immediate;
Oracle instance shut down
RMAN> startup;
connected to target database (not started)
Oracle instance started
database mounted
database opened
Total System Global Area 205520896 bytes
Fixed Size 1289700 bytes
Variable Size 180355612 bytes
Database Buffers 16777216 bytes
Redo Buffers 7098368 bytes
SQL> create pfile from spfile;
File created.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/36590/viewspace-708113/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/36590/viewspace-708113/