Professional Documents
Culture Documents
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:
/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:
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;
'/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;
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;
SQL> ! ls -l /oradata/orcl/control01.ctl
-rw-r----- 1 oracle dba 3096576 Aug 20 16:45
/oradata/orcl/control01.ctl[/code]
Database altered.
Database altered.
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:
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.
Alternatively, add the above commands into your database's startup command script, and
bounce the database.
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.
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.
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