Sunday, June 14, 2015

RMAN restore and recovery

To restore the database from HOST_A to HOST_B with a recovery catalog:
  1. Copy the init.ora file for HOST_A to HOST_B using an O/S utility.
  2. Connect to the HOST_B target instance and HOST_A recovery catalog. For example, enter:
    % rman target sys/change_on_install@host_b rman/rman@rcat
        
    
    
    
  3. Start the instance without mounting it:
    startup nomount;
        
    
    
    
  4. Restore and mount the control file. Execute a run command with the following sub-commands:
    1. Allocate at least one channel.
    2. Restore the control file.
    3. Mount the control file.
      run {
           allocate channel ch1 type disk;
           restore controlfile;
           alter database mount;
      }
      
      
  5. Because there may be multiple threads of redo, use change-based recovery. Obtain the SCN for recovery termination by finding the lowest SCN among the most recent archived redo logs for each thread.
    Start SQL*Plus and use the following query to determine the necessary SCN:
    SELECT min(scn) 
    FROM (SELECT max(next_change#) scn 
          FROM v$archived_log 
          GROUP BY thread#);
    
    
  6. Execute a run command with the following sub-commands:
    1. Set the SCN for recovery termination using the value obtained from the previous step.
    2. Allocate at least one channel.
    3. Restore the database.
    4. Recover the database.
    5. Open the database with the RESETLOGS option.
      run {
           set until scn = 500;  # use appropriate SCN for incomplete recovery
           allocate channel ch1 type 'sbt_tape';
           restore database;
           recover database;
           sql "ALTER DATABASE OPEN RESETLOGS";
      }
      
To restore from HOST_A to HOST_B without a recovery catalog:

  1. Copy the init.ora file for HOST_A to HOST_B using an O/S utility.
  2. Use an O/S utility to make an image copy of the HOST_A control file and transfer it to HOST_B using an O/S utility.
  3. Connect to the HOST_B target instance with the nocatalog option. For example, enter:
    % rman target sys/change_on_install@host_b nocatalog
        
    
    
    
  4. Mount the database:
    startup mount;
    
    
  5. Because there may be multiple threads of redo, use change-based recovery. Obtain the SCN for recovery termination by finding the lowest SCN among the most recent archived redo logs for each thread.
    Start SQL*Plus and use the following query to determine the necessary SCN:
    SELECT min(scn) 
    FROM (SELECT max(next_change#) scn 
          FROM v$archived_log 
          GROUP BY thread#);
        
    
    
    
  6. Execute a run command with the following sub-commands:
    1. Set the SCN for recovery termination using the value obtained from the previous step.
    2. Allocate at least one channel.
    3. Restore the database.
    4. Recover the database.
    5. Open the database with the RESETLOGS option.
      run {
           set until scn 500;  # use appropriate SCN for incomplete recovery
           allocate channel ch1 type 'sbt_tape';
           alter database mount;
           restore database;
           recover database;
           sql "ALTER DATABASE OPEN RESETLOGS";
      }

No comments: