Saturday 1 February 2014

RMAN 12c feature - network based restore

In 12c Data Guard environments, RMAN can recover/restore using a new network-enabled restore method. During a recovery/restore RMAN can now retrieve the datafiles/logs/backupsets that it needs for a recovery operation from its remote Data Guard counterpart.

The files needed for a restore/recovery operation are transferred to the requesting site using compressed backupsets to reduce network overhead. This technique is called network-based restore.

New syntax is introduced to support this. There is a new RESTORE FROM SERVICE <servicename> command to perform this, and it is used in memory scripts generated, for instance, during database duplication. The service name can point to a tns entry for the remote DG counterpart site.

RESTORE FROM SERVICE <dbSERVICE> <RESTOREOBJ>

Therefore, there are now two techniques available for database duplication, depending on mode of connection, number of auxiliary channels allocated and duplicate command-line options specified.
  • Existing image copy method (push based) where target channels do most of the duplication.
  • The new backupsets method (pull based) where the auxiliary channels do the bulk of the work.
Possible advantages of backupset method:
  • Auxiliary channels do the bulk of the duplication effort, so the target database - if its  a production database - does not incur the overhead of the operation. 
  • Backupsets are compact, smaller than datafiles, and are more efficient to transport over the network. User can specify that compressed backupsets be used.

The network based restore operation is seen in the rman memory scripts generated during the duplicaton of a 12c primary database as a standby.

The steps for creating a physical standby for a container database are the same as for noncdbs.
Data guard specific init params need to be set on both instnaces, tnsnames networking needs to be configured, standby logs, and archive log destinations need to be configured .

The auxiliary instance needs to be set up using a temp init.ora and temp password file, and should be  be running in nomount mode, registered statically with its listener.

The section below discusses the RMAN actions and memory scripts generated during the duplication of a CDB called CDB1 as a physical standby.

The method used here is active database duplication.


Connect to primary as target and to the standby as auxiliary from rman and issue the DUPLICATE DATABASE command.

$ > rman target sys/oracle@cdb1_scott auxiliary sys/oracle@cdb1_tiger
Issue the duplicate database command shown below.

duplicate target database for standby 
 from active database
 nofilenamecheck dorecover
  spfile
     parameter_value_convert 'scott','tiger'
      set db_unique_name 'TIGER'
      set log_archive_dest_2 'service=CDB1 async valid_for=(online_logfiles,primary_role) db_unique_name=CDB1';


The main duplication actions that follow are discussed below.
    

     1)  Copy the password file and spfile from primary (password file copy done implicitly when duplicating for creating physical standby)

contents of Memory Script: (edited for clarity)
     {
        backup as copy reuse
        targetfile  '/u01/.../dbhome_1/dbs/orapwCDB1' 

            auxiliary format '/u01/app/.../dbhome_1/dbs/orapwCDB1'   ;
        restore clone from service  'cdb1_scott' spfile to
            '/u01/app/.../dbhome_1/dbs/spfileCDB1.ora';
        sql clone "alter system set spfile= ''/u01/app/...dbhome_1/dbs/spfileCDB1.ora''";
    }

     2) Set up requested site-specific init params on standby as specified in the DUPLICATE ...SPFILE SET option.

    
          contents of Memory Script:
          {
             sql clone "alter system set  db_unique_name =  ''TIGER'' comment=
           '''' scope=spfile";
             sql clone "alter system set  log_archive_dest_2 = ''service=CDB1 async valid_for=(online_logfiles,primary_role) db_unique_name=CDB1'' comment=
           '''' scope=spfile";
             shutdown clone immediate;
             startup clone nomount;
          }    

     3) Restore primary controlfile to standby as a standby controlfile. Note that this is a network-based restore from an appropriate controlfile backupset.

          contents of Memory Script:
          {
             restore clone from service  'cdb1_scott' standby controlfile;
          }    
          channel ORA_AUX_DISK_1: starting datafile backup set restore
          channel ORA_AUX_DISK_1: using network backup set from service cdb1_scott
          channel ORA_AUX_DISK_1: restoring control file
          channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
          output file name=/u01/app/oracle/oradata/cdb1/control1.ctl
          output file name=/u01/app/oracle/oradata/cdb1/control2.ctl
          Finished restore at 02-FEB-14


     4) Mount the standby database using the restored controlfile.

          contents of Memory Script:
          {
             sql clone 'alter database mount standby database';
          }


     5) Restore all datafiles. RMAN uses the restore from service syntax

  
  executing Memory Script

  contents of Memory Script:
  {
     set newname for tempfile  1 to  "/u01/app/oracle/oradata/cdb1/temp.ora";
       ...
     set newname for tempfile  7 to  "/u01/app/oracle/oradata/cdb1/exnoncdb/temp.ora";
     switch clone tempfile all;

     set newname for datafile  1 to  "/u01/app/oracle/oradata/cdb1/system.ora";
     ...
     set newname for datafile  55 to  "/u01/app/oracle/oradata/cdb1/salespdb/ts_recovery.ora";

     restore  from service  'cdb1_scott'  clone database
     ;
     sql 'alter system archive log current';
  }   
  channel ORA_AUX_DISK_1: starting datafile backup set restore
  channel ORA_AUX_DISK_1: using network backup set from service cdb1_scott
  channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
  channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/cdb1/system.ora
  ...
  ...
  ...
  channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
  channel ORA_AUX_DISK_1: restoring datafile 00055 to /u01/app/oracle/oradata/cdb1/salespdb/ts_recovery.ora
  channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
  Finished restore at 02-FEB-14


  6) Recover the datafiles to the recovery point specified, if any.

    Note below, that the archive log files with sequence 59 and 60 are being pulled from primary.
    Then they are applied to the standby instance datafiles.
       
  contents of Memory Script:
  {
     restore clone force from service  'cdb1_scott'
          archivelog from scn  1871401;

     switch clone datafile all;
  }    
  channel ORA_AUX_DISK_1: starting archived log restore to default destination
  channel ORA_AUX_DISK_1: using network backup set from service cdb1_scott


  channel ORA_AUX_DISK_1: restoring archived log
  archived log thread=1 sequence=59
  channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
  channel ORA_AUX_DISK_1: starting archived log restore to default destination
  channel ORA_AUX_DISK_1: using network backup set from service cdb1_scott
  channel ORA_AUX_DISK_1: restoring archived log
  archived log thread=1 sequence=60
  channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
  Finished restore at 02-FEB-14

  contents of Memory Script:
 {
    set until scn  1873330;
    recover
    standby
    clone database
    delete archivelog
   ;
 }
 executing Memory Script

 executing command: SET until clause

 Starting recover at 02-FEB-14
 using channel ORA_AUX_DISK_1

 starting media recovery

 archived log for thread 1 with sequence 59 is already on disk as file /u01/.../arch1_59_837593794.dbf
 archived log for thread 1 with sequence 60 is already on disk as file /u01/.../arch1_60_837593794.dbf
 archived log file name=/u01/.../arch1_59_837593794.dbf thread=1 sequence=59
 archived log file name=/u01/.../arch1_60_837593794.dbf thread=1 sequence=60
 media recovery complete, elapsed time: 00:00:03
 Finished recover at 02-FEB-14
 Finished Duplicate Db at 02-FEB-14 
 
  


No comments:

Post a Comment