Sie sind auf Seite 1von 11

HOW TO DUPLICATE A 11gR2 INSTANCE USING

RMAN AND ACTIVE DATABASE


Platform:
Oracle Version:
Source server:
Target server:

Windows/Linux
11.2.0.2.0
ap2-ora01.ap2.ap2.se
rs-ora01.ap2.ap2.se

I start with a standard database created by dbca, i called the db MJ and I will create a copy
on another server named VJ.
We start on the server where the copy (VJ) should go:
Create tns alias for both instances MJ and VJ, in 11g you cannot use connect / anymore.
You have to connect both to target and auxiliary using a tns alias. Im using net configuration
assistant to create mine. When they are created edit the tnsnames.ora file and add (UR=A)
for the VJ entry
So it looks like this.
VJ =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = rs-ora01.ap2.ap2.se)(PORT = 1521))
)
(CONNECT_DATA =
(UR=A)
(SERVICE_NAME = VJ)
)
)
You can use tnsping to verify the names
E:\app\oracle\product\11.2.0\dbhome_1\database>tnsping mj
TNS Ping Utility for 64-bit Windows: Version 11.2.0.2.0 - Production on 05-JAN-2011 14:05:25
Copyright (c) 1997, 2010, Oracle. All rights reserved.
Used parameter files:
E:\app\oracle\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ap2ora01.ap2.ap2.se)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = MJ)))
OK (0 msec)
E:\app\oracle\product\11.2.0\dbhome_1\database>tnsping vj
TNS Ping Utility for 64-bit Windows: Version 11.2.0.2.0 - Production on 05-JAN-2011 14:05:30
Copyright (c) 1997, 2010, Oracle. All rights reserved.
Used parameter files:
E:\app\oracle\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rsora01.ap2.ap2.se)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = VJ)))
OK (0 msec)

Now we should create a static entry in the listener for instance VJ, use net manager to do
that. You can do both the tns alias and static entry by manually edit the tnsnames.ora and
listener.ora file. Be careful if you do that, it can easily become an invalid entry.
I recommend using the tools.

After you have saved and exit net manager you have to reload the listener to register the
instanses.
Lsnrctl reload, verify it by issue lsnrctl status
C:\Windows\system32>lsnrctl reload
LSNRCTL for 64-bit Windows: Version 11.2.0.2.0 - Production on 07-JAN-2011 15:20:23
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=RS-ORA01.ap2.ap2.se)(PORT=1521)))
The command completed successfully
C:\Windows\system32>lsnrctl status
LSNRCTL for 64-bit Windows: Version 11.2.0.2.0 - Production on 07-JAN-2011 15:20:27
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=RS-ORA01.ap2.ap2.se)(PORT=1521)))
STATUS of the LISTENER
-----------------------Alias
LISTENER
Version
TNSLSNR for 64-bit Windows: Version 11.2.0.2.0 - Production

Start Date
07-JAN-2011 13:27:28
Uptime
0 days 1 hr. 53 min. 2 sec
Trace Level
off
Security
ON: Local OS Authentication
SNMP
OFF
Listener Parameter File E:\app\oracle\product\11.2.0\dbhome_1\network\admin\listener.ora
Listener Log File
e:\app\oracle\diag\tnslsnr\RS-ORA01\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=RS-ORA01.ap2.ap2.se)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "VJ" has 1 instance(s).
Instance "VJ", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

create a init.ora file, name = initvj.ora


it has one row only:
db_name=vj
Copy the password file PWDMJ.ora from the source db and rename it to PWDVJ.ora.
You should be able to create a new password file using orapwd and using the same
password creating the MJ instance. I had issues with ORA-01017, invalid password which
was solved when copying the file from the source server. If you are on linux and wants to
create a password file run:
Orapwd filename=orapw<sid> password=kalle
If you are on windows the password file is created when creating the service

This step is only needed if you run on Windows:


Create a service using oradim, some examples have -intpwd this creates the passwordfile
since we copy ours I omit -intpwd
oradim -new -sid VJ [-intpwd kalle] -startmode AUTO
Confirm that your service exists

Now lets move to the source server


