Friday 29 November 2013

RMAN Backup Completion Check

Let’s assume, we are doing a backup of a large database. At a given time, if we need to check, how much backup is finished & how much is left, so that we can have some estimates.
Following query can be used to check the RMAN backup status
If multiple channels are allocated for the backup, then this query will return multiple records. Each record will be indicating the status of individual channel

Oracle Dba Real Time Interview Question's And Answer's



1.       Which types of backups you can take in Oracle?

2.       A database is running in NOARCHIVELOG mode then which type of backups you can take?

3.       Can you take partial backups if the Database is running in NOARCHIVELOG mode?

4.       Can you take Online Backups if the the database is running in NOARCHIVELOG mode?

5.       How do you bring the database in ARCHIVELOG mode from NOARCHIVELOG mode?

6.       You cannot shutdown the database for even some minutes, then in which mode you should run
the database?

7.       Where should you place Archive logfiles, in the same disk where DB is or another disk?

8.       Can you take online backup of a Control file if yes, how?

9.       What is a Logical Backup?

10.   Should you take the backup of Logfiles if the database is running in ARCHIVELOG mode?
11.   Why do you take tablespaces in Backup mode?

12.   What is the advantage of RMAN utility?

13.   How RMAN improves backup time?

14.   Can you take Offline backups using RMAN?

15.   How do you see information about backups in RMAN?

16.   What is a Recovery Catalog?

17.   Should you place Recovery Catalog in the Same DB?

18.   Can you use RMAN without Recovery catalog?

19.   Can you take Image Backups using RMAN?

20.   Can you use Backupsets created by RMAN with any other utility?

21.   Where RMAN keeps information of backups if you are using RMAN without Catalog?

22.   You have taken a manual backup of a datafile using o/s. How RMAN will know about it?

23.   You want to retain only last 3 backups of datafiles. How do you go for it in RMAN?

24.   Which is more efficient Incremental Backups using RMAN or Incremental Export?

25.   Can you start and shutdown DB using RMAN?

26.   How do you recover from the loss of datafile if the DB is running in NOARCHIVELOG mode?

27.   You loss one datafile and it does not contain important objects. The important objects are there in other datafiles which are intact. How do you proceed in this situation?

28.   You lost some datafiles and you don't have any full backup and the database was running in NOARCHIVELOG mode. What you can do now?

29.   How do you recover from the loss of datafile if the DB is running in ARCHIVELOG mode?

30.   You loss one datafile and DB is running in ARCHIVELOG mode. You have full database backup of 1 week old and partial backup of this datafile which is just 1 day old. From which backup should you restore this file?

31.   You loss controlfile how do you recover from this?

32.    The current logfile gets damaged. What you can do now?

33.   What is a Complete Recovery?

34.   What is Cancel Based, Time based and Change Based Recovery?

35.   Some user has accidentally dropped one table and you realize this after two days. Can you recover this table if the DB is running in ARCHIVELOG mode?

36.   Do you have to restore Datafiles manually from backups if you are doing recovery using RMAN?

37.   A database is running in ARCHIVELOG mode since last one month. A datafile is added to the database last week. Many objects are created in this datafile. After one week this datafile gets damaged before you can take any backup. Now can you recover this datafile when you don't have any backups?

38.   How do you recover from the loss of a controlfile if you have backup of controlfile?

39.   Only some blocks are damaged in a datafile. Can you just recover these blocks if you are using RMAN?

40.   Some datafiles were there on a secondary disk and that disk has become damaged and it will take some days to get a new disk. How will you recover from this situation?


41.   Have you faced any emergency situation. Tell us how you resolved it?

42.   At one time you lost parameter file accidentally and you don't have any backup. How you will recreate a new parameter file with the parameters set to previous values.

43.   What is Consistent Backup?
A Consistent backup is one in which the files being backed up contain all changes upto the same system change number (SCN)

44.   What is fractured Block?
Because the database continues writing to the file during an online backup, there is the possibility of backing up inconsistent data within a block. For example, assume that either RMAN or an operating system utility reads the block while database writer is in the middle of updating the block. In this case, RMAN or the copy utility could read the old data in the top half of the block and the new data in the bottom top half of the block. The block is a fractured block, meaning that the data in this block is not consistent.
45.   What are the steps to performing complete recovery on the whole database?
Mount the database
Ensure that all datafiles you want to recover are online
Restore a backup of the whole database or the files you want to recover
Apply online or archived redo logs, or a combination of the two

46.   What are the steps to performing complete recovery on a tablespace or datafile?
Take the tablespace or datafile to be recovered offline if the database is open
Restore a backup of the datafiles you want to recover
Apply online or archived redo logs, or a combination of the two



47.   What are the components of physical database structure of Oracle database?
Oracle database is comprised of three types of files. One or more datafiles, two are more redo log files, and one or more control files.

48.   What are the components of logical database structure of Oracle database?
There are tablespaces and database's schema objects.

49.   What is a tablespace?
A database is divided into Logical Storage Unit called tablespaces. A tablespace is used to grouped related logical structures together.

50.   What is SYSTEM tablespace and when is it created?
Every Oracle database contains a tablespace named SYSTEM, which is automatically created when the database is created. The SYSTEM tablespace always contains the data dictionary tables for the entire database.

51.   Explain the relationship among database, tablespace and data file.
Each databases logically divided into one or more tablespaces one or more data files are explicitly created for each tablespace.

52.   What is schema?
A schema is collection of database objects of a user.

53.   What are Schema Objects?
Schema objects are the logical structures that directly refer to the database's data. Schema objects include tables, views, sequences, synonyms, indexes, clusters, database triggers, procedures, functions packages and database links.

54.   Can objects of the same schema reside in different tablespaces?
Yes.

55.   Can a tablespace hold objects from different schemes?
Yes.

56.   What is Oracle table?
A table is the basic unit of data storage in an Oracle database. The tables of a database hold all of the user accessible data. Table data is stored in rows and columns.

57.   What is an Oracle view?
A view is a virtual table. Every view has a query attached to it. (The query is a SELECT statement that identifies the columns and rows of the table(s) the view uses.)

58.   Do a view contain data?
Views do not contain or store data.

59.   Can a view based on another view?
Yes.

60.   What are the advantages of views?
- Provide an additional level of table security, by restricting access to a predetermined set of rows and columns of a table.
- Hide data complexity.
- Simplify commands for the user.
- Present the data in a different perspective from that of the base table.
- Store complex queries.

61.   What is an Oracle sequence?
A sequence generates a serial list of unique numbers for numerical columns of a database's tables.

62.   What is a synonym?
A synonym is an alias for a table, view, sequence or program unit.

63.   What are the types of synonyms?
There are two types of synonyms private and public.

64.   What is a private synonym?
Only its owner can access a private synonym.

65.   What is a public synonym?

66.   Any database user can access a public synonym.


67.   What are synonyms used for?
- Mask the real name and owner of an object. - Provide public access to an object - Provide location transparency for tables, views or program units of a remote database. - Simplify the SQL statements for database users.

68.   What is an Oracle index?
An index is an optional structure associated with a table to have direct access to rows, which can be created to increase the performance of data retrieval. Index can be created on one or more columns of a table.

69.   How are the index updates?
Indexes are automatically maintained and used by Oracle. Changes to table data are automatically incorporated into all relevant indexes.

70.   What are clusters?
Clusters are groups of one or more tables physically stores together to share common columns and are often used together.

71.   What is cluster key?
The related columns of the tables in a cluster are called the cluster key.

72.   What is index cluster?
A cluster with an index on the cluster key.

73.   What is hash cluster?
A row is stored in a hash cluster based on the result of applying a hash function to the row's cluster key value. All rows with the same hash key value are stores together on disk.

