Cloning Database with RMAN
SOURCE DB: UAT
Location='u01/app/oracle/product/11.2.0/dbhome_1'
TARGET DB: CLONE
Location='u02/app/oracle/product/11.2.0/dbhome_1'
STEP 1: TAKE YOUR DATABASE TO MOUNT STAGE.
Location='u01/app/oracle/product/11.2.0/dbhome_1'
TARGET DB: CLONE
Location='u02/app/oracle/product/11.2.0/dbhome_1'
STEP 1: TAKE YOUR DATABASE TO MOUNT STAGE.
[oracle@ramdev02 ~]$ export ORACLE_SID=uat
[oracle@ramdev02 ~]$ sqlplus / as sysdba
Connected to ideal instance:
SQL> startup mount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed
Size
1218968 bytes
Variable
Size
88082024 bytes
Database Buffers
188743680 bytes
Redo Buffers
7168000 bytes
Database mounted.
STEP 2: PUT YOUR DATABASE IN ARCHIVELOG MODE.
SQL> alter database archivelog;
Database altered.
STEP 3: NOW TAKE YOUR DATABASE TO OPEN STAGE
SQL> alter database open;
Database altered.
STEP 4: CONNECT TO YOUR SOURCE DATABASE THROUGH RMAN AND PERFORM BACKUP OF YOUR DATABASE AND ARCHIVELOG FILES
oracle@ramdev02 ~$ export ORACLE_SID=uat
oracle@ramdev02 ~$ rman target /
connected to target database: UAT
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO
BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_uat.f'; # default
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 5;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 5 BACKUP TYPE TO
BACKUPSET;
new RMAN configuration parameters are successfully stored
RMAN> backup database plus archivelog;
It will be stored in '/u01/app/oracle/flash_recovery_area/UAT/backupset/YYYY_MM_DD’
STEP 5: CREATE A PARAMETER FILE FOR CLONE DATABASE
SQL> create pfile='$ORACLE_HOME/dbs/initclone.ora' from spfile;
File created.
oracle@ramdev02 ~$ vi initclone.ora (target database) $ORACLE_HOME/dbs
STEP 6: DO THE FOLLOWING CHANGE IN CLONE PARAMETER FILE
Source need change to
Target (Name and file system location)
clone.__db_cache_size=184549376
clone.__java_pool_size=4194304
clone.__large_pool_size=4194304
clone.__shared_pool_size=83886080
clone.__streams_pool_size=0
*.audit_file_dest='/u02/app/oracle/admin/clone/adump'
*.background_dump_dest='/u02/app/oracle/admin/clone/bdump'
*.compatible='11.2.0.1.0'
*.control_files='/u02/app/oracle/oradata/clone/control01.ctl','/u02/app/oracle/oradata/clone/control02.ctl','/u02/app/oracle/oradata/clone/control03.ctl'
*.core_dump_dest='/u02/app/oracle/admin/clone/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='clone'
#*.db_recovery_file_dest='/u02/app/oracle/flash_recovery_area'
#*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=cloneXDB)'
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=283115520
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u02/app/oracle/admin/clone/udump'
db_file_name_convert='/u01/app/oracle/oradata/uat','/u02/app/oracle/oradata/clone'
log_file_name_convert='/u01/app/oracle/oradata/uat','/u02/app/oracle/oradata/clone'
STEP 7: CREATE THE FOLLOWING DIRECTORIES FOR CONE DATABASE
oracle@ramdev02 ~$ mkdir -p /u02/app/oracle/oradata/clone
oracle@ramdev02 ~$ mkdir –p /u02/app/oracle/admin/clone
oracle@ramdev02 ~$ mkdir –p /u02/app/oracle/admin/clone/adump
oracle@ramdev02 ~$ mkdir –p
/u02/app/oracle/admin/clone/bdump
oracle@ramdev02 ~$ mkdir –p
/u02/app/oracle/admin/clone/cdump
oracle@ramdev02 ~$ mkdir –p
/u02/app/oracle/admin/clone/udump
oracle@ramdev02 ~$ mkdir –p /u02/app/oracle/flash_recovery_area/clone/
STEP 8: CREATE A
PASSWORD FILE FOR CLONE DATABASE
oracle@ramdev02 ~$ orapwd file=$ORACLE_HOME/dbs/orapwclone
password=oracle entries=5
STEP 9: FIRE THE FOLLWOING COMMAND ON PRIMARY DATABASE TO SET THE SAME PASSWORD OF CLONE DATABASE
alter user sys identified by oracle;
STEP 10: TAKE YOUR DATABASE TO NOMOUNT STAGE AND EXIT FROM SQL PROMPT
oracle@ramdev02 ~$ export ORACLE_SID=clone
oracle@ramdev02 ~$ sqlplus / as sysdba
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed
Size
1218316 bytes
Variable Size
62916852 bytes
Database Buffers
100663296 bytes
Redo
Buffers
2973696 bytes
SQL>
SQL> exit
oracle@ramdev02 ~$
STEP 11: CONNECT TO PRIMARY DATABASE AND CLONE DATABASE BY FIRING FOLLOWING COMMAND
STEP 11: CONNECT TO PRIMARY DATABASE AND CLONE DATABASE BY FIRING FOLLOWING COMMAND
[oracle@ramdev02 ~]$ export ORACLE_SID=uat
[oracle@ramdev02 ~]$ rman auxiliary /
connected to auxiliary database: uat (not mounted)
STEP 12: FIRE THE FOLLOWING COMMAND TO CREATE THE CLONE
RMAN>duplicate database to "clone" backup location
'/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26' nofilenamecheck;
Starting Duplicate Db at
27-MAR-14
contents of Memory
Script:
{
sql clone
"alter system set db_name =
''UAT'' comment=
''Modified by RMAN
duplicate'' scope=spfile";
sql clone
"alter system set db_unique_name =
''CLONE'' comment=
''Modified by RMAN
duplicate'' scope=spfile";
shutdown
clone immediate;
startup
clone force nomount
restore
clone primary controlfile from
'/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_ncnnf_TAG20140326T194706_9m5rc4xy_.bkp';
alter clone
database mount;
}
executing Memory Script
sql statement: alter
system set db_name = ''UAT'' comment= ''Modified by RMAN
duplicate'' scope=spfile
sql statement: alter
system set db_unique_name = ''CLONE'' comment= ''Modified by RMAN
duplicate'' scope=spfile
Oracle instance shut
down
Oracle instance started
Total System Global
Area 1252663296 bytes
Fixed
Size
2212936 bytes
Variable
Size
805309368 bytes
Database
Buffers
436207616 bytes
Redo
Buffers
8933376 bytes
Starting restore at
27-MAR-14
allocated channel:
ORA_AUX_DISK_1
channel ORA_AUX_DISK_1:
SID=18 device type=DISK
channel ORA_AUX_DISK_1:
restoring control file
channel ORA_AUX_DISK_1:
restore complete, elapsed time: 00:00:01
output file
name=/u02/app/oracle/oradata/clone/control01.ctl
output file
name=/u02/app/oracle/flash_recovery_area/clone/control02.ctl
Finished restore at
27-MAR-14
database mounted
released channel:
ORA_AUX_DISK_1
allocated channel:
ORA_AUX_DISK_1
channel ORA_AUX_DISK_1:
SID=18 device type=DISK
contents of Memory
Script:
{
set until
scn 1024051;
set newname
for datafile 1 to
"/u02/app/oracle/oradata/clone/system01.dbf";
set newname
for datafile 2 to
"/u02/app/oracle/oradata/clone/sysaux01.dbf";
set newname
for datafile 3 to
"/u02/app/oracle/oradata/clone/undotbs01.dbf";
set newname
for datafile 4 to
"/u02/app/oracle/oradata/clone/users01.dbf";
set newname
for datafile 5 to
"/u02/app/oracle/oradata/clone/example01.dbf";
restore
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
27-MAR-14
using channel
ORA_AUX_DISK_1
channel ORA_AUX_DISK_1:
starting datafile backup set restore
channel ORA_AUX_DISK_1:
specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1:
restoring datafile 00001 to /u02/app/oracle/oradata/clone/system01.dbf
channel ORA_AUX_DISK_1:
reading from backup piece
/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_nnndf_TAG20140326T194706_9m5rc49m_.bkp
channel ORA_AUX_DISK_1:
piece handle=/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_nnndf_TAG20140326T194706_9m5rc49m_.bkp
tag=TAG20140326T194706
channel ORA_AUX_DISK_1:
restored backup piece 1
channel ORA_AUX_DISK_1:
restore complete, elapsed time: 00:00:25
channel ORA_AUX_DISK_1:
starting datafile backup set restore
channel ORA_AUX_DISK_1:
specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1:
restoring datafile 00002 to /u02/app/oracle/oradata/clone/sysaux01.dbf
channel ORA_AUX_DISK_1:
reading from backup piece /u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_nnndf_TAG20140326T194706_9m5rc6s5_.bkp
channel ORA_AUX_DISK_1:
piece
handle=/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_nnndf_TAG20140326T194706_9m5rc6s5_.bkp
tag=TAG20140326T194706
channel ORA_AUX_DISK_1:
restored backup piece 1
channel ORA_AUX_DISK_1:
restore complete, elapsed time: 00:00:16
channel ORA_AUX_DISK_1:
starting datafile backup set restore
channel ORA_AUX_DISK_1:
specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1:
restoring datafile 00003 to /u02/app/oracle/oradata/clone/undotbs01.dbf
channel ORA_AUX_DISK_1:
reading from backup piece
/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_nnndf_TAG20140326T194706_9m5rc6jj_.bkp
channel ORA_AUX_DISK_1:
piece handle=/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_nnndf_TAG20140326T194706_9m5rc6jj_.bkp
tag=TAG20140326T194706
channel ORA_AUX_DISK_1:
restored backup piece 1
channel ORA_AUX_DISK_1:
restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1:
starting datafile backup set restore
channel ORA_AUX_DISK_1:
specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1:
restoring datafile 00004 to /u02/app/oracle/oradata/clone/users01.dbf
channel ORA_AUX_DISK_1:
reading from backup piece
/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_nnndf_TAG20140326T194706_9m5rcb1d_.bkp
channel ORA_AUX_DISK_1:
piece
handle=/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_nnndf_TAG20140326T194706_9m5rcb1d_.bkp
tag=TAG20140326T194706
channel ORA_AUX_DISK_1:
restored backup piece 1
channel ORA_AUX_DISK_1:
restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1:
starting datafile backup set restore
channel ORA_AUX_DISK_1:
specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1:
restoring datafile 00005 to /u02/app/oracle/oradata/clone/example01.dbf
channel ORA_AUX_DISK_1:
reading from backup piece
/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_nnndf_TAG20140326T194706_9m5rc6cn_.bkp
channel ORA_AUX_DISK_1:
piece
handle=/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_nnndf_TAG20140326T194706_9m5rc6cn_.bkp
tag=TAG20140326T194706
channel ORA_AUX_DISK_1:
restored backup piece 1
channel ORA_AUX_DISK_1:
restore complete, elapsed time: 00:00:03
Finished restore at
27-MAR-14
contents of Memory
Script:
{
switch
clone datafile all;
}
executing Memory Script
datafile 1 switched to
datafile copy
input datafile copy
RECID=6 STAMP=843322272 file name=/u02/app/oracle/oradata/clone/system01.dbf
datafile 2 switched to
datafile copy
input datafile copy
RECID=7 STAMP=843322272 file name=/u02/app/oracle/oradata/clone/sysaux01.dbf
datafile 3 switched to
datafile copy
input datafile copy RECID=8
STAMP=843322272 file name=/u02/app/oracle/oradata/clone/undotbs01.dbf
datafile 4 switched to
datafile copy
input datafile copy
RECID=9 STAMP=843322272 file name=/u02/app/oracle/oradata/clone/users01.dbf
datafile 5 switched to
datafile copy
input datafile copy
RECID=10 STAMP=843322272 file name=/u02/app/oracle/oradata/clone/example01.dbf
contents of Memory
Script:
{
set until
scn 1024051;
recover
clone
database
delete archivelog
;
}
executing Memory Script
executing command: SET
until clause
Starting recover at
27-MAR-14
using channel
ORA_AUX_DISK_1
starting media recovery
channel ORA_AUX_DISK_1:
starting archived log restore to default destination
channel ORA_AUX_DISK_1:
restoring archived log
archived log thread=1
sequence=7
channel ORA_AUX_DISK_1:
reading from backup piece
/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_annnn_TAG20140326T194757_9m5rdp84_.bkp
channel ORA_AUX_DISK_1:
piece handle=/u01/app/oracle/flash_recovery_area/UAT/backupset/2014_03_26/o1_mf_annnn_TAG20140326T194757_9m5rdp84_.bkp
tag=TAG20140326T194757
channel ORA_AUX_DISK_1:
restored backup piece 1
channel ORA_AUX_DISK_1:
restore complete, elapsed time: 00:00:01
archived log file
name=/u02/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_7_843246981.dbf thread=1
sequence=7
channel clone_default:
deleting archived log(s)
archived log file
name=/u02/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_7_843246981.dbf RECID=1
STAMP=843322274
media recovery complete,
elapsed time: 00:00:02
Finished recover at
27-MAR-14
contents of Memory
Script:
{
shutdown
clone immediate;
startup
clone nomount;
sql clone
"alter system set db_name =
''CLONE'' comment=
''Reset to
original value by RMAN'' scope=spfile";
sql clone
"alter system reset db_unique_name scope=spfile";
shutdown
clone immediate;
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 1252663296 bytes
Fixed
Size
2212936 bytes
Variable
Size
805309368 bytes
Database
Buffers
436207616 bytes
Redo
Buffers
8933376 bytes
sql statement: alter
system set db_name = ''CLONE'' comment= ''Reset to original value by RMAN''
scope=spfile
sql statement: alter
system reset db_unique_name scope=spfile
Oracle instance shut
down
connected to auxiliary
database (not started)
Oracle instance started
Total System Global
Area 1252663296 bytes
Fixed
Size
2212936 bytes
Variable
Size
805309368 bytes
Database
Buffers
436207616 bytes
Redo
Buffers
8933376 bytes
sql statement: CREATE
CONTROLFILE REUSE SET DATABASE "CLONE" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 (
'/u02/app/oracle/oradata/clone/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 (
'/u02/app/oracle/oradata/clone/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 (
'/u02/app/oracle/oradata/clone/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/u02/app/oracle/oradata/clone/system01.dbf'
CHARACTER SET
AL32UTF8
contents of Memory
Script:
{
set newname
for tempfile 1 to
"/u02/app/oracle/oradata/clone/temp01.dbf";
switch
clone tempfile all;
catalog
clone datafilecopy
"/u02/app/oracle/oradata/clone/sysaux01.dbf",
"/u02/app/oracle/oradata/clone/undotbs01.dbf",
"/u02/app/oracle/oradata/clone/users01.dbf",
"/u02/app/oracle/oradata/clone/example01.dbf";
switch
clone datafile all;
}
executing Memory Script
executing command: SET
NEWNAME
renamed tempfile 1 to /u02/app/oracle/oradata/clone/temp01.dbf
in control file
cataloged datafile copy
datafile copy file
name=/u02/app/oracle/oradata/clone/sysaux01.dbf RECID=1 STAMP=843322296
cataloged datafile copy
datafile copy file
name=/u02/app/oracle/oradata/clone/undotbs01.dbf RECID=2 STAMP=843322296
cataloged datafile copy
datafile copy file
name=/u02/app/oracle/oradata/clone/users01.dbf RECID=3 STAMP=843322296
cataloged datafile copy
datafile copy file
name=/u02/app/oracle/oradata/clone/example01.dbf RECID=4 STAMP=843322296
datafile 2 switched to
datafile copy
input datafile copy
RECID=1 STAMP=843322296 file name=/u02/app/oracle/oradata/clone/sysaux01.dbf
datafile 3 switched to
datafile copy
input datafile copy
RECID=2 STAMP=843322296 file name=/u02/app/oracle/oradata/clone/undotbs01.dbf
datafile 4 switched to
datafile copy
input datafile copy
RECID=3 STAMP=843322296 file name=/u02/app/oracle/oradata/clone/users01.dbf
datafile 5 switched to
datafile copy
input datafile copy
RECID=4 STAMP=843322296 file name=/u02/app/oracle/oradata/clone/example01.dbf
contents of Memory
Script:
{
Alter clone
database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at
27-MAR-14
RMAN> exit
Recovery Manager
complete.
[oracle@ramdev02 ~]$ .
./clone.env
[oracle@ramdev02 ~]$
sqlplus / as sysdba
SQL*Plus: Release
11.2.0.1.0 Production on Thu Mar 27 16:13:55 2014
Copyright (c) 1982,
2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g
Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning,
OLAP, Data Mining and Real Application Testing options
SQL> select name,open_mode from v$database;
NAME
OPEN_MODE
---------
--------------------
CLONE READ WRITE
No comments:
Post a Comment