Anda di halaman 1dari 13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

About
Experts
RedGateOracleTools
Login

SearchATO...

AllThingsOracle

FullArticles
Webinars
Experts
DatabaseDev
AppDev
DBA
PL/SQL
APEX
Puzzles

DataGuardPhysicalStandbyDatabaseBestPracticesPartI
WissemElKhlifion07August2012with30comments

Introduction
OracleDataGuardisoneofthesoftwaresolutionsprovidedbyOracleCorporationtomaximizehighavailabilityofOracledatabases.OracleData
Guardmaintainsoneormanysecondarydatabasesasalternativestotheprimaryproductiondatabase.

DataGuardArchitecture
OracleDataGuardsupportsbothphysicalstandbyandlogicalstandbysites.
PhysicalStandby:Whentheprimarydatabasetransactionsgenerateredoentries,aredoapplyprocesskeepsupthesecondarydatabaseswiththe
exactblockcopiesoftheprimarydatabase.
LogicalStandby:SQLapplyprocessesreadtheredoandconvertittoSQLtransactions.Thesearethenappliedtothesecondarydatabase.

DataGuardModes
OracleDataGuardcanoperatein3differentmodes:
MaximumProtection:Transactionsarenotallowedtocommituntilallredodataarewrittentotheonlineredologsandpropagatedtoatleast
onesynchronizedsecondarydatabase.Ifforanyreason,theprimarydatabasecannotpropagateitsredostreamtoonesecondarydatabase,the
primarywillshutdowntoensuremaximumprotectionmode.
MaximumPerformance:Transactionsarenotallowedtocommitassoonastheredoarewrittentotheonlineredologs.Theredostreamis
asynchronouslypropagatedtothesecondarydatabasestoensuremaximumperformancemode.
MaximumAvailability:Transactionsarenotallowedtocommituntilallredodataarewrittentotheonlineredologsandpropagatedtoatleast
onesynchronizedsecondarydatabase.Ifforanyreason,theprimarydatabasecannotpropagateitsredostreamtoonesecondarydatabase,the
primarywillNOTshutdownandoperatesasititwereinmaximumperformancemodeuntilissuesarefixed.

Glossary
Roletransition:Changingtheroleofeachdatabasecomponentfromprimarydatabasetothesecondarydatabaseorfromsecondarydatabase
totheprimarydatabase.
http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

1/13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

Switchover:Plannedroletransitionfortesting.Manualintervention.
FailOver:Unplannedfailure.ManualorAutomaticintervention.Automaticroletransitionistherecommended.
Primarydatabase:Wheretheusersareconnectedtoaccesstothedatabase.
Standbydatabase:Existsinthethedisasterrecovery(DR)site.Wheretheusersareconnectedinthecaseofplannedroletransition
(Switchover)orinthecaseofunplannedfailure(FailOver).
DataGuardObserver:Processmonitorsbothprimaryandstandbydatabasesandperformsanautomaticfailoverwhennecessary.
TheBroker:ThemanagementframeworkforOracleDataGuard.Itcomesintegratedintotheoracledatabaseenterpriseedition.
FastStartFailOver(FSFO):Automaticfailovertothestandbydatabaseoccursincaseoffailure.FSFOrequiresthebroker.

TheEnvironment
Ihave3VMwithversionofOracleEnterpriseLinux5installed.
IwillusetheOracleDatabase11gEnterpriseEditionRelease211.2.0.1.0ontheprimarydatabaseandthestandbydatabase.
Oraclesoftwareisinstalledandadatabaseisalreadycreatedontheprimarysite.
Oraclesoftwareisinstalledandthedatabasewillbecreatedduringthisdemonstrationforthestandbysite.
Onthethirdhost,IhaveinstalledaversionofOracledatabase11gClientwithadministratoroption11.2.0.1.0.ThisistheDataGuard
Observerhost.
TheOracleHomeisonidenticalpathonbothnodes:primarydatabaseandthestandbydatabase.
Primarydatabaseservernameisdg1withadatabasenamedg1.
Standbydatabaseservernameisdg2withadatabasenamedg2.
TheDataGuardObserverservernameisdg3.
Fortherestofthedocument,IamgoingtoimplementaphysicalDataGuardenvironmentinmaximumperformancemode.Thewholedocument
willbesplitin2parts:
1. PreparetheDataGuardenvironment.
2. Createthestandbydatabaseandveritythephysicalstandbydatabase.IwillthenConfiguretheDataGuardBroker,enableFastStartFail
Over(FSFO)andrunaDataGuardObserver.