74.   When can hash cluster used?
Hash clusters are better choice when a table is often queried with equality queries. For such queries the specified cluster key value is hashed. The resulting hash key value points directly to the area on disk that stores the specified rows.

75.   What is database link?
A database link is a named object that describes a "path" from one database to another.

76.   What are the types of database links?
Private database link, public database link & network database link.

77.   What is private database link?
Private database link is created on behalf of a specific user. A private database link can be used only when the owner of the link specifies a global object name in a SQL statement or in the definition of the owner's views or procedures.

78.   What is public database link?
Public database link is created for the special user group PUBLIC. A public database link can be used when any user in the associated database specifies a global object name in a SQL statement or object definition.

79.   What is network database link?
Network database link is created and managed by a network domain service. A network database link can be used when any user of any database in the network specifies a global object name in a SQL statement or object definition.

80.   What is data block?
Oracle database's data is stored in data blocks. One data block corresponds to a specific number of bytes of physical database space on disk.

81.   How to define data block size?
A data block size is specified for each Oracle database when the database is created. A database users and allocated free database space in Oracle data blocks. Block size is specified in init.ora file and cannot be changed latter.

82.   What is row chaining?
In circumstances, all of the data for a row in a table may not be able to fit in the same data block. When this occurs, the data for the row is stored in a chain of data block (one or more) reserved for that segment.

83.   What is an extent?
An extent is a specific number of contiguous data blocks, obtained in a single allocation and used to store a specific type of information.

84.   What is a segment?
A segment is a set of extents allocated for a certain logical structure.

85.   What are the different types of segments?
Data segment, index segment, rollback segment and temporary segment.

86.   What is a data segment?
Each non-clustered table has a data segment. All of the table's data is stored in the extents of its data segment. Each cluster has a data segment. The data of every table in the cluster is stored in the cluster's data segment.

87.   What is an index segment?
Each index has an index segment that stores all of its data.

88.   What is rollback segment?
A database contains one or more rollback segments to temporarily store "undo" information.



89.   What are the uses of rollback segment?
To generate read-consistent database information during database recovery and to rollback uncommitted transactions by the users.

90.   What is a temporary segment?
Temporary segments are created by Oracle when a SQL statement needs a temporary work area to complete execution. When the statement finishes execution, the temporary segment extents are released to the system for future use.

91.   What is a datafile?
Every Oracle database has one or more physical data files. A database's data files contain all the database data. The data of logical database structures such as tablesand indexes is physically stored in the data files allocated for a database.

92.   What are the characteristics of data files?
A data file can be associated with only one database. Once created a data file can't change size. One or more data files form a logical unit of database storage called a tablespace.

93.   What is a redo log?
The set of redo log files for a database is collectively known as the database redo log.

94.   What is the function of redo log?
The primary function of the redo log is to record all changes made to data.

95.   What is the use of redo log information?
The information in a redo log file is used only to recover the database from a system or media failure prevents database data from being written to a database's data files.

96.   What does a control file contains?
- Database name - Names and locations of a database's files and redolog files. - Time stamp of database creation.

97.   What is the use of control file?
When an instance of an Oracle database is started, its control file is used to identify the database and redo log files that must be opened for database operation to proceed. It is also used in database recovery

Thursday 28 November 2013

ORACLE 11203 RMAN Active Database Cloning without Source Backup



11203 RMAN Active Database Cloning without Source Backup:

Source database will be in Mount Stage (No ArchiveLog Mode) è SRCDB
Target Database will be In NoMount Stage while Active cloning:  è DUPB
Time Taken: 12mins for 180GB (Same Server with ASM DiskGroup) 

Steps Overview:

Step1: Source DB = Mount (NO ARCHIVE LOG)

Setp2: Target DB - Nomount  (Auxiliary)

Step3: RMAN -

