Sep 19, 2008

Cloning Using Rman

1. Creating Catalog DB called “Cloning Using Rman Buckup”.

2. Register the target DB “Source “with catalog db “rman_buckup” using rman client.

3. Configure and full back up the target db “source” using rman catalog mode.

4. Now we are going to duplicate the target db “source” using rman catalog. Duplicate database name is DEST

A. Create all necessary folders on duplicate database location “dest”
     Bdump, cdump, udump, pfile, create
B. Backup spfile or copy pfile from target db “source” to duplicate db “dest” location.
    SQL> Create pfile=’/oracle/admin/dest/pfile/initdest.ora’ from spfile;
   $ cp ‘/oracle/admin/source/pfile/initsource.ora’ ‘/oracle/admin/dest/pfile/initsdest.ora’

5. Edit the parameter file and add additional parameters in dest db pfile

  Replace db_name=source to db_name=dest

  Replace all location (path) names to duplication database location

  Include additional parameters in the duplication “dest” database pfile

  Db_file_name_convert= (‘/oracle/oradata/source’, ‘/oracle/oradata/dest’)

  log_file_name_convert= (‘/oracle/oradata/source’, ‘/oracle/oradata/dest’)

6. Create a password file for duplicate database “dest”

  $ orapwd file=’/u01/app/oracle/product/9.2.0/dbs/PWDdest.ora’ password=dest entries=5

7. Make an entry in TNSNAME and LISTNER for “dest” database

8. Reload the listener : lsnrctl reload

9. Now login and connect the “dest” database in nomount stage

    $ sqlplus "sys@dest as sysdba"
    SQL*Plus: Release - Production on Sat Jun 21 19:05:53 2008
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Enter password:
    Connected to an idle instance.
    SQL> startup pfile='E: \oracle\admin\dest\pfile\initdest.ora' nomount;
    ORACLE instance started.
    Total System Global Area 97589952 bytes
    Fixed Size 453312 bytes
    Variable Size 46137344 bytes
    Database Buffers 50331648 bytes
   Redo Buffers 667648 bytes

 · Leave this session alive and move to rman session

10. Invoke the rman session and connect the catalog db, target db and duplicate db

 $ rman catalog rman/rman@rman target sys/admin@source auxiliary sys/admin@dest
 Recovery Manager: Release - Production
 Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
 connected to target database: SOURCE (DBID=596212533)
 connected to recovery catalog database
 connected to auxiliary database: dest (not mounted)

 OR another way to connect rman

  $ rman
   Recovery Manager: Release - Production
   Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved
   Rman> connect catalog rman/rman@rman
               connected to recovery catalog database
   Rman> connect target sys/admin@source
                connected to target database: SOURCE (DBID=596212533)
   Rman> connect auxiliary sys/admin@dest
               connected to auxiliary database: dest (not mounted)

11. Now Execute the below script to clone the new database.

   RMAN> run {allocate auxiliary channel c1 type disk;
          2> duplicate target database to dest};

12. After executing the script, rman start execute some internal script to create instance for the duplicate database and also restore target database data files to the duplicate database location, then start applying archive logs from target database backup locations to duplicate database locations.

13. While run this script, rman itself internally run some scripts to allocated instance for the duplicate database. In middle of the script running that is “executing script: Memory Script “rman may stop execute further. So no need to worry, leave the session remain or close it. Move to your duplicate “dest” database session and execute the below script.

        SQL> alter database open resetlogs;
        Database altered.

Before that ensure all files are restore properly to duplicate database location “dest”

        SQL> select name,dbid from v$database;
        NAME DBID
       --------- ----------
       DEST 596212533

Both database source and dest database ID will be remain same. 
So we need to change the dbid in dest db using DBNEW ID utility.

No comments: