clone database using RMAN without new incarnation (with NORESETLOGS)_1608236.1

rongshiyuan發表於2014-05-13

How to clone the database using RMAN without new incarnation (with NORESETLOGS) (Doc ID 1608236.1)


In this Document

Goal
Solution
References


Applies to:

Oracle Database - Enterprise Edition - Version 10.2.0.2 to 11.2.0.4 [Release 10.2 to 11.2]
Information in this document applies to any platform.

Goal

++ To Clone the database WITHOUT new incarnation (with NO RESETLOGS).

 

Solution


++ In general while performing incomplete recovery in another server using RMAN backup, it requires resetlogs.

++ Since we are specific NOT to resetlogs, we can try below option 

Assuming:  (a) Full backup is taken at Server A ,

                 (b) And backup pieces are moved to host Server B ( Auxiliary).

 

At Server B (auxiliary instance )

 

step: (1)  Startup auxiliary instance at NOMOUNT state


step: (2) Initiate RMAN session and Restore controlfile from backup

step: (3) Mount database 

step: (4) catalog the backup piece

step: (5) Restore database

step: (6) shutdown immediate  Auxiliary instance

step: (7) shutdown the Source database (Server A) AND  COPY below files to  (cloned ) auxiliary instance ( Server B)
              (7a) controlfile
              (7b) archivelogs       # which is newly generated after backup at source database (Server A) 
              (7c) REDO logs      


At Server B ( Auxiliary Instance ):
step: (8)  Replace the auxiliary instance controlfile with newly copied controlfile

              Startup mount with new controlfile and catalog the archivelogs 



Step: (9) if Datafile and REDO file location of cloned database (Server B) is different from source database (Server A) then

             We should rename the datafiles and redo logs . Otherwise this step not necessary 


Step: (10) recover database and open database (without resetlogs )

         sql > recover database  ;
         sql > alter database open;

 

Example:

Here example is on windows platform. The steps are same for unix.

  

 

At Server A ( Source Database )

        RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

        RMAN>  backup database plus archivelog  ; 

Assuming : Full database backup is taken and copied to Server B 

 

At Server B ( Auxiliary Instance ): 

~~~~~~~~~~~~~~~~~~~~~~~

step:(1) sqlplus sys/syspwd@tnsmast112aux as sysdba

            ..

            Copyright (c) 1982, 2010, Oracle. All rights reserved.
            Connected to an idle instance.

           SQL> startup nomount 
                   ORACLE instance started.

                   Total System Global Area 363266048 bytes
                   Fixed Size 2253248 bytes
                   Variable Size 117444160 bytes
                   Database Buffers 239075328 bytes
                   Redo Buffers 4493312 bytes


step:(2) rman target sys/syspwd@tnsmast112aux
             ..
            connected to target database: MAST112 (not mounted)

step:(2a) RMAN> restore controlfile from 'F:\Share\C-3202207085-20131214-00';

               Starting restore at 14-DEC-13
               using target database control file instead of recovery catalog
               allocated channel: ORA_DISK_1
               channel ORA_DISK_1: SID=10 device type=DISK

               channel ORA_DISK_1: restoring control file

               channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
               output file name=E:\ORADATA\M11202AUX\CTL\CONTROL01.CTL
               output file name=E:\ORADATA\M11202AUX\CTL\CONTROL02.CTL
               Finished restore at 14-DEC-13

step: (3) RMAN> alter database mount;
step: (4) RMAN> catalog start with 'F:\Share';

                      searching for all files that match the pattern F:\Share

                      List of Files Unknown to the Database
                      =====================================
                       File Name: F:\Share\C-3202207085-20131214-00
                       File Name: F:\Share\MAST112_1473_834142977_E1ORG0O1_1_1.BKP
                       File Name: F:\Share\MAST112_1474_834142979_E2ORG0O3_1_1.BKP
                       File Name: F:\Share\MAST112_1474_834142979_E2ORG0O3_2_1.BKP
                       File Name: F:\Share\MAST112_1475_834142979_E3ORG0O3_1_1.BKP
                       File Name: F:\Share\MAST112_1476_834142982_E4ORG0O6_1_1.BKP
                       File Name: F:\Share\MAST112_1477_834143079_E5ORG0R7_1_1.BKP

                       Do you really want to catalog the above files (enter YES or NO)? yes
                       cataloging files...
                       cataloging done

                       List of Cataloged Files
                       =======================
                       File Name: F:\Share\C-3202207085-20131214-00
                       File Name: F:\Share\MAST112_1473_834142977_E1ORG0O1_1_1.BKP
                       File Name: F:\Share\MAST112_1474_834142979_E2ORG0O3_1_1.BKP
                       File Name: F:\Share\MAST112_1474_834142979_E2ORG0O3_2_1.BKP
                       File Name: F:\Share\MAST112_1475_834142979_E3ORG0O3_1_1.BKP
                       File Name: F:\Share\MAST112_1476_834142982_E4ORG0O6_1_1.BKP
                       File Name: F:\Share\MAST112_1477_834143079_E5ORG0R7_1_1.BKP


step:(5): RMAN> run
{
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate channel prmy4 type disk;
SET NEWNAME for datafile 1 to 'E:\ORADATA\M11202AUX\DATA\SYSTEM01.DBF';
SET NEWNAME for datafile 2 to 'E:\ORADATA\M11202AUX\DATA\SYSAUX01.DBF';
SET NEWNAME for datafile 3 to 'E:\ORADATA\M11202AUX\DATA\UNDOTBS01.DBF';
SET NEWNAME for datafile 4 to 'E:\ORADATA\M11202AUX\DATA\USERS01.DBF';
SET NEWNAME for datafile 5 to 'E:\ORADATA\M11202AUX\DATA\DRPTBS01.DBF';
SET NEWNAME for tempfile 1 to 'E:\ORADATA\M11202AUX\DATA\TEMP01.DBF';
restore database;
switch datafile all;
}

output:
..
Finished restore at 14-DEC-13

datafile 1 switched to datafile copy
input datafile copy RECID=43 STAMP=834150521 file name=E:\ORADATA\M11202AUX\DATA\SYSTEM01.DBF
datafile 2 switched to datafile copy
input datafile copy RECID=44 STAMP=834150521 file name=E:\ORADATA\M11202AUX\DATA\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=45 STAMP=834150521 file name=E:\ORADATA\M11202AUX\DATA\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=46 STAMP=834150522 file name=E:\ORADATA\M11202AUX\DATA\USERS01.DBF
datafile 5 switched to datafile copy
input datafile copy RECID=47 STAMP=834150522 file name=E:\ORADATA\M11202AUX\DATA\DRPTBS01.DBF
released channel: prmy1
released channel: prmy2
released channel: prmy3
released channel: prmy4


step:(6) SQL> shutdown immediate
                ..
              Database dismounted.
              ORACLE instance shut down.


step:(7) shutdown the source database at Server A, Copy the controlfile AND archivelogs AND REDO logs to Server B (cloned ) auxiliary instance

            Using OS command or winscp copy following files to Server B ( Auxiliary instance )

             *.ctl
             *.arc # Archivelogs is newly generated after backup at source database (Server A )
             REDO*.log

At Server B ( Auxiliary Instance ):


step:(8) Replace the auxiliary instance controlfile with newly copied controlfile

             Startup mount with new controlfile and catalog the archivelogs in any of below methods

             Sql> startup mount; # Auxiliary instance

              c:>rman target sys/syspwd@tnsmast112aux

              RMAN> CATALOG ARCHIVELOG 'F:\bkp\ARC0000000103_0828353631.0001';
              RMAN> CATALOG ARCHIVELOG 'F:\bkp\ARC0000000104_0828353631.0001';
               ..

                or

             RMAN> CATALOG start with 'F:\bkp\ARC*';

Step:(9) In this test case, Datafile, Redo location, Archivelog , Control location are NOT identical amount source database and destination database.
             So we need to rename Datafile and Redo file locatin

            SQL> alter database rename file '' to '';                       # do all for datafiles
               ..
               ..
            SQL> alter database rename file '' to '';   # do all for REDO logs

Step:(10) SQL > recover database ;
               SQL > alter database open;

 

 

Note:
Please keep in mind if you want to register this 'cloned' database to same RMAN Catalog as
TARGET (Source Database) is registered, then you must change the DBID to get a unique DBID for this cloned database.

Otherwise if you register a database with a DBID which already exist in RMAN Catalog, this will corrupt the RMAN Catalog.

(Doc ID 863800.1) How to Change the DBID, DBNAME Using NID Utility in version 10gR2 onwards.

 

References

NOTE:863800.1 - How to Change the DBID, DBNAME Using NID Utility in version 10gR2 onwards

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17252115/viewspace-1160607/,如需轉載,請註明出處,否則將追究法律責任。

相關文章