run {
 ALLOCATE CHANNEL d1 TYPE DISK ;
 ALLOCATE CHANNEL d2 TYPE DISK ;
 ALLOCATE CHANNEL d3 TYPE DISK ;
 ALLOCATE AUXILIARY CHANNEL a1 TYPE DISK ;
 ALLOCATE AUXILIARY CHANNEL a2 TYPE DISK ;
 ALLOCATE AUXILIARY CHANNEL a3 TYPE DISK ;
 duplicate target database to DUPDB  from active database;
 }

Step 4: Copy the wallet encryption file from source db  to target db (if you having Wallet encryption in your database)

Step5: start the db in mount stage (after cloning) 

step6: open the wallet

step7: Alter database open;


Generating Pfile from Cloning Duplicate Database:

[oracle@MyServer ~]$ echo $ORACLE_SID
SRCDB
[oracle@MyServer ~]$ sqlplus '/as sysdba'
SQL> create pfile='/localfs/export/SRCDB/initSRCDB.ora' from spfile;
File created.
SQL> exit
Edit your PFILE:
[oracle@MyServer SRCDB]$ cp initSRCDB.ora initDUPDB.ora
[oracle@MyServer SRCDB]$ vi initDUPDB.ora           
*.audit_file_dest='/localfs/orasrc/admin/DUPDB/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
#*.control_files='/localfs/oradata/DUPDB/control01.ctl','/localfs/oradata/DUPDB/control02.ctl'
*.db_block_size=8192
*.db_domain='MYDOMAIN.ORG'
*.db_name='DUPDB'
*.diagnostic_dest='/localfs/orasrc'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=DUPDBXDB)'
*.open_cursors=300
*.pga_aggregate_target=235929600
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=707788800
*.undo_tablespace='UNDOTBS1'
db_file_name_convert='/localfs/oradata/SRCDB/','/localfs/oradata/DUPDB/'
log_file_name_convert='/localfs/oradata/SRCDB/','/localfs/oradata/DUPDB/'
 
Copy your Soruce Password file
[oracle@MyServer SRCDB]$ cd $ORACLE_HOME/dbs
[oracle@MyServer dbs]$ cp orapwSRCDB orapwDUPDB
[oracle@MyServer dbs]$ cd -
/localfs/export/SRCDB 
Creating Spfile:
[oracle@MyServer SRCDB]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.2.0 Production on Tue Feb 19 04:14:33 2013
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> create spfile from pfile='/localfs/export/SRCDB/initDUPDB.ora';
File created. 
SQL> startup nomount;
ORACLE instance started.
Total System Global Area  705662976 bytes
Fixed Size                  2229840 bytes
Variable Size             201329072 bytes
Database Buffers          494927872 bytes
Redo Buffers                7176192 bytes
SQL> exit
Source Database Mount:
[oracle@MyServer admin]$ echo $ORACLE_SID
SRCDB 
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area  705662976 bytes
Fixed Size                  2229840 bytes
Variable Size             201329072 bytes
Database Buffers          494927872 bytes
Redo Buffers                7176192 bytes
Database mounted.
SQL> exit
My Listener Entries:
LSNR_DUPDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = MyServer.MYDOMAIN.ORG)(PORT = 1522))
  )
SID_LIST_LSNR_DUPDB =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = DUPDB.MYDOMAIN.ORG)
      (ORACLE_HOME = /localfs/orasrc/product/db/11.2.0.2)
      (SID_NAME = DUPDB)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = SRCDB.MYDOMAIN.ORG)
      (ORACLE_HOME = /localfs/orasrc/product/db/11.2.0.2)
      (SID_NAME = SRCDB)
    )
  )
