0% found this document useful (0 votes)
193 views

Duplicate Oracle Duplicate Oracle Database With RMANDatabase With RMAN

A duplicate database is distinct from a standby database, although both types of databases are created with the DUPLICATE command. A standby database is a copy of the primary database that you can update continually or periodically by using archived logs from the primary database. If the primary database is damaged or destroyed, then you can perform failover to the standby database and effectively transform it into the new primary database. A duplicate database, on the other hand, cannot be used in this way: it is not intended for failover scenarios and does not support the various standby recovery and failover options.

Uploaded by

Cesar Eduardo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
193 views

Duplicate Oracle Duplicate Oracle Database With RMANDatabase With RMAN

A duplicate database is distinct from a standby database, although both types of databases are created with the DUPLICATE command. A standby database is a copy of the primary database that you can update continually or periodically by using archived logs from the primary database. If the primary database is damaged or destroyed, then you can perform failover to the standby database and effectively transform it into the new primary database. A duplicate database, on the other hand, cannot be used in this way: it is not intended for failover scenarios and does not support the various standby recovery and failover options.

Uploaded by

Cesar Eduardo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

DuplicateOracleDatabasewithRMAN

MartinZahn,30.10.2008
Detailssee:OracleDatabaseBackupandRecoveryAdvancedUser'sGuide10gRelease2(10.2)

Overview
ApowerfulfeatureofRMANistheabilitytoduplicate(clone),adatabasefromabackup.Itispossibleto
createaduplicatedatabaseon:
Aremoteserverwiththesamefilestructure
Aremoteserverwithadifferentfilestructure
Thelocalserverwithadifferentfilestructure
Aduplicatedatabaseisdistinctfromastandbydatabase,althoughbothtypesof
databasesarecreatedwiththeDUPLICATEcommand.Astandbydatabaseisacopy
oftheprimarydatabasethatyoucanupdatecontinuallyorperiodicallybyusing
archivedlogsfromtheprimarydatabase.Iftheprimarydatabaseisdamagedor
destroyed,thenyoucanperformfailovertothestandbydatabaseandeffectively
transformitintothenewprimarydatabase.Aduplicatedatabase,ontheotherhand,
cannotbeusedinthisway:itisnotintendedforfailoverscenariosanddoesnot
supportthevariousstandbyrecoveryandfailoveroptions.
Topreparefordatabaseduplication,youmustfirstcreateanauxiliaryinstance.Fortheduplicationtowork,
youmustconnectRMANtoboththetarget(primary)databaseandanauxiliaryinstancestartedinNOMOUNT
mode.
SolongasRMANisabletoconnecttotheprimaryandduplicateinstances,theRMANclientcanrunonany
machine.However,allbackups,copiesofdatafiles,andarchivedlogsusedforcreatingandrecoveringthe
duplicatedatabasemustbeaccessiblebytheserversessionontheduplicatehost.
Aspartoftheduplicatingoperation,RMANmanagesthefollowing:
Restoresthetargetdatafilestotheduplicatedatabaseandperformsincompleterecoverybyusingall
availablebackupsandarchivedlogs.

Shutsdownandstartstheauxiliarydatabase.

OpenstheduplicatedatabasewiththeRESETLOGSoptionafterincompleterecoverytocreatethe
onlineredologs.

Generatesanew,uniqueDBIDfortheduplicatedatabase.

PreparingtheDuplicate(Auxiliary)InstanceforDuplication
CreateanOraclePasswordFile
Firstwemustcreateapasswordfilefortheduplicateinstance.
exportORACLE_SID=APP2
orapwdfile=orapwAPP2password=managerentries=5force=y

EnsureOracleNetConnectivitytobothInstances
NextaddtheappropriateentriesintotheTNSNAMES.ORAandLISTENER.ORAfilesinthe$TNS_ADMIN
directory.
LISTENER.ORA
APP1=TargetDatabase,APP2=AuxiliaryDatabase
LISTENER=
(DESCRIPTION_LIST=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=gentic)(PORT=1521))
)

)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=APP1.WORLD)
(ORACLE_HOME=/opt/oracle/product/10.2.0)
(SID_NAME=APP1)
)
(SID_DESC=
(GLOBAL_DBNAME=APP2.WORLD)
(ORACLE_HOME=/opt/oracle/product/10.2.0)
(SID_NAME=APP2)
)
)
TNSNAMES.ORA
APP1=TargetDatabase,APP2=AuxiliaryDatabase
APP1.WORLD=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=gentic)(PORT=1521))
)
(CONNECT_DATA=
(SERVICE_NAME=APP1.WORLD)
)
)
APP2.WORLD=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=gentic)(PORT=1521))
)
(CONNECT_DATA=
(SERVICE_NAME=APP2.WORLD)
)
)
SQLNET.ORA
NAMES.DIRECTORY_PATH=(TNSNAMES)
NAMES.DEFAULT_DOMAIN=WORLD
NAME.DEFAULT_ZONE=WORLD
USE_DEDICATED_SERVER=ON
NowrestarttheListener
lsnrctlstop
lsnrctlstart