If you perform all the duplicate actions from the target server you can omit these
steps.
Create tns alias for both instances MJ and VJ. Im uisng net configuration assistant to create
mine. When they are created edit the tnsnames.ora file and add (UR=A) for the VJ entry
so it looks like this.
VJ =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = rs-ora01.ap2.ap2.se)(PORT = 1521))
)
(CONNECT_DATA =
(UR=A)
(SERVICE_NAME = VJ)
)
)
You can use tnsping to verify the names
C:\Windows\system32>tnsping mj
TNS Ping Utility for 64-bit Windows: Version 11.2.0.2.0 - Production on 05-JAN-2011 14:19:42
Copyright (c) 1997, 2010, Oracle. All rights reserved.
Used parameter files:
E:\app\oracle\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ap2ora01.ap2.ap2.se)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = MJ)))
OK (10 msec)
C:\Windows\system32>tnsping vj
TNS Ping Utility for 64-bit Windows: Version 11.2.0.2.0 - Production on 05-JAN-2011 14:19:49
Copyright (c) 1997, 2010, Oracle. All rights reserved.
Used parameter files:
E:\app\oracle\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rsora01.ap2.ap2.se)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = VJ)))
OK (0 msec)

Now lets start the duplicate


Go to the target server and start RMAN and connect to both instances, make sure you use
the alias you created before.
You are not allowed to connect using / as in previous releases.
If you do that the duplicate will fail!!!!
I tested to run the duplicate script from the source server, it ended up with a crash. I tested
again and ran it from the target server and it worked. You should be able to run it from any
server but if you have issues, try to run it from the target server and see if it works.
C:\Windows\system32>rman target sys@mj
Recovery Manager: Release 11.2.0.2.0 - Production on Wed Jan 5 14:36:27 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
target database Password:
connected to target database: MJ (DBID=3394831997)
RMAN> connect auxiliary sys@vj
auxiliary database Password:
connected to auxiliary database: VJ (not mounted)
RMAN>
Now we launch the duplicate script, here is the listing from the whole process.
RMAN> duplicate target database
2> to VJ
3> from active database
4> spfile
5> parameter_value_convert ='MJ','VJ'
6> set log_file_name_convert ='MJ','VJ'
7> db_file_name_convert ='MJ','VJ';
Starting Duplicate Db at 07-JAN-11
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=169 device type=DISK
contents of Memory Script:
{
backup as copy reuse
targetfile 'E:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\SPFILEMJ.ORA' auxiliary format
'E:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\SPFILEVJ.ORA' ;
sql clone "alter system set spfile= ''E:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\SPFILEVJ.ORA''";
}
executing Memory Script
Starting backup at 07-JAN-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
Finished backup at 07-JAN-11
sql statement: alter system set spfile= ''E:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\SPFILEVJ.ORA''
contents of Memory Script:
{
sql clone "alter system set db_name =
''VJ'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set audit_file_dest =
''e:\app\oracle\admin\VJ\adump'' comment=
'''' scope=spfile";
sql clone "alter system set control_files =
''F:\oradata\VJ\control01.ctl'', ''G:\flash_recovery_area\VJ\control02.ctl'' comment=
'''' scope=spfile";

sql clone "alter system set dispatchers =


''(PROTOCOL=TCP) (SERVICE=VJXDB)'' comment=
'''' scope=spfile";
sql clone "alter system set log_file_name_convert =
''MJ'', ''VJ'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set db_name = ''VJ'' comment= ''duplicate'' scope=spfile
sql statement: alter system set audit_file_dest = ''e:\app\oracle\admin\VJ\adump'' comment= '''' scope=spfile
sql statement: alter system set control_files = ''F:\oradata\VJ\control01.ctl'', ''G:\flash_recovery_area\VJ\control02.ctl''
comment= '''' scope=spfile
sql statement: alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=VJXDB)'' comment= '''' scope=spfile
sql statement: alter system set log_file_name_convert = ''MJ'', ''VJ'' comment= '''' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers

3991842816 bytes

2259344 bytes
2147485296 bytes
1828716544 bytes
13381632 bytes

contents of Memory Script:


{
sql clone "alter system set db_name =
''MJ'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''VJ'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
backup as copy current controlfile auxiliary format 'F:\ORADATA\VJ\CONTROL01.CTL';
restore clone controlfile to 'G:\FLASH_RECOVERY_AREA\VJ\CONTROL02.CTL' from
'F:\ORADATA\VJ\CONTROL01.CTL';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''MJ'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''VJ'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers

3991842816 bytes

2259344 bytes
2147485296 bytes
1828716544 bytes
13381632 bytes

Starting backup at 07-JAN-11


using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=E:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\SNCFMJ.ORA tag=TAG20110107T150018
RECID=3 STAMP=739810819
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 07-JAN-11
Starting restore at 07-JAN-11

allocated channel: ORA_AUX_DISK_1


channel ORA_AUX_DISK_1: SID=254 device type=DISK
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 07-JAN-11
database mounted
contents of Memory Script:
{
set newname for datafile 1 to
"F:\ORADATA\VJ\SYSTEM01.DBF";
set newname for datafile 2 to
"F:\ORADATA\VJ\SYSAUX01.DBF";
set newname for datafile 3 to
"F:\ORADATA\VJ\UNDOTBS01.DBF";
set newname for datafile 4 to
"F:\ORADATA\VJ\USERS01.DBF";
set newname for datafile 5 to
"F:\ORADATA\VJ\EXAMPLE01.DBF";
backup as copy reuse
datafile 1 auxiliary format
"F:\ORADATA\VJ\SYSTEM01.DBF" datafile
2 auxiliary format
"F:\ORADATA\VJ\SYSAUX01.DBF" datafile
3 auxiliary format
"F:\ORADATA\VJ\UNDOTBS01.DBF" datafile
4 auxiliary format
"F:\ORADATA\VJ\USERS01.DBF" datafile
5 auxiliary format
"F:\ORADATA\VJ\EXAMPLE01.DBF" ;
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
Starting backup at 07-JAN-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=F:\ORADATA\MJ\SYSTEM01.DBF
output file name=F:\ORADATA\VJ\SYSTEM01.DBF tag=TAG20110107T150031
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=F:\ORADATA\MJ\SYSAUX01.DBF
output file name=F:\ORADATA\VJ\SYSAUX01.DBF tag=TAG20110107T150031
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=F:\ORADATA\MJ\EXAMPLE01.DBF
output file name=F:\ORADATA\VJ\EXAMPLE01.DBF tag=TAG20110107T150031
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=F:\ORADATA\MJ\UNDOTBS01.DBF
output file name=F:\ORADATA\VJ\UNDOTBS01.DBF tag=TAG20110107T150031
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=F:\ORADATA\MJ\USERS01.DBF
output file name=F:\ORADATA\VJ\USERS01.DBF tag=TAG20110107T150031
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 07-JAN-11
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like "G:\FLASH_RECOVERY_AREA\MJ\ARCHIVELOG\2011_01_07\O1_MF_1_10_6LG75CXD_.ARC" auxiliary
format

"G:\FLASH_RECOVERY_AREA\VJ\ARCHIVELOG\2011_01_07\O1_MF_1_10_%U_.ARC" ;
catalog clone recovery area;
switch clone datafile all;
}
executing Memory Script
Starting backup at 07-JAN-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=10 RECID=7 STAMP=739810877
output file name=G:\FLASH_RECOVERY_AREA\VJ\ARCHIVELOG\2011_01_07\O1_MF_1_10_ARCH_D-MJ_ID3394831997_S-10_T-1_A-739633790_08M1H7HT_.ARC RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 07-JAN-11
searching for all files in the recovery area
List of Files Unknown to the Database
=====================================
File Name: G:\FLASH_RECOVERY_AREA\VJ\ARCHIVELOG\2011_01_07\O1_MF_1_10_ARCH_D-MJ_ID-3394831997_S10_T-1_A-739633790_08M1H7HT_.ARC
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: G:\FLASH_RECOVERY_AREA\VJ\ARCHIVELOG\2011_01_07\O1_MF_1_10_ARCH_D-MJ_ID-3394831997_S10_T-1_A-739633790_08M1H7HT_.ARC
List of files in Recovery Area not managed by the database
==========================================================
File Name: G:\FLASH_RECOVERY_AREA\VJ\CONTROL02.CTL
RMAN-07526: Reason: File is not an Oracle Managed File
number of files not managed by recovery area is 1, totaling 9.28MB
datafile 1 switched to datafile copy
input datafile copy RECID=3 STAMP=739810880 file name=F:\ORADATA\VJ\SYSTEM01.DBF
datafile 2 switched to datafile copy
input datafile copy RECID=4 STAMP=739810881 file name=F:\ORADATA\VJ\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=739810881 file name=F:\ORADATA\VJ\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=6 STAMP=739810882 file name=F:\ORADATA\VJ\USERS01.DBF
datafile 5 switched to datafile copy
input datafile copy RECID=7 STAMP=739810883 file name=F:\ORADATA\VJ\EXAMPLE01.DBF
contents of Memory Script:
{
set until scn 1165400;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 07-JAN-11
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 10 is already on disk as file
G:\FLASH_RECOVERY_AREA\VJ\ARCHIVELOG\2011_01_07\O1_MF_1_10_ARCH_D-MJ_ID-3394831997_S-10_T1_A-739633790_08M1H7HT_.ARC
archived log file name=G:\FLASH_RECOVERY_AREA\VJ\ARCHIVELOG\2011_01_07\O1_MF_1_10_ARCH_D-MJ_ID3394831997_S-10_T-1_A-739633790_08M1H7HT_.ARC thread=1 sequence=1
0
media recovery complete, elapsed time: 00:00:02
Finished recover at 07-JAN-11
Oracle instance started
Total System Global Area

3991842816 bytes

Fixed Size
Variable Size
Database Buffers
Redo Buffers

2259344 bytes
2147485296 bytes
1828716544 bytes
13381632 bytes

contents of Memory Script:


{
sql clone "alter system set db_name =
''VJ'' 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
sql statement: alter system set db_name = ''VJ'' 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

3991842816 bytes

Fixed Size
2259344 bytes
Variable Size
2147485296 bytes
Database Buffers
1828716544 bytes
Redo Buffers
13381632 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "VJ" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS
3
MAXDATAFILES
100
MAXINSTANCES 8
MAXLOGHISTORY
292
LOGFILE
GROUP 1 ( 'F:\ORADATA\VJ\REDO01.LOG' ) SIZE 50 M REUSE,
GROUP 2 ( 'F:\ORADATA\VJ\REDO02.LOG' ) SIZE 50 M REUSE,
GROUP 3 ( 'F:\ORADATA\VJ\REDO03.LOG' ) SIZE 50 M REUSE
DATAFILE
'F:\ORADATA\VJ\SYSTEM01.DBF'
CHARACTER SET WE8MSWIN1252
contents of Memory Script:
{
set newname for tempfile 1 to
"F:\ORADATA\VJ\TEMP01.DBF";
switch clone tempfile all;
catalog clone datafilecopy "F:\ORADATA\VJ\SYSAUX01.DBF",
"F:\ORADATA\VJ\UNDOTBS01.DBF",
"F:\ORADATA\VJ\USERS01.DBF",
"F:\ORADATA\VJ\EXAMPLE01.DBF";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to F:\ORADATA\VJ\TEMP01.DBF in control file
cataloged datafile copy
datafile copy file name=F:\ORADATA\VJ\SYSAUX01.DBF RECID=1 STAMP=739810946
cataloged datafile copy
datafile copy file name=F:\ORADATA\VJ\UNDOTBS01.DBF RECID=2 STAMP=739810946
cataloged datafile copy
datafile copy file name=F:\ORADATA\VJ\USERS01.DBF RECID=3 STAMP=739810947
cataloged datafile copy
datafile copy file name=F:\ORADATA\VJ\EXAMPLE01.DBF RECID=4 STAMP=739810947
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=739810946 file name=F:\ORADATA\VJ\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=739810946 file name=F:\ORADATA\VJ\UNDOTBS01.DBF

datafile 4 switched to datafile copy


input datafile copy RECID=3 STAMP=739810947 file name=F:\ORADATA\VJ\USERS01.DBF
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=739810947 file name=F:\ORADATA\VJ\EXAMPLE01.DBF
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 07-JAN-11
RMAN>

NOTE:
I experienced ORA-12514 when I ran the duplicate script. This was seen because the
instance VJ was not statically registered with the listener on the target server. Use lsnrctl
status to verify that the instance is listed even if it is down.
If you analyze the output from the duplicate you will find
RMAN-07526: Reason: File is not an Oracle Managed File

It seems to be known why we see it, google the errorcode or look into oracle support.
It isnt an issue with the clone.

Das könnte Ihnen auch gefallen