data guard

147
1 ORACLE DATAGUARD ADMINISTRATION What is Data Guard? Data Guard, which was introduced as the standby database in Oracle database Version 7.3 under the name of Data Guard with Version 9i, is a data protection and availability solution for Oracle databases. The basic function of Oracle Data Guard is to keep a synchronized copy of a database as standby, in order to make provision, in case the primary database is inaccessible to end users. These cases are hardware errors, natural disasters, and so on. Each new Oracle release added new functionalities to Data Guard and the product became more and more popular with offerings such as data protection, high availability, and disaster recovery for Oracle databases. Using Oracle Data Guard, it's possible to direct user connections to a Data Guard standby database automatically with no data loss, in case of an outage in the primary database. Data Guard also offers taking advantage of the standby database for reporting, test, and backup offloading. Corruptions on the primary database may be fixed automatically by using the non- corrupted data blocks on the standby database. There will be minimal outages (seconds to minutes) on the primary database in planned maintenances such as patching and hardware changes by using the switchover feature of Data Guard, which changes the roles of the primary and standby databases. All of these features are available with Data Guard, which doesn't require an installation but a cloning and configuration of the Oracle database. A Data Guard configuration consists of two main components: primary database and standby database. The primary database is the database for which we want to take precaution for its inaccessibility. Fundamentally, changes on the data of the primary database are passed through the standby database and these changes are applied to the standby database in order to keep it synchronized. The following figure shows the general structure of Data Guard: Let's look at the standby database and its properties more closely. Without Data Guard

Upload: sravankumarthadakamalla

Post on 18-Aug-2015

226 views

Category:

Documents


0 download

DESCRIPTION

dg

TRANSCRIPT

