CLONING A DATABASE USING RMAN (simple steps)

CLONING A DATABASE USING RMAN (simple steps)

orcl = parent database,  (must be in OPEN mode)
dupli= duplicate database. (must be in NOMOUNT mode)

[oracle@localhost ~]$ ORACLE_SID=orcl
[oracle@localhost ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 – Production on Fri Dec 23 12:18:53 2011

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

connected to target database: ORCL (DBID=1297119988)

RMAN> backup incremental level 0 database;

Starting backup at 23-DEC-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=152 devtype=DISK
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/oracle/product/10.2.0/db_1/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/oracle/product/10.2.0/db_1/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/oracle/product/10.2.0/db_1/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u01/oracle/product/10.2.0/db_1/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/oracle/product/10.2.0/db_1/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 23-DEC-11
channel ORA_DISK_1: finished piece 1 at 23-DEC-11
piece handle=/u01/oracle/product/10.2.0/db_1/flash_recovery_area/ORCL/backupset/2011_12_23/o1_mf_nnnd0_TAG20111223T121912_7h8939on_.bkp tag=TAG20111223T121912 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:48
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 23-DEC-11
channel ORA_DISK_1: finished piece 1 at 23-DEC-11
piece handle=/u01/oracle/product/10.2.0/db_1/flash_recovery_area/ORCL/backupset/2011_12_23/o1_mf_ncsn0_TAG20111223T121912_7h896s29_.bkp tag=TAG20111223T121912 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 23-DEC-11

RMAN>  quit

Recovery Manager complete.
[oracle@localhost ~]$ mkdir /u01/oracle/product/10.2.0/db_1/oradata/dupli
[oracle@localhost ~]$ vi /u01/oracle/product/10.2.0/db_1/dbs/initdupli.ora

——–ENTRY—————–
db_name=dupli
instance_name=dupli
db_file_name_convert=(‘/u01/oracle/product/10.2.0/db_1/oradata/orcl’,’/u01/oracle/product/10.2.0/db_1/oradata/dupli’)
log_file_name_convert=(‘/u01/oracle/product/10.2.0/db_1/oradata/orcl’,’/u01/oracle/product/10.2.0/db_1/oradata/dupli’)
compatible=10.2.0.1.0
SGA_TARGET=1G
SGA_MAX_SIZE=1G
——————————

[oracle@localhost ~]$ orapwd file=/u01/oracle/product/10.2.0/db_1/dbs/orapwdupli password=oracle force=y
[oracle@localhost ~]$ netmgr        ////create listener and service for both database////

[oracle@localhost ~]$ lsnrctl reload

LSNRCTL for Linux: Version 10.2.0.1.0 – Production on 23-DEC-2011 12:32:31

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
The command completed successfully
[oracle@localhost ~]$ tnsping dupli

TNS Ping Utility for Linux: Version 10.2.0.1.0 – Production on 23-DEC-2011 12:32:43

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

Used parameter files:
/u01/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = dupli)))
OK (70 msec)
[oracle@localhost ~]$  ORACLE_SID=dupli
[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 – Production on Fri Dec 23 13:04:25 2011

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

SQL> conn /as sysdba
Connected.
SQL> create spfile from pfile=’/u01/oracle/product/10.2.0/db_1/dbs/initdupli.ora’;

File created.

SQL> startup force nomount;
ORACLE instance started.

Total System Global Area 1073741824 bytes
Fixed Size                  1223540 bytes
Variable Size             264242316 bytes
Database Buffers          805306368 bytes
Redo Buffers                2969600 bytes
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – Production
With the Partitioning, OLAP and Data Mining options
[oracle@localhost ~]$ ORACLE_SID=orcl
[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 – Production on Fri Dec 23 13:06:42 2011

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

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – Production
With the Partitioning, OLAP and Data Mining options

SQL> alter system switch logfile;

System altered.

SQL> quit;
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – Production
With the Partitioning, OLAP and Data Mining options
[oracle@localhost ~]$ rman target / auxiliary sys/oracle@dupli

Recovery Manager: Release 10.2.0.1.0 – Production on Fri Dec 23 13:07:02 2011

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

connected to target database: ORCL (DBID=1297119988)
connected to auxiliary database: DUPLI (not mounted)

RMAN> duplicate target database to dupli;

Starting Duplicate Db at 23-DEC-11
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=36 devtype=DISK

contents of Memory Script:
{
set until scn  681541;
set newname for datafile  1 to
“/u01/oracle/product/10.2.0/db_1/oradata/dupli/system01.dbf”;
set newname for datafile  2 to
“/u01/oracle/product/10.2.0/db_1/oradata/dupli/undotbs01.dbf”;
set newname for datafile  3 to
“/u01/oracle/product/10.2.0/db_1/oradata/dupli/sysaux01.dbf”;
set newname for datafile  4 to
“/u01/oracle/product/10.2.0/db_1/oradata/dupli/users01.dbf”;
set newname for datafile  5 to
“/u01/oracle/product/10.2.0/db_1/oradata/dupli/example01.dbf”;
restore
check readonly
clone database
;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 23-DEC-11
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/oracle/product/10.2.0/db_1/oradata/dupli/system01.dbf
restoring datafile 00002 to /u01/oracle/product/10.2.0/db_1/oradata/dupli/undotbs01.dbf
restoring datafile 00003 to /u01/oracle/product/10.2.0/db_1/oradata/dupli/sysaux01.dbf
restoring datafile 00004 to /u01/oracle/product/10.2.0/db_1/oradata/dupli/users01.dbf
restoring datafile 00005 to /u01/oracle/product/10.2.0/db_1/oradata/dupli/example01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/oracle/product/10.2.0/db_1/flash_recovery_area/ORCL/backupset/2011_12_23/o1_mf_nnnd0_TAG20111223T125918_7h8cghgp_.bkp
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/oracle/product/10.2.0/db_1/flash_recovery_area/ORCL/backupset/2011_12_23/o1_mf_nnnd0_TAG20111223T125918_7h8cghgp_.bkp tag=TAG20111223T125918
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:15
Finished restore at 23-DEC-11
sql statement: CREATE CONTROLFILE REUSE SET DATABASE “DUPLI” RESETLOGS ARCHIVELOG
MAXLOGFILES     16
MAXLOGMEMBERS      3
MAXDATAFILES      100
MAXINSTANCES     8
MAXLOGHISTORY      292
LOGFILE
GROUP  1 ( ‘/u01/oracle/product/10.2.0/db_1/oradata/dupli/redo01.log’ ) SIZE 50 M  REUSE,
GROUP  2 ( ‘/u01/oracle/product/10.2.0/db_1/oradata/dupli/redo02.log’ ) SIZE 50 M  REUSE,
GROUP  3 ( ‘/u01/oracle/product/10.2.0/db_1/oradata/dupli/redo03.log’ ) SIZE 50 M  REUSE
DATAFILE
‘/u01/oracle/product/10.2.0/db_1/oradata/dupli/system01.dbf’
CHARACTER SET WE8ISO8859P1

contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script

released channel: ORA_AUX_DISK_1
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=770648916 filename=/u01/oracle/product/10.2.0/db_1/oradata/dupli/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=770648916 filename=/u01/oracle/product/10.2.0/db_1/oradata/dupli/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=770648916 filename=/u01/oracle/product/10.2.0/db_1/oradata/dupli/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=770648916 filename=/u01/oracle/product/10.2.0/db_1/oradata/dupli/example01.dbf

contents of Memory Script:
{
set until scn  681541;
recover
clone database
delete archivelog
;
}
executing Memory Script

executing command: SET until clause

Starting recover at 23-DEC-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=36 devtype=DISK

starting media recovery

archive log thread 1 sequence 3 is already on disk as file /u01/oracle/product/10.2.0/db_1/flash_recovery_area/ORCL/archivelog/2011_12_23/o1_mf_1_3_7h8cwoqb_.arc
archive log filename=/u01/oracle/product/10.2.0/db_1/flash_recovery_area/ORCL/archivelog/2011_12_23/o1_mf_1_3_7h8cwoqb_.arc thread=1 sequence=3
media recovery complete, elapsed time: 00:00:01
Finished recover at 23-DEC-11

contents of Memory Script:
{
shutdown clone;
startup clone nomount ;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1073741824 bytes

Fixed Size                     1223540 bytes
Variable Size                264242316 bytes
Database Buffers             805306368 bytes
Redo Buffers                   2969600 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE “DUPLI” RESETLOGS ARCHIVELOG
MAXLOGFILES     16
MAXLOGMEMBERS      3
MAXDATAFILES      100
MAXINSTANCES     8
MAXLOGHISTORY      292
LOGFILE
GROUP  1 ( ‘/u01/oracle/product/10.2.0/db_1/oradata/dupli/redo01.log’ ) SIZE 50 M  REUSE,
GROUP  2 ( ‘/u01/oracle/product/10.2.0/db_1/oradata/dupli/redo02.log’ ) SIZE 50 M  REUSE,
GROUP  3 ( ‘/u01/oracle/product/10.2.0/db_1/oradata/dupli/redo03.log’ ) SIZE 50 M  REUSE
DATAFILE
‘/u01/oracle/product/10.2.0/db_1/oradata/dupli/system01.dbf’
CHARACTER SET WE8ISO8859P1

contents of Memory Script:
{
catalog clone datafilecopy  “/u01/oracle/product/10.2.0/db_1/oradata/dupli/undotbs01.dbf”;
catalog clone datafilecopy  “/u01/oracle/product/10.2.0/db_1/oradata/dupli/sysaux01.dbf”;
catalog clone datafilecopy  “/u01/oracle/product/10.2.0/db_1/oradata/dupli/users01.dbf”;
catalog clone datafilecopy  “/u01/oracle/product/10.2.0/db_1/oradata/dupli/example01.dbf”;
switch clone datafile all;
}
executing Memory Script

cataloged datafile copy
datafile copy filename=/u01/oracle/product/10.2.0/db_1/oradata/dupli/undotbs01.dbf recid=1 stamp=770648922

cataloged datafile copy
datafile copy filename=/u01/oracle/product/10.2.0/db_1/oradata/dupli/sysaux01.dbf recid=2 stamp=770648922

cataloged datafile copy
datafile copy filename=/u01/oracle/product/10.2.0/db_1/oradata/dupli/users01.dbf recid=3 stamp=770648922

cataloged datafile copy
datafile copy filename=/u01/oracle/product/10.2.0/db_1/oradata/dupli/example01.dbf recid=4 stamp=770648922

datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=770648922 filename=/u01/oracle/product/10.2.0/db_1/oradata/dupli/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=770648922 filename=/u01/oracle/product/10.2.0/db_1/oradata/dupli/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=770648922 filename=/u01/oracle/product/10.2.0/db_1/oradata/dupli/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=770648922 filename=/u01/oracle/product/10.2.0/db_1/oradata/dupli/example01.dbf

contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 23-DEC-11

RMAN> quit

Recovery Manager complete.
[oracle@localhost ~]$ ORACLE_SID=dupli
[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 – Production on Fri Dec 23 13:10:31 2011

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

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – Production
With the Partitioning, OLAP and Data Mining options

SQL> select status from v$instance;

STATUS
————
OPEN

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s