[oracle@MyServer admin]$ ps -ef | grep tns
oracle   28013     1  0 04:36 ?        00:00:00 /localfs/orasrc/product/db/11.2.0.2/bin/tnslsnr LSNR_DUPDB -inherit
Note:  NoMount Stage Database required the Seperate Listener to avoid the below error while cloning the database using RMAN Auxiliary connection
ORA-12528: TNS:listener: all appropriate instances are blocking new connections
My TnsName Entry:
SRCDB.MYDOMAIN.ORG =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = MyServer.MYDOMAIN.ORG)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = SRCDB.MYDOMAIN.org)
    )
  )
DUPDB.MYDOMAIN.ORG =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = MyServer.MYDOMAIN.ORG)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = DUPDB.MYDOMAIN.org)
    )
  )
=============================================================================
RMAN Execution:
[oracle@MyServer SRCDB]$ rman
Recovery Manager: Release 11.2.0.2.0 - Production on Tue Feb 19 04:40:54 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
RMAN> connect auxiliary sys/PassWd@DUPDB
connected to auxiliary database: DUPDB (not mounted)
RMAN> connect target sys/PassWd@SRCDB
connected to target database: SRCDB (DBID=523443299, not open)
RMAN> run
2>  {
3>  ALLOCATE CHANNEL d1 TYPE DISK ;
 ALLOCATE CHANNEL d2 TYPE DISK ;
4> 5>  ALLOCATE CHANNEL d3 TYPE DISK ;
6>  ALLOCATE AUXILIARY CHANNEL a1 TYPE DISK ;
7>  ALLOCATE AUXILIARY CHANNEL a2 TYPE DISK ;
8>  ALLOCATE AUXILIARY CHANNEL a3 TYPE DISK ;
9>  duplicate target database to DUPDB from active database;
10>  }
using target database control file instead of recovery catalog
allocated channel: d1
channel d1: SID=63 device type=DISK
allocated channel: d2
channel d2: SID=129 device type=DISK
allocated channel: d3
channel d3: SID=191 device type=DISK
allocated channel: a1
channel a1: SID=63 device type=DISK
allocated channel: a2
channel a2: SID=129 device type=DISK
allocated channel: a3
channel a3: SID=192 device type=DISK
Starting Duplicate Db at 19-FEB-13
contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''SRCDB'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''DUPDB'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  '/localfs/orasrc/product/db/11.2.0.2/dbs/cntrlDUPDB.dbf';
   alter clone database mount;
}
executing Memory Script
......
......
......
......
contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 19-FEB-13
released channel: d1
released channel: d2
released channel: d3
released channel: a1
released channel: a2
released channel: a3
RMAN> exit

Recovery Manager complete.
[oracle@MyServer SRCDB]$
=============================================================================
[oracle@MyServer ~]$ export ORACLE_SID=DUPDB
[oracle@MyServer ~]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.2.0 Production on Tue Feb 19 04:45:02 2013
Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select open_mode from v$database;
OPEN_MODE
------------------------------------------------------------
READ WRITE
======================================================================


with and without AUTOBACKUP-Restoring the SPFILE

Let us look at some backup and recovery scenarios pertaining to the SPFIILE. The SPFILE is a small but very important file and if we lose the spfile, we cannot start the database even if all the other database files are present and intact.
So in my opinion, it is quite an important thing to consider in our disaster recovery strategy.
Remember best practise is to turn the autobackup of the control file to ON (it is OFF by default).
SPFILE is automatically backed up along with the database control file when any of the following events occur and when the control file autobackup has been enabled in RMAN. .
RMAN> show controlfile autobackup;

RMAN configuration parameters for database with db_unique_name GAVIN are:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
When does the SPFILE gat backed up with AUTOBACKUP now tuned on?
  • After every BACKUP or CREATE CATALOG command
  • After every BACKUP command contained in a RUN block
  • After every structural change to the database occurs like adding a new tablespace, altering the state of a tablespace or datafile (for example, bringing it online), adding a new online redo log, renaming a file

Where does the SPFILE autobackup reside?
RMAN> show controlfile autobackup format ;