CreateanInitializationParameterFilefortheAuxiliaryInstance
CreateanINIT.ORAparameterfilefortheauxiliaryinstance,youcancopythatfromthetargetinstanceand
thenmodifytheparameters.
###DuplicateDatabase
###
#Thisisonlyusedwhenyouduplicatethedatabase
#onthesamehosttoavoidnameconflicts
DB_FILE_NAME_CONVERT=(/u01/oracle/db/APP1/,/u01/oracle/db/APP2/)
LOG_FILE_NAME_CONVERT=(/u01/oracle/db/APP1/,/u01/oracle/db/APP2/,
/opt/oracle/db/APP1/,/opt/oracle/db/APP2/)
###Globaldatabasenameisdb_name.db_domain
###
db_name=APP2

db_unique_name=APP2_GENTIC
db_domain=WORLD
service_names=APP2
instance_name=APP2
###BasicConfigurationParameters
###
compatible=10.2.0.4
db_block_size=8192
db_file_multiblock_read_count=32
db_files=512
control_files=/u01/oracle/db/APP2/con/APP2_con01.con,
/opt/oracle/db/APP2/con/APP2_con02.con
###DatabaseBufferCache,I/O
###
#TheParameterSGA_TARGETenablesAutomaticSharedMemoryManagement
sga_target=500M
sga_max_size=600M
###REDOLoggingwithoutDataGuard
###
log_archive_format=APP2_%s_%t_%r.arc
log_archive_max_processes=2
log_archive_dest=/u01/oracle/db/APP2/arc
###SystemManagedUndo
###
undo_management=auto
undo_retention=10800
undo_tablespace=undo
###Traces,DumpsandPasswordfile
###
audit_file_dest=/u01/oracle/db/APP2/adm/admp
user_dump_dest=/u01/oracle/db/APP2/adm/udmp
background_dump_dest=/u01/oracle/db/APP2/adm/bdmp
core_dump_dest=/u01/oracle/db/APP2/adm/cdmp
utl_file_dir=/u01/oracle/db/APP2/adm/utld
remote_login_passwordfile=exclusive

CreateafullDatabaseBackup
Makesurethatafullbackupofthetargetisaccessibleontheduplicatehost.YoucanusethefollowingBASH
scripttobackupthetargetdatabase.
rmannocatalogtarget/<<EOF
configureretentionpolicytorecoverywindowof3days
configurebackupoptimizationon
configurecontrolfileautobackupon
configuredefaultdevicetypetodisk
configuredevicetypediskparallelism1backuptypetocompressedbackupset
configuredatafilebackupcopiesfordevicetypediskto1
configuremaxsetsizetounlimited
configuresnapshotcontrolfilenameto'/u01/backup/snapshot_controlfile'
showall
run{
allocatechannelch1typeDiskmaxpiecesize=1900M
backupfulldatabasenoexclude
includecurrentcontrolfile
format'/u01/backup/datafile_%s_%p.bak'
tag'datafile_daily'
}

run{
allocatechannelch1typeDiskmaxpiecesize=1900M
backuparchivelogall
deleteallinput
format'/u01/backup/archivelog_%s_%p.bak'
tag'archivelog_daily'
}
run{
allocatechannelch1typeDiskmaxpiecesize=1900M
backupformat'/u01/backup/controlfile_%s.bak'currentcontrolfile
}
crosscheckbackup
listbackupofdatabase
reportunrecoverable
reportschema
reportneedbackup
reportobsolete
deletenopromptexpiredbackupofdatabase
deletenopromptexpiredbackupofcontrolfile
deletenopromptexpiredbackupofarchivelogall
deletenopromptobsoleterecoverywindowof3days
quit
EOF

