Académique Documents
Professionnel Documents
Culture Documents
Quick Guide to configuring Oracle 11gR2 Data Guard Physical Standby Part I
Author: Jed Walker is the Manager of Database Operations for the Comcast Media Center in Centennial Colorado. He has been orking ith Oracle Database since 1!!" and is an Oracle Certified #rofessional for !i$ 1%g$ and 11g Database.
Table of Contents
Table of Contents
&ntroduction..............................................................................................................................................................' Wh( )se Data *uard+.............................................................................................................................................' ,(stem ,etup............................................................................................................................................................' -he .asic ,tuff$ that & shouldn/t ha0e to mention...................................................................................................1 #reparing the #rimar( for Data *uard.....................................................................................................................1 )se 2lashback Database..........................................................................................................................................3 ,er0er ,45678- Configuration.............................................................................................................................9 Configuring :edo -ransport...................................................................................................................................." #reparing the ,tandb( en0ironment.........................................................................................................................; Creating the ,tandb( Database..............................................................................................................................1% ,tarting :edo Appl( on the ,tandb(.....................................................................................................................11 <erif(ing that :edo Appl( is orking...................................................................................................................1= Conclusion.............................................................................................................................................................1'
'
Introduction
Data *uard is an Oracle feature that primaril( pro0ides database redundanc(. -his is done b( ha0ing a standb( >ph(sical cop(? database$ preferabl( in another location and on separate disk. -his standb( database is maintained b( appl(ing the changes from the primar( database to it. ,tandb( databases can be maintained ith either :edo >#h(sical standb(? or ,45 >5ogical standb(?. M( intention ith this paper is primaril( to sho that configuring Data *uard is not comple@$ and does not reAuire an( special skills or training to accomplish. &t ill step the reader Auickl( through the process of configuring a #h(sical ,tandb( database for database redundanc( of the primar( s(stem. M( hope is that if (ou/re ne to Data *uard$ Bust considering it$ or orried that it is too hard to setup$ this paper ill help (ou Auickl( through the process and get (ou up and running. &f (ou find mistakes$ additional important notes or considerations$ please let me kno .
Syste# Setu$
2or this particular e@ample$ & ill detail the en0ironment a bit so (ou kno hat &/m orking ith. After riting the paper & used D.)A to create a brandCne database called J8D and reCran these steps to ensure that on a basic Oracle 11g database this ould ork. -he #rimar( database is called J8D and resides on a ser0er called de0Cdb1. -he ph(sical standb( ill be called J8D= and reside on a ser0er called de0Cdb=.
&n the 2O:C8E5O**&7* column (ou should no see D8,. 7e@t e/ll make sure that hen e add or drop datafiles on our primar( database$ that those files are also added or dropped on the standb(. -his is done ith:
3
SQL> alter s!stem set standb!_file_management " #A$%&#;
Once this is done$ e need to make sure the primar( database has ,tandb( 5og 2iles. ,tandb( 5og 2iles are used b( a standb( database to store the redo it recei0es from the primar( database. & create these on the primar( for t o reasons$ 1? it ma( become a standb( later and ould then need them$ =? hen e create the standb( the( ill be created as part of that process. ,tandb( log files should be created the same siFe as the online logfiles. #referabl( (ou should ha0e as man($ or more$ standb( logfile groups as online logfile groups. -o easil( differentiate them in the <G 0ie s$ & like to number m( standb( logfile groups so the( are in a different range from online logfiles >e.g. online logfile groups ould be 1C9$ standb( logfile groups ould be 11C19?. -o create a standb( logfile group:
alter database add standb! logfile group '' (#)oradata)*+D)g''m,'-sdo#,#)oradata)*+D)g''m,.-sdo#/ si0e 1.2.33,,,;
&f (ou are not using ,,5 for :edo -ransport >likel( (ou aren/t?$ then (ou ill need to use Oracle pass ord file authentication. 2or this (ou must create a pass ord file and ha0e :8MO-8E5O*&7E#A,,WO:D2&58 set to 8HC5),&<8 or ,HA:8D. &t is likel( this is alread( done so check first$ but if not:
SQL> alter s!stem set remote_login_passwordfile"e4clusive scope"spfile; >and bounce? &S> orapwd password"5the s!s password>
Dou should also make sure (our primar( database has the dbEuniAueEname parameter set for consistenc(.
SQL> show parameter db_uni6ue_name
&f it isn/t set correctl( for some reason$ (ou can change it 0ia the A5-8: ,D,-8M command.
7o that (ou ha0e the 2ast :eco0er( Area configured (ou need to turn on 2lashback 5ogging. -o do this:
SQL> alter database flashbac; on;
9
SQL> select flashbac;_on from v database;
<erif( that the 25A,H.ACMEO7 column is D8,. &f (ou got the error J O:AC%113': an incompatible media reco0er( is acti0eJ then (ou are likel( doing this on a standb( and need to cancel managed reco0er( and tr( again. Don/t forget to restart managed reco0er( hen (ou/re done. DO 7O- *8- .):78DN & disco0ered after a failo0er$ that turning flashback on 0ia Ialter databaseJ does not propagate to (our standb( databases ith the redo >like man( other things?. Dou M),- run the alter database command on each of (our standb( databases. &f (ou ha0en/t done this (ou/ll find later that (ou can/t flashback after a failo0er and ill ha0e to completel( rebuild (our old primar( to make it a standb(.
-7, 7ames
"
(ADD:+SS_L<S% " (ADD:+SS " (B:&%&>&L " %>B/(A&S% " devCdb./ (B&:% " '1.'// / (>&==+>%_DA%A " (S+:D<>+_=AM+ " *+D./ (S+:D+: " D+D<>A%+D/ / / / &S> lsnrctl reload &S> tnsping *+D 5should return &E> / (ADD:+SS_L<S% " (ADD:+SS " (B:&%&>&L " %>B/(A&S% " devC db'/(B&:% " '1.'// / (>&==+>%_DA%A " (S+:D<>+_=AM+ " *+D/ (S+:D+: " D+D<>A%+D/
-esting
-his statement sa(s to use the D.E:8CO<8:DE2&58ED8,- as the location to archi0e to$ that it should be used to archi0e all logfiles in an( >all? roles$ and that this is for the database J8D. -he manual sa(s to use onlineElogfilesP ho e0er$ this ill result in the ,tandb( being unable to archi0e the standb( logfiles because the( are not online logfiles. &f (ou use allElogfiles both the primar( and standb( ill be able to archi0e logfiles hether the( are online or standb(. Dou/ll ant this if (ou/re backing up on the standb( and ant to ha0e archi0ed logfiles backed up there too. Dou could configure this to archi0e onl( on the primar( or onl( on the standb( if (ou/d like. 7e@t e configure the transport of the redo to the ,tandb( database.
SQL> alter s!stem set log_archive_dest_. " #service"*+D. as!nc valid_for"(online_logfile,primar!_role/ db_uni6ue_name"*+D.#;
-his statement sa(s that if it is the primar( database$ it should transport online logfiles using the ser0ice name J8D= and that the target is the database J8D=.
; At this point$ & should note that the ,-A7D.DEA:CH&<8ED8,- parameter is deprecated and not needed. While troubleshooting & had man( ellCintentioned suggestions to add this parameter$ but about all (ou/ll get from it is IO:AC'=%%1: obsolete or deprecated parameter>s? specified for :D.M, instanceJ hen (ou start (our database. -he ne@t parameter is 2A5E,8:<8:. -his specifies here the database should look for missing archi0e logs if there is a gap in the logs. &t is used hen the database is in the standb( role and has a gap in the redo it has recei0ed. -his t(pe of situation occurs hen redo transport is interrupted$ for e@ample hen (ou do maintenance on the standb( ser0er. During that maintenance no logs ould ha0e been transported and a gap ould e@ist. ,etting this parameter allo s the standb( to find the missing redo and ha0e it transported.
SQL> alter s!stem set fal_server " #*+D.#;
7ote that the 2A5EC5&87- parameter is deprecated in 11g and not needed. We then need to let the database kno hat other databases are in the Data *uard configuration.
Once this is done$ e are read( to prepare the en0ironment for the standb( and create the standb(.
7o $ before & continue & ant to discuss a seemingl( nice feature O creation of the ,#2&58 0ia :MA7. -his feature is designed to allo (ou to let :MA7 create (our spfile for (ou on (our standb( location. Here is h( & don/t use it. 1. & ha0e to cop( the pass ord file o0er to the standb( an( a($ so it doesn/t sa0e me ha0ing to cop( files o0er. =. -o use this feature (ou still ha0e to do a lot of replacement ork b( setting the parameterE0alueEcon0ert parameter and the ,#2&58 clause and the 0arious ,8- statements to make sure e0er(thing is correct.
! & find it easier to cop( a pfile o0er >(ou can e0en Bust cut and paste?$ rename it$ and then change the parameters in it. -his is eas( to do and (ou/ll learn a lot b( re0ie ing e0er(thing and making sure it is correct. & spend less time doing this and fi@ing things than going through the :MA7 ,#2&58 creation. ,o$ ith that saidQ After creating (our primar( pfile$ cop( it o0er to the standb( ser0er in the same location$ but change the name to ha0e the standb( ,&D >e.g. initJ8D.ora ill become initJ8D=.ora?. Dou ill no need to make the follo ing changes to it >and note that in (our situation there might be others$ re0ie (our pfile carefull(?: Depending on (our configuration and file locations on the standb( (ou might needed to change the A)D&-E2&58ED8,-$ CO7-:O5E2&58, and D&,#A-CH8:, parameters >there ma( be others$ but be careful$ not e0er(thing should be changed this a(?. &n 5O*EA:CH&<8ED8,-E1 change dbEuniAueEname to the standb( ,&D >in this case J8D=?. &n 5O*EA:CH&<8ED8,-E= change the ser0ice and dbEuniAueEname to the primar( ,&D >in this case J8D?. Change 2A5E,8:<8: to the primar( ,&D >J8D?. Add the follo ing parameters: o dbEuniAueEnameRJ8D= o dbEfileEnameEcon0ert and logEfileEnameEcon0ert if (ou are changing the location of the datafiles andKor logfiles. & like to do this to make it ob0ious hose datafiles the( are >e.g. KoradataKJ8D 0ersus KoradataKJ8D= b( using dbEfileEnameEcon0ertRKoradataKJ8D/$/KoradataKJ8D=/? 7o $ on (our standb( ser0er create the director( structures and modif( files to support the ne database. -hese should at least be: GO:AC58E.A,8KadminKGO:AC58E,&D GO:AC58E.A,8KadminKGO:AC58E,&DKadump >or hate0er (our auditEfileEdest is? Datafile directories Controlfile directories 5ogfile directories D. :eco0er( 2ile Destination >2ast :eco0er( Area? Add (our standb( to the KetcKoratab file.
Dou should no be read( to startup (our standb( instance for creation of the database. Dou also ant to make sure (ou create an spfile in the process. -o do this:
1%
SQL> startup nomount pfile"5&:A>L+_A&M+>)dbs)init*+D.-ora SQL> create spfile from pfile; SQL> shutdown SQL> startup nomount SQL> show parameter spfile SQL> e4it
-he Isho parameter spfileJ should sho the location of (our spfile$ and (our standb( should be in 7OMO)7-.
As of 11.=.%.=.% (ou can connect to the target ith Iconnect targetJP ho e0er$ if (ou don/t specif( the username a duplication to standb( ill fail later ith Iin0alid usernameKpass ordJ.
While this command is running & like to tail the standb( alert log and see hat is going and atch for errors. 7ote that it is normal and OM to get IO:AC="%'": unable to obtain file statusJ on the online and standb( log files. -o perform the duplication in parallel to impro0e performance (ou can allocate primar( and standb( channels and then run the duplicate command.
11
run G allocate channel chan' t!pe dis;; allocate channel chan. t!pe dis;; allocate channel chanH t!pe dis;; allocate channel chan2 t!pe dis;; allocate au4iliar! channel au4' t!pe dis;; allocate au4iliar! channel au4. t!pe dis;; allocate au4iliar! channel au4H t!pe dis;; allocate au4iliar! channel au42 t!pe dis;; duplicate target database for standb! from active database ; I
&f e0er(thing orks (ou should see something similar to the follo ing in :MA7:
9inished Duplicate Db at ,JCMAKC',
&t is at this point that & like to turn on flashback logging for the standb(:
SQL> alter database flashbac; on;
-his starts the reco0er( process using the standb( logfiles that the primar( is riting the redo to. &t also tells the standb( to return (ou to the ,45 command line once the command is complete. &f (ou ant to stop the reco0er( (ou do:
SQL> AL%+: DA%A@AS+ :+>&D+: MA=A?+D S%A=D@K DA%A@AS+ >A=>+L;
1=
-he destinations should sho as <A5&D. 7o $ e/ll see if the redo is actuall( being applied. 2rom the primar( run:
SQL> select S+Q$+=>+L, 9<:S%_%<M+, =+M%_%<M+, ABBL<+D, A:>A<D+D from D A:>A<D+D_L&? where name " #*+D.# order b! 9<:S%_%<M+;
Dou should see D8, for the A##5&8D and A:CH&<8D columns if both archi0ing and redo appl( are orking correctl(. Man( e@amples of this Auer( use Iorder b( ,84)87C8SJ$ but & don/t recommend this. &f (ou order b( ,84)87C8S and then do a failo0er the seAuence numbers ill start again at 1 and (ou on/t see (our latest records at the end of the resultCset. -he first time & did this & could not figure out h( & asn/t getting an( ne ro s for archi0ed redo. &n fact$ & as$ but & Bust asn/t seeing them. As a result$ & al a(s order this Auer( b( 2&:,-E-&M8. &f (ou notice that logs aren/t appl(ing$ it is possible (ou might ha0e a gap in (our redo$ in hich case the standb( cannot appl(. &f (ou ha0e the 2A5E,8:<8: parameter set correctl($ this shouldn/t be a problem. Dou can check to see if there are an( gaps in the redo$ b( running the follo ing Auer( on the primar(:
SQL> select S%A%$S, ?AB_S%A%$S from D A:>A<D+_D+S%_S%A%$S where D+S%_<D " .;
&t should return <A5&D and 7O *A# if e0er(thing is OM. &f (ou ant to pla( around ith this and see ho the 2A5E,8:<8: orks (ou can shutdo n (our standb($ s itch out se0eral logs$ ait a bit$ bring (our standb( back up$ and s itch another log out. Dou should soon see a *A# appear. &f (our 2A5E,8:<8: parameter is correct on the standb( and points to the ser0ice name of the primar($ then the logs should be brought o0er and applied. -he <GDA-A*)A:DE,-A-), 0ie is 0er( useful for looking for errors or Bust seeing hat has happened. Dou can Auer( it on the primar( and standb( to see status for that database.
SQL> select N from D DA%A?$A:D_S%A%$S order b! %<M+S%AMB;
All of this is good$ but sometimes (ou ant to reall( kno the data is there. A more reassuring a( to 0erif( is to actuall( check the standb( and 0erif( that the ne data is there. Dou can do this b( changing the standb(/s role to readonl(. 2irst (ou/ll need to stop managed reco0er( and then run:
SQL> AL%+: DA%A@AS+ &B+= :+AD &=LK;
1' Dou can no run (our Auer( to see that the changes ha0e come across. When (ou/re done$ do not forget to take (our database back to MO)7- and restart reco0er(. &n #art &&$ (ou/ll find out ho (ou can do this t(pe of check more easil( ith Oracle 11g Acti0e Data *uard.
Conclusion
At this point (ou no ha0e a Data *uard Configuration orking and therefore a redundant cop( of (our database a0ailable. & don/t ant to lea0e (ou ithout going through s itcho0er$ failo0er$ rebuilding$ and other items$ but that ill ha0e to ait until #art && of this paper. .esides$ if (ou got this done then & need some a( to bring (ou back for moreN & hope this paper helps (ou get (our Data *uard configuration set up easil( and Auickl(.