Tuesday, December 20, 2011

How to create duplicate oracle database from rman backups in oralce 11g

How to create duplicate oracle database from rman backups in oralce 11g
I think it is not advisable to clone database on same production primary database host to be safe side (excuse me if I am wrong, it does not mean we can not do clone on same host), however please check with oracle online documenation or my oraclesupport for further info if need arise.

I did clone the database from RMAN backups on same host.

Create instance for new oracle database: you my see earlier posts on how to create oracle instance

on target:\-intpwd password=oracle -startmode a -pfile D:\TESTDELETE\initclonedb1.ora
orapwd file=F:\app\HOME\product\11.2.0\dbhome_1\database\PWDclonedb1.ora password=oracle entries=50
Add entry into listener.ora and tnsnames.ora file.
ensure tnsping clonedb1
ensure tnsping orcl
SET ORACLE_SID=CLONEDB1
lsnrctl reload -- incase required.
startup nomount pfile='D:\TESTDELETE\initclonedb1.ora'
SQL> startup nomount pfile='D:\TESTDELETE\initclonedb1.ora'
ORACLE instance started.

Total System Global Area 640286720 bytes
Fixed Size 1376492 bytes
Variable Size 314576660 bytes
Database Buffers 318767104 bytes
Redo Buffers 5566464 bytes

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
clonedb1

SQL>exit

on source db:
-------------
SET ORACLE_SID=ORCL
rman target /
BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
EXIT;
exit;
open cmd prompt;

C:\Users\HOME>SET ORACLE_SID=ORCL

C:\Users\HOME>RMAN TARGET / AUXILIARY SYS/ORACLE@CLONEDB1

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Dec 21 05:06:20 2011

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

connected to target database: ORCL (DBID=1297854480)
connected to auxiliary database: CLONEDB1 (not mounted)

RMAN> run {
SET NEWNAME FOR DATAFILE 1 TO 'F:\app\HOME\oradata\clonedb1\SYSTEM01.DBF';
SET NEWNAME FOR DATAFILE 2 TO 'F:\app\HOME\oradata\clonedb1\SYSAUX01.DBF';
SET NEWNAME FOR DATAFILE 3 TO 'F:\app\HOME\oradata\clonedb1\UNDOTBS01.DBF';
SET NEWNAME FOR DATAFILE 4 TO 'F:\app\HOME\oradata\clonedb1\USERS01.DBF';
SET NEWNAME FOR DATAFILE 5 TO 'F:\app\HOME\oradata\clonedb1\EXAMPLE01.DBF';
SET NEWNAME FOR TEMPFILE 1 TO 'F:\app\HOME\oradata\clonedb1\TEMP01.DBF';
DUPLICATE DATABASE TO clonedb1
pfile 'D:\TESTDELETE\initclonedb1.ora'
BACKUP LOCATION 'F:\app\HOME\flash_recovery_area\orcl\'
LOGFILE GROUP 1 ('F:\app\HOME\oradata\clonedb1\REDO01.LOG') SIZE 60M REUSE,
GROUP 2 ('F:\app\HOME\oradata\clonedb1\REDO02.LOG.rdo') SIZE 60M REUSE,
GROUP 3 ('F:\app\HOME\oradata\clonedb1\REDO03.LOG') SIZE 60M REUSE;
}

No comments:

Post a Comment