Documente Academic
Documente Profesional
Documente Cultură
This guide is a quick-reference guide for Recovery Manager (RMAN), Oracle's utility to anage all of the Oracle data!ase !acku" and recovery activities# This guide is not a co "rehensive !acku" and recovery !ook# $t contains an overvie% of RMAN architecture, sho%s !riefly ho% to !acku" and restore data!ases using RMAN, descri!es catalog setu" issues, and "rovides quick-reference synta& diagra s of RMAN co ands# The "ur"ose of this guide is to hel" you quickly find the synta& for, and use, RMAN co ands to !ack u", restore, and recover a data!ase# 'e also "oint out that the !atch ode e&a "les in this guide are scri"ted %ith (ni& shell scri"ts# Many of these e&a "les contain (ni& "aths that are a""ro"riate for our environ ent# $f you are develo"ing your o%n set of scri"ts, you %ill %ant to change the e&a "les to reflect your o%n environ ent# The real success of a !acku" de"ends on ho% effectively you can restore the data!ases fro these !acku"s# )evelo" recovery scri"ts and ake sure to test and "ractice the different recovery scenarios# After a ne% incarnation of a data!ase is created, ake sure to run a full !acku" of the data!ase# Also, ake sure to run a full e&"ort of the data!ase once the data!ase is recovered# $t %ill go through all the data!ase !locks and is a good %ay to check %hether there are still corru"t datafiles# Which Files must be backed up? All files in the grey area !elo% ust !e !acked u"#
o o o o o
)ata!ase *iles (%ith RMAN) +ontrol *iles (%ith RMAN) Offline Redolog *iles (%ith RMAN) $N$T#ORA ( anually) ,ass%ord *iles ( anually)
Note that the Online Redolog *iles are not !acked u" The "ara eter file $N$T#ORA and the "ass%ord file ust !e !acked u" anually#
RMAN Architecture
Recovery Manager (RMAN) is a utility that can anage all of your Oracle !acku" and recovery activities# ).As are often %ary of using RMAN !ecause of its "erceived co "le&ity and its control over "erfor ing critical tasks# The traditional !acku" and recovery ethods are tried-and-true# Thus, %hen your livelihood de"ends on your a!ility to !ack u" and recover the data!ase, %hy i "le ent a technology like RMAN/ The reason is that RMAN co es %ith several !enefits0 o o o o o o $ncre ental !acku"s that only co"y data !locks that have changed since the last !acku"# Tablespaces are not put in backup mode, thus there is no e&tra redo log generation during online !acku"s# )etection of corru"t !locks during !acku"s# ,aralleli1ation of $2O o"erations# Auto atic logging of all !acku" and recovery o"erations# .uilt-in re"orting and listing co ands#
RMAN's architecture is a co !ination of an e&ecuta!le "rogra (the RMAN utility) and !ackground "rocesses that interact %ith one or ore data!ases and %ith $2O devices# There are several key architectural co "onents to !e a%are of0 o o o o o o o RMAN e&ecuta!le 3erver "rocesses +hannels Target data!ase Recovery catalog data!ase (o"tional) Media anage ent layer (o"tional) .acku"s, !acku" sets, and !acku" "ieces
RMAN !ecutable
The RMAN e&ecuta!le, usually na ed rman, is the "rogra that anages all !acku" and recovery o"erations# 4ou interact %ith the RMAN e&ecuta!le to s"ecify !acku" and recovery o"erations you %ant to "erfor # The e&ecuta!le then interacts %ith the target data!ase, starts the necessary server "rocesses, and "erfor s the o"erations that you requested# *inally, the RMAN e&ecuta!le records those o"erations in the target data!ase's control file and the recovery catalog data!ase, if you have one#
Server "rocesses
RMAN server "rocesses are !ackground "rocesses, started on the server, used to co unicate !et%een RMAN and the
data!ases# They can also co unicate !et%een RMAN and any disk, ta"e, or other $2O devices# RMAN server "rocesses do all the real %ork for a !acku" or restore o"eration, and a ty"ical !acku" or restore o"eration results in several server "rocesses !eing started# 3erver "rocesses are started under the follo%ing conditions0 o o o 'hen you start RMAN and connect to your target data!ase 'hen you connect to your catalog -- if you are using a recovery catalog data!ase 'hen you allocate and o"en an $2O channel during a !acku" or recovery o"eration
#hannels
A channel is an RMAN server "rocess started %hen there is a need to co unicate %ith an $2O device, such as a disk or a ta"e# A channel is %hat reads and %rites RMAN !acku" files# Any ti e you issue an RMAN allocate channel command, a server "rocess is started on the target data!ase server# $t is through the allocation of channels that you govern $2O characteristics such as0 o o o o o Ty"e of $2O device !eing read or %ritten to, either a disk or an s!t5ta"e Nu !er of "rocesses si ultaneously accessing an $2O device Ma&i u si1e of files created on $2O devices Ma&i u rate at %hich data!ase files are read Ma&i u nu !er of files o"en at a ti e
Tar$et %atabase
The target data!ase is the data!ase on %hich RMAN "erfor s !acku", restore, and recovery o"erations# This is the data!ase that o%ns the datafiles, control files, and archived redo files that are !acked u", restored, or recovered# Note that RMAN does not back up the online redo lo$s o& the tar$et database #
The catalog is ty"ically a data!ase that you !uild on a different host fro your target data!ase# The reason for this is that you don't %ant a failure on the target host to affect your a!ility to use the catalog# $f !oth the catalog and target are on the sa e !o&, a single edia failure can "ut you in a situation fro %hich you can't recover your target data!ase# $nside the catalog data!ase is a s"ecial sche a containing the ta!les that store infor ation a!out RMAN !acku" and recovery activities# This includes infor ation such as0 o o o )etails a!out the "hysical structure of the target data!ase A log of !acku" o"erations "erfor ed on the target data!ase's datafiles, control files, and archived redo log files 3tored scri"ts containing frequently used sequences of RMAN co ands
'hy is the catalog o"tional/ 'hen RMAN "erfor s any !acku" o"eration, it writes in&ormation about that task to the tar$et database(s control &iles) Therefore, RMAN does not need a catalog to o"erate# $f you choose to i "le ent a
recovery catalog data!ase, then RMAN %ill store additional infor ation a!out %hat %as !acked u" -- often called -- in the catalog#
etadata
The "ri ary reason for i "le enting a catalog is that it ena!les the greatest fle&i!ility in !acku" and recovery scenarios# (sing a catalog gives you access to a longer history of !acku"s and allo%s you to anage all of your !acku" and recovery o"erations fro one re"ository# (tili1ing a catalog akes availa!le to you all the features of RMAN# *or reasons such as these, %e reco end using a catalog data!ase#
'hen !acking u" files to ta"e, an MM7 kee"s track of %hich files %ere %ritten to %hich ta"es# $n the event that restoration of a data!ase file is required, RMAN co unicates to the MM7 a list of the !acku" files that are required to restore the data!ase file# The MM7 then deter ines %hich ta"es contain the required !acku" files, retrieves the requested !acku" files, and "asses the !ack to RMAN8 RMAN then restores the data!ase file#
o o o
A datafile can s"an !acku" "ieces as long as it stays %ithin one !acku" set# )atafiles and control files can coe&ist in the sa e !acku" sets# Archived redo log files are never in the sa e !acku" set as datafiles or control files#
RMAN is the only tool that can o"erate on !acku" "ieces# $f you need to restore a file fro an RMAN !acku", you ust use RMAN to do it# There's no %ay for you to anually reconstruct data!ase files fro the !acku" "ieces# 4ou ust use RMAN to restore files fro a !acku" "iece#
-nstallin$ a #atalo$
One i "ortant decision %hen using RMAN is deciding %hether to use a recovery catalog# This section covers the "ros and cons of a catalog and then details catalog i "le entation issues#
#atalo$ advanta$es
'hen you use a catalog re"ository, you get ore fle&i!ility and access to all the features of RMAN# The advantages of using a catalog accrue in the follo%ing areas0 o o o o $f you are using Oracle9i, it can !e difficult to recover control files# 4ou can retain !acku" and recovery etadata for long "eriods of ti e# 4ou can centrali1e o"erations# RMAN !eco es ore fle&i!le in certain !acku" and recovery scenarios#
A catalog ena!les you to recover your control files in the event that they are all corru"ted or lost# $f you are not using a catalog, and you haven't !acked u" your control files via an A7T:R )ATA.A3: .A+;(, +ONTRO7*$7: co and, you could find yourself in the unenvia!le "osition of not !eing a!le to recover your target# Another good reason to use a catalog is that infor ation "ertaining to your RMAN !acku" and recovery activities can !e stored for very long "eriods of ti e# $f for any reason you had to use a !acku" set that %as several onths old, a catalog "rovides ore fle&i!ility to go !ack further in ti e than %ith the NO+ATA7O< o"tion# 'ith a catalog, you can anage all of your !acku" and recovery activities fro one re"ository# The advantage of this is that if you have ulti"le data!ases to aintain, you're storing all of your !acku" and recovery etadata in one "lace# *inally, %hen using the catalog, you have greater fle&i!ility during certain recovery situations# *or e&a "le, you can use "revious incarnations of the data!ase for recovery#
#atalo$ disadvanta$es
'hile the advantages of the catalog are su!stantial, there are a fe% "otential headaches that you should !e a%are of0 o o o ("grades and co "ati!ility can !e "ro!le atic# A catalog adds co "le&ity# (sing a catalog created "rior to Oracle =ersion 9#>#? %ith
"ro!le atic# A catalog can increase your needs for hard%are and ).A resources#
$f you're !acking u" "roduction data!ases, and you %ant the ost fle&i!ility "ossi!le for any given !acku" and recovery scenario, Oracle reco ends that you use a catalog data!ase# @o%ever, if you have non"roduction data!ases for %hich you %ant to i "le ent RMAN functionality, !ut you don't %ant the overhead of a catalog, you ay %ant to consider 6ust using the target control files#
:ach ethod has its advantages and disadvantages that you should %eigh !ased on your !usiness require ents# 3o e of the significant issues related to each !acku" ethod are discussed ne&t# Full e!port A full e&"ort is one of the si "lest ethods to !ack u" a data!ase# The do%nside to a full e&"ort is that you can only recover your data!ase u" to the last ti e you took a full e&"ort# $f you have to restore your catalog fro a full e&"ort, ensure that you take full or level A !acku"s of all your target data!ases as soon as "ossi!le# #old backup +old !acku"s are si "le to i "le ent !ut require do%nti e# $f your catalog data!ase is in archivelog cold !acku"s to do "oint-in-ti e recovery of your catalog if necessary# /ot backup @ot !acku"s are slightly ore co "le& to i "le ent than cold !acku"s !ut have the advantage of kee"ing the data!ase online during the !acku"# *or these reasons, this is our "referred ethod for !acking u" the catalog# ode, you can use
RMAN backup RMAN can !e used to !ack u" your catalog either %ith another catalog or %ith the NO+ATA7O< o"tion# +reating another catalog to !ack u" your catalog adds co "le&ity to your architecture# $f you use RMAN %ith no catalog, ake sure that you have a se"arate echanis to !ack u" the control files# /ot standb' @ot stand!ys let you quickly !ring u" a stand!y data!ase if the "ri ary is do%n# @o%ever, hot stand!ys can !e co "le& to i "le ent and consu e ore resources# Recreatin$ a catalo$ $f you co "letely lose your catalog and have no usa!le !acku"s of it, you can recreate it and then reregister and !ack u" your targets# The risk of this ethod is that during this "eriod, if you lose a target data!ase and its control files you ay not !e a!le to recover the #
#atalo$ -ssues
The creation of the catalog data!ase is fairly straightfor%ard# $t is, after all, 6ust a data!ase, sche a, and o!6ects# @ere are so e issues you should consider0 o o o o 'here to "ut the data!ase that %ill host the catalog 'hich data!ase version to use for the catalog @o% to si1e the catalog @o% to anage ulti"le target data!ases
"h'sical location o& the catalo$ 4ou should "lace the catalog data!ase on a different server than the target data!ase# $f you fail to do this, you 6eo"ardi1e !acku" and recovery o"erations, !ecause you ake it "ossi!le to lose !oth the catalog and target data!ases# The catalog can coe&ist in a data!ase used for other a""lications# The advantage to this is that you leverage e&isting resources# The disadvantage is that the "erfor ance and availa!ility of your catalog can !e affected !y other a""lications %ithin the sa e data!ase# 0ersion o& catalo$ 'hat version of Oracle should you use to create the catalog data!ase/ 'e suggest that the catalog data!ase !e created %ith the latest version of Oracle in your "roduction environ ent# This hel"s to ini i1e co "ati!ility issues and co "le&ity %hen you start to !ack u" your target data!ases#
#reatin$ a #atalo$
The e&a "les in this section "rovide details for creating a catalog data!ase and registering a target data!ase %ithin the catalog# These e&a "les assu e that your catalog data!ase is on a different host than your target data!ase# +atalog )ata!ase0 Oracle B#C#A#D (<:;>) on gecko Target )ata!a!ase0 Oracle >A#>#A#C (A;$>) on akira To create a recovery catalog, follo% these ste"s0 ># +reate a s"ecific ta!les"ace to hold the catalog o!6ects#
C# +reate a catalog sche a# E# $ssue a""ro"riate grants# D# +reate the sche a o!6ects# oracle@akira:~> sqlplus syst m!mana" #$%EK& CREATE TABLESPACE #man'cat DATAFILE (!u)&!o#acl !d*!%EK&!cat!#man'cat')&.d*+( SI,E -)./ No% that you have a ta!les"ace to store your sche a o!6ects, you can create the sche a0 CREATE USER #mancat IDENTIFIED B0 #mancat DEFAULT TABLESPACE #man'cat TE.PORAR0 TABLESPACE t mp 1UOTA UNLI.ITED ON #man'cat/ .efore you can create the catalog o!6ects, you need to grant s"ecial "rivileges to your ne% sche a# These "rivileges, granted through the R:+O=:R45+ATA7O<5O'N:R role, lets the sche a anage its catalog o!6ects# %RANT # co2 #y'catalo"'o3n # TO #mancat/ %RANT CREATE T0PE to #mancat/ 4ou can no% create the catalog o!6ects %ithin your ne% sche a# $n order to "erfor this ste", invoke RMAN, connect to your ne%ly created catalog sche a, and issue the create catalog co and# $f you don't s"ecify a ta!les"ace %ith the create catalog co and, the catalog o!6ects are created in the default ta!les"ace assigned to the catalog o%ner# oracle@akira:~> #man catalo" #mancat!#mancat$%EK& Recovery Manager: Release 10.1.0.2.0 - rod!ction "o#yright $c% 1&&'(200)( *racle. All rights reserved. connected to recovery catalog data+ase recovery catalog is not installed RMAN> c# at catalo"/ recovery catalog created RMAN> 45t
data+ase registered in recovery catalog starting 3!ll resync o3 recovery catalog 3!ll resync com#lete RMAN> 45t
4ou %ill no% configure the follo%ing "ara eters0 o o o o o E !acku"s of each datafile .acku"s to !e stored on disk in the 4!014oracle4d+4A,-14+ck directory C server "rocesses to do !acku"2restore o"erations in "arallel (se the ne% controlfile auto!acku" feature 3et !acku" o"ti i1ation on
$f 4!014oracle4d+4A,-14+ck does not e&ist "lease create is no%# 6 #man ta#" t ! catalo" #mancat!#mancat$%EK& RMAN> RMAN> RMAN> RMAN> CONFI%URE DEFAULT DE7ICE T0PE TO DISK/ CONFI%URE RETENTION POLIC0 TO REDUNDANC0 8/ CONFI%URE DE7ICE T0PE DISK PARALLELIS. 9/ CONFI%URE C:ANNEL DE7ICE T0PE DISK FOR.AT (!u)&!o#acl !d*!AKI&!*c;!o#a'd+<t's<s's<p(/ RMAN> CONFI%URE CONTROLFILE AUTOBACKUP ON/ RMAN> CONFI%URE CONTROLFILE AUTOBACKUP FOR.AT FOR DE7ICE T0PE DISK TO (!u)&!o#acl !d*!AKI&!*c;!o#a'c+<F(/ RMAN> CONFI%URE BACKUP OPTI.I,ATION ON/ RMAN> S:O= ALL/ RMAN con3ig!ration #arameters are: "*N5-67R8 R898N9-*N *:-"; 9* R8.7N.AN"; <= "*N5-67R8 /A",7 * 9-M->A9-*N *N= "*N5-67R8 .85A7:9 .8?-"8 9; 8 9* .-@,= "*N5-67R8 "*N9R*:5-:8 A79*/A",7 *N= "*N5-67R8 "*N9R*:5-:8 A79*/A",7 5*RMA9 5*R .8?-"8 9; 8 .-@, 9* A4!014oracle4d+4A,-14+ck4oraBc3C5A= "*N5-67R8 .8?-"8 9; 8 .-@, ARA::8:-@M 2 /A",7 9; 8 9* /A",7 @89= "*N5-67R8 .A9A5-:8 /A",7 "* -8@ 5*R .8?-"8 9; 8 .-@, 9* 1= D de3a!lt
AR"E-?8:*6 /A",7 "* -8@ 5*R .8?-"8 9; 8 .-@, 9* 1= D de3a!lt "EANN8: .8?-"8 9; 8 .-@, 5*RMA9 A4!014oracle4d+4A,-14+ck4oraBd3CtBsCsBsC#A= MAF@89@->8 9* 7N:-M-98.= D de3a!lt AR"E-?8:*6 .8:89-*N *:-"; 9* N*N8= D de3a!lt @NA @E*9 "*N9R*:5-:8 NAM8 9* A4o#t4oracle4#rod!ct410.1.04d+s4sna#c3BA,-1.3A= D
.efore you connect to your target data!ase, you ust ensure that the standard (ni& environ ent varia!les are esta!lished# These varia!les include0 ORA+7:53$), ORA+7:5@OM:, ,AT@, N7357AN<, and N735)AT:5*ORMAT# They govern the na e of the instance, the "ath to the RMAN e&ecuta!le8 and the !ehavior of !acku", restore, and re"orting co ands# 'hen using RMAN, N7357AN< should !e set to the character set that your data!ase %as created %ith# $f you do not set N7357AN<, you ay encounter "ro!le s %hen issuing .A+;(,, R:3TOR:, and R:+O=:R co ands# Once you have the a""ro"riate environ ent varia!les set, you then need access to an O23 account or a data!ase sche a that has 343).A "rivileges# 4ou ust have access to the 343).A "rivilege !efore you can connect to the target data!ase using RMAN# There are t%o ethods of ad inistering the 343).A "rivilege0 o o 7ocally via O23 authentication Re otely via "ass%ord file
O23 authentication is esta!lished %hen you install the Oracle !inaries# At that ti e, you set u" a (ni& grou", often na ed dba, and s"ecify this as the O23 grou" %ith 343).A "rivileges# Often the (ni& account used to install the Oracle !inaries is na ed oracle# This account is usually set u" to !elong to the d!a grou", and consequently, it lets you start RMAN and
connect to the target data!ase# O23 authentication is %hat "er its you to connect locally %ithout having to s"ecify the A3 343).A o"tion# *or local connections, RMAN auto atically connects you to the target data!ase %ith 343).A "rivileges#
3etting u" a "ass%ord file is the other ethod !y %hich you can ad inister the 343).A "rivilege# There are t%o good reasons to use RMAN %ith a "ass%ord file0 o o Oracle has de"recated the use of +ONN:+T $NT:RNA7 and 3erver Manager# 4ou ay %ant to ad inister RMAN re otely through a net%ork connection#
*or e&a "le, if you're in an environ ent %here you %ant to !ack u" all of your target data!ases fro one "lace and not have to log on to each host and !ack u" the data!ase, you ust do it via a net%ork connection# To re otely ad inister RMAN through a net%ork connection, you need to do the follo%ing0 o o +reate a "ass%ord file :na!le re ote logins for "ass%ord file users
#reate a "assword File &or Tar$et To create the "ass%ord file, as the Oracle soft%are o%ner or as a J cd J*RA":8BE*M84d+s J ora#Kd 3ile0sidname #assKord0password entries0n There are three user-"rovided varia!les in this e&a "le0 o o o sidname0 The 3$) of the target instance password0 The "ass%ord to !e used %hen you connect a user 343 %ith 343).A "rivilege# n0 The a&i u nu !er of sche as allo%ed in the "ass%ord files# e !er of the d!a grou0
*or e&a "le, say that you have an instance na ed AKI1, that you %ant the "ass%ord to !e goofi, and that you %ant at the ost EA entries in the "ass%ord file0 J cd J*RA":8BE*M84d+s J ora#Kd 3ile0ora#KA,-1 #assKord0goo3i entries0<0 The resulting "ass%ord file is na ed orapwAKI1 and is in the $ORACLE_HOME/dbs directory# After you create a "ass%ord file, you need to ena!le re ote logins# To do this, set the instance's R:MOT:57O<$N5,A33'OR)*$7: initiali1ation "ara eter to e&clusive, as sho%n0 remoteBloginB#assKord3ile 0 eIcl!sive 3etting this "ara eter to e&clusive signifies that only one data!ase can use the "ass%ord file and that users other than sys and internal can reside in it# 2ou can now use a network connection to connect to 'our tar$et database as S2S%+A) Test the connection, try to connect fro a ,+ to the re ote data!ase as 343 %ith 343).A "rivileges0
Note that you have to create a "ass%ord file only for the target data!ase and not for the catalog# This is !ecause %hen you connect to the target, you need to connect as an account that has the 343).A "rivilege# 'hen you connect re otely to a target data!ase, the 343).A "rivilege is ena!led through the "ass%ord file# This is unlike a connection to the catalog, for %hich 343).A is not required, !ecause you log in as the o%ner of the catalog sche a# 'hen the 343).A "rivilege is granted to a s"ecified user, that user can !e queried in the =F,'*$7:5(3:R3 vie%# *or e&a "le0 @M:> "#ant S0SDBA to #manadm5n/ 6rant s!cceeded. @M:> s l ct @ +#om 26p3+5l 'us #s 3? # us #nam A(R.ANAD.IN(/ 7@8RNAM8 @;@./ @;@* ------------------------------ ----- ----RMANA.M-N 9R78 5A:@8
RMAN> *ro here you can use RMAN's co and-line interface language to "erfor !acku" and recovery tasks#
/idin$ the password 3u""lying userna es and "ass%ords on the co and line is convenient# (nfortunately, this "ractice "oses a serious
security risk# 'ith (ni&, your co and line ay !e visi!le to other users on the syste via the "s co and# *ortunately, there is a %ay around having your "ass%ord sho% u" in the "rocess status out"ut# )on't s"ecify connection infor ation %hile at the O23 "ro "t, !ut connect after an RMAN session as !een initiated# *or e&a "le0
+onnecting to the data!ase after RMAN has !een invoked "revents any "ass%ord infor ation fro list#
"o#yright $c% 1&&'( 200)( *racle. All rights reserved. connected to target data+ase: A,-1 $./-.01&&))&1020% connected to recovery catalog data+ase This connects you to the target and catalog data!ase at the sa e ti e# Alternatively, you can invoke RMAN first and then
issue connect co
J #man RMAN> conn ct catalo" #mancat!#mancat$%EK& RMAN> conn ct ta#" t ! $ssuing connect co ands fro users can vie% the # "assword authentication $f you are using a "ass%ord file, the net%ork connection to the target is use of a net service na e for !oth connections# ade as sho%n in the follo%ing e&a "le# Note the %ithin RMAN "revents any "ass%ords fro a""earing in the "rocess list %here other O23
client-#c> #man ta#" t sys!"oo+5$AKI& catalo" #mancat!#mancat$%EK& Recovery Manager: Release 10.1.0.2.0 rod!ction
"o#yright $c% 1&&'( 200)( *racle. All rights reserved. connected to target data+ase: A,-1 $./-.01&&))&1020% connected to recovery catalog data+ase $t doesn't atter %hether you connect to the target or the catalog first, as long as you connect to !oth !efore issuing any other RMAN co ands#
+ackups
This section "rovides a series of RMAN and korn shell scri"ts that illustrate !acking u" a data!ase and its se"arate co "onents# RMAN can !ack u" datafiles, control files, archived redo files, and !acku" "ieces# RMAN does not !ack u" the online redo logs#
RMAN, as "art of its default !acku" !ehavior, touches each datafile !lock, "erfor s verification checks, and then logs any detected corru"tion# 4ou can onitor "otential corru"tion !y querying the =F.A+;(,5+ORR(,T$ON and =F+O,45+ORR(,T$ON vie%s#
*or a data!ase to !e !acked u" it must be in mount or open mode# The data!ase needs to at least !e in !ecause RMAN needs to access the target data!ase control file !efore "erfor ing a !acku"#
ount
ode,
in archivelog
@ere's a shell scri"t for an Oracle4356 data!ase that shuts do%n the data!ase, BC!*5n!*as?
#man ta#" t ! catalo" #mancat!#mancat$%EK& DDEOF s?utdo3n 5mm d5at / sta#tup mount/ *ac;up data*as +o#mat (!u)&!o#acl !d*!AKI&!*c;!o#a'd+<t's<s's<p(/ alt # data*as op n/ EOF 45t 6 .!#man'o++l5n .*as? The follo%ing files are created0 J cd 4!014oracle4d+4A,-14+ck> J ls -l -rK-r----- 1 oracle d+a 1012<'2 oraBc3c-1&&))&1020-200)0&21-02 -rK-r----- 1 oracle d+a <)&111&20 oraBd3'<1&1'H'2Bs<&Bs1 -rK-r----- 1 oracle d+a 1<21222H) oraBd3'<1&1'H'2Bs)0Bs1 @ere's the shell scri"t for Oracle7 DN4+in4+ash rman target 4 catalog rmancat4rmancat@68,1 OO8*5 sh!tdoKn immediate= start!# mo!nt= #un E allocat c?ann l d& typ d5s;/ *ac;up data*as +o#mat (!u)&!o#acl !d*!AKI&!*c;!o#a'd+<t's<s's<p(/ F alter data+ase o#en= 8*5 eIit 'e've used the for at "ara eter in !oth e&a "les to "rovide a s"ecific location and unique na e for the !acku" "ieces# $f the for at "ara eter is not used, the !acku" "ieces %ill !e directed to FORA+7:5@OM:2d!s#
45t (nlike traditional online (hot) !acku"s, RMAN does not "ut ta!les"aces in !acku" ode# No e&tra redo is generated# *or high-transaction data!ases, this can lead to significant resource savings#
Again, note that %ith Oracle7i, the synta& is a !it different %ith res"ect to the runGH co DN4+in4+ash
and0
rman target 4 catalog rmancat4rmancat@68,1 OO8*5 #un E allocat c?ann l d& typ d5s;/ *ac;up data*as +o#mat (!u)&!o#acl !d*!AKI&!*c;!o#a'd+<t's<s's<p(/ F 8*5 eIit
+ackin$ .p a Tablespace
The a!ility to s"ecify only a su!set of ta!les"aces in a !acku" o"eration can add fle&i!ility to your !acku" strategy# *or OracleBi, the synta& can !e fairly si "le0 RMAN> *ac;up ta*l spac syst m +o#mat (!u)&!o#acl !d*!AKI&!*c;!o#a'd+<t's<s's<p(/ and0
Once again, note that %ith Oracle9i, the synta& is a !it different %ith res"ect to the runGH co #un E allocat c?ann l d& typ d5s;/ *ac;up ta*l spac syst mG us #s 5nclud cu## nt cont#ol+5l +o#mat (!u)&!o#acl !d*!AKI&!*c;!o#a'd+<t's<s's<p(/ F
3!ll resync com#lete RMAN> CONFI%URE CONTROLFILE AUTOBACKUP FOR.AT FOR DE7ICE T0PE DISK TO (!u)&!o#acl !d*!AKI&!*c;!o#a'c+<F.con(/ neK RMAN con3ig!ration #arameters: "*N5-67R8 "*N9R*:5-:8 A79*/A",7 5*RMA9 5*R .8?-"8 9; 8 .-@, 9* A4!014oracle4d+4A,-14+ck4oraBc3C5.conA= neK RMAN con3ig!ration #arameters are s!ccess3!lly stored starting 3!ll resync o3 recovery catalog 3!ll resync com#lete No% !acku" a ta!les"ace and %atch the logging out"ut for the saved controlfile RMAN> +ack!# ta+les#ace !sers 3ormat A4!014oracle4d+4A,-14+ck4rmanBCsBCtBCd.+ckA= @tarting "ontrol 5ile A!to+ack!# at 21-@8 -0) #iece handle04!014oracle4d+4A,-14+ck4o#a'c+cH&IIJJIK)L)H9))J)I9KH)K.con comment0N*N8 5inished "ontrol 5ile A!to+ack!# at 21-@8 -0)
$f you have a non-RMAN "rocess re ove the redo log files, the control files or the o"tional recovery catalog %ill not !e a%are that they are no longer accessi!le# +onsequently, you %ould have to "eriodically issue the co and0 RMAN> c?an" a#c?52 lo" all 2al5dat / fro the filesyste %hen they are no longer
-ncremental +ackups
One of the ost i "ressive features of RMAN is its a!ility to "erfor incre ental !acku"s# Recall that %ith traditional file!ased !acku"s -- such as hot or cold -- all !locks in a data!ase datafile are co"ied, %hether they have !een used or not# RMAN has the a!ility to detect %hich !locks in a datafile have changed since the last !acku" and %ill co"y only those odified !locks# 'hen RMAN co"ies only the odified !locks during a !acku", this is called compression# $f there are unused or un odified !locks in a datafile, RMAN %ill ski" those !locks#
3ki""ing un odified !locks gives RMAN a !ig advantage over file-!ased !acku"s in that the resources required to do a
!acku" or restore can !e considera!ly less# Additionally, this eans that the !acku" ti e and ta"e2disk s"ace required correlates to the nu !er of changes ade to the data!ase, and not necessarily to the si1e of the data!ase# *or very large data!ases, this alone can necessitate the use of RMAN# Much of the no enclature around incre ental !acku"s contains the ter level# The !asic idea !ehind RMAN level-!ased !acku"s is to !ack u" only !locks that have !een odified since the "revious !acku"# $ncre ental !acku"s can !e a""lied to the data!ase, ta!les"aces, or datafiles# Oracle refers to this usage of levels as a ultilevel incre ental !acku"# These levels can range fro level A to a a&i u of level D# There are t%o flavors of incre ental !acku"s -- differential and cu ulative# A differential incre ental !acku" tells RMAN to !ack u" !locks that have changed since level n or lo%er# *or e&a "le, if you take a level > differential !acku", you %ill !ack u" !locks that have changed since the "revious level > !acku"# )ifferential !acku"s are the default incre ental !acku" ode# $f you take an incre ental !acku" higher than level A, and no "rior level A e&ists, RMAN auto atically creates a level A !acku"#
A cu ulative incre ental !acku" instructs RMAN to !ack u" !locks that have changed since level n-> or lo%er# *or e&a "le, if you take a level > cu ulative !acku", RMAN %ill !ack u" !locks that have changed since the ost recent level A !acku"# A full !acku" !acks u" the e&act sa e !locks as alevel A# The difference !et%een a full !acku" and a level !acku" is that a full!acku" is not kno%n to any su!sequent incre ental !acku"s# Therefore, they cannot !e used as a !asis %hen a""lying incre ental !acku"s during a recovery o"eration# A full!acku" is the default !acku" ty"e if no incre ental level is s"ecified#
'hy all the choices/ A differential !acku" takes less s"ace and ti e to "erfor !ut requires ore ti e to restore# $t follo%s that a cu ulative !acku" takes ore s"ace and ti e to "erfor !ut less ti e to restore# 3o it !eco es a tradeoff issue8 do you %ant to ini i1e your !acku" ti e or ini i1e your restore ti e/ 'e "refer to ini i1e our restore ti e, and therefore, %e use cu ulative !acku"s# *or s all data!ases, %e reco end daily RMAN level A !acku"s# 7evel A .acku" RMAN> *ac;up 5nc# m ntal l 2 l ) data*as / @ere's an OracleBi cu ulative !acku" e&a "le in %hich you tell RMAN to !ack u" all !locks that have !een the ost recent level E or lo%er !acku"# RMAN> *ac;up 5nc# m ntal l 2 l J cumulat52 data*as / odified since
0alidatin$ backups
One nice feature of RMAN is the a!ility to re"ort on the status of !acku"s# The si "lest %ay to vie% !acku" infor ation is via the list !acku" co and# 0iew +ackup -n&ormation
RMAN> l5st *ac;up/ 0iew Schema RMAN> # po#t sc? ma/ Re#ort o3 data+ase schema 5ile ,-+ytes 9a+les#ace ---- ---------- ------------1 21&200 @;@98M 2 20)200 7N.* < 21&200 @;@A7F ) 10<0) 7@8R@ ' 21&2H) 9A/ H 21&2H) -.F -s +ackup restorable ? RMAN also has a %ay to verify %hether the !acku" files are restora!le# 4ou acco "lish this !y issuing the restore data!ase validate co and# This co and doesn't actually restore any datafiles, it 6ust validates that the contents of the !acku" sets can !e restored if necessary# The follo%ing e&a "le %orks %ith !oth Oracle9i and OracleBi0 RMAN> #un E allocat c?ann l d& typ d5s;/ # sto# data*as 2al5dat / F 0alidate +ackup 4ou can run a test RMAN !acku" that does not generate any out"ut# The test checks datafiles for "hysical and logical corru"tion and that all data!ase files e&ist and are in the correct locations# *or e&a "le0 RMAN> *ac;up 2al5dat data*as a#c?52 lo" all/ R/ segs ------;8@ ;8@ N* N* N* N* .ata3ile Name ------------------4!014oracle4d+4A,-14sys4A,-1Bsys1.d+3 4!014oracle4d+4A,-14sys4A,-1B!ndo1.d+3 4!014oracle4d+4A,-14sys4A,-1Bsysa!I1.d+3 4!014oracle4d+4A,-14!sr4A,-1B!sers1.d+3 4!014oracle4d+4A,-14ta+4A,-1Bta+.d+3 4!014oracle4d+4A,-14idI4A,-1BidI1.d+3
Recover' Methods
># :nsure that the target data!ase is started in the a""ro"riate ode for the restoration o"eration# *or lost control files, this %ill !e no ount ode# $f the entire data!ase needs to !e restored, this %ill !e ount ode# $f datafiles that don't !elong to the 343T:M ta!les"ace are da aged, you have the o"tion of kee"ing the data!ase o"en and taking only the ta!les"ace(s)2datafile(s) that needs to !e restored offline# C# 3tart RMAN and connect to the target and recovery catalog if one is !eing used# E# Run the a""ro"riate RMAN R:3TOR: co and to !ring !ack required files# The requested files and the a""ro"riate archived redo log files %ill !e restored# Once the necessary files are restored, you need to recover your data!ase and o"en it for use# 4ou can recover the data!ase fro either RMAN, 3I7J,lus, or 3erver Manager (Oracle9i only)#
@M:> conn ct sys!... as S0SDBA/ @M:> s?utdo3n a*o#t/ *RA":8 instance sh!t doKn. Ne&t, you need to start u" your target data!ase in ount ode# RMAN cannot restore datafiles unless the data!ase is at least in ount ode, !ecause RMAN needs to !e a!le to access the control file to deter ine %hich !acku" sets are necessary to recover the data!ase# $f the control file isn't availa!le, you have to recover it first# $ssue the 3TART(, MO(NT co and sho%n in the follo%ing e&a "le to ount the data!ase0 @M:> sta#tup mount/ *racle instance started. 3ince !acku" set files are created in an RMAN-s"ecific for at, you connect to the target data!ase0 ust use RMAN to restore the datafiles# To use RMAN,
J #man ta#" t ! catalo" #mancat!#mancat$%EK& The re ainder of this e&a "le sho%s ho% to restore all of the datafiles of the target data!ase# RMAN %ill go to its last good !acku" set and restore the datafiles to the state they %ere in %hen that !acku" set %as created# 'hen restoring data!ase files %ith OracleBi, RMAN reads the datafile header and akes the deter ination as to %hether the file needs to !e restored# The recovery is done !y allocating a channel for $2O and then issuing the RMAN restore data!ase co and# 'ith Oracle4i, you don't need to allocate a channel e&"licitly# $nstead, you can use the default channel RMAN> # sto# data*as / RMAN> # co2 # data*as / RMAN> alt # data*as op n/ *or Oracle7i, the A77O+AT:, R:3TOR:, and R:+O=:R co RMAN> r!n P allocate channel d1 ty#e disk= restore data+ase= recover data+ase= Q alter data+ase o#en= Or alternatively, once RMAN has restored the datafiles, you can use 3I7J,lus to recover the data!ase and o"en it for use0 J sGl#l!s 4nolog @M:> connect sys4... as @;@./A= @M:> recover data+ase= @M:> alter data+ase o#en= ands need to !e enclosed !y the runGH co and0 ode0
Take the ta!les"ace2datafile that needs recovery offline, restore the ta!les"ace2datafile, recover the ta!les"ace2datafile, and !ring the ta!les"ace2datafile online# $f you cannot take the ta!les"ace2datafile offline, then shutdo%n a!ort the data!ase and restore in ount ode# *irst try to take the Ta!les"ace offline8 sGl#l!s Lsys4managase as sysd+aL @M:> alter ta+les#ace ta+ o33line= J #man ta#" t ! catalo" #mancat!#mancat$%EK& RMAN> # sto# ta*l spac ta*/ RMAN> # co2 # ta*l spac ta*/ @M:> alt # ta*l spac ta* op n/ $f this fails0 @M:> conn ct sys!... as S0SDBA/ @M:> s?utdo3n a*o#t/ @M:> sta#tup mount/ J #man ta#" t ! catalo" #mancat!#mancat$%EK& RMAN> # sto# ta*l spac ta*/ RMAN> # co2 # ta*l spac ta*/ @M:> alt # data*as op n/ $nstead of a ta!les"ace, you can restore and recover a s"ecific datafile0 RMAN> restore data3ile A4!014oracle4d+4A,-14ta+4A,-1Bta+.d+3A RMAN> recover data3ile A4!014oracle4d+4A,-14ta+4A,-1Bta+.d+3A
$n an ideal %orld you'll never use RMAN to restore a control file# .ut if so ething catastro"hic ha""ens, and you lose all control files, here are the ste"s for getting the !ack0 'ith OracleBi, if you are not using a catalog, you can still restore the control file if you have used RMAN's auto!acku" feature to !ack it u" %ith each !acku" that you do#
The follo%ing e&a "les assu e that you are using a catalog# *irst, here's the si "lest OracleBi synta& for restoring a control file0 @M:> conn ct sys!... as S0SDBA/ @M:> s?utdo3n a*o#t/ @M:> sta#tup nomount/ J #man ta#" t ! catalo" #mancat!#mancat$%EK& RMAN> # sto# cont#ol+5l / RMAN> alt # data*as mount/ RMAN> alt # data*as op n/ $f this fails %ith ### RMAN-00'11: 00000000000000000000000000000000000000000000000000000000000 RMAN-00'H&: 000000000000000 8RR*R M8@@A68 @9A", 5*::*R@ 000000000000000 RMAN-00'11: 00000000000000000000000000000000000000000000000000000000000 RMAN-0<002: 3ail!re o3 alter d+ command at 0&4224200) 10:<1:'2 *RA-01'2&: m!st !se R8@89:*6@ or N*R8@89:*6@ o#tion 3or data+ase o#en ### then you ust "erfor a recover data!ase0
@M:> s?utdo3n a*o#t/ @M:> sta#tup mount/ J #man ta#" t ! catalo" #mancat!#mancat$%EK& RMAN> # co2 # data*as /
sGl#l!s Lsys4manager as sysd+aL @M:> s?utdo3n a*o#t/ @M:> sta#tup nomount/ J #man ta#" t ! catalo" #mancat!#mancat$%EK& RMAN> # sto# cont#ol+5l / RMAN> alt # data*as mount/ RMAN> # sto# data*as / RMAM> # co2 # data*as / RMAN-00'11: RMAN-00'H&: RMAN-00'11: RMAN-0<002: RMAN-0H0'): 00000000000000000000000000000000000000000000000000000000000 000000000000000 8RR*R M8@@A68 @9A", 5*::*R@ 000000000000000 00000000000000000000000000000000000000000000000000000000000 3ail!re o3 recover command at 0&4224200) 11:0<:2< media recovery reG!esting !nknoKn log: thread 1 seG 1 loKscn 2))2)1)
3ince the online logs %ere lost, co "lete recovery is not "ossi!le# O"en the data!ase %ith resetlogs to continue# RMAN> alt # data*as op n # s tlo"s/ a full !ack as soon as "ossi!le#
Media failure destroys so e or all of the online redo logs# A user error causes data loss, for e&a "le, a user inadvertently dro"s a ta!le# 4ou cannot "erfor co "lete recovery !ecause an archived redo log is issing# 4ou lose your current control file and ust use a !acku" control file to o"en the data!ase#
To "erfor inco "lete edia recovery, you ust restore all datafiles fro !acku"s created "rior to the ti e to %hich you %ant to recover and then o"en the data!ase %ith the R:3:T7O<3 o"tion %hen recovery co "letes# The R:3:T7O<3 o"eration creates a ne% incarnation of the data!ase8 in other %ords, a data!ase %ith a ne% strea of log sequence nu !ers starting %ith log sequence ># sGl#l!s Lsys4manager as sysd+aL @M:> s?utdo3n a*o#t/ @M:> sta#tup mount/ J #man ta#" t ! catalo" #mancat!#mancat$%EK& RMAN> # sto# data*as / @M:> # co2 # data*as unt5l t5m (9))JH)IH9IM&)M8-M))(/ media recovery com#lete. @M:> alt # data*as op n # s tlo"s/
Maintenance #ommands
RMAN has a fe% RMAN> # po#t n aintenance co d *ac;up/ ands, sho%n ne&t# 'hat files require a !acku" no% )eter ines %hether a !acku" set and its related "ieces still e&ist on edia# $f a !acku" "iece e&ists in the location recorded in the control file of the target data!ase or in the o"tional recovery catalog, its status
is arked as A=A$7A.7:# $f it is not at the s"ecified location, it is arked as :K,$R:)# RMAN> d l t RMAN> d l t 4p5# d *ac;up o+ data*as / *or OracleBi, this co and deletes the "hysical files *ac;up o+ data*as / associated %ith !acku" sets and datafile co"ies, u"dates their status in the control file, and re oves their infor ation fro the o"tional recovery catalog (if one is used)# $n Oracle9i and OracleBi, !acku"s are flagged as :K,$R:) if they cannot !e found at their recorded location# )eletion of :K,$R:) !acku"s re oves their infor ation fro the control file and fro the o"tional recovery catalog (if one is used)# +reate Recovery +atalog# )ro"s all o!6ects associated %ith the recovery catalog sche a# To re"ort on those datafiles that, if restored, %ould require a""lication of t%o days (or ore) %orth of archived redo log files0 To generate the sa e re"ort !ut only for 343T:M ta!les"ace datafiles0 To list !acku"s considered o!solete Re"orts on all unrecovera!le datafiles
RMAN> c# at catalo"/ RMAN> d#op catalo"/ RMAN> # po#t n data*as / d *ac;up days 9
RMAN> # po#t n d *ac;up days 9 ta*l spac syst m/ RMAN> # po#t o*sol t / RMAN> # po#t un# co2 #a*l /