In sweet memories of my ever loving brother "kutty thambi " ARUN KUMAR

Monday, August 8, 2011

Duplicate a database without connecting to a target database and a recovery catalog (11gR2 New Features)

Users can duplicate a database without connecting to a target database. The only requirements for this operation are a connection to a catalog and an auxiliary database. This new functionality is useful when the target database is not always available.
Users can also duplicate a database without connecting to a target database and a recovery catalog. In this case, the only requirement is that you provide a disk backup location where RMAN can find all the backups, datafile copies, archived logs, and control file copies for database duplication. This database duplication enhancement is helpful when it is not possible to connect to the target database and the recovery catalog.

here is an demo, In our example i am going to create a duplicate database with the name CLONEDB from the database DB2


1. Take backup of target database.
2. Copy the backupsets to the machine where you would like to clone the target database.
3. Create a new pfile for clone database or copy the pfile of target database and replace/edit the pfile entries for the clone database.
4. Create a password file
5. Create required folders for dump and database files.
6. Add an entry in /etc/oratab file
7. Create pfile for duplicate database
8. Add required TNS entry in tnsnames.ora file
9. startup nomount the clone/duplicate database.
10. Duplicate command in auxiliary instance.


  
SQL> select name from v$database;

NAME
--------------------------------------------------------
DB2

[oracle@node2 backupnew]$ . oraenv
ORACLE_SID = [db2] ?
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle
[oracle@node2 backupnew]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Aug 8 00:31:43 2011

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

connected to target database: DB2 (DBID=1922019997)

RMAN> backup as compressed backupset database format '/u01/app/oracle/backup/%d_%s_%I_%T' plus archivelog format '/u01/app/oracle/backup/%d_%s_%I_%T';

RMAN> backup archivelog all format '/u01/app/oracle/backup/%d_%s_%I_%T';

RMAN> EXIT;

[oracle@node2 backup]$ cd /u01/app/oracle/backup
[oracle@node2 backup]$ pwd
/u01/app/oracle/backup
[oracle@node2 backup]$ ls -ltr
total 463128
-rw-r----- 1 oracle dba 28600320 Aug 8 00:33 DB2_26_1922019997_20110808
-rw-r----- 1 oracle dba 265560064 Aug 8 00:35 DB2_27_1922019997_20110808
-rw-r----- 1 oracle dba 1114112 Aug 8 00:35 DB2_28_1922019997_20110808
-rw-r----- 1 oracle dba 94208 Aug 8 00:35 DB2_29_1922019997_20110808
-rw-r----- 1 oracle dba 89183232 Aug 8 00:36 DB2_30_1922019997_20110808
-rw-r----- 1 oracle dba 89189376 Aug 8 00:37 DB2_31_1922019997_20110808
******************************************************************************
copy the backups to the second server where you would like to clone the database

[oracle@node1 oracle]$ pwd
/u01/app/oracle
[oracle@node1 oracle]$ mkdir backup

[oracle@node2 backup]$ pwd
/u01/app/oracle/backup
[oracle@node2 backup]$ scp * oracle@192.168.2.101:/u01/app/oracle/backup
DB2_26_1922019997_20110808 100% 27MB 13.6MB/s 00:02
DB2_27_1922019997_20110808 100% 253MB 6.5MB/s 00:39
DB2_28_1922019997_20110808 100% 1088KB 1.1MB/s 00:00
DB2_29_1922019997_20110808 100% 92KB 92.0KB/s 00:00
DB2_30_1922019997_20110808 100% 85MB 6.5MB/s 00:13
DB2_31_1922019997_20110808 100% 85MB 14.2MB/s 00:06
[oracle@node2 backup]$

[oracle@node2 dbs]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@node2 dbs]$ ls | grep init
initdb2.ora
init.ora
initorcl2.ora
[oracle@node2 dbs]$ scp initdb2.ora oracle@192.168.2.101:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initclonedb.ora

edit/replace the name and directory/folder for the clone database

eg:- I have replaced/edited the pfile as below
clonedb.__db_cache_size=541065216
clonedb.__java_pool_size=4194304
clonedb.__large_pool_size=4194304
clonedb.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
clonedb.__pga_aggregate_target=260046848
clonedb.__sga_target=780140544
clonedb.__shared_io_pool_size=0
clonedb.__shared_pool_size=218103808
clonedb.__streams_pool_size=4194304
*.audit_file_dest='/u01/app/oracle/admin/clonedb/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/clonedb/control01.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='clonedb'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=clonedbXDB)'
*.open_cursors=300
*.pga_aggregate_target=258998272
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=776994816
*.undo_tablespace='UNDOTBS1'
db_file_name_convert='/u01/app/oracle/db2/','/u01/app/oracle/clonedb/'
log_file_name_convert='/u01/app/oracle/db2/','/u01/app/oracle/clonedb/'
*******************************************************************************
create a password file for clonedb
*******************************************************************************
[oracle@node1 dbs]$ orapwd file=$ORACLE_HOME/dbs/orapwclonedb password=oracle

create required folders and directories for database files and dump files
[oracle@node1 clonedb]$ mkdir -p /u01/app/oracle/admin/clonedb/adump
[oracle@node1 clonedb]$ mkdir -p /u01/app/oracle/admin/clonedb/udump
[oracle@node1 clonedb]$ mkdir -p /u01/app/oracle/admin/clonedb/bdump
[oracle@node1 clonedb]$ mkdir -p /u01/app/oracle/admin/clonedb/cdump
[oracle@node1 clonedb]$ mkdir -p /u01/app/oracle/clonedb

add an entry in the /etc/oratab file
clonedb:/u01/app/oracle/product/11.2.0/dbhome_1:N

[oracle@node1 clonedb]$ . oraenv
ORACLE_SID = [RAC1] ? clonedb
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle
[oracle@node1 clonedb]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Mon Aug 8 01:05:39 2011

Copyright (c) 1982, 2009, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 778387456 bytes
Fixed Size 1339344 bytes
Variable Size 222298160 bytes
Database Buffers 549453824 bytes
Redo Buffers 5296128 bytes
SQL>

[oracle@node1 clonedb]$ . oraenv
ORACLE_SID = [RAC1] ? clonedb
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle
[oracle@node1 clonedb]$ rman auxiliary /

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Aug 8 01:06:32 2011

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

connected to auxiliary database: CLONEDB (not mounted)

RMAN> duplicate database to clonedb backup location '/u01/app/oracle/backup' nofilenamecheck;


SQL> select name from v$database;

NAME
---------
CLONEDB

SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1


5 comments:

Raju said...

Good one man . really it's helped me lot --Raju

chandu reddy said...

Nice post and same here too

http://www.chandu208.blogspot.com/2011/12/11g-rman-cloning-using-duplicate.html

Anonymous said...

J ' followed the prodcedure and here is my errors


ORA-27101: shared memory realm does not exist

RMAN-03015: error occurred in stored script Memory Script
RMAN-04014: startup failed: ORA-00600: internal error code, arguments: [kck_rls_check must use (11,0,0,0,0) or lower], [kdt.c], [9576], [11.2.0.2.0], [], [], [], [], [], [], [], []
RMAN-04017: startup error description: ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance


What to make
thanks
sam

srikanth Bondugula said...

Increase your SGA size in your parameter file and retest again .

Anonymous said...

Excellent Post ! Thank you

 
Share/Bookmark