Monday, April 22, 2013

Clone / Duplicate a database with RMAN



1.  create parameter file.
SQL> create pfile from spfile;
$ cp initdrprod.ora initadil.ora

2. edit parameter file and replace OLD SID with NEW SID
$ vi initadil.ora
adil.__db_cache_size=176160768
adil.__java_pool_size=4194304
adil.__large_pool_size=4194304
adil.__shared_pool_size=411041792
adil.__streams_pool_size=8388608
*.audit_file_dest='/u01/app/oracle/admin/adil/adump'
*.background_dump_dest='/u01/app/oracle/admin/adil/bdump'
*.compatible='10.2.0.3.0'
*.control_files='/u01/app/oracle/oradata/adil/control01.ctl',
                              '/u01/app/oracle/oradata/adil/control02.ctl',
                              '/u01/app/oracle/oradata/adil/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/adil/cdump'
*.db_block_size=8192
*.db_domain='omeir.global'
*.db_file_multiblock_read_count=16
*.db_name='adil'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=adilXDB)'
*.job_queue_processes=10
*.local_listener='LISTENER_ADIL'
*.log_archive_dest_1='location=/zone/archive/adil/'
*.log_archive_format='adil_%t_%s_%r.arc'
*.open_cursors=300
*.pga_aggregate_target=203423744
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=612368384
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/adil/udump'
*.db_file_name_convert='/u01/app/oracle/oradata/drprod/','/u01/app/oracle/oradata/adil/'
*.log_file_name_convert='/u01/app/oracle/oradata/drprod/','/u01/app/oracle/oradata/adil/'



3. Create password file:
orapwd file=orapw$ORACLE_SID password=adil entries=50;

====
4. Create dump files:
$ cd /u01/app/oracle/admin/adil/
$ mkdir adump bdump cdump udump dpdump pfile  -- dump directory location
$ cd /u01/app/oracle/oradata/
$ mkdir adil                                                       -- controlfiles/datafiles/relofiles location
$ cd /zone
$ mkdir adil/arch                                             -- archive location.
====

5. Update listener and tnsnames.ora files
====

6.
set ORACLE_SID and start the database in nomount state.

===
7. execute the following duplicate database command ( run from auxiliary db console ‘oracle_sid’)
connect target sys/drprod@drprod
connect catalog rman/rman@catdb
connect auxiliary sys/adil@adil 

run {
set newname for datafile 1 to '/u01/app/oracle/oradata/adil/system01.dbf';
set newname for datafile 2 to '/u01/app/oracle/oradata/adil/undotbs01.dbf';
set newname for datafile 3 to '/u01/app/oracle/oradata/adil/sysaux01.dbf';
set newname for datafile 4 to '/u01/app/oracle/oradata/adil/users';


allocate channel c2 type disk;
set until sequence 2 thread 1;

duplicate target database to adil
logfile
  GROUP 1 ('/u01/app/oracle/oradata/adil/redo01.log') SIZE 5M  REUSE,
  GROUP 2 ('/u01/app/oracle/oradata/adil/redo02.log') SIZE 5M  REUSE,
  GROUP 3 ('/u01/app/oracle/oradata/adil/redo03.log') SIZE 5M  REUSE,
  GROUP 4 ('/u01/app/oracle/oradata/adil/redo04.log') SIZE 5M  REUSE;
}

8. Change passwords of sys/system/sysman/dbsnmp (if required)

9. Register database with catalog ( if required)

$ rman target sys/adil@adil catalog rman/rman@catdb
Recovery Manager: Release 10.2.0.4.0 - Production on Mon Apr 22 16:09:37 2013
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database: ADIL (DBID=2245812828)
connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

RMAN> backup database plus archivelog;


10 Create Enterprise manager Db controle
$ emca -repos drop
$ emca -repos create
$ emca -config dbcontrol db

No comments:

Post a Comment