RMAN configuration parameters for database with db_unique_name GAVIN are:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
This is the default setting for CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK
By default, RMAN will send the autobackup to the flash recovery area (if used).
Let us now remove the default keyword
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
new RMAN configuration parameters are successfully stored
In this case the SPFILE (and control file) autobackup is located anywhere you specify, but default location will be %ORACLE_HOME%\Database on Windows and $ORACLE_HOME/dbs on UNIX.
RMAN> list backup of spfile;

using target database control file instead of recovery catalog

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
252     Full    9.73M      DISK        00:00:00     13-JUN-13
        BP Key: 267   Status: AVAILABLE  Compressed: NO  Tag: TAG20130613T144508
        Piece Name: /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-2968723077-20130613-00
Let us now specify an actual location on disk instead of just the %F,
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup/%F';

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup/%F';
new RMAN configuration parameters are successfully stored


RMAN> list backup of spfile;

using target database control file instead of recovery catalog

List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
256     Full    9.73M      DISK        00:00:01     13-JUN-13
        BP Key: 271   Status: AVAILABLE  Compressed: NO  Tag: TAG20130613T155004
        Piece Name: /u01/backup/c-2968723077-20130613-01
Note the SPFILE autobackup is now located at /u01/backup and we can see the format of the backup file on disk is no longer OMF.
The DBID (2968723077) and the timestamp (20130613) is now contained in the backup file name c-2968723077-20130613-01
Let us now revert the autobackup back to the FRA.
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;


old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
RMAN configuration parameters are successfully reset to default value

RMAN> show CONTROLFILE AUTOBACKUP FORMAT;

RMAN configuration parameters for database with db_unique_name GAVIN are:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default


RMAN> list backup of spfile;

using target database control file instead of recovery catalog

List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
266     Full    9.73M      DISK        00:00:01     13-JUN-13
        BP Key: 281   Status: AVAILABLE  Compressed: NO  Tag: TAG20130613T162411
        Piece Name: /u01/app/oracle/fast_recovery_area/GAVIN/autobackup/2013_06_13/o1_mf_s_818007851_8vlsdd3n_.bkp
Autobackup is now back to OMF.
Recovery scenarios involving loss of SPFILE
Case 1) Autobackup in Flash (or now called Fast) Recovery Area
The SPFILE has accidently been deleted and now the database is not starting up after a shutdown has been executed.
FRA has been configured.
If FRA has been configured, the backup of the SPFILE is located in the autobackup sub-directory.
For example:
/u01/app/oracle/fast_recovery_area/GAVIN/autobackup/2013_06_10/ o1_mf_s_818007851_8vlsdd3n_.bkp
Note that it is stored in OMF format in this example. The ‘s’ in the string identifies the OMF as a backup related to the SPFILE
To recover from loss of SPFILE if you are NOT using an RMAN Catalog, we need to do two things first :
1) Set the DBID
2) Issue the STARTUP NOMOUNT FORCE command from an RMAN prompt (note – not SQL*PLUS)
RMAN> SET DBID=2968723077;

executing command: SET DBID

RMAN> startup force nomount;

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initgavin.ora'

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

Total System Global Area     158662656 bytes

Fixed Size                     2226456 bytes
Variable Size                104859368 bytes
Database Buffers              46137344 bytes
Redo Buffers                   5439488 bytes
This is a typical error we will face when either restoring the SPFILE or control file from an autobackup.
RMAN>  restore controlfile from autobackup;

Starting restore at 13-JUN-13
using channel ORA_DISK_1

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130613
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130612
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130611
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130610
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130609
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130608
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130607
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 06/13/2013 17:15:52
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece
The reason in this case is that since the spfile is missing and we have mounted the instance using a dummy spfile, the database needs to know where to look to find the autobackup of the spfile .
So now we include the db_file_recovery_dest and db_name parameters in the RESTORE SPFILE command.
RMAN> restore spfile from autobackup db_recovery_file_dest='/u01/backup/fast_recovery_area' db_name='GAVIN';

