Skip to content
Home » Oracle » Duplicate a Standby Database (3/4) - With Targetless Duplication

Duplicate a Standby Database (3/4) - With Targetless Duplication

Tagetless duplication does not require RMAN to connect to the target database or catalog, but it will need at least one copy of backup that comes from the primary database and is stored in the standby side.

  1. Connect to the primary database with RMAN.
  2. [oracle@primary01 ~]$ rman target sys/password@primdb1
    ...
    connected to target database: COMPDB (DBID=841830157)

  3. Backup database for duplication.
  4. RMAN> backup database;

    Starting backup at 23-JAN-13
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=79 instance=primdb1 device type=DISK
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00001 name=+DATA/primdb/datafile/system.897.797943475
    input datafile file number=00002 name=+DATA/primdb/datafile/sysaux.898.797943569
    input datafile file number=00003 name=+DATA/primdb/datafile/undotbs1.899.797943687
    input datafile file number=00005 name=+DATA/primdb/datafile/example.900.797943711
    input datafile file number=00006 name=+DATA/primdb/datafile/undotbs2.901.797943737
    input datafile file number=00004 name=+DATA/primdb/datafile/users.902.797943753
    channel ORA_DISK_1: starting piece 1 at 23-JAN-13
    channel ORA_DISK_1: finished piece 1 at 23-JAN-13
    piece handle=+DATA/primdb/backupset/2013_01_23/nnndf0_tag20130123t100747_0.1111.805457271 tag=TAG20130123T100747 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:04:52
    Finished backup at 23-JAN-13

    Starting Control File and SPFILE Autobackup at 23-JAN-13
    piece handle=+DATA/primdb/autobackup/2013_01_23/s_805457561.1112.805457565 comment=NONE
    Finished Control File and SPFILE Autobackup at 23-JAN-13

    RMAN> list backup;


    List of Backup Sets
    ===================

    ...
    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    7       Full    1.15G      DISK        00:04:47     23-JAN-13
            BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20130123T100747
            Piece Name: +DATA/primdb/backupset/2013_01_23/nnndf0_tag20130123t100747_0.1111.805457271
      List of Datafiles in backup set 7
      File LV Type Ckp SCN    Ckp Time  Name
      ---- -- ---- ---------- --------- ----
      1       Full 3092332    23-JAN-13 +DATA/primdb/datafile/system.897.797943475
      2       Full 3092332    23-JAN-13 +DATA/primdb/datafile/sysaux.898.797943569
      3       Full 3092332    23-JAN-13 +DATA/primdb/datafile/undotbs1.899.797943687
      4       Full 3092332    23-JAN-13 +DATA/primdb/datafile/users.902.797943753
      5       Full 3092332    23-JAN-13 +DATA/primdb/datafile/example.900.797943711
      6       Full 3092332    23-JAN-13 +DATA/primdb/datafile/undotbs2.901.797943737
    ...

  5. Copy the backup dumps to a backup location in the standby cluster.
  6. Here we copy the backup dumps by asmcmd between the two ASM instances.

    [oracle@standby02 ~]$ asmcmd
    ASMCMD> cp [email protected].+ASM2:+DATA/primdb/backupset/2013_01_23/nnndf0_tag20130123t100747_0.1111.805457271 +DATA/backup/database.bak
    Enter password: **********
    ASMCMD> cp [email protected].+ASM2:+DATA/primdb/autobackup/2013_01_23/s_805457561.1112.805457565 +DATA/backup/control.bak
    Enter password: **********
    ASMCMD>

  7. Connect to the standby database as auxiliary role with RMAN.
  8. [oracle@primary01 ~]$ rman auxiliary sys/password@standb1
    ...
    connected to auxiliary database: COMPDB (not mounted)

    Notice that the standby database is NOMOUNT now.

  9. Duplicate the database using said backup location.
  10. RMAN> RUN {
    1> DUPLICATE DATABASE FOR STANDBY
    2> BACKUP LOCATION '+data/backup'
    3> NOFILENAMECHECK;
    4> }

    Starting Duplicate Db at 23-JAN-13

    contents of Memory Script:
    {
       sql clone "alter system set  control_files =
      ''+DATA/compdb/controlfile/current.260.761849575'' comment=
     ''Set by RMAN'' scope=spfile";
       restore clone standby controlfile from  '+data/backup/control.bak';
    }
    executing Memory Script

    sql statement: alter system set  control_files =   ''+DATA/compdb/controlfile/current.260.761849575'' comment= ''Set by RMAN'' scope=spfile

    Starting restore at 23-JAN-13
    allocated channel: ORA_AUX_DISK_1
    channel ORA_AUX_DISK_1: SID=36 instance=standb1 device type=DISK

    channel ORA_AUX_DISK_1: restoring control file
    channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
    output file name=+DATA/compdb/controlfile/current.260.761849575
    Finished restore at 23-JAN-13

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

    sql statement: alter database mount standby database
    released channel: ORA_AUX_DISK_1
    allocated channel: ORA_AUX_DISK_1
    channel ORA_AUX_DISK_1: SID=36 instance=standb1 device type=DISK
    RMAN-05529: WARNING: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.

    contents of Memory Script:
    {
       set newname for tempfile  1 to
     "+data";
       switch clone tempfile all;
       set newname for datafile  1 to
     "+data";
       set newname for datafile  2 to
     "+data";
       set newname for datafile  3 to
     "+data";
       set newname for datafile  4 to
     "+data";
       set newname for datafile  5 to
     "+data";
       set newname for datafile  6 to
     "+data";
       restore
       clone database
       ;
    }
    executing Memory Script

    executing command: SET NEWNAME

    renamed tempfile 1 to +data in control file

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    Starting restore at 23-JAN-13
    using channel ORA_AUX_DISK_1

    channel ORA_AUX_DISK_1: starting datafile backup set restore
    channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
    channel ORA_AUX_DISK_1: restoring datafile 00001 to +data
    channel ORA_AUX_DISK_1: restoring datafile 00002 to +data
    channel ORA_AUX_DISK_1: restoring datafile 00003 to +data
    channel ORA_AUX_DISK_1: restoring datafile 00004 to +data
    channel ORA_AUX_DISK_1: restoring datafile 00005 to +data
    channel ORA_AUX_DISK_1: restoring datafile 00006 to +data
    channel ORA_AUX_DISK_1: reading from backup piece +DATA/backup/database.bak
    channel ORA_AUX_DISK_1: piece handle=+DATA/backup/database.bak tag=TAG20130123T100747
    channel ORA_AUX_DISK_1: restored backup piece 1
    channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:04:15
    Finished restore at 23-JAN-13

    contents of Memory Script:
    {
       switch clone datafile all;
    }
    executing Memory Script

    datafile 1 switched to datafile copy
    input datafile copy RECID=7 STAMP=805463213 file name=+DATA/standb/datafile/system.1143.805462959
    datafile 2 switched to datafile copy
    input datafile copy RECID=8 STAMP=805463213 file name=+DATA/standb/datafile/sysaux.1144.805462959
    datafile 3 switched to datafile copy
    input datafile copy RECID=9 STAMP=805463213 file name=+DATA/standb/datafile/undotbs1.1145.805462963
    datafile 4 switched to datafile copy
    input datafile copy RECID=10 STAMP=805463213 file name=+DATA/standb/datafile/users.1148.805462967
    datafile 5 switched to datafile copy
    input datafile copy RECID=11 STAMP=805463214 file name=+DATA/standb/datafile/example.1146.805462963
    datafile 6 switched to datafile copy
    input datafile copy RECID=12 STAMP=805463214 file name=+DATA/standb/datafile/undotbs2.1147.805462965
    Finished Duplicate Db at 23-JAN-13

    RMAN>

  11. Check standb1 for the standby database.
  12. Since RMAN mounts the standby database in the process of the duplication, standb1 will be mounted. Please notice that DATABASE_ROLE is PHYSICAL STANDBY now.

    [oracle@standby01 ~]$ sqlplus / as sysdba
    SQL> select open_mode, database_role, switchover_status from v$database;

    OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS
    -------------------- ---------------- --------------------
    MOUNTED              PHYSICAL STANDBY RECOVERY NEEDED

  13. Restart the standby cluster database.
  14. SQL> shutdown immediate;
    ...
    [oracle@standby01 ~]$ srvctl start database -d compdb -o mount
    [oracle@standby01 ~]$ sqlplus / as sysdba
    ...
    SQL> select inst_id, open_mode, database_role, switchover_status from gv$database;

       INST_ID OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS
    ---------- -------------------- ---------------- --------------------
             1 MOUNTED              PHYSICAL STANDBY RECOVERY NEEDED
             2 MOUNTED              PHYSICAL STANDBY RECOVERY NEEDED

    SQL> select inst_id, process, status, thread#, sequence#, block#, blocks from gv$managed_standby where process in ('RFS','LNS') or process like 'MR%';

       INST_ID PROCESS   STATUS          THREAD#  SEQUENCE#     BLOCK#     BLOCKS
    ---------- --------- ------------ ---------- ---------- ---------- ----------
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  1         89        249          1
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  2         85        231          1

    8 rows selected.

  15. Start applying service.
  16. SQL> alter database recover managed standby database disconnect from session;

    Database altered.

    SQL> select inst_id, process, status, thread#, sequence#, block#, blocks from gv$managed_standby where process in ('RFS','LNS') or process like 'MR%';

       INST_ID PROCESS   STATUS          THREAD#  SEQUENCE#     BLOCK#     BLOCKS
    ---------- --------- ------------ ---------- ---------- ---------- ----------
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  1         89        316          1
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  2         85        356          1
             1 MRP0      APPLYING_LOG          2         78      16500      19767

    9 rows selected.

    SQL> /

       INST_ID PROCESS   STATUS          THREAD#  SEQUENCE#     BLOCK#     BLOCKS
    ---------- --------- ------------ ---------- ---------- ---------- ----------
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  1         89        536          1
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  0          0          0          0
             1 RFS       IDLE                  2         85        941          1
             1 MRP0      WAIT_FOR_LOG          1         89          0          0

    9 rows selected.

Leave a Reply

Your email address will not be published. Required fields are marked *