Oracle DUPLICATE Without Connection to Target Database, that's a 11gR2 Feature. DUPLICATE can be performed without connecting to a target database. This requires connecting to a catalog and auxiliary database.
Start...
- Create password file
$ orapwd file=/oracle/product/11.2.0/dbhome_1/dbs/orapwAUX entries=5- Create pfile (use ORACLE_SID=AUX)
Enter password for SYS:
SQL> create pfile='/oracle/product/11.2.0/dbhome_1/dbs/initAUX.ora' from spfile;Modify initAUX.ora file.
File created.
*.audit_file_dest='/oracle/product/admin/AUX/adump'- Check parameters and create some directories
*.compatible='11.2.0.0.0'
*.control_files='+DISK01/AUX/controlfile/current.263.696964775','+DISK02/AUX/controlfile/current.492.696964779'
*.db_block_size=8192
*.db_create_file_dest='+DISK01'
*.db_domain=''
*.db_name='AUX'
*.db_recovery_file_dest='+DISK02'
*.db_recovery_file_dest_size=10737418240
*.diagnostic_dest='/oracle/product'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=AUXXDB)'
*.job_queue_processes=1000
*.log_archive_format='%t_%s_%r.dbf'
*.log_buffer=33554432
*.memory_target=813694976
*.open_cursors=300
*.processes=150
*.remote_listener='RHEL5-T-cluster-scan:1521'
*.remote_login_passwordfile='exclusive'
*.undo_tablespace='UNDOTBS1'
$ mkdir -p /oracle/product/admin/AUX/adump- Check Target Database in Catalog
$ sqlplus rman/password@catalog- STARTUP NOMOUNT (AUXILIARY) database
SQL> select * from rc_database ;
DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE# RESETLOGS
---------- ---------- ---------- -------- ----------------- ---------
1 501 1224745511 ORCL 3626383 03-NOV-09
$ export ORACLE_SID=AUX- Duplicate Database by RMAN
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Tue Nov 3 19:27:19 2009
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 810053632 bytes
Fixed Size 2217712 bytes
Variable Size 469764368 bytes
Database Buffers 301989888 bytes
Redo Buffers 36081664 bytes
$ rman- Check
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Nov 4 12:38:14 2009
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
RMAN> CONNECT AUXILIARY /
connected to auxiliary database: AUX (not mounted)
RMAN> CONNECT CATALOG rman/password@catalog
connected to recovery catalog database
RMAN> DUPLICATE DATABASE orcl TO AUX ;
Starting Duplicate Db at 04-NOV-09
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=14 device type=DISK
contents of Memory Script:
{
sql clone "create spfile from memory";
}
executing Memory Script
sql statement: create spfile from memory
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 810053632 bytes
Fixed Size 2217712 bytes
Variable Size 469764368 bytes
Database Buffers 301989888 bytes
Redo Buffers 36081664 bytes
contents of Memory Script:
{
sql clone "alter system set control_files =
''+DISK01/aux/controlfile/current.282.702045937'', ''+DISK02/aux/controlfile/current.349.702045941'' comment=
''Set by RMAN'' scope=spfile";
sql clone "alter system set db_name =
''ORCL'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''AUX'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile;
alter clone database mount;
}
executing Memory Script
sql statement: alter system set control_files = ''+DISK01/aux/controlfile/current.282.702045937'', ''+DISK02/aux/controlfile/current.349.702045941'' comment= ''Set by RMAN'' scope=spfile
sql statement: alter system set db_name = ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''AUX'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 810053632 bytes
Fixed Size 2217712 bytes
Variable Size 469764368 bytes
Database Buffers 301989888 bytes
Redo Buffers 36081664 bytes
Starting restore at 04-NOV-09
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=140 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece +DISK02/orcl/autobackup/2009_11_03/s_701989468.353.701989473
channel ORA_AUX_DISK_1: piece handle=+DISK02/orcl/autobackup/2009_11_03/s_701989468.353.701989473 tag=TAG20091103T210428
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:17
output file name=+DISK01/aux/controlfile/current.282.702045937
output file name=+DISK02/aux/controlfile/current.349.702045941
Finished restore at 04-NOV-09
database mounted
contents of Memory Script:
{
set until scn 3657467;
set newname for clone datafile 1 to new;
set newname for clone datafile 2 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 5 to new;
set newname for clone datafile 6 to new;
set newname for clone datafile 7 to new;
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
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 04-NOV-09
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 +DISK01
channel ORA_AUX_DISK_1: restoring datafile 00002 to +DISK01
channel ORA_AUX_DISK_1: restoring datafile 00003 to +DISK01
channel ORA_AUX_DISK_1: restoring datafile 00004 to +DISK01
channel ORA_AUX_DISK_1: restoring datafile 00005 to +DISK01
channel ORA_AUX_DISK_1: restoring datafile 00006 to +DISK01
channel ORA_AUX_DISK_1: restoring datafile 00007 to +DISK01
channel ORA_AUX_DISK_1: reading from backup piece /oracle/RMAN/12ktf0ar_1_1
channel ORA_AUX_DISK_1: piece handle=/oracle/RMAN/12ktf0ar_1_1 tag=TAG20091103T210011
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:04:25
Finished restore at 04-NOV-09
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=19 STAMP=702046260 file name=+DISK01/aux/datafile/system.283.702045995
datafile 2 switched to datafile copy
input datafile copy RECID=20 STAMP=702046260 file name=+DISK01/aux/datafile/sysaux.284.702045997
datafile 3 switched to datafile copy
input datafile copy RECID=21 STAMP=702046261 file name=+DISK01/aux/datafile/undotbs1.287.702045999
datafile 4 switched to datafile copy
input datafile copy RECID=22 STAMP=702046261 file name=+DISK01/aux/datafile/users.289.702046003
datafile 5 switched to datafile copy
input datafile copy RECID=23 STAMP=702046261 file name=+DISK01/aux/datafile/example.286.702045999
datafile 6 switched to datafile copy
input datafile copy RECID=24 STAMP=702046261 file name=+DISK01/aux/datafile/tbs1.285.702045999
datafile 7 switched to datafile copy
input datafile copy RECID=25 STAMP=702046261 file name=+DISK01/aux/datafile/tbs_fda.288.702046001
contents of Memory Script:
{
set until scn 3657467;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 04-NOV-09
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 1 is already on disk as file +DISK02/orcl/archivelog/2009_11_04/thread_1_seq_1.351.702037355
archived log for thread 1 with sequence 2 is already on disk as file +DISK02/orcl/archivelog/2009_11_04/thread_1_seq_2.350.702039149
archived log file name=+DISK02/orcl/archivelog/2009_11_04/thread_1_seq_1.351.702037355 thread=1 sequence=1
archived log file name=+DISK02/orcl/archivelog/2009_11_04/thread_1_seq_2.350.702039149 thread=1 sequence=2
media recovery complete, elapsed time: 00:00:33
Finished recover at 04-NOV-09
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set db_name =
''AUX'' 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 810053632 bytes
Fixed Size 2217712 bytes
Variable Size 469764368 bytes
Database Buffers 301989888 bytes
Redo Buffers 36081664 bytes
sql statement: alter system set db_name = ''AUX'' 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 810053632 bytes
Fixed Size 2217712 bytes
Variable Size 469764368 bytes
Database Buffers 301989888 bytes
Redo Buffers 36081664 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUX" RESETLOGS ARCHIVELOG
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 292
LOGFILE
GROUP 1 SIZE 50 M ,
GROUP 2 SIZE 50 M ,
GROUP 3 SIZE 50 M
DATAFILE
'+DISK01/aux/datafile/system.283.702045995'
CHARACTER SET TH8TISASCII
contents of Memory Script:
{
set newname for clone tempfile 1 to new;
switch clone tempfile all;
catalog clone datafilecopy "+DISK01/aux/datafile/sysaux.284.702045997",
"+DISK01/aux/datafile/undotbs1.287.702045999",
"+DISK01/aux/datafile/users.289.702046003",
"+DISK01/aux/datafile/example.286.702045999",
"+DISK01/aux/datafile/tbs1.285.702045999",
"+DISK01/aux/datafile/tbs_fda.288.702046001";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to +DISK01 in control file
cataloged datafile copy
datafile copy file name=+DISK01/aux/datafile/sysaux.284.702045997 RECID=1 STAMP=702046345
cataloged datafile copy
datafile copy file name=+DISK01/aux/datafile/undotbs1.287.702045999 RECID=2 STAMP=702046345
cataloged datafile copy
datafile copy file name=+DISK01/aux/datafile/users.289.702046003 RECID=3 STAMP=702046345
cataloged datafile copy
datafile copy file name=+DISK01/aux/datafile/example.286.702045999 RECID=4 STAMP=702046345
cataloged datafile copy
datafile copy file name=+DISK01/aux/datafile/tbs1.285.702045999 RECID=5 STAMP=702046345
cataloged datafile copy
datafile copy file name=+DISK01/aux/datafile/tbs_fda.288.702046001 RECID=6 STAMP=702046345
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=702046345 file name=+DISK01/aux/datafile/sysaux.284.702045997
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=702046345 file name=+DISK01/aux/datafile/undotbs1.287.702045999
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=702046345 file name=+DISK01/aux/datafile/users.289.702046003
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=702046345 file name=+DISK01/aux/datafile/example.286.702045999
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=702046345 file name=+DISK01/aux/datafile/tbs1.285.702045999
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=702046345 file name=+DISK01/aux/datafile/tbs_fda.288.702046001
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 04-NOV-09
SQL> select dbid, name from v$database;Fun ;) to duplicate database without connection to target database.
DBID NAME
---------- ---------
1555302662 AUX
4 comments:
Hi,
That’s a great info. Thanks for sharing, really like your view.
I can see that you are putting a lot of time and effort into your blog.
Keep posting the good work.
To Ashley,
Thank You. I'm just fun to post after I learned, tested and understood.
Just Sharing -)
Great post, I love reading your blogs!
Thank You
Post a Comment