Clone database from 11g physical standby
I found a great blog entry around cloning a database from an 11g physical standby. I decided to complete the steps myself. The method basically entails turning your physical standby into a snapshot standby database via dgmgrl (11g only).
For 11gR2, flashback logging is not a requirement. Otherwise, flashback logging being enabled is a requirement as converting physical standby into snapshot standby requires a guaranteed restore point to be created; this allows the snapshot standby to be converted back into physical standby.
Setting db_recovery_file_dest and db_recovery_file_dest_size are configured is the only caveat.
1. Startup clone instance with startup nomount.
SQL*Plus: Release 11.2.0.1.0 Production on Wed May 11 13:06:12 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 217157632 bytes
Fixed Size 2211928 bytes
Variable Size 159387560 bytes
Database Buffers 50331648 bytes
Redo Buffers 5226496 bytes
SQL>
For 11gR2, flashback logging is not a requirement. Otherwise, flashback logging being enabled is a requirement as converting physical standby into snapshot standby requires a guaranteed restore point to be created; this allows the snapshot standby to be converted back into physical standby.
Setting db_recovery_file_dest and db_recovery_file_dest_size are configured is the only caveat.
1. Startup clone instance with startup nomount.
SQL*Plus: Release 11.2.0.1.0 Production on Wed May 11 13:06:12 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 217157632 bytes
Fixed Size 2211928 bytes
Variable Size 159387560 bytes
Database Buffers 50331648 bytes
Redo Buffers 5226496 bytes
SQL>
2. Convert physical standby into snapshot standby.
DGMGRL> CONVERT DATABASE ctrlmstb TO SNAPSHOT STANDBY;
Converting database "ctrlmstb" to a Snapshot Standby database, please wait...
Database "ctrlmstb" converted successfully
DGMGRL>
3. Ensure that the listeners are configured and tns entries are added for both your clone and primary instances on both target and auxiliary servers.
4. Startup RMAN duplicate process.
Recovery Manager: Release 11.2.0.1.0 - Production on Wed May 11 13:22:04 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target *
2> connect auxiliary *
3> run {
4> allocate channel prm1 type disk;
5> allocate channel prm2 type disk;
6> allocate channel prm3 type disk;
7> allocate channel prm4 type disk;
8> allocate channel prm5 type disk;
9> allocate auxiliary channel stb1 type disk;
10> allocate auxiliary channel stb2 type disk;
11> allocate auxiliary channel stb3 type disk;
12> duplicate target database to "clone" from active database
15> spfile
16> PARAMETER_VALUE_CONVERT '/ctrlmstb/','/clone/'
17> set 'db_unique_name'='clone'
20> set 'control_files'='+DG02'
21> set db_create_file_dest='+DG02'
22> set db_create_online_log_dest_1='+DG02'
23> set db_recovery_file_dest='+FRA01'
24> set db_recovery_file_dest_size='15G'
25> set cluster_database='FALSE'
26> set instance_number='1'
27> nofilenamecheck;
28> }
29>
connected to target database: CTRLMPRD (DBID=2874717782)
connected to auxiliary database: CLONE (not mounted)
using target database control file instead of recovery catalog
allocated channel: prm1
channel prm1: SID=204 instance=ctrlmstb1 device type=DISK
allocated channel: prm2
channel prm2: SID=300 instance=ctrlmstb1 device type=DISK
allocated channel: prm3
channel prm3: SID=397 instance=ctrlmstb1 device type=DISK
allocated channel: prm4
channel prm4: SID=687 instance=ctrlmstb1 device type=DISK
allocated channel: prm5
channel prm5: SID=9 instance=ctrlmstb1 device type=DISK
allocated channel: stb1
channel stb1: SID=25 device type=DISK
allocated channel: stb2
channel stb2: SID=48 device type=DISK
allocated channel: stb3
channel stb3: SID=67 device type=DISK
Starting Duplicate Db at 11-MAY-2011
contents of Memory Script:
{
backup as copy reuse
targetfile '+DG01/ctrlmstb/parameterfile/spfile.11818.743352599' auxiliary format
'/orabase/product/11.2.0.1.0/db_1/dbs/spfileclone.ora' ;
sql clone "alter system set spfile= ''/orabase/product/11.2.0.1.0/db_1/dbs/spfileclone.ora''";
}
executing Memory Script
Starting backup at 11-MAY-2011
Finished backup at 11-MAY-2011
sql statement: alter system set spfile= ''/orabase/product/11.2.0.1.0/db_1/dbs/spfileclone.ora''
contents of Memory Script:
{
sql clone "alter system set db_name =
''CLONE'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''CLONE'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set audit_file_dest =
''/orabase/admin/clone/adump'' comment=
'''' scope=spfile";
sql clone "alter system set dg_broker_config_file1 =
''+DG01/clone/dr1ctrlmstb.dat'' comment=
'''' scope=spfile";
sql clone "alter system set dg_broker_config_file2 =
''+DG01/clone/dr2ctrlmstb.dat'' comment=
'''' scope=spfile";
sql clone "alter system set db_unique_name =
''clone'' comment=
'''' scope=spfile";
sql clone "alter system set db_file_name_convert =
''/ctrlmstb/'', ''/clone/'' comment=
'''' scope=spfile";
sql clone "alter system set log_file_name_convert =
''/ctrlmstb/'', ''/clone/'' comment=
'''' scope=spfile";
sql clone "alter system set control_files =
''+DG02'' comment=
'''' scope=spfile";
sql clone "alter system set db_create_file_dest =
''+DG02'' comment=
'''' scope=spfile";
sql clone "alter system set db_create_online_log_dest_1 =
''+DG02'' comment=
'''' scope=spfile";
sql clone "alter system set db_recovery_file_dest =
''+FRA01'' comment=
'''' scope=spfile";
sql clone "alter system set db_recovery_file_dest_size =
15G comment=
'''' scope=spfile";
sql clone "alter system set cluster_database =
FALSE comment=
'''' scope=spfile";
sql clone "alter system set instance_number =
1 comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set db_name = ''CLONE'' comment= ''duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''CLONE'' comment= ''duplicate'' scope=spfile
sql statement: alter system set audit_file_dest = ''/orabase/admin/clone/adump'' comment= '''' scope=spfile
sql statement: alter system set dg_broker_config_file1 = ''+DG01/clone/dr1ctrlmstb.dat'' comment= '''' scope=spfile
sql statement: alter system set dg_broker_config_file2 = ''+DG01/clone/dr2ctrlmstb.dat'' comment= '''' scope=spfile
sql statement: alter system set db_unique_name = ''clone'' comment= '''' scope=spfile
sql statement: alter system set db_file_name_convert = ''/ctrlmstb/'', ''/clone/'' comment= '''' scope=spfile
sql statement: alter system set log_file_name_convert = ''/ctrlmstb/'', ''/clone/'' comment= '''' scope=spfile
sql statement: alter system set control_files = ''+DG02'' comment= '''' scope=spfile
sql statement: alter system set db_create_file_dest = ''+DG02'' comment= '''' scope=spfile
sql statement: alter system set db_create_online_log_dest_1 = ''+DG02'' comment= '''' scope=spfile
sql statement: alter system set db_recovery_file_dest = ''+FRA01'' comment= '''' scope=spfile
sql statement: alter system set db_recovery_file_dest_size = 15G comment= '''' scope=spfile
sql statement: alter system set cluster_database = FALSE comment= '''' scope=spfile
sql statement: alter system set instance_number = 1 comment= '''' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1043886080 bytes
Fixed Size 2219952 bytes
Variable Size 608174160 bytes
Database Buffers 427819008 bytes
Redo Buffers 5672960 bytes
allocated channel: stb1
channel stb1: SID=684 device type=DISK
allocated channel: stb2
channel stb2: SID=4 device type=DISK
allocated channel: stb3
channel stb3: SID=100 device type=DISK
contents of Memory Script:
{
sql clone "alter system set control_files =
''+DG02/clone/controlfile/current.773.750864177'' comment=
''Set by RMAN'' scope=spfile";
sql clone "alter system set db_name =
''CTRLMPRD'' 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
backup as copy current controlfile auxiliary format '+DG02/clone/controlfile/current.774.750864177';
sql clone "alter system set control_files =
''+DG02/clone/controlfile/current.774.750864177'' comment=
''Set by RMAN'' scope=spfile";
shutdown clone immediate;
startup clone nomount;
alter clone database mount;
}
executing Memory Script
sql statement: alter system set control_files = ''+DG02/clone/controlfile/current.773.750864177'' comment= ''Set by RMAN'' scope=spfile
sql statement: alter system set db_name = ''CTRLMPRD'' 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 1043886080 bytes
Fixed Size 2219952 bytes
Variable Size 608174160 bytes
Database Buffers 427819008 bytes
Redo Buffers 5672960 bytes
allocated channel: stb1
channel stb1: SID=684 device type=DISK
allocated channel: stb2
channel stb2: SID=4 device type=DISK
allocated channel: stb3
channel stb3: SID=100 device type=DISK
Starting backup at 11-MAY-2011
channel prm1: starting datafile copy
copying current control file
output file name=/orabase/product/11.2.0.1.0/db_1/dbs/snapcf_ctrlmstb1.f tag=TAG20110511T132314 RECID=10 STAMP=750864195
channel prm1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 11-MAY-2011
sql statement: alter system set control_files = ''+DG02/clone/controlfile/current.774.750864177'' comment= ''Set by RMAN'' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1043886080 bytes
Fixed Size 2219952 bytes
Variable Size 608174160 bytes
Database Buffers 427819008 bytes
Redo Buffers 5672960 bytes
allocated channel: stb1
channel stb1: SID=684 device type=DISK
allocated channel: stb2
channel stb2: SID=4 device type=DISK
allocated channel: stb3
channel stb3: SID=100 device type=DISK
database mounted
RMAN-05529: WARNING: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.
contents of Memory Script:
{
set newname for datafile 1 to
"+dg01";
set newname for datafile 2 to
"+dg01";
set newname for datafile 3 to
"+dg01";
set newname for datafile 4 to
"+dg01";
set newname for datafile 5 to
"+dg01";
set newname for datafile 6 to
"+dg01";
set newname for datafile 7 to
"+dg01";
backup as copy reuse
datafile 1 auxiliary format
"+dg01" datafile
2 auxiliary format
"+dg01" datafile
3 auxiliary format
"+dg01" datafile
4 auxiliary format
"+dg01" datafile
5 auxiliary format
"+dg01" datafile
6 auxiliary format
"+dg01" datafile
7 auxiliary format
"+dg01" ;
sql 'alter system archive log current';
}
executing Memory Script
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 backup at 11-MAY-2011
channel prm1: starting datafile copy
input datafile file number=00002 name=+DG01/ctrlmstb/datafile/sysaux.6362.743340889
channel prm2: starting datafile copy
input datafile file number=00001 name=+DG01/ctrlmstb/datafile/system.21147.743340889
channel prm3: starting datafile copy
input datafile file number=00003 name=+DG01/ctrlmstb/datafile/undotbs1.8949.743340889
channel prm4: starting datafile copy
input datafile file number=00004 name=+DG01/ctrlmstb/datafile/undotbs2.10045.743340889
channel prm5: starting datafile copy
input datafile file number=00006 name=+DG01/ctrlmstb/datafile/svc_em.11949.743340889
output file name=+DG01/clone/datafile/svc_em.4307.750864223 tag=TAG20110511T132341
channel prm5: datafile copy complete, elapsed time: 00:00:07
channel prm5: starting datafile copy
input datafile file number=00007 name=+DG01/ctrlmstb/datafile/svc_ctm.11739.743340925
output file name=+DG01/clone/datafile/undotbs1.11570.750864223 tag=TAG20110511T132341
channel prm3: datafile copy complete, elapsed time: 00:00:14
channel prm3: starting datafile copy
input datafile file number=00005 name=+DG01/ctrlmstb/datafile/users.15292.743340961
output file name=+DG01/clone/datafile/undotbs2.23201.750864223 tag=TAG20110511T132341
channel prm4: datafile copy complete, elapsed time: 00:00:15
output file name=+DG01/clone/datafile/svc_ctm.19499.750864231 tag=TAG20110511T132341
channel prm5: datafile copy complete, elapsed time: 00:00:08
output file name=+DG01/clone/datafile/system.15604.750864223 tag=TAG20110511T132341
channel prm2: datafile copy complete, elapsed time: 00:00:19
output file name=+DG01/clone/datafile/users.16097.750864239 tag=TAG20110511T132341
channel prm3: datafile copy complete, elapsed time: 00:00:04
output file name=+DG01/clone/datafile/sysaux.10917.750864223 tag=TAG20110511T132341
channel prm1: datafile copy complete, elapsed time: 00:00:23
Finished backup at 11-MAY-2011
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like "+FRA01/ctrlmstb/archivelog/2011_05_11/thread_1_seq_1.3640.750864247" auxiliary format
"+FRA01" archivelog like
"+FRA01/ctrlmstb/archivelog/2011_05_11/thread_2_seq_2.2449.750864247" auxiliary format
"+FRA01" ;
catalog clone recovery area;
switch clone datafile all;
}
executing Memory Script
Starting backup at 11-MAY-2011
channel prm1: starting archived log copy
input archived log thread=1 sequence=1 RECID=20873 STAMP=750864246
channel prm2: starting archived log copy
input archived log thread=2 sequence=2 RECID=20874 STAMP=750864247
output file name=+FRA01/clone/archivelog/2011_05_11/thread_1_seq_1.8416.750864271 RECID=0 STAMP=0
channel prm1: archived log copy complete, elapsed time: 00:00:01
output file name=+FRA01/clone/archivelog/2011_05_11/thread_2_seq_2.7023.750864271 RECID=0 STAMP=0
channel prm2: archived log copy complete, elapsed time: 00:00:01
Finished backup at 11-MAY-2011
searching for all files in the recovery area
List of Files Unknown to the Database
=====================================
File Name: +fra01/CLONE/ARCHIVELOG/2011_05_11/thread_1_seq_1.8416.750864271
File Name: +fra01/CLONE/ARCHIVELOG/2011_05_11/thread_2_seq_2.7023.750864271
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: +fra01/CLONE/ARCHIVELOG/2011_05_11/thread_1_seq_1.8416.750864271
File Name: +fra01/CLONE/ARCHIVELOG/2011_05_11/thread_2_seq_2.7023.750864271
datafile 1 switched to datafile copy
input datafile copy RECID=10 STAMP=750864272 file name=+DG01/clone/datafile/system.15604.750864223
datafile 2 switched to datafile copy
input datafile copy RECID=11 STAMP=750864273 file name=+DG01/clone/datafile/sysaux.10917.750864223
datafile 3 switched to datafile copy
input datafile copy RECID=12 STAMP=750864273 file name=+DG01/clone/datafile/undotbs1.11570.750864223
datafile 4 switched to datafile copy
input datafile copy RECID=13 STAMP=750864273 file name=+DG01/clone/datafile/undotbs2.23201.750864223
datafile 5 switched to datafile copy
input datafile copy RECID=14 STAMP=750864273 file name=+DG01/clone/datafile/users.16097.750864239
datafile 6 switched to datafile copy
input datafile copy RECID=15 STAMP=750864273 file name=+DG01/clone/datafile/svc_em.4307.750864223
datafile 7 switched to datafile copy
input datafile copy RECID=16 STAMP=750864273 file name=+DG01/clone/datafile/svc_ctm.19499.750864231
contents of Memory Script:
{
set until scn 321940177773;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 11-MAY-2011
starting media recovery
archived log for thread 1 with sequence 1 is already on disk as file +FRA01/clone/archivelog/2011_05_11/thread_1_seq_1.8416.750864271
archived log for thread 2 with sequence 2 is already on disk as file +FRA01/clone/archivelog/2011_05_11/thread_2_seq_2.7023.750864271
archived log file name=+FRA01/clone/archivelog/2011_05_11/thread_1_seq_1.8416.750864271 thread=1 sequence=1
archived log file name=+FRA01/clone/archivelog/2011_05_11/thread_2_seq_2.7023.750864271 thread=2 sequence=2
media recovery complete, elapsed time: 00:00:01
Finished recover at 11-MAY-2011
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 1043886080 bytes
Fixed Size 2219952 bytes
Variable Size 637534288 bytes
Database Buffers 398458880 bytes
Redo Buffers 5672960 bytes
allocated channel: stb1
channel stb1: SID=684 device type=DISK
allocated channel: stb2
channel stb2: SID=4 device type=DISK
allocated channel: stb3
channel stb3: SID=100 device type=DISK
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 1043886080 bytes
Fixed Size 2219952 bytes
Variable Size 637534288 bytes
Database Buffers 398458880 bytes
Redo Buffers 5672960 bytes
allocated channel: stb1
channel stb1: SID=683 device type=DISK
allocated channel: stb2
channel stb2: SID=4 device type=DISK
allocated channel: stb3
channel stb3: SID=100 device type=DISK
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONE" RESETLOGS ARCHIVELOG
MAXLOGFILES 480
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 80
MAXLOGHISTORY 2336
LOGFILE
GROUP 1 ( '+dg01' ) SIZE 128 M REUSE,
GROUP 2 ( '+dg01' ) SIZE 128 M REUSE
DATAFILE
'+DG01/clone/datafile/system.15604.750864223'
CHARACTER SET AL32UTF8
sql statement: ALTER DATABASE ADD LOGFILE
INSTANCE 'i2'
GROUP 3 ( '+dg01' ) SIZE 128 M REUSE,
GROUP 4 ( '+dg01' ) SIZE 128 M REUSE
contents of Memory Script:
{
set newname for tempfile 1 to
"+dg01";
switch clone tempfile all;
catalog clone datafilecopy "+DG01/clone/datafile/sysaux.10917.750864223",
"+DG01/clone/datafile/undotbs1.11570.750864223",
"+DG01/clone/datafile/undotbs2.23201.750864223",
"+DG01/clone/datafile/users.16097.750864239",
"+DG01/clone/datafile/svc_em.4307.750864223",
"+DG01/clone/datafile/svc_ctm.19499.750864231";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to +dg01 in control file
cataloged datafile copy
datafile copy file name=+DG01/clone/datafile/sysaux.10917.750864223 RECID=1 STAMP=750864321
cataloged datafile copy
datafile copy file name=+DG01/clone/datafile/undotbs1.11570.750864223 RECID=2 STAMP=750864321
cataloged datafile copy
datafile copy file name=+DG01/clone/datafile/undotbs2.23201.750864223 RECID=3 STAMP=750864321
cataloged datafile copy
datafile copy file name=+DG01/clone/datafile/users.16097.750864239 RECID=4 STAMP=750864321
cataloged datafile copy
datafile copy file name=+DG01/clone/datafile/svc_em.4307.750864223 RECID=5 STAMP=750864321
cataloged datafile copy
datafile copy file name=+DG01/clone/datafile/svc_ctm.19499.750864231 RECID=6 STAMP=750864321
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=750864321 file name=+DG01/clone/datafile/sysaux.10917.750864223
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=750864321 file name=+DG01/clone/datafile/undotbs1.11570.750864223
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=750864321 file name=+DG01/clone/datafile/undotbs2.23201.750864223
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=750864321 file name=+DG01/clone/datafile/users.16097.750864239
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=750864321 file name=+DG01/clone/datafile/svc_e
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=750864321 file name=+DG01/clone/datafile/svc_c
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 11-MAY-2011
released channel: prm1
released channel: prm2
released channel: prm3
released channel: prm4
released channel: prm5
released channel: stb1
released channel: stb2
released channel: stb3
RMAN-08591: WARNING: invalid archived log deletion policy
Recovery Manager complete.
5. Convert snapshot standby back to physical standby.
DGMGRL> CONVERT DATABASE ctrlmstb TO PHYSICAL STANDBY;
Converting database "ctrlmstb" to a Physical Standby database, please wait...
Operation requires shutdown of instance "ctrlmstb1" on database "ctrlmstb"
Shutting down instance "ctrlmstb1"...
Database closed.
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "ctrlmstb1" on database "ctrlmstb"
Starting instance "ctrlmstb1"...
ORACLE instance started.
Database mounted.
Database "ctrlmstb" converted successfully.
6. Clone instance should be now open read/write.
SQL*Plus: Release 11.2.0.1.0 Production on Wed May 11 13:38:55 2011
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, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
clone
Comments
thanks for your post ...........today i did by using your website.......
Thanks
Hector C form Mexico