Sunday, June 14, 2015

RMAN complete database recovery

Recovering the Database

The procedure for performing complete recovery on the database differs depending on whether the control file is available.
To recover the database when the control file is intact:
  1. Start RMAN and connect to the target database and, optionally, the recovery catalog database. For example, enter:
    % rman target / catalog rman/rman@rcat
        
    
    
    
  2. If the database is open, shut it down, then mount it:
    shutdown immediate;
    startup mount;
        
    
    
    
  3. After allocating channels, restore the database and recover it. This example skips the read-only TEMP tablespace:
    run { 
         allocate channel ch1 type disk;
         restore database;
         recover database
           skip tablespace temp;
    }
        
    
    
    
  4. Examine the output to see if recovery was successful. After RMAN restores the necessary datafiles, look for RMAN-08055 in the output:
    RMAN-08024: channel ch1: restore complete
    RMAN-03023: executing command: partial resync
    RMAN-08003: starting partial resync of recovery catalog
    RMAN-08005: partial resync complete
     
    RMAN-03022: compiling command: recover
     
    RMAN-03022: compiling command: recover(1)
     
    RMAN-03022: compiling command: recover(2)
     
    RMAN-03022: compiling command: recover(3)
    RMAN-03023: executing command: recover(3)
    RMAN-08054: starting media recovery
    RMAN-08515: archivelog filename=/oracle/arc_dest/arcr_1_40.arc thread=1 sequence=40
    RMAN-08515: archivelog filename=/oracle/arc_dest/arcr_1_41.arc thread=1 sequence=41
    RMAN-08055: media recovery complete
     
    RMAN-03022: compiling command: recover(4)
    RMAN-08031: released channel: ch1
    
To recover the database using a backup control file:
When you perform a restore operation using a backup control file and you use a recovery catalog, RMAN automatically adjusts the control file to reflect the structure of the restored backup.

  1. Start RMAN and connect to the target database and, optionally, the recovery catalog database. If you use a recovery catalog, RMAN updates the control file. For example, enter:
    % rman target / catalog rman/rman@rcat
        
    
    
    
  2. Start the instance without mounting the database:
    startup nomount;
        
    
    
    
  3. After allocating one or more channels, do the following:
    1. Use the restore controlfile command to restore the control file to all locations specified in the CONTROL_FILES initialization parameter.
    2. Mount the database.
    3. Restore and recover the database.
    4. Open the database with the RESETLOGS option.
      run { 
           allocate channel ch1 type 'sbt_tape';
           restore controlfile;
           alter database mount;
           restore database;
           recover database;
           sql "ALTER DATABASE OPEN RESETLOGS";
      }
      
      
  4. Reset the database:
    reset database;
    
    
  5. Immediately back up the database. Because the database is a new incarnation, the pre-RESETLOGS backups are not usable. For example, enter:
    run { 
         allocate channel ch1 type 'sbt_tape';
         backup database;
    }

No comments: