You are on page 1of 7

Can one restore RMAN backups without a CONTROLFILE and

RECOVERY CATALOG?

Details of RMAN backups are stored in the database control files and optionally a
Recovery Catalog. If both these are gone, RMAN cannot restore the database. In such a
situation one must extract a control file (or other files) from the backup pieces written out
when the last backup was taken. Let's look at an example:

Let's take a backup (partial in our case for illustrative purposes):

$ rman target / nocatalog


Recovery Manager: Release 10.1.0.2.0 - 64bit Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1046662649)


using target database controlfile instead of recovery catalog

RMAN> backup datafile 1;

Starting backup at 20-AUG-04


allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=146 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oradata/orcl/system01.dbf
channel ORA_DISK_1: starting piece 1 at 20-AUG-04
channel ORA_DISK_1: finished piece 1 at 20-AUG-04
piece handle=
/
flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_nnndf_TAG20040820T15
3256_0lczd9tf_.bkp comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current controlfile in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 20-AUG-04
channel ORA_DISK_1: finished piece 1 at 20-AUG-04
piece handle=
/
flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_ncsnf_TAG20040820T15
3256_0lczfrx8_.bkp comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 20-AUG-04[/code]

Now, let's destroy one of the control files:

SQL> show parameters CONTROL_FILES


NAME TYPE VALUE
------------------------------------ -----------
------------------------------
control_files string
/oradata/orcl/control01.ctl,
/oradata/orcl/control02.ctl,

/oradata/orcl/control03.ctl
SQL> shutdown abort;
ORACLE instance shut down.
SQL> ! mv /oradata/orcl/control01.ctl /tmp/control01.ctl</pre>

Now, let's see if we can restore it. First we need to start the databaase in NOMOUNT
mode:

SQL> startup NOMOUNT


ORACLE instance started.

Total System Global Area 289406976 bytes


Fixed Size 1301536 bytes
Variable Size 262677472 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes</pre>

Now, from SQL*Plus, run the following PL/SQL block to restore the file:

DECLARE
v_devtype VARCHAR2(100);
v_done BOOLEAN;
v_maxPieces NUMBER;

TYPE t_pieceName IS TABLE OF varchar2(255) INDEX BY binary_integer;


v_pieceName t_pieceName;
BEGIN
-- Define the backup pieces... (names from the RMAN Log file)
v_pieceName(1) :=

'/flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_ncsnf_TAG20040820T
153256_0lczfrx8_.bkp';
v_pieceName(2) :=

'/flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_nnndf_TAG20040820T
153256_0lczd9tf_.bkp';
v_maxPieces  := 2;

-- Allocate a channel... (Use type=>null for DISK, type=>'sbt_tape'


for TAPE)
v_devtype := DBMS_BACKUP_RESTORE.deviceAllocate(type=>NULL,
ident=>'d1');

-- Restore the first Control File...


DBMS_BACKUP_RESTORE.restoreSetDataFile;

-- CFNAME mist be the exact path and filename of a controlfile taht


was backed-up

DBMS_BACKUP_RESTORE.restoreControlFileTo(cfname=>'/app/oracle/oradata/or
cl/control01.ctl');
dbms_output.put_line('Start restoring '||v_maxPieces||' pieces.');
FOR i IN 1..v_maxPieces LOOP
dbms_output.put_line('Restoring from piece '||v_pieceName(i));
DBMS_BACKUP_RESTORE.restoreBackupPiece(handle=>v_pieceName(i),
done=>v_done, params=>null);
exit when v_done;
END LOOP;

-- Deallocate the channel...


DBMS_BACKUP_RESTORE.deviceDeAllocate('d1');
EXCEPTION
WHEN OTHERS THEN
DBMS_BACKUP_RESTORE.deviceDeAllocate;
RAISE;
END;
/

Let's see if the controlfile was restored:

SQL> ! ls -l /oradata/orcl/control01.ctl
-rw-r----- 1 oracle dba 3096576 Aug 20 16:45
/oradata/orcl/control01.ctl[/code]

We should now be able to MOUNT the database and continue recovery...

SQL> ! cp /oradata/orcl/control01.ctl /oradata/orcl/control02.ctl

SQL> ! cp /oradata/orcl/control01.ctl /oradata/orcl/control03.ctl

SQL> alter database mount;

SQL> recover database using backup controlfile;


ORA-00279: change 7917452 generated at 08/20/2004 16:40:59 needed for
thread 1
ORA-00289: suggestion :
/flash_recovery_area/ORCL/archivelog/2004_08_20/o1_mf_1_671_%u_.arc
ORA-00280: change 7917452 for thread 1 is in sequence #671

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}


/oradata/orcl/redo02.log
Log applied.
Media recovery complete.

Database altered.

SQL> alter database open resetlogs;

Database altered.

I've lost an archived/online REDO LOG file, can I get my DB back?


The following INIT.ORA/SPFILE parameter can be used if your current redologs are
corrupted or blown away. It may also be handy if you do database recovery and one of
the archived log files are missing and cannot be restored.

NOTE: Caution is advised when enabling this parameter as you might end-up losing
your entire database. Please contact Oracle Support before using it.

_allow_resetlogs_corruption = true

This should allow you to open the database. However, after using this parameter your
database will be inconsistent (some committed transactions may be lost or partially
applied).

Steps:

 Do a "SHUTDOWN NORMAL" of the database


 Set the above parameter
 Do a "STARTUP MOUNT" and "ALTER DATABASE OPEN RESETLOGS;"
 If the database asks for recovery, use an UNTIL CANCEL type recovery and
apply all available archive and on-line redo logs, then issue CANCEL and reissue
the "ALTER DATABASE OPEN RESETLOGS;" command.
 Wait a couple of minutes for Oracle to sort itself out
 Do a "SHUTDOWN NORMAL"
 Remove the above parameter!
 Do a database "STARTUP" and check your ALERT.LOG file for errors.
 Extract the data and rebuild the entire database

How does one put a database into ARCHIVELOG mode?

The main reason for running in archivelog mode is that one can provide 24-hour
availability and guarantee complete data recoverability. It is also necessary to enable
ARCHIVELOG mode before one can start to use on-line database backups.

Issue the following commands to put a database into ARCHIVELOG mode:

SQL> CONNECT sys AS SYSDBA


SQL> STARTUP MOUNT EXCLUSIVE;
SQL> ALTER DATABASE ARCHIVELOG;
SQL> ARCHIVE LOG START;
SQL> ALTER DATABASE OPEN;

Alternatively, add the above commands into your database's startup command script, and
bounce the database.

The following parameters needs to be set for databases in ARCHIVELOG mode:

log_archive_start = TRUE
log_archive_dest_1 = 'LOCATION=/arch_dir_name'
log_archive_dest_state_1 = ENABLE
log_archive_format = %d_%t_%s.arc

NOTE 1: Remember to take a baseline database backup right after enabling archivelog
mode. Without it one would not be able to recover. Also, implement an archivelog
backup to prevent the archive log directory from filling-up.

NOTE 2:' ARCHIVELOG mode was introduced with Oracle 6, and is essential for
database point-in-time recovery. Archiving can be used in combination with on-line and
off-line database backups.

NOTE 3: You may want to set the following INIT.ORA parameters when enabling
ARCHIVELOG mode: log_archive_start=TRUE, log_archive_dest=..., and
log_archive_format=...

NOTE 4: You can change the archive log destination of a database on-line with the
ARCHIVE LOG START TO 'directory'; statement. This statement is often used to switch
archiving between a set of directories.

NOTE 5: When running Oracle Real Application Clusters (RAC), you need to shut down
all nodes before changing the database to ARCHIVELOG mode.

What is the difference between restoring and recovering?

Restoring involves copying backup files from secondary storage (backup media) to disk.
This can be done to replace damaged files or to copy/move a database to a new location.

Recovery is the process of applying redo logs to the database to roll it forward. One can
roll-forward until a specific point-in-time (before the disaster occurred), or roll-forward
until the last transaction recorded in the log files.

SQL> connect SYS as SYSDBA


SQL> RECOVER DATABASE UNTIL TIME '2001-03-06:16:00:00' USING BACKUP
CONTROLFILE;
RMAN> run {
set until time to_date('04-Aug-2004 00:00:00', 'DD-MON-YYYY
HH24:MI:SS');
restore database;
recover database;
}

How to clone a database using RMAN Backups?

Recently i had faced a requirement where we need to restore backups of some production
database on some different system to test the validity of backups and and also setup and
an test environment.This can be done in many ways. I prefer following techique.
If we have autobackup enabled in rman configuration which should be enabled while
taking an RMAN backup then each time u take an backup controlfile and spfile is
automatically backuped up at the end of each rman backup.The default location for this
autobackup $ORACLE_HOME/dbs for unix systems and $ORACLE_HOME/database
for windows. and is of the form c--.

To restore the database on new system u must have oracle binaries of same versions
installed on the new system.Also preferably use the init.ora file of ur original databse and
copy it in $ORACLE_HOME/dbs in unix and $ORACLE_HOME/database.Now set the
environmental variables and start the database in nomount stage.
Now log into rman as sys if password file is copied from original system

rman target /

RMAN> set dbid (dbid can be determined from controlfile AUTOBACKUP header)

RMAN> restore controlfile from autobackup; (this will restore the controlfile to location
specified by control_file parameter in init.ora)

RMAN> run
2{
3 sql ‘ alter database mount’;
4 allocate channel dup1 device type disk;
5 allocate channel dup2 device type disk;
6 restore database;
7 recover database;
8 sql ‘alter database open resetlogs’;
9}

The above script will restore the database and perform incomplete recovery until the
archive logs backuped up and will open the database with reset logs.

Alternatively u can use duplicate command of rman to clone the target database to
auxiliary database.

Note: USING THE ABOVE TECHNIQUE WILL KEEP DB ID SAME FOR THE
DATABASE WHEREAS USING DUPLICATE COMMAND WILL PRODUCE
DIFFRENT DBID FOR CLONE DATABASE.
DATABASE CLONING WITH RMAN
DATABASE CLONING WITH RMAN.......................................................................... 1
Recovery Catalog is created and registered with Database................................................. 2
Listener for recover catalog is up and running.................................................................... 2
Target database is started and running................................................................................. 2
Listener of Target database is up and running
Steps to be performed under target database
Steps to be performed under Clone (Duplicate) Database

You might also like