Implementationnotes
Thesearethestepstofollow:
1. Enableforcedlogging
2. Createapasswordfile
3. Configureastandbyredolog
4. Enablearchiving
5. Setuptheprimarydatabaseinitializationparameters
6. Configurethelistenerandtnsnamestosupportthedatabaseonbothnodes
Note:ItisrecommendedtoapplyallpatchesontheprimaryandthestandbybeforesettinguptheDataGuardenvironment.

PreparetheprimaryandthephysicalStandbyEnvironments
PrimaryServer:Step1
OracleDataGuardrequirestheprimarydatabasetoberuninFORCELOGGINGmode.ThismeansthatstatementsusingtheNOLOGGING
optionwillstillgenerateredoinformationtomaintaintheDataGuardstandbydatabases.
[oracle@dg1~]$sqlplus/assysdba
SQL>selectforce_loggingfromv$database;
FOR

NO
SQL>alterdatabaseforcelogging;
Databasealtered.
SQL>

Thestandbylogfilesarerequiredtostoreredoreceivedfromtheprimarydatabase.Standbyredologsmustbeequalorlargertothelargestredolog
fileintheprimarydatabase.Thestandbyredologmusthaveatleastonemoreredologgroupthantheredologontheprimarydatabase.Itis
recommendedthatthestandbyredologiscreatedontheprimarydatabaseandpropagatedtothestandbyforanyswitchoverorfailoveroperations.
SQL>select*fromv$log;
GROUP#THREAD#SEQUENCE#BYTESBLOCKSIZEMEMBERSARCSTATUSFIRST_CHANGE#FIRST_TIMNEXT_CHANGE#NEXT_TIME

117524288005122YESINACTIVE82895215JAN1284910516JAN12

http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

2/13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

218524288005122NOCURRENT84910516JAN122.8147E+14
316524288005122YESINACTIVE82230415JAN1282895215JAN12
SQL>alterdatabaseaddstandbylogfilesize50M;
Databasealtered.
SQL>
SQL>alterdatabaseaddstandbylogfilesize50M;
Databasealtered.
SQL>alterdatabaseaddstandbylogfilesize50M;
Databasealtered.
SQL>alterdatabaseaddstandbylogfilesize50M;
Databasealtered.
SQL>
SQL>select*fromv$logfile;

Next,settheLOG_ARCHIVE_CONFIGparameter.TheLOG_ARCHIVE_CONFIGparameterenablesordisablesthesendingofredostreamsto
thestandbysites.TheDB_UNIQUE_NAMEoftheprimarydatabaseisdg1andtheDB_UNIQUE_NAMEofthestandbydatabaseisdg2.The
primarydatabaseisconfiguredtoshipredologstreamtothestandbydatabase.Inthisexample,thestandbydatabaseserviceisdg2.
Next,STANDBY_FILE_MANAGEMENTissettoAUTOsothatwhenOraclefilesareaddedordroppedfromtheprimarydatabase,these
changesaremadetothestandbydatabasesautomatically.TheSTANDBY_FILE_MANAGEMENTisonlyapplicabletothephysicalstandby
databases.
SettingtheSTANDBY_FILE_MANAGEMENTparametertoAUTOisisrecommendedwhenusingOracleManagedFiles(OMF)ontheprimary
database.Next,theprimarydatabasemustberunninginARCHIVELOGmode.
SQL>showparameterdb_name
NAMETYPEVALUE

db_namestringdg1
SQL>showparameterdb_unique_name
NAMETYPEVALUE

db_unique_namestringdg1
SQL>altersystemsetlog_archive_config='dg_config=(dg1,dg2)';
Systemaltered.
SQL>altersystemsetlog_archive_dest_2=
2'service=dg2asyncvalid_for=(online_logfile,primary_role)db_unique_name=dg2';
Systemaltered.
SQL>altersystemsetstandby_file_management=AUTO;
Systemaltered.
SQL>
SQL>archiveloglist;
DatabaselogmodeArchiveMode
AutomaticarchivalEnabled
ArchivedestinationUSE_DB_RECOVERY_FILE_DEST
Oldestonlinelogsequence7
Nextlogsequencetoarchive9
Currentlogsequence9
SQL>exit;