Starting restore at 13-JUN-13
using channel ORA_DISK_1

recovery area destination: /u01/backup/fast_recovery_area
database name (or database unique name) used for search: GAVIN
channel ORA_DISK_1: AUTOBACKUP /u01/backup/fast_recovery_area/GAVIN/autobackup/2013_06_10/o1_mf_s_818007851_8vlsdd3n_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130613
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/backup/fast_recovery_area/GAVIN/autobackup/2013_06_10/o1_mf_s_818007851_8vlsdd3n_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 13-JUN-13
Case 2) Autobackup in non-FRA location – non OMF
RMAN> startup nomount force

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initgavin.ora'

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

Total System Global Area     158662656 bytes

Fixed Size                     2226456 bytes
Variable Size                104859368 bytes
Database Buffers              46137344 bytes
Redo Buffers                   5439488 bytes

RMAN> set DBID=2968723077

executing command: SET DBID

RMAN>  run {
2> set CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup/%F';
3> restore spfile from autobackup;
4> }

executing command: SET CONTROLFILE AUTOBACKUP FORMAT

Starting restore at 13-JUN-13
using channel ORA_DISK_1

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130613
channel ORA_DISK_1: AUTOBACKUP found: '/u01/backup/c-2968723077-20130613-01
channel ORA_DISK_1: restoring spfile from AUTOBACKUP '/u01/backup/c-2968723077-20130613-01
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 13-JUN-13
Case 3) Total Disaster Recovery ( restore by specifying the backup file name)
In this scenario, the entire database server has crashed and we have lost the entire database files including the SPFILE.
A new server has been provisioned and all the latest backup files have been restored from tape to a location on disk /u01/backup.
In this case the backup files are OMF and we have been able to identify the SPFILE backup file from the ‘s’ keyword in the backup file name
RMAN> restore spfile from '/u01/backup/o1_mf_s_818007851_8vlsdd3n_.bkp';

Starting restore at 13-JUN-13
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/backup/o1_mf_s_818007851_8vlsdd3n_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 13-JUN-13

Case 4) Total Disaster Recovery ( restore by specifying restore from AUTOBACKUP)
In this case, the scenario is the same as the above.
But what happens if we want to use the AUTOBACKUP command to restore the spfile because many backup files have been restored and we are not sure which backup file contains the SPFILE backup.
But what happens in this case when we try to restore the SPFILE from the location where the backup has been restored.
RMAN>  run {
2> set CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup/%F';
3> restore spfile from autobackup;
4> }

executing command: SET CONTROLFILE AUTOBACKUP FORMAT

Starting restore at 17-JUN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=171 device type=DISK

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130617
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130616
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130615
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130614
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130613
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130612
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130611
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 06/17/2013 15:29:58
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece
So to work around this, we tried to fool RMAN by creating the directory structure when using a FRA.
We create the directory structure GAVIN/autobackup/2013_06_17 under the to level location /u01/backup and copy the backup pieces to this location.
-bash-3.2$ cd /u01/backup
-bash-3.2$ mkdir -p GAVIN/autobackup/2013_06_17
-bash-3.2$ mv /u01/backup/o1* /u01/backup/GAVIN/autobackup/2013_06_17
Now we are able to restore the SPFILE from autobackup!
RMAN>  run {
2> restore spfile from autobackup db_recovery_file_dest='/u01/backup/' db_name='GAVIN';
3> }

Starting restore at 17-JUN-13
using channel ORA_DISK_1

recovery area destination: /u01/backup/
database name (or database unique name) used for search: GAVIN
channel ORA_DISK_1: AUTOBACKUP /u01/backup/GAVIN/autobackup/2013_06_17/o1_mf_s_818349778_8vx79lo6_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130617
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/backup/GAVIN/autobackup/2013_06_17/o1_mf_s_818349778_8vx79lo6_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 17-JUN-13