ORACLE DATAGUARD ADMINISTRATION 1What is Data Guard?Data Guard, which was introduced as the standby database in Oracle database Version 7.3 under the nameof Data Guard with Version 9i, is a data protection and availability solution for Oracle databases. The basicfunction of Oracle Data Guard is to eep a synchroni!ed copy of a database as standby, in order to maeprovision, incasetheprimarydatabaseisinaccessibletoendusers. Thesecasesarehardwareerrors,naturaldisasters,and so on."achnew Oracle release added newfunctionalities to DataGuard and theproduct became more and more popular with offerin#s such as data protection, hi#h availability, and disasterrecovery for Oracle databases. $sin#Oracle DataGuard, it%s possibletodirect user connections toaDataGuardstandbydatabaseautomatically with no data loss, in case of an outa#e in the primary database. Data Guard also offers tain#advanta#e of the standby database for reportin#, test, and bacup offloadin#. &orruptions on the primarydatabase may be fi'ed automatically by usin# the non(corrupted data blocs on the standby database. Therewill be minimal outa#es )seconds to minutes* on the primary database in planned maintenances such aspatchin# and hardware chan#es by usin# the switchover feature of Data Guard, which chan#es the roles oftheprimaryandstandbydatabases. +ll of thesefeaturesareavailablewithDataGuard, whichdoesn%tre,uire an installation but a clonin# and confi#uration of the Oracle database. + Data Guard confi#uration consists of two main components- primary database and standby database. Theprimary database is the database for which we want to tae precaution for its inaccessibility. .undamentally,chan#es on the data of the primary database are passed throu#h the standby database and these chan#esare applied to the standby database in order to eep it synchroni!ed. The followin# fi#ure shows the #eneral structure of Data Guard-/et%s loo at the standby database and its properties more closely. 0ithout Data GuardORACLE DATAGUARD ADMINISTRATION 2With Data GuardStandby database 1t is possible to confi#ure a standby database simply by copyin#, clonin#, or restorin# a primary database toadifferent server. Then the DataGuard confi#urations are made on thedatabases in order to start thetransfer of redo information from primary to standby and also to start the apply process on the standbydatabase.Primary and standby databases may exist on the same server; however,this kind of configuration should only be used for testing. In aproduction environment, the primary and standby database servers aregenerally preferred to be on separate data centers.Data Guard eeps the primary and standby databases synchroni!ed by usin# redo information. +s you maynow,transactionsonanOracledatabaseproduceredorecords. Thisredoinformationeepsall of thechan#es made to the database. The Oracle database first creates redo information in memory )redo lo#buffers*. Then they%re written into online redo lo#files, and when an online redo lo#file is full, its content iswritten into an archived redo lo#.An Oracle database can run in the A!"I#$%O& mode or theORACLE DATAGUARD ADMINISTRATION 3'OA!"I#$%O& mode. In the A!"I#$%O& mode, online redo logfiles arewritten into archived redo logs and in the 'OA!"I#$%O& mode, redologfiles are overwritten without being archived as they become full.In a (ata &uard environment, the primary database must be in theA!"I#$%O& mode.1n Data Guard, transfer of the chan#ed data from the primary to standby database is achieved by redo withno alternative. 2owever,the applyprocessoftheredocontentto thestandby database mayvary. Thedifferent methods on the apply process reveal different type of standby databases. Thereweretwoindsof standbydatabasesbeforeOracledatabaseVersion33g, whichwere-physicalstandbydatabaseandlo#ical standbydatabase. 0ithinVersion33gweshouldmentionathirdtypeofstandby database which is snapshot standby. /et%s loo at the properties of these standby database types. Physical standby database The4hysical standbydatabaseis abloc(basedcopyof theprimarydatabase. 1naphysical standbyenvironment, in addition to containin# the same database ob5ects and same data, the primary and standbydatabases are identical on a bloc(for(bloc basis. 4hysical standby databases use 6edo +pply method toapply chan#es. 6edo +pply uses Managed recovery process )MRP* in order to mana#e application of thechan#e in information on redo. 1nVersion33g, aphysical standbydatabasecanbeaccessibleinread(onlymodewhile6edo+pplyisworin#, which is called +ctive Data Guard. $sin# the +ctive Data Guard feature, we can offload report 5obsfrom the primary to physical standby database.Physical standby database is the only option that has no limitationon storage vendor or data types to keep a synchroni)ed copy of theprimary database.Physical LogicalCharacteristics A physically identical copy of the primary database on a block-for-block basisContains the same logical information as the production database, although a physical organization and structure of the data can be different.Synchronization mechanismRedo Apply SL ApplyRead-only access !es, but only in a e"clusi#e mode $no redo apply at the same time%Can be &ueried for reports 'hile logs arebeing applied #ia SLAdditional benefits-Can be used to offload backups-Redo apply is fastest and most efficient approach to apply changes- Can create additional inde"es and materialized #ie's for better &uery performanceLimitations -(ses more resources than physical-)as some restrictions on datatypes, types of tables, **L and *+LLogical standby database /o#icalstandby database is a feature introduced in Version 9i67. 1n this confi#uration, redo data is firstconverted into 89/ statements and then applied to the standby database. This process is called 89/ +pply.This method maes it possible to access the standby database permanently and allows read:write while thereplication of data is active. Thus, you%re also able to create database ob5ects on the standby database thatORACLE DATAGUARD ADMINISTRATION 4don%t e'ist on the primary database. 8o a lo#ical standby database can be used for many other purposesalon# with hi#h availability and disaster recovery. Duetothebasicsof 89/+pply,alo#ical standbydatabasewill containthesamedataastheprimarydatabase but in a different structure on the diss. One discoura#in# aspect of the lo#ical standby database is the unsupported data types, ob5ects, and DD/s.The followin# data types are not supported to be replicated in a lo#ical standby environment- 3 ;.1/" 7 &ollections )includin# V+66+ > R;S 5*L3 ABDAEDED0E0 0e can see that, the =64 is not waitin# for any old se,uenceC it%s waitin# for the lo# se,uence that is on theway from primary to standby. );ecause the /G06 attribute is used on lo# transport, this lo# is the currentlo# se,uence on the primary.*7. /et%s loo at the alert lo# a#ain- Thu +u# E9 EE-77-3D 7E37 =edia 6ecovery /o# M.6+:test:archivelo#:7E37JE@JE9:threadJ3J se,J>7E.?3?.79E@7E7>? Thu +u# E9 EE-77-?7 7E37 Media Recovery Waiting for thread 1 se#uence $/1 (in transit) ORACLE DATAGUARD ADMINISTRATION 12+syoucansee there%sno te't inalert lo#aboutthedelay,becauseitwascancelled.The=64process applied the lo# se,uence >7E and started to wait for the ne't lo# )>73* to completely arriveand #et archived. 1t also indicates that the ne't lo# is in transit, which means it is currently bein#received by 6.8. @. /et%s convert the 6edo +pply mode to real(time apply and see how Data Guard will apply the redo asit received from the primary database. .irst we%ll stop 6edo +pply on the standby database and starta#ain in the real(time apply mode- SL, AL73R *A7A8AS3 R3C> > R;S5*L3 ABDIACEFCFD AA Fow it%s obvious that =64 is applyin# the lo# as it arrives to standby. The 6.8 process is transferrin# the lo#se,uence>73,whichisthecurrentlo#ontheprimary side,andat thesametimethe=64process isapplyin# the same lo# se,uence. /oo at the bloc number columnC we can see that =64 is applyin# theredo blocs that have 5ust arrived. !ou should also kno' that, e#en there is a *3LA! #alue specified on theprimary database1 if the apply mode is real-time apply on the standbydatabase, the *3LA! 'ill be ignored. !ou.ll see the follo'ing lines in thestandby alert log in such a caseJ+anaged standby reco#ery started 'ith (S529 C(RR327 L minutesS,L 'pply (logical standby databases) The 89/ +pply technolo#y resides on minin# the standby redo lo#s, buildin# 89/ transactions that apply thechan#es in ,uestion, and finally, e'ecutin# the 89/ on the standby database, which is read:write accessible.This process is more e'pensive in terms of hardware resource usa#e as a matter of course. The /84 processmana#es the application of chan#es to a lo#ical standby database. The #eneral purpose of buildin# a lo#ical standby database is reportin# the needs with read: write accessre,uirement. 89/ +pply is not suitable for disaster recovery and hi#h availability as much as 6edo +pplybecause of the unsupported data types and lo#ically different database infrastructure. 89/ +pply offers the followin# benefits to its users- 3 The lo#icalstandby database is always read:write accessible while 89/ +pply is runnin#C so thatusers mayrunreports, createtemporarytables andinde'es for performanceissues. +lsoit%spossible to create ob5ects and eep data on the standby database, which do not e'ist on primary. 7 Thelo#ical standbydatabaseisopenfor read:writeactivity.;ut normallytherearenowritespossible on the standby ob5ects, which e'ist on primary. This feature maintains the consistency ofthe replicated primary data. 3 1t%spossibletoup#radetheOracledatabasesoftwareversionwithalmostnodowntimeusin#alo#ical standby database. &ole transitions 6ole transitions basically enable users to chan#e the roles of the databases in a Data Guard confi#uration.There are two role transition options in Data Guard, which are s+itchover and failover.S%itchover 1n a basic Data Guard confi#uration with one primary and one standby database, a switchover operationchan#es the roles of these databases, and so the direction of the redo shippin#. 1n a correctly desi#nedconfi#uration, archived lo# shippin# in the opposite direction starts immediately after switchover and clientsdo not need to chan#e their connection descriptions in order to connect the new primary database. ORACLE DATAGUARD ADMINISTRATION 131f there is more than one standby database in a Data Guard confi#uration, it%s possible to perform switchoverbetween the primary and any of the standby databases. +fter the switchover, the new primary database cancontinue to send redo to all of the standby databases in the confi#uration. 6e#ardless of the confi#uration of Data Guard, a switchover operation always #uarantees !ero data loss. Thisbrin#s hi#h reliability to switchover and thus it%s widely used for planned maintenance operations, such ashardware or operatin# systemup#rades, database software rollin# up#rade, and other infrastructuremaintenances. 8witchover reduces the downtime for these maintenance operations by a si#nificant amountof time.-ailover .ailover is the operation of convertin# a standby database to a primary database, because of a failure in theori#inal primarydatabase. 1fthe flashbacdatabaseisdisabledonthe primary database,failoveris anoperation with no return. 1n other words, we have to flashbac the failed primary database to a state beforefailover in order to re(establish the confi#uration. 0ithout flashbac, Data Guard confi#uration needs to bebuilt from scratch. + manual database failover may be performed in the case of failure with the initiative of the database owner.2owever, this will re,uire e'tra outa#e for the decision main#. 1f fast(start failover is used, which is a 3Egrelease 7 feature, the failover operation will perform automatically.-ast.start ailover This property of automatin# the failover operation can only be used in Data Guard broer enabledconfi#uration. The observer process whichruns ona different server fromthe primary and standbydatabases, continuously monitors the accessibility of the primary database. 1f both the observer and thestandby database cannot reach the primary database for a predefined len#th of time, a fully(automatedfailover process is started. 0ith 33g 6elease 7, we callit fully automated, because this process includeschan#in# the role of the standby as primary, startin# the database services on the new primary database,disconnectin# the client fromthe failedprimary database, and redirectin# themtothe newprimarydatabase.1ftheobserver establishesthe connectionwiththeori#inal primary databasea#ainafter the failover,itinforms the database that the failover was performed and it will automatically reinstate the database usin#flashbac. 1n order to confi#ure fast(start failover, we need to specify the fast recovery area and enableflashbac on the primary and standby databases. Heep in mind that in Version 33g, Data Guard must be on =a'imum +vailability or =a'imum 4erformancemode in order to use fast(start failover. 1n 3Eg 6elease 7, only =a'imum +vailability mode is supported forfast(start failover.Data Guard bac/ground processes 1n a Data Guard confi#uration we can see some Oracle Data Guard specific bac#round processes in both,primaryandstandbydatabases. Theseprocessesperformtheoperationsof redotransport andapplyservices. Data Guard broer also has some specific bac#round processes. 0e can see the description andduties of the most important Data Guard processes as follows- MRP' )Managed Stand&y Recovery Process* coordinates the read and apply process of redo in aphysical standby database. RFS )Remote File Server* is responsible for receivin# the redo data, which is sent by the primarydatabase to the standby database. 0SP' )0ogical Stand&y 1oordinator Process* coordinates the 89/ +pply processes, which are theminin# processes and apply processes. 0SP1 )0ogical Stand&y Dictionary 2uild Process* is used on the lo#ical standby databases whena switchover or failover is in action. 0SP, )0ogical Stand&y Set Guard Process* is used to operate Database Guard settin#s. DatabaseGuard specifies which ob5ects will be protected for modification in a lo#ical standby database. 3S"n )Redo *ransport 3S"1 Process* is used on the primary database to ship redo data to thestandby database when +8> Hu>AHappHoracleHoradataHorclHredo>0.log I52AC7543 A>> Hu>AHappHoracleHoradataHorclHredo>I.log B52AC7543 A>> Hu>AHappHoracleHoradataHorclHredo>B.log*n this single instance of the primar' database, we have fo#r redolog gro#ps, each with one member and a si+e of ,-- %.) !e sho#ldcreate at least five standb' redo log gro#ps)>. +dd the standby redo lo#files as shown in the followin# e'ample- SL, alter database add standby logfile group AA $.Hu>AHappHoracleHoradataHorclHstandby/redo>A.log.% size A>>m1 SL, alter database add standby logfile group A0 $.Hu>AHappHoracleHoradataHorclHstandby/redo>0.log.% size A>>m1 SL, alter database add standby logfile group AI $.Hu>AHappHoracleHoradataHorclHstandby/redo>I.log.% size A>>m1 SL, alter database add standby logfile group AB $.Hu>AHappHoracleHoradataHorclHstandby/redo>B.log.% size A>>m1 SL, alter database add standby logfile group AF $.Hu>AHappHoracleHoradataHorclHstandby/redo>F.log.% size A>>m1 ?. &hec the status of new the standby redo lo#files- SL, select group?, bytes, status from #-standby/log1 9RBEFD=>>(2ASS5923* A0A>BEFD=>>(2ASS5923* AIA>BEFD=>>(2ASS5923* ABA>BEFD=>>(2ASS5923* AFA>BEFD=>>(2ASS5923*0hat 1ust happened2 0e%ve completed the optionaltas of creatin# standby redo lo#s on the primary database. +#ain,if thestandby redo lo#s were created on primary, the 6=+F duplicate will create them on standby automatically. -ast recovery area (-&') 4rior to 33g 67, .6+ stood for Flash Recover "rea, but since Oracle Database 33g 67, .6+ stands for FastRecovery "rea. 1t%s a place on the dis where the database automatically mana#es namin#, retention, anddeletionof recovery(relatedfiles. .6+cancontaincontrol files, onlineredolo#files, archivedredolo#s,flashbac lo#s, and 6=+F bacups. 1t%s not mandatory but stron#ly recommended to confi#ure .6+.1n order to enable .6+, you need to set two initiali!ation parameters and you don%t need to shut down andrestart thedatabase. Fotethat, inOracle6+&, theseparametersshouldhavethesamevaluesacrossinstances and the location must be on shared stora#e. ORACLE DATAGUARD ADMINISTRATION 17+i"e or action enabling -&' 4erform the followin# steps on the primary database now. 0e%ll be enablin# .6+ on the standby databaselater. 3. &hec the default .6+ location as follows- SL, sho' parameter db/reco#ery/file/dest 2A+3 7!P3 4AL(3 ------------------------------------ ---------------------- db/reco#ery/file/dest string7. &onfi#ure the .6+ si!e. SL, alter system set db/reco#ery/file/dest/size6Bg1 System altered. 3. &onfi#ure the .6+ destination. SL, alter system set db/reco#ery/file/dest6.Hu>AHappHoracleH flash/reco#ery/area.1 System altered. >. &ontrol the .6+ confi#uration. SL, sho' parameter db/reco#ery/file/dest 2A+34AL(3 ---------------------- ------------------------ db/reco#ery/file/destHu>AHappHoracleHflash/reco#ery/area db/reco#ery/file/dest/size B9*n $A/ databases, #se the ke'word sid0"*" this ens#res that thechange will appl' to all instances in the cl#ster)0hat 1ust happened2 0e%ve enabled the .ast 6ecovery +rea on the primary database, which is not mandatory but a recommendedstep. 0hen preparin# init.ora for a standby instance and startin# this instance in the followin# steps, we%llalsoset .6+(relatedinitiali!ationparametersfor standby,so.6+will alsobeenabledonthestandbydatabase.3nderstanding initiali4ation para"eters 1n the primary database, there are some parameters that are related to the Data Guard confi#uration andneed to be verified or modified. Fow we%re #oin# to loo into the details of these parameters.!hen changing an initiali+ation parameter, if 'o# are #sing a 12*L3,'o# need to edit the file and e(ec#te an AL43$ S5S43% S34 command,parameter0 "val#e" scope0memor', to load the change into the s'stem)*f 'o# #se an S12*L3, 'o# can 6#st e(ec#te the AL43$ S5S43% S34command, parameter0 "val#e" scope0both, which will set the change inmemor' and write it to the S12*L3 to make the change valid at thene(t database restart)D567'*8 The D;JF+=" parameter specifies the database identifier up to ei#ht characters. This parameter must bethe same in all the instances of the 6+& database and also in the physical standby database. This parameteris validated at =O$FT status when the instance reads the control fileC if the D;JF+=" parameter does notmatch the name of the database mentioned in the control file, you will #et the followin# error- KAF>BJ database name .*ummy. does not match parameter db/name .orcl.K in 33g. Dependin# on thenumber of remote destinations and redo activity on the primary database, you may need to increase thevalue. Heep in mind that increasin# the value means more resource usa#e and database start:stop times willalso be affected.*t"s also important to set a s#fficient val#e for L78_A$/9*:3_%A;_1$7/3SS3S on the standb' database for switchover p#rposes, and especiall'if the cascade FD0>I0 db/uni&ue/name6.turkey/un. diagnostic/dest6.Hu>AHappHoracle. fal/ser#er6.52*5A. ? for s'itcho#er purpose instance/name6.7(R@3!. local/listener6.L5S7323R. log/archi#e/dest/A6.LAHappHoracleHoradataHorcl.,.Hu>0HappH oracleHoradataHorcl. memory/target6E00>EIFEB remote/login/pass'ordfile6.3MCL(S543. standby/file/management6.A(7 Production on Sun Aug A0 A0JADJ>A 0>A0 Copyright $c% ACE0, 0>>C, bytes ;i"ed Size 00ADDC0 bytes 4ariable Size F>DFAI>0B bytes *atabase 8uffers I>=AEBAC0 bytes Redo 8uffers 0BE=0D0 bytes SL, select host/name,status from #-instance1 ). The followin# are the 89/GFet confi#urations. 0ith 33g, we can use 6=+F duplicate without the need of primary database bacup. The 6=+Fduplicate usin# the active database feature reads from the ori#inal database files. 1n order to usethis feature, we have to performstatic re#istration of theservice to the listener.To do this,weconfi#ure both the listener and TF8names. The standby database instance must be in theFO=O$FT state before the duplicate command. 1n the FO=O$FT state, the database instance willnot self(re#ister with the listener. +nother item to note is that you must use a dedicated server toconnect when the database is in the FO=O$FT state. ;efore we 5ump into confi#uration, let%s describe static service information. 8tatic service informationis normally not re,uired in thelistener.oraconfi#uration file. 1n order to perform duplicate usin#activedatabasetoconnectinstanceinFO=O$FTstatus, weareusin#staticlistenerentry.Theparameters re,uired for static service information are81DJF+=",G/O;+/JD;F+=", andO6+&/"J2O=". 81DJF+="- The Oracle 81D is the instance identifier, as in the 1F8T+F&"JF+=" parameter of theparameter file G/O;+/JD;F+="- The G/O;+/JD;F+=" parameter is typically a concatenation of the D;JDO=+1Fand D;JF+=" parameters in the parameter file or the same as the 8"6V1&"JF+="8 parameter inthe parameter file O6+&/"J2O="- 1t%s the installation directory of the Oracle database software &onfi#urethelistener andTF8confi#urationonboththeprimaryandstandbydatabases. Thefollowin# is the e'ample of the standby database%s listener.ora confi#uration- ORACLE DATAGUARD ADMINISTRATION 25LISTENER5 6DESCRI2TION5 6ADDRESS3LIST5 6ADDRESS562ROTOCOL5tcp7 6-OST5 orac#e$sty762ORT58(&877 6ADDRESS562ROTOCOL5ipc769EY5e:tproc7777 SID3LIST3LISTENER 5 6SID3LIST 5 6SID3DESC 5 6SID3NAME 5 2LSE:t2roc7 6ORACLE3-OME 5 ;u%8;app;orac#e;product;88A0 ORACLE DATAGUARD ADMINISTRATION 24Copyright $c% ACE0, 0>>C, >A name6Hu>AHappHoracleHoradataH orclHsystem>A.dbf output file name6Hu>0HappHoracleHoradataHorclHsystem>A.dbf tag67A90>A0>D0=7A=>DFA channel >J>AJ>B channel 0HappHoracleHoradataHorclHsystem>A.dbf ... ;inished *uplicate *b at 0=-S(L-A0ORACLE DATAGUARD ADMINISTRATION 28!hen a restore is in progress, 'o# can monitor how m#ch is completeand how m#ch is still pending #sing the *=session3#on1ops view fromthe primar' database)>. &onfi#ure the primary database initiali!ation parameters re,uired for Data Guard. SL, alter system set log/archi#e/dest/06.S3R45C3652*5A L9:R AS!2C4AL5*/;AHappHoracleHoradataHorcl, Hu>0HappHoracleHoradataHorcl?. Verify if theredotransportservice isactiveusin#thevImana#edJstandbyviewon the standbydatabase- SL, S3L3C7 7)R3A*?,S3(32C3?,PR>7/ILM 6L*@R D6*6G6/@ R@2G 9ount the standb$ database and start re%o#er$ at this sta!e)14) 1o' et's tr$ to %han!e the data prote%tion (ode to 9a:i(u( 6#aiabiit$ as sho'n in the foo'in! Auer$3 /ILM 6L*@R D6*6G6/@ /@* /*61DG0 D6*6G6/@ *< 96NI9I=@ 6K6IL6GILI*07 Database atered) 15) It's possibe to perfor( this prote%tion (ode %han!e 'ithout puttin! the pri(ar$ database in the (ount state) We %an see the %han!e in the standb$ database aert o! as foo's3 2ri/ary dataase is in MASIMUM A.AILA4ILITY /ode Chan1in1 standy contro#Q#e to MASIMUM A.AILA4ILITY /ode Standy contro#Q#e consistent with pri/ary 16) *r$ to shut do'n the standb$ database as sho'n in the foo'in! Auer$3 /ILM /-E*D83 database not open Database dis(ounted) 3>>3>> 1>?1>?2>12 153>7351 app$ a! C>> >>3>>3>> 1>?1>?2>12 153>7351 app$ &nish ti(e C>> >>3>>3>> 1>?1>?2>12 153>7351 ORACLE DATAGUARD ADMINISTRATION 45esti(ated startup ti(e 16 1>?1>?2>12 153>7351 /ILM Vdate Wed 153>7352 I/* 2>128) @nsure that no ba%5up Wobs are runnin!) Disabe the R961 and @N;?@N;D; ba%5up Wobsfro( 2R) If the pri(ar$ and standb$ databases are (onitored 'ith @9 2oud?Grid 2ontro and $ou're perfor(in! s'it%ho#er usin! /ILD;us or Data Guard bro5er, ba%5 out the database unti the tas5 is %o(peted) 11) /et the X>' ID %:CeFc'Ce> dest 8) >E ID %:CeFc'Ce> dest 8) % &%8& Thread 8 ad*anced to #o1 se+uence C'& 6LGHR switch7 Current #o1D 8 se+D C'& /e/D %) ;u%8;app;orac#e;oradata;orc#; redo%8>7 2>87152 ro's %reated) /ILM %o((it7 2o((it %o(pete) /ILM see%t %ount+D, fro( pa%5t)ora%e7 24>1821) /hut do'n the database and put it in the 9 Bro( step 1, the nu(ber of ro's inserted are 2>87152, and after perfor(in! a Qashba%5 to the restore point, a the ne'$ inserted ro's 'i be re#erted)Data Guard "rchitecture 4racle 11g Part-C4racle Data Guard is the most effective and comprehensive data availability, data protection anddisaster recovery solution for enterprise databases. 1t provides a method for customers to actively utili!etheir disaster recovery confi#uration for read(only ,ueries and reports while it is in standby role. +dditionally,a standby database can be used to offload bacups from production databases or for 9uality +ssurance andother test activities that re,uire read(write access to an e'act replica of production.These capabilities areuni,ue to Oracle .ORACLE DATAGUARD ADMINISTRATION 64Oracle Data Guardis the mana#ement, monitorin#, and automation software infrastructurethatcreates, maintains, andmonitors oneor more standbydatabases to protect enterprise data from failures, disasters, errors, and corruptions. Data Guard is basically a ship redo and then apply redo, as wenow redo is the information needed to recover a database transaction. + production database referred to asa primary database transmits redo to one or more independent replicas referred to as standby databases.8tandby databases are in a continuous state of recovery, validatin# and applyin# redo to maintainsynchroni!ation with the primary database. + standby database will also automatically re(synchroni!e if itbecomes temporary disconnected to the primary due to power outa#es, networ problems, etc.The dia#ram below shows the overview of Data Guard, firstly the redo transport services transmits redo datafrom the primary to the standby as it is #enerated, secondly services apply the redo data and update thestandby database files, thirdly independently of Data Guard the database writer process updates the primarydatabase files and lastly Data Guard will automatically re(synchroni!e the standby database followin# poweror networ outa#es usin# redo data that has been archived at the primary.6edo records contain all the information needed to reconstruct chan#es made to a database. Durin# recoverythe database will read the chan#e vectors in the redorecords and apply the chan#es to the relevantblocs. 6edorecords arebufferedin a circular fashion inthe redo lo#bufferof the 8G+, thelo#writer process )/G06*is the bac#roundprocess that handlesredolo#buffer mana#ement. The/G06atspecific times writes redo lo# entries into a se,uential file )online redo lo# file* to free space in the buffer,the /G06 writes the followin#.1.) " commit record ! 0henever a transaction is committed the /G06 writes the transaction redo recordsfrom thebuffer tothelo#fileandassi#nsasystemchan#enumber )8&F*, onlywhenthisprocessiscomplete isthe transaction said to be committed.,.) Redo log &uffers!1f the redo lo# becomes a third full or if 3 seconds have passed sine the last timethe /G06 wrote to the lo# file, all redo entries in the buffer will be written to the lo# file. This means thatredo records can be written to the lo# file before the transaction has been committed and if necessary mediarecovery will rollbac these chan#es usin# undo that is also part of the redo entry.6emember that the /G06 can write to the lo# file usin# A#roupA commits, basically entire list of redo entriesof waitin# transactions )not yet committed* can be written to dis in one operation, thus reducin# 1:O. "venthrou#h the data buffer cache has not been written to dis, Oracle #uarantees that no transaction will be lostdue to the redo lo# havin# successfully saved any chan#es.Data Guard Redo *ransport Services coordinate the transmission of redo from the primary database tothe standby database, at the same time the /G06 is processin# redo, a separate Data Guard process calledthe /o# Fetwor 8erver )/F8* is readin# from the redo buffer in the 8G+ and passes redo to Oracle Fet8ervices from transmission to a standby database, it is possible to direct the redo data to nine standbydatabases, we can also use Oracle 6+& and they don%t all need to be a 6+& setup. The process 6emote .ile8erver )6.8* receives theredo from /F8 and writes it to a se,uential file called a standby redolo# file)86/*.ORACLE DATAGUARD ADMINISTRATION 68Data Guard +rchitecture Oracle 33# 4art(1103S )lo#(writenetwor(server* and "R1G )archiver* processesrunnin#ontheprimarydatabaseselectarchived redo lo#s and send them to the standby database, where the RFS )remote file server* bac#roundprocess within the Oracle instance performs the tas of receivin# archived redo(lo#s ori#inatin# from theprimary database .The 03S process support two modes as1.) Synchronous and,.) "synchronous.1.) Synchronous Mode ! 8ynchronous transport )8Jero data loss> methodbecause the /G06 is not allowed to acnowled#e a commit has succeeded until the /F8 can confirm that theredo needed to recover the transaction has been written at the standby site. 1n the below dia#ram, thephases of a transaction are! ORACLE DATAGUARD ADMINISTRATION 7>The user commits a transaction creatin# a redo record in the 8G+, the /G06 reads the redo record from thelo# buffer and writes it to the online redo lo# file and waits for confirmation from the /F8. The /F8 reads thesame redo record from the buffer and transmits it to the standby database usin# Oracle Fet 8ervices, the6.8 receives the redo at the standby database and writes it to the 86/. 0hen the 6.8 receives a writecomplete from the dis, it transmits an acnowled#ment bac to the /F8 process on the primary databasewhichinturnsnotifiesthe/G06that thetransmissioniscompleteC the/G06thensendsacommitacnowled#ment to the user.This setup really does depend on networ performance and can have a dramatic impact on the primarydatabasesC low latency on the networ will have a bi# impact on response times. The impact can be seen inthe wait event A/F8 wait on 8"FD6"9A found in the vFsystem select group?, bytes, .online. as type from #-logCunionJselect group?, bytes, .standby. as type from #-standby/logKorder by [email protected] 4513EEEEEEEEEE EEEEEEEEEE EEEEEEE ,,-KNDOP-- 7&L*&3 C,-KNDOP-- 7&L*&3 J,-KNDOP-- 7&L*&3 K,-KNDOP-- S4A& alter database open1.or =a'imum +vailability mode-SQL> alter database set standby database to ma"imize a#ailability1SQL> alter database open17. 9uery the data dictionary on the primary database to verify the new protection mode-SQL> S3L3C7 PR alter database add standby logfile group = size A>>m1SQL> alter database add standby logfile group D size A>>m1H:erif' new standb' redo logs on primar' databaseISQL> select group?, bytes, .online. as type from #-logCunionJselect group?, bytes, .standby. as type from #-standby/logKorder by [email protected] 4513EEEEEEEEEE EEEEEEEEEE EEEEEEE ,,-KNDOP-- 7&L*&3 C,-KNDOP-- 7&L*&3ORACLE DATAGUARD ADMINISTRATION 41 J,-KNDOP-- 7&L*&3 K,-KNDOP-- S4A& connect sysHchange/on/installOtestdb/#mlinu"I.ide#elopment.info as sysdbaSQL> shutdo'n immediateSQL> startup mountH/onnect to the standb' databaseISQL> connect sysHchange/on/installOtestdb/#mlinu"B.ide#elopment.info as sysdbaSQL> alter database reco#er managed standby database cancel1SQL> shutdo'n immediateSQL> startup nomountSQL> alter database mount standby database1>. Down#rade the primary database to the desired protection mode-ORACLE DATAGUARD ADMINISTRATION 42H/onnect to the primar' databaseISQL> connect sysHchange/on/installOtestdb/#mlinu"I.ide#elopment.info as sysdbaH2or %a(im#m 1erformance modeISQL> alter database set standby database to ma"imize performance1H2or %a(im#m Availabilit' modeISQL> alter database set standby database to ma"imize a#ailability1?. ;oth of the hi#her protection modes )=a'imum +vailability and =a'imum 4rotection* re,uire the useof standby redo lo#s on the destination standby database. 1t you were to down#rade from =a'imum4rotection mode to =a'imum +vailability mode, you would need to eep the standby redo lo#s thate'ist for the standby database. 1f down#radin# to =a'imum 4erformance mode, you can drop thestandby redo lo#s from the standby unless you are #oin# to be confi#urin# lo# transport services touse /G06. .or this e'ample, 1 am #oin# to be down#radin# to ma'imum performance mode andusin# +6&2 for lo#transport servicesandcanthereforedropanystandbyredolo#sfromthestandby database )and the primary if they e'ist*-H/onnect to the standb' databaseISQL> connect sysHchange/on/installOtestdb/#mlinu"B.ide#elopment.info as sysdbaH connect sysHchange/on/installOtestdb/#mlinu"I.ide#elopment.info as sysdbaH connect sysHchange/on/installOtestdb/#mlinu"B.ide#elopment.info as sysdbaSQL> alter database reco#er managed standby database disconnect from session1H/onnect to the primar' databaseISQL> connect sysHchange/on/installOtestdb/#mlinu"I.ide#elopment.info as sysdbaSQL> alter database open1ORACLE DATAGUARD ADMINISTRATION 43@. 9uery the data dictionary on the primary database to verify the new protection mode-SQL> select protection/mode, protection/le#el, database/role from #-database11$743/4*7&_%7 ,TNC, C-,,, 7racle)All rights reserved)/onnected to an idle instance)SL, select instance/name,status,database/role from #-database,#-instance1 *&S4A&/3_&A%3S4A4@S 3/o#ical 8tandby Databases are lo#ically identical to primary databases althou#h the physical or#ani!ationand structure of the data can be different. /o#ical 8tandby Databases are updated usin# 89/statements. /o#ical standby database can be used for recovery and reportin# simultaneously. Determine ifthe primary database contains tables and datatypes that were not supported by a lo#ical stand by database.1f the primary database contains tables that were unsupported, lo# apply services will e'clude the tablesapplyin# to the lo#ical stand by database. 6un the followin# ,ueries to see unsupported tables. select * from 61. K1stanbulL 1f the primary database is accessible and runnin#, then it must providedto send redo buffer tothe standby database.SQL> alter s'stem fl#sh redo to standb'_db_nameSQL>alter s'stem archive log c#rrent1f you donSt receive an error, you can continue with step ?th. 1n this case, the system can be opened by !erodata loss. 1f you receive an error, 0e continue with step 7 to open the system at least data loss.,. K;auL 0e must run the followin# ,uery to learn last applied archive lo# se,uence number.SQL> S3L3/4 @&*Q@3 49$3A AS LAS4from :$A$/9*:3 alter database register ph'sical logfile "?oracle?ora,,g?dbs?arch?4AL*1_TT,NJKK,J_,_,-C)arc "$. K;auL &hec the standby database for redo #ap. 1f there is a #ap then we must copy archive lo# files andre#ister.SQL> S3L3/4 49$3A alter database register ph'sical logfile "?oracle?ora,,g?dbs?arch?4AL*1_TT,NJKK,J_,_,-,)arc "+s a result of the above ,uery until it returns to !ero.N. K;auL 8top the redo apply process in standby database.SQL> AL43$ $o, now ( have control file for +hysical $tandby database and (Bm able to start ,anaged 2ecovery and ( thin! that it is much easierC)uic!er than using standard procedure or ma!ing new standby control file on primary, copying it to standby host, restoring, etc.+hysical $tandby out of sync DSo Ph+sical Sand,+ o# of s+nc EEhen you are using Data guard, there are several scenarios when physical standby can go out of sync with the primary database.#efore doing anything to correct the problem, we need to verify that why standby is not in sync with the primary. (n this particular article, we are covering the scenario where a log is missing from the standby but apart from the missing log, all logs are available.6erify from v$archived_log that there is a gap in the se)uence number. All the logs up to that gap should have A++&(3DF43$ and all the se)uenceG after the missing log se)uenceG are A++&(3DFH/. "his means that due to the missing log, ,2+ is not applying the logs on standby but the logs are still being transmitted to the standby and are available.$%&= $3&35" $3%I3H53G, A++&(3D F2/, 6JA25K(63D@&/G?$o for e-ample, if the missing log se)uenceG is '99, then the above )uery should show that up to se)uenceGLL, all have A++&(3DF43$ and starting from '9:, all are A++&(3DFH/."here are few steps to be performed when the standby is not in sync with the primary because there is a gap of logs on standby."hese steps are*S('P F/< "a!e an incremental bac!up of primary from the $5H where standby is lagging behind and apply on the standby serverS('P F0< (f stepG: is not able to sync up, then re-create the controlfile of standby database from the primaryS('P F3< (f after stepG2, you still find that logs are not being applied on the standby, chec! the alert log and you may need to re-register the logs with the standby database.GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGS('PF/:. /n $"AHD#4 database )uery the v$database view and record the current $5H of the standby database*$%&= $3&35" 5I223H"@$5H F2/, 6JDA"A#A$3?5I223H"@$5H-----------:.L' cop' datafile D to "?ora?back#p?addnew)dbf"$se scp or other means, transfer the datafile to the standby server )for e'ample to :ora:standbyJdb: location- scp Ep ?ora?back#p?addnew)dbf oracleWstandb'_server_ip_or_name:?ora?standb'_db?*.&onnect the standby database throu#h 6=+F and catalo# the datafile that you copied in the above steprman> catalog ?ora?standb'_db?addnew)dbfrman> switch datafile to cop'33. +nd once everythin# is verified a#ain put it bac into mana#ed recovery modeSQL> AL43$