CreatingaDuplicateDatabaseontheLocalHost
BeforebeginningRMANduplication,useSQL*Plustoconnecttotheauxiliaryinstanceandstartitin
NOMOUNTmode.Ifyoudonothaveaserversideinitializationparameterfilefortheauxiliaryinstancein
thedefaultlocation,thenyoumustspecifytheclientsideinitializationparameterfilewiththePFILE
parameterontheDUPLICATEcommand.

GetoriginalFilenamesfromTARGET
TorenamethedatabasefilesyoucanusetheSETNEWNAMEcommand.Therefore,gettheoriginal
filenamesfromthetargetandmodifythesenamesintheDUPLICATEcommand.
ORACLE_SID=APP1
exportORACLE_SID
setfeedoff
setpagesize10000
columnnameformata40heading"Datafile"
columnfile#format99heading"FileID"
selectname,file#fromv$dbfile
columnmemberformata40heading"Logfile"
columngroup#format99heading"GroupNr"
selectmember,group#fromv$logfile
DatafileFileID


/u01/oracle/db/APP1/sys/APP1_sys1.dbf1
/u01/oracle/db/APP1/sys/APP1_undo1.dbf2
/u01/oracle/db/APP1/sys/APP1_sysaux1.dbf3
/u01/oracle/db/APP1/usr/APP1_users1.dbf4
LogfileGroupNr

/u01/oracle/db/APP1/rdo/APP1_log1A.rdo1
/opt/oracle/db/APP1/rdo/APP1_log1B.rdo1
/u01/oracle/db/APP1/rdo/APP1_log2A.rdo2
/opt/oracle/db/APP1/rdo/APP1_log2B.rdo2
/u01/oracle/db/APP1/rdo/APP1_log3A.rdo3
/opt/oracle/db/APP1/rdo/APP1_log3B.rdo3
/u01/oracle/db/APP1/rdo/APP1_log4A.rdo4
/opt/oracle/db/APP1/rdo/APP1_log4B.rdo4
/u01/oracle/db/APP1/rdo/APP1_log5A.rdo5
/opt/oracle/db/APP1/rdo/APP1_log5B.rdo5
/u01/oracle/db/APP1/rdo/APP1_log6A.rdo6
/opt/oracle/db/APP1/rdo/APP1_log6B.rdo6
/u01/oracle/db/APP1/rdo/APP1_log7A.rdo7
/opt/oracle/db/APP1/rdo/APP1_log7B.rdo7
/u01/oracle/db/APP1/rdo/APP1_log8A.rdo8
/opt/oracle/db/APP1/rdo/APP1_log8B.rdo8
/u01/oracle/db/APP1/rdo/APP1_log9A.rdo9
/opt/oracle/db/APP1/rdo/APP1_log9B.rdo9
/u01/oracle/db/APP1/rdo/APP1_log10A.rdo10
/opt/oracle/db/APP1/rdo/APP1_log10B.rdo10

CreateDirectoriesfortheduplicateDatabase
mkdirp/u01/oracle/db/APP2
mkdirp/opt/oracle/db/APP2
cd/opt/oracle/db/APP2
mkdirconrdo
cd/u01/oracle/db/APP2
mkdiradmarcconrdosystmpusrbck
cdadm
mkdiradmpbdmpcdmpudmputld

CreateSymbolicLinkstoPasswordandINIT.ORAFile
OraclemustbeabletolocatethePasswordandINIT.ORAFile.
cd$ORACLE_HOME/dbs
lns/home/oracle/config/10.2.0/orapwAPP2orapwAPP2
lns/home/oracle/config/10.2.0/initAPP2.orainitAPP2.ora

