Duplicate a Standby Database (1/4) - With Active Database

  • by

For 19c Standby database duplication, you may check the post: How to Duplicate a 19c Physical Standby Database

Duplicate a standby database with an active target database in RMAN could be the easiest way to create a standby database. With this method, RMAN copies the newest data files to the auxiliary database through the network, no intermediate backups will be left, just like the network-mode data pump.

  1. Stop the standby cluster database.
  2. [oracle@standby01 ~]$ srvctl stop database -d compdb
  3. Startup only one instance of the standby cluster database.
  4. [oracle@standby01 ~]$ sqlplus / as sysdba
    ...
    SQL> startup nomount;
    ...

  5. Connect to target and auxiliary database by RMAN and run duplicate.
  6. [oracle@primary01 ~]$ rman target sys/password@primdb1 auxiliary sys/password@standb1

    Recovery Manager: Release 11.2.0.1.0 - Production on Sun Jan 20 13:55:46 2013

    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

    connected to target database: COMPDB (DBID=841830157)
    connected to auxiliary database: COMPDB (not mounted)

    RMAN> RUN {
    2> DUPLICATE TARGET DATABASE
    3> FOR STANDBY FROM ACTIVE DATABASE
    4> NOFILENAMECHECK;
    5> }


    Starting Duplicate Db at 20-JAN-13
    using target database control file instead of recovery catalog
    allocated channel: ORA_AUX_DISK_1
    channel ORA_AUX_DISK_1: SID=34 instance=standb1 device type=DISK

    contents of Memory Script:
    {
       backup as copy reuse
       targetfile  '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwprimdb1' auxiliary format
     '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwstandb1'   ;
    }
    executing Memory Script

    Starting backup at 20-JAN-13
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=67 instance=primdb1 device type=DISK
    Finished backup at 20-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";
       backup as copy current controlfile for standby auxiliary format  '+DATA/compdb/controlfile/current.260.761849575';
       sql clone "alter system set  control_files =
      ''+DATA/compdb/controlfile/current.260.761849575'' comment=
     ''Set by RMAN'' scope=spfile";
       shutdown clone immediate;
       startup clone nomount;
    }
    executing Memory Script

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

    Starting backup at 20-JAN-13
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting datafile copy
    copying standby control file
    output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_primdb1.f tag=TAG20130120T173910 RECID=16 STAMP=805225155
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
    Finished backup at 20-JAN-13

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

    Oracle instance shut down

    connected to auxiliary database (not started)
    Oracle instance started

    Total System Global Area     839282688 bytes

    Fixed Size                     2217992 bytes
    Variable Size                792725496 bytes
    Database Buffers              41943040 bytes
    Redo Buffers                   2396160 bytes

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

    sql statement: alter database mount standby database
    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";
       backup as copy reuse
       datafile  1 auxiliary format
     "+data"   datafile
     2 auxiliary format
     "+data"   datafile
     3 auxiliary format
     "+data"   datafile
     4 auxiliary format
     "+data"   datafile
     5 auxiliary format
     "+data"   datafile
     6 auxiliary format
     "+data"   ;
       sql 'alter system archive log current';
    }
    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 backup at 20-JAN-13
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00001 name=+DATA/primdb/datafile/system.897.797943475
    output file name=+DATA/standb/datafile/system.1108.805225209 tag=TAG20130120T173956
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:15
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00002 name=+DATA/primdb/datafile/sysaux.898.797943569
    output file name=+DATA/standb/datafile/sysaux.1109.805225341 tag=TAG20130120T173956
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:15
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00003 name=+DATA/primdb/datafile/undotbs1.899.797943687
    output file name=+DATA/standb/datafile/undotbs1.1110.805225477 tag=TAG20130120T173956
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00005 name=+DATA/primdb/datafile/example.900.797943711
    output file name=+DATA/standb/datafile/example.1111.805225501 tag=TAG20130120T173956
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00006 name=+DATA/primdb/datafile/undotbs2.901.797943737
    output file name=+DATA/standb/datafile/undotbs2.1112.805225537 tag=TAG20130120T173956
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00004 name=+DATA/primdb/datafile/users.902.797943753
    output file name=+DATA/standb/datafile/users.1113.805225553 tag=TAG20130120T173956
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
    Finished backup at 20-JAN-13

    sql statement: alter system archive log current

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

    datafile 1 switched to datafile copy
    input datafile copy RECID=16 STAMP=805225555 file name=+DATA/standb/datafile/system.1108.805225209
    datafile 2 switched to datafile copy
    input datafile copy RECID=17 STAMP=805225556 file name=+DATA/standb/datafile/sysaux.1109.805225341
    datafile 3 switched to datafile copy
    input datafile copy RECID=18 STAMP=805225556 file name=+DATA/standb/datafile/undotbs1.1110.805225477
    datafile 4 switched to datafile copy
    input datafile copy RECID=19 STAMP=805225556 file name=+DATA/standb/datafile/users.1113.805225553
    datafile 5 switched to datafile copy
    input datafile copy RECID=20 STAMP=805225556 file name=+DATA/standb/datafile/example.1111.805225501
    datafile 6 switched to datafile copy
    input datafile copy RECID=21 STAMP=805225556 file name=+DATA/standb/datafile/undotbs2.1112.805225537
    Finished Duplicate Db at 20-JAN-13

  7. Check the status after duplication.
  8. [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

  9. Restart the standby cluster database.
  10. SQL> shutdown immediate;
    ORA-01109: database not open


    Database dismounted.
    ORACLE instance shut down.
    ...
    [oracle@standby01 ~]$ srvctl start database -d compdb -o mount

  11. Start to recovery managed standby database.
  12. [oracle@standby01 ~]$ sqlplus / as sysdba
    ...
    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 MRP0      APPLYING_LOG          1         86        806        807
             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         84      48051          1
             1 RFS       IDLE                  1         89        397          1
             2 RFS       IDLE                  0          0          0          0

    8 rows selected.

    SQL> /

       INST_ID PROCESS   STATUS          THREAD#  SEQUENCE#     BLOCK#     BLOCKS
    ---------- --------- ------------ ---------- ---------- ---------- ----------
             1 MRP0      WAIT_FOR_LOG          2         84          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                  0          0          0          0
             1 RFS       IDLE                  2         84      48127          1
             1 RFS       IDLE                  1         89        437          1
             2 RFS       IDLE                  0          0          0          0

    8 rows selected.

Leave a Reply

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