EnsuretheOracleNetServicesaliasesforboththeprimarydatabaseandstandbydatabaseareaddedtothetnsnames.orafile.
[oracle@dg1~]$cat$ORACLE_HOME/network/admin/tnsnames.ora
dg1=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=dg1.localdomain)(PORT=1521))
(CONNECT_DATA=
(SERVER=DEDICATED)
(SERVICE_NAME=dg1)
)
)
dg2=
(DESCRIPTION=

http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

3/13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

(ADDRESS=(PROTOCOL=TCP)(HOST=dg2.localdomain)(PORT=1521))
(CONNECT_DATA=
(SERVER=DEDICATED)
(SERVICE_NAME=dg2)
)
)
[oracle@dg1~]$

Copytheupdatedtnsnames.orafiletothestandbysite(host).
StandbyServer:Step2
TheOracledatabasebinarieshavealreadybeeninstalledatthislocation($ORACLE_HOME).Thenewstandbydatabasewillhavedg2astheSID.
Thelisteneronthestandbysitemustbeconfiguredwithastaticserviceentryforthestandbydatabase.Restartthelisteneraftermodification.
[oracle@dg2admin]$catlistener.ora
LISTENER=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=dg2.localdomain)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=dg2)
(SID_NAME=dg2)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
)
)

[oracle@dg2admin]$lsnrctlstart

Createauditdirectoryfilesunder$ORACLE_BASE/admin/$ORACLE_SID/adump.Inmyexample,IwillalsocreatetheFastrecoverareaandthe
oradatadirectories.
[oracle@dg2~]$mkdirp$ORACLE_BASE/admin/dg2/adump
[root@dg2~]#mkdirp/opt/oradata
[root@dg2~]#mkdirp/opt/fast_recovery_area

Next,createasimpleparameterfileonthestandbyhistwiththeDB_NAMEvalue.
[oracle@dg2dbs]$echoDB_NAME=dg2>initdg2.ora
[oracle@dg2dbs]$catinitdg2.ora
DB_NAME=dg2
[oracle@dg2dbs]$

Theprimarydatabasepasswordfilemustbecopiedtothestandbysystemforredoauthentication.
[oracle@dg2dbs]$scpdg1:$ORACLE_HOME/dbs/orapwdg1orapwdg2

Inthenextpartofthedocument,wewillcreatethestandbydatabase,veritythephysicalstandbydatabase.WewillthenconfiguretheBroker,set
uptheFastStartfailoverandtheDataGuardObserver.

References:
docs.oracle.com/cd/E11882_01/server.112/e25608/toc.htm
en.wikipedia.org/wiki/Oracle_Data_Guard
Like

Tweet

Share

Tags:OracleDataGuard

WissemElKhlifi
12cDataguard:RecoverfromService

6Comments
11g,12c,AllThingsOracleFullArticles,DatabaseAdministration,DatabaseDevelopment,OracleDatabase,Troubleshooting
http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

4/13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

GainingmaximumbenefitsfromOracleDataGuard

6Comments
11g,AllThingsOracleFullArticles,DatabaseAdministration
Comments
Trackbacks

30Comments

1.
VickyBartholo
17/08/2012Reply
Thiswasveryuseful.Ithelpedmevalidatemysetup.WherecanIseethesectionregardingDataGuardBroker,enableFastStartFailOver
(FSFO)andrunaDataGuardObserver?

ashu
28/05/2013Reply
hii
thisisashu,ihadadout.couldweconvertlogicalstandbytophysicalstandby..
actuallywhathappenitryit..butitisnotcomebackitpreviousstage..
pleasesend.

Thanks&Reply

Ashu

2.
AllThingsOracle
20/08/2012Reply
HiVicky,
ThankyouforyourcommentI'mpleasedthearticlehashelpedyou.Part2willwillpublishedonheresoon.
Thanks,
James

3.
MuhammadIkram
22/08/2012Reply
Wisem,Itwasreallynicestepbystepguide,waitingforthesecondpart.

http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

5/13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

4.
Wissem
22/08/2012Reply
Hello,

Thankyouforyourcomment.TheBrokersetupwillbepublishedinthepart2,soon.
Bestregards,
Wissem

5.
Gaetano
22/08/2012Reply
Wissem,
Thanksalotforsharingthisarticle.
Waitingthenextpart(s).
BR,
Gaetano

6.
Rafael
23/08/2012Reply
Nicearticle,IwilluseitformynextDataGuardsetup.thankyouSirandhopetoseeyoursecondpartsoon.
Rafael

7.
Wissem
23/08/2012Reply
Muhammad,
Thankyouforyournicecomment.
Bestregards,
Wissem

8.
Eric
28/08/2012Reply
Wassem,
Shouldn'tthisstatmenthavetheNOTremoved.
MaximumPerformance:Transactionsarenotallowedtocommitassoonastheredoarewrittentotheonlineredologs.Theredostreamis
asynchronouslypropagatedtothesecondarydatabasestoensuremaximumperformancemode.
thanks,
Eric

http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

6/13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

9.
goutham
28/08/2012Reply
Hi
Nicedocument.goodexplanation

thanks

10.
dheeraj
29/08/2012Reply
whencanweexpectpart2?anyestimateddate?

11.
oraclemanconsulting
30/08/2012Reply
great
whenwillpart2beavailable?

12.
Wissem
31/08/2012Reply
Hello,
Thankyouallforyourcomments.Hopefully,Icanpublishthesecondpartin2weeks.
Wissem

13.
MahirM.Quluzade
03/09/2012Reply
HiWissem
Verythanksforinterestingarticle.Waitingyouarticle'spartII.
IcreatedvideosonOracleDataGuard11gandIusedBroker.
Ishallveryglad,pleasevisitmyOracleDataGuard11gchannelonyoutube:
http://www.youtube.com/playlist?list=PLBE4B252DFE0F757F&feature=plcp
BestRegards
Mahir

http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

7/13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

14.
MarcVandermeiren
03/09/2012Reply
@Eric:correct,
MaximumPerformance:Transactionsarenotallowedtocommitassoonastheredoarewrittentotheonlineredologs.Theredostreamis
asynchronouslypropagatedtothesecondarydatabasestoensuremaximumperformancemode.
shouldbe
MaximumPerformance:Transactionsareallowedtocommitassoonastheredoarewrittentotheonlineredologs.Theredostreamis
asynchronouslypropagatedtothesecondarydatabasestoensuremaximumperformancemode.
bestregards,
Marc