DuplicatetheDatabase
NowyouarereadytoduplicatethedatabaseAPP1toAPP2.
ORACLE_SID=APP2
exportORACLE_SID
sqlplussys/managerassysdba
startupforcenomountpfile='/home/oracle/config/10.2.0/initAPP2.ora'
exit
rmanTARGETsys/manager@APP1AUXILIARYsys/manager@APP2
RecoveryManager:Release10.2.0.4.0ProductiononTueOct2812:00:132008
Copyright(c)1982,2007,Oracle.Allrightsreserved.
connectedtotargetdatabase:APP1(DBID=3191823649)
connectedtoauxiliarydatabase:APP2(notmounted)
RUN
{
SETNEWNAMEFORDATAFILE1TO'/u01/oracle/db/APP2/sys/APP2_sys1.dbf'
SETNEWNAMEFORDATAFILE2TO'/u01/oracle/db/APP2/sys/APP2_undo1.dbf'

SETNEWNAMEFORDATAFILE3TO'/u01/oracle/db/APP2/sys/APP2_sysaux1.dbf'
SETNEWNAMEFORDATAFILE4TO'/u01/oracle/db/APP2/usr/APP2_users1.dbf'
DUPLICATETARGETDATABASETOAPP2
PFILE=/home/oracle/config/10.2.0/initAPP2.ora
NOFILENAMECHECK
LOGFILEGROUP1('/u01/oracle/db/APP2/rdo/APP2_log1A.rdo',
'/opt/oracle/db/APP2/rdo/APP2_log1B.rdo')SIZE10MREUSE,
GROUP2('/u01/oracle/db/APP2/rdo/APP2_log2A.rdo',
'/opt/oracle/db/APP2/rdo/APP2_log2B.rdo')SIZE10MREUSE,
GROUP3('/u01/oracle/db/APP2/rdo/APP2_log3A.rdo',
'/opt/oracle/db/APP2/rdo/APP2_log3B.rdo')SIZE10MREUSE,
GROUP4('/u01/oracle/db/APP2/rdo/APP2_log4A.rdo',
'/opt/oracle/db/APP2/rdo/APP2_log4B.rdo')SIZE10MREUSE,
GROUP5('/u01/oracle/db/APP2/rdo/APP2_log5A.rdo',
'/opt/oracle/db/APP2/rdo/APP2_log5B.rdo')SIZE10MREUSE,
GROUP6('/u01/oracle/db/APP2/rdo/APP2_log6A.rdo',
'/opt/oracle/db/APP2/rdo/APP2_log6B.rdo')SIZE10MREUSE,
GROUP7('/u01/oracle/db/APP2/rdo/APP2_log7A.rdo',
'/opt/oracle/db/APP2/rdo/APP2_log7B.rdo')SIZE10MREUSE,
GROUP8('/u01/oracle/db/APP2/rdo/APP2_log8A.rdo',
'/opt/oracle/db/APP2/rdo/APP2_log8B.rdo')SIZE10MREUSE,
GROUP9('/u01/oracle/db/APP2/rdo/APP2_log9A.rdo',
'/opt/oracle/db/APP2/rdo/APP2_log9B.rdo')SIZE10MREUSE,
GROUP10('/u01/oracle/db/APP2/rdo/APP2_log10A.rdo',
'/opt/oracle/db/APP2/rdo/APP2_log10B.rdo')SIZE10MREUSE
}
Thewhole,longoutputisnotshownhere,butcheck,thatRMANwasabletoopentheduplicatedatabase
withtheRESETLOGSoption.
.....
.....
contentsofMemoryScript:
{
Alterclonedatabaseopenresetlogs
}
executingMemoryScript
databaseopened
FinishedDuplicateDbat28OCT08
Asthefinalstep,eliminateoruncommenttheDB_FILE_NAME_CONVERTandLOG_FILE_NAME_CONVERTinthe
INIT.ORAfileandrestartthedatabase.
initAPP2.ora
###DuplicateDatabase
###
#Thisisonlyusedwhenyouduplicatethedatabase
#onthesamehosttoavoidnameconflicts
#DB_FILE_NAME_CONVERT=(/u01/oracle/db/APP1/,/u01/oracle/db/APP2/)
#LOG_FILE_NAME_CONVERT=(/u01/oracle/db/APP1/,/u01/oracle/db/APP2/,
/opt/oracle/db/APP1/,/opt/oracle/db/APP2/)
sqlplus/assysdba
shutdownimmediate
startup
TotalSystemGlobalArea629145600bytes
FixedSize1269064bytes
VariableSize251658936bytes
DatabaseBuffers373293056bytes
RedoBuffers2924544bytes
Databasemounted.
Databaseopened.

CreatingaDuplicateDatabasetoRemoteHost
Thisscenarioisexactlythesameasdescribedforthelocalhost.CopytheRMANBackupfilestotheremote
hostonthesamedirectoryasonthelocalhost.

cd/u01/backup
scpgentic:/u01/backup/*.
TheotherstepsarethesameasdescribedunderCreatingaDuplicateDatabaseontheLocalHost.

You might also like