Sei sulla pagina 1di 3

25/9/2015

CloningPluggableDatabases

CloningPluggableDatabases

Overview

Purpose
Thistutorialcoversthestepsrequiredtocloneapluggabledatabase(PDB)fromacontainerdatabase(CDB)intothesameCDB.

TimetoComplete
Approximately15minutes

Introduction
YoucancopyasourcePDBfromaCDBandplugthecopyintothesameCDBorintoanotherCDB.Thiscapabilityissuitableforthefollowing
situations:
YouwanttotesttheapplicationpatchofyourproductionPDB.YoufirstcloneyourproductionapplicationinaclonedPDB,patchthe
clonedPDB,andtestit.
Youwanttodiagnoseperformanceissuesorperformperformanceregressiontestsonyourapplication.Becauseyoucannotperformthis
operationinparallelwiththeproductioninthesamedatabase,youclonethePDBintoanotherCDB.

Scenario
Inthistutorial,youwilluseSQL*PlustoperformaPDBcloningoperationwithinthesameCDB.
Note:IfyouwanttocloneaPDBfromaCDBintoanotherCDB,youidentifythesourceCDBbycreatingadatabaselinktoitfromthe
CDBinwhichyouwanttocreatetheclone.

Prerequisites
Beforestartingthistutorial,youshould:
EnsurethatyouhaveenoughdiskspacetoholdacompletecloneofthePDB.
InstallOracleDatabase12c.
CreateoneCDBwithonePDBinit.
Theenvironmentusedinthedevelopmentofthistutorialisasfollows:
ORACLE_HOME:/u01/app/oracle/product/12.1.0
TNSListenerport:1521
Containerdatabases:
SID:cdb1
SID:cdb2
Pluggabledatabases(incdb1):
pdb1
pdb2

PreparingtheSourcePDBtoClone

Inthissection,youpreparethesourcePDBtobeclonedandthetargetnewPDBtobecreated.

SettingtheSourcePDBtoREADONLYMode
1. UseSQL*PlustoclosethePDBthatyouwanttoclone.
.oraenv
[entercdb1attheprompt]
sqlplus/assysdba
alterpluggabledatabasepdb1closeimmediate
2. OpenthePDBthatyouwanttocloneinREADONLYmode.
alterpluggabledatabasepdb1openreadonly
exit

CreatingaDirectoryfortheNewClonePDB
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/pdb/pdb_clone/pdb_clone.html

1/3

25/9/2015

CloningPluggableDatabases
1. Navigateto/stageorwhereveryoucanfindenoughavailablespacetostorethedatafilesforpdb1_clone.
cd/stage
2. Createasubdirectorycalledpdb1_cloneunder/stage.Note:Youmayneedtologinasroottocreatethesubdirectory,and
thenchangetheownertooracleandthegrouptooinstall.
mkdirpdb1_clone

ConfiguringOMFtotheDirectoryoftheClonePDB
1. UseSQL*Plustoconnectassysdbaandsetthefollowingparameter:
sqlplus/assysdba
altersystemsetdb_create_file_dest='/stage/pdb1_clone'

CloningthePDBWithintheCDB

UseSQL*PlustoclonethePDBwithinthesameCDB.
1. Executethefollowingstatement:
createpluggabledatabasepdb1_clonefrompdb1
2. Openthenewpdb.
alterpluggabledatabasepdb1_cloneopen
3. Connecttothenewpdb.
connectsystem/oracle@localhost:1521/pdb1_clone
4. VerifythatyouareconnectedtothenewPDB:
showcon_name

SettingtheSourcePDBBacktoOpenMode

1. ConnecttotherootintheCDB.
connect/assysdba
altersessionsetcontainer=cdb$root
2. Executethefollowingstatement:
alterpluggabledatabasepdb1closeimmediate
3. Openthesourcepdb.
alterpluggabledatabasepdb1open

http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/pdb/pdb_clone/pdb_clone.html

2/3

25/9/2015

CloningPluggableDatabases

ResettingYourEnvironment

PerformthefollowingstepstoresetyourenvironmentpriortorepeatingtheactivitiescoveredinthisOBEorstartinganotherOBE.
1. ClosetheclonePDB.
alterpluggabledatabasepdb1_clonecloseimmediate
2. DeletetheclonePDBanditsdatafiles.
droppluggabledatabasepdb1_cloneincludingdatafiles

Summary

Inthistutorial,youlearnedhowto:
PrepareanexistingPDBtobeclonedwithinthesameCDB
ClonethePDB

Resources
Tolearnmoreaboutpluggabledatabases,refertoadditionalOBEsintheOracleLearningLibrary

Credits
CurriculumDevelopers:DominiqueJeunot,JeanFrancoisVerrier

http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/pdb/pdb_clone/pdb_clone.html

3/3

Potrebbero piacerti anche