15.
dheeraj
25/09/2012Reply
StillawaitingforpartII....:(

AllThingsOracle
25/09/2012Reply
HiDheeraj,
Part2willbepublishednextweeksorryforthedelay.Ifyouaresubscribedtoreceivenotificationsaboutnewcommentsforthispost
youwillbesentanemailwhenthearticleispublished.
Thanks,
James

16.
AllThingsOracle
27/09/2012Reply
Part2hasnowbeenpublished:http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticespartii/

17.
TrevorNorth
14/04/2013Reply
Fordataguardyouwillneedtwoservers,ideallylocatedindifferentgeographiclocationsandhavingthesameconfigurationsothatinthe
eventofafailover,thestandbycansupportthesamenumberofusersastheprimarydatabase.
Butthismeansyouhavedoubleduponyourhardware.Whatkindofoverheaddoesthefailoverhaveintermsofapplyingtheredologs?
http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

8/13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

IfyouhadtwoproductionOraclebasedapplications,andyouputtheserversindifferentlocations,woulditbepossibletohavebotha
primarydatabaseforoneapplicationandastandbydatabasefortheotherononeserverwiththelatterupdatedbydataguardfromaphysical
serverinanotherlocation.Andthenmirrorthisontheotherserversothatyouhavebothproductionserversprotectedandintheeventofa
disaster,youwouldhavebothprimarydatabasesonthesameserverbutonlyforthedurationoftheoutage.
Obviouslyit'snotperfectfromaperformanceperspectiveintheeventofadisasterbutasthesehappeninfrequently,thismeansyougetto
useyourstandbyhardwareinsteadofhavingitidle.Isthisafeasiblesetuporistheresomethingindataguardthatwouldpreventthisfrom
working?

18.
WilmerJimmy
23/05/2013Reply
Because,Youdontconfigurepfileparameterfileinproductionandstandbynodes,Iseethatothersmanualsifconfigureit.
Beside,Itshowbugsinduplicatewithrman.

19.
AshokRoy
19/06/2013Reply
Thedocumentsthatyouhavesharedisreallysogood.ThanksWissemElKhlifi.

20.
shivkumar.dba@gmail.coma
29/06/2013Reply
VerygoodarticlebyWissemOndataguard,ithelpsmelot.
Thankalotforprovidinginformation.
Regards,
Shiv

21.
Alex
08/10/2013Reply
HelloWissem.

Firstofall,wellwritenarticle.
Ihavesetan11.2.0.4DGreplicationondifferentnodes.
Switchoverworksfineinbothways(finally!).
FastFailoverandObserver(oneoneofthenodesfortestingthefailover).
Now,afterkilling9onthePrimarydatabase,ObserverefectivellyopentheformerStandbydatabasebutforsomereason,Observerisnot
startingmountandreinstatingtheformerPrimary(nowStandby)automatically.
IfImanually"startupmount"theformerPrimaryDB,ObservercontinueshisworkonreinstatingthedatabasebutIwasexpectingallthisto
beautomaticafterafailure.
AnyIdeawhereIcancheckthat?
Thanksalotinadvance!
Alex.

22.
http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

9/13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

Alex
24/10/2013Reply
Againme.
DataGuardwillNOTstartuptheformerprimarydatabaseautomatically.DatabasehealthhastobecheckedandstartedbytheDBA.

Thanks,
Alex.

23.
Niranjan
13/01/2014Reply
HOWTOSEETHEHOWMANYSTANDBYDATABASESINDATAGUARD

24.
Nitesh
21/04/2014Reply
Niceexplanation.Itsveryveryhelpful.
Regards,
Niteshpareek.

25.
Mina
06/08/2014Reply
IhavetriedmanytimestoinstallDGbutneversucceeded.Withyourmanuelifinallysucceeded.

Inormallynevercommentonblogsonforumsbutyourarticlesisverygoodandyoudeservethecredits!

Thanks!

26.
WillC
19/08/2014Reply
InStep2onthestandbytosetupsomepathstotheFastrecoverareaandtheoradatadirectories.Whydidyouputthemin/opt?

27.
ramu
14/10/2014Reply
reallyniceexplanationandifpossiblecouldyouplzsendyourseconddocument......

28.
http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

10/13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

kashifIqbal
27/03/2015Reply
NICEStepbyStepguide.afterpublishing2ndpartitwillbecomemorevalueable.

Leavearesponse
Name

*Required

Email

*Required

Website

SubmitComment

Notifymeoffollowupcommentsviaemail.Youcanalsosubscribewithoutcommenting.
Submitcomment

CaryMillsapslatestbook

LearnallaboutOracleextendedSQLtracedatafromCaryMillsap.IncludesafullchapterofcasestudiesusingMethodRsoftware.
Buynow

http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

11/13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

OakTableNews
Windows10Again
PresentinginPerthon9SeptemberandAdelaideon11September(Stage)
Avoidingpublicembarrassmentwithtriggers
MessedUpAppoftheDay:CruxCCH01W
PythonPassthePigs

RMOUGNews
ComeLearnandPlayQEWAugust7thatElitchGardens
May2015QuarterlyEducationalWorkshop
CallforNominationsfortheRMOUGBoardOfDirectors20152016
RMOUGBigDataSpecialInterestGroupMeetup
ThankYouforAttendingRMOUGTrainingDays2015!

ODTUGNews
2016ODTUGLeadershipProgramClassAnnounced
ODTUGDatabaseTwitChatRevisited
NewTechJournalArticleNowAvailable
ODTUGMemberSeries:AManandHisHotSauce
ODTUGDatabaseCommunityNewsletter

http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

12/13

8/24/2015

DataGuardPhysicalStandbyDatabaseBestPracticesPartIAllThingsOracle

Categories
10g(11)
11g(46)
12c(37)
8i(3)
9i(3)
AllThingsOracleFullArticles(152)
APEX(29)
ApplicationDevelopment(40)
BackupandRecovery(3)
ContinuousDelivery(2)
DatabaseAdministration(142)
DatabaseDevelopment(184)
eBook(6)
EM12c(2)
EnterpriseManager(2)
OracleCloud(6)
OracleDatabase(138)
OracleForms(1)
PerformanceTuning(50)
PL/SQL(52)
Polls(1)
Puzzles(7)
RAC(4)
Troubleshooting(44)
Uncategorized(7)
Video(15)
Webinar(44)

SubscribetoAllThingsOracle
Name:
Email:
JobTitle:
ApplicationDeveloper
Subscribe

2015RedgateSoftwareandassociatedcontentauthorsAllRightsReservedPrivacypolicyTermsandConditions

http://allthingsoracle.com/dataguardphysicalstandbydatabasebestpracticesparti/

13/13

Anda mungkin juga menyukai