In this lab, the spfile and pfile are recovered when the database is lost in both open and shutdown conditions.
Oracle @ aoracle dbs] $ rman target rman_user/rman_user;
Recovery Manager: Release 10.2.0.1.0-Production on Thu Dec 8 19:21:38 2011
Copyright (c) 1982,200 5, Oracle. All rights reserved.
Connected to target database: EZHOU (DBID = 4046377924, not open)
RMAN> restore spfile;
Starting restore at 08-DEC-11
Using target database control file instead of recovery catalog
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: sid = 149 devtype = DISK
RMAN-00571: ========================================================== ==============================
RMAN-00569: ==================== error message stack follows ==========================
RMAN-00571: ========================================================== ==============================
RMAN-03002: failure of restore command at 12/08/2011 19:21:56
RMAN-06564: must use the TO clause when the instance is started with SPFILE
RMAN> restore spfile to '/u02/rman/spfile. ora' from autobackup;
Starting restore at 08-DEC-11
Using channel ORA_DISK_1
Channel ORA_DISK_1: looking for autobackup on day: 20111208
Channel ORA_DISK_1: autobackup found:/u02/rman/ctl_c-4046377924-20111208-00
Channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 08-DEC-11
RMAN>
Copy the spfile to $ ORACLE_HOME/dbs.
==============================
Run the following: the database is closed, and spfile and pfile are lost.
[Oracle @ aoracle dbs] $ mv spfileezhou. ora spfileezhou. ora_ B
[Oracle @ aoracle dbs] $ mv initezhou. ora initezhou. ora_ B
[Oracle @ aoracle dbs] $ ls-l * ezhou *. ora *
-Rw-r -- 1 oracle oinstall 986 Dec 6 initezhou. ora_ B
-Rw-r ----- 1 oracle oinstall 2560 Dec 8 spfileezhou. ora_ B
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
[Oracle @ aoracle admin] $ sqlplus/as sysdba
SQL * Plus: Release 10.2.0.1.0-Production on Thu Dec 8 20:01:33 2011
Copyright (c) 1982,200 5, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup;
ORA-01078: failure in processing system parameters
LRM-00109: cocould not open parameter file '/u01/pp/oracle/product/10.2/db_1/dbs/initezhou. ora'
SQL> startup nomount;
ORA-01078: failure in processing system parameters
LRM-00109: cocould not open parameter file '/u01/pp/oracle/product/10.2/db_1/dbs/initezhou. ora'
SQL> startup force nomount;
ORA-01078: failure in processing system parameters
LRM-00109: cocould not open parameter file '/u01/pp/oracle/product/10.2/db_1/dbs/initezhou. ora'
SQL>!
[Oracle @ aoracle admin] $ rman target/
Recovery Manager: Release 10.2.0.1.0-Production on Thu Dec 8 20:04:10 2011
Copyright (c) 1982,200 5, Oracle. All rights reserved.
Connected to target database (not started)
RMAN> restore spfile from '/u02/rman/ctl_c-4046377924-20111208-00'
2>;
Starting restore at 08-DEC-11
RMAN-00571: ========================================================== ==============================
RMAN-00569: ==================== error message stack follows ==========================
RMAN-00571: ========================================================== ==============================
RMAN-03002: failure of restore command at 12/08/2011 20:05:29
RMAN-12010: automatic channel allocation initialization failed
RMAN-06403: cocould not obtain a fully authorized session
A ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
RMAN> startup force nomount;
Startup failure: ORA-01078: failure in processing system parameters
LRM-00109: cocould not open parameter file '/u01/pp/oracle/product/10.2/db_1/dbs/initezhou. ora'
Starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
Total System Global Area 159383552 bytes
Fixed Size 1218268 bytes
Variable Size 54528292 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes
RMAN> restore spfile from autobackup;
Starting restore at 08-DEC-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 12/08/2011 20:06:44
RMAN-06495: must explicitly specify DBID with set dbid command
RMAN> set dbid 4046377924
Executing command: SET DBID
RMAN> restore spfile from autobackup;
Starting restore at 08-DEC-11
Using channel ORA_DISK_1
Channel ORA_DISK_1: looking for autobackup on day: 20111208
Channel ORA_DISK_1: looking for autobackup on day: 20111207
Channel ORA_DISK_1: looking for autobackup on day: 20111206
Channel ORA_DISK_1: looking for autobackup on day: 20111205
Channel ORA_DISK_1: looking for autobackup on day: 20111204
Channel ORA_DISK_1: looking for autobackup on day: 20111203
Channel ORA_DISK_1: looking for autobackup on day: 20111202
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 12/08/2011 20:07:18
RMAN-06172: no autobackup found or specified handle is not a valid copy or piece
RMAN> restore spfile from '/u02/rman/ctl_c-4046377924-20111208-00 ';
Starting restore at 08-DEC-11
Using channel ORA_DISK_1
Channel ORA_DISK_1: autobackup found:/u02/rman/ctl_c-4046377924-20111208-00
Channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 08-DEC-11
RMAN>
Pfile can be created from spfile create.
==========
Conclusion: spfile and pfile are successfully restored in both open and shutdown databases.