Backup and Recovery Scenarios

Published on May 2016 | Categories: Documents | Downloads: 33 | Comments: 0 | Views: 248
of 8
Download PDF   Embed   Report

Comments

Content


Backup and Recovery Scenarios
Backup and Recovery Scenarios [ID 94114.1]
In this Document
Purpose
Instructions for the Reader
Troubleshooting Details
BACKUP SC!ARI"S
a) Consistent backups
b) Inconsistent backups
c) Database Archive mode
d) Backup Methods
e) Incremental backups
f) upport scenarios
RC"#R$ SC!ARI"S
!" #nline Block Recover$"
%" Thread Recover$"
&" Media Recover$"
Media 'ailure and Recover$ in (oarchivelog Mode
Media 'ailure and Recover$ in Archivelog Mode
a) Point in Time recover$)
b) Recover$ *ithout control file
c) Recover$ of missing datafile *ith rollback segments
d) Recover$ of missing datafile *ithout undo segments
e) Recover$ *ith missing online redo logs
f) Recover$ *ith missing archived redo logs
g) Recover$ *ith resetlogs option
h) Recover$ *ith corrupted undo segments"
i) Recover$ *ith $stem Clock change"
+) Recover$ *ith missing $stem tablespace"
k) Media Recover$ of offline tablespace
l) Recover$ of Read,#nl$ tablespaces
Re%erences
App&ies 'o(
#racle erver , Personal -dition , .ersion) /"%"&"0 to !0"%"0"1 , Release) /"%"& to !0"%
#racle erver , -nterprise -dition , .ersion) /"&"1"2 to !0"%"0"1 3Release) /"&"1 to !0"%4
#racle erver , tandard -dition , .ersion) /"%"%"0 to !0"%"0"1 3Release) /"%"% to !0"%4
Information in this document applies to an$ platform"
555Checked for relevance on 0!,Mar,%0!!555
Purpose
Describe various Backup and Recover$ cenarios"
Instructions for the Reader
A Troubleshooting 6uide is provided to assist in debugging a specific issue" 7hen possible8
diagnostic tools are included in the document to assist in troubleshooting"
Troubleshooting Details
BACKUP SC!ARI"S

a) Consis'en' *ackups
A consistent backup means that all data files and control files are consistent to a point in time"
I"e" the$ have the same C(" This is the onl$ method of backup *hen the database is in (#
Archive log mode"
*) Inconsis'en' *ackups
An Inconsistent backup is possible onl$ *hen the database is in Archivelog mode" 9ou must
appl$ redo logs to the data files8 in order to restore the database to a consistent state" Inconsistant
backups can be taken using RMA(*hen the database is open"
Inconsistant backups can also be taken using other # tools provided the tablespaces :or
database) is put into backup mode"
ie) ;<= alter tablespace data begin backup>
;<= alter database begin backup> :version !0 and above onl$)
c) Da'a*ase Arc+ive ,ode
The database can run in either Archivelog mode or noarchivelog mode" 7hen $ou first create the
database8 $ou specif$ if it is to be in Archivelog mode" Then in the init"ora file $ou set the
parameter log?archive?start@true so that archiving *ill start automaticall$ on startup"
If the database has not been created *ith Archivelog mode enabled8 $ou can issue the command
*hilst the database is mounted8 not open"
;<= alter database Archivelog>"
;<= log archive start
;<= alter database open>
;<= archive log list
This command *ill sho* $ou the log mode and if automatic archival is set"
d) Backup -e'+ods
-ssentiall$8 there are t*o backup methods8 hot and cold8 also kno*n as online and offline8
respectivel$" A cold backup is one taken *hen the database is shutdo*n" The database must be
shutdo*n cleanl$" A hot backup is on taken *hen the database is running" Commands for a hot
backup)
.or non R-A! *ackups(
!" Aave the database in archivelog mode :see above)
%" ;<= archive log list
,,This *ill sho* *hat the oldest online log seBuence is" As a precaution8 al*a$s keep the all
archived log files starting from the oldest online log seBuence"
&" ;<= Alter tablespace tablespace?name B-6I( BACCDP>
or ;<= alter database begin backup :for v!0 and above)"
1" ,,Dsing an # command8 backup the datafile:s) of this tablespace"
2" ;<= Alter tablespace tablespace?name -(D BACCDP
,,, repeat step &8 18 2 for each tablespace"
or ;<= alter database end backup> for version !0 and above
E" ;<= archive log list
,,,do this again to obtain the current log seBuence" 9ou *ill *ant to make sure $ou have a cop$
of this redo log file"
/" o to force an archived log8 issue
;<= A<T-R 9T-M 7ITCA <#6'I<-
A better *a$ to force this *ould be)
;<= alter s$stem archive log current>
F" ;<= archive log list
This is done again to check if the log file had been archived and to find the latest archived
seBuence number"
G" Backup all archived log files determined from steps % and F"
!0" Back up the control file)
;<= Alter database backup controlfile to HfilenameH
.or R-A! *ackups(
see (ote"II&G/&!2"!== RMA( , ample Backup cripts !0g
or the appropriate RMA( documentation"
e) Incremental backups
These are backups that are taken on blocks that have been modified since the last backup" These
are useful as the$ donHt take up as much space and time" There are t*o kinds of incremental
backups Cumulative and (on cumulative"
Cumulative incremental backups include all blocks that *ere changed since the last backup at a
lo*er level" This one reduces the *ork during restoration as onl$ one backup contains all the
changed blocks"
(oncumulative onl$ includes blocks that *ere changed since the previous backup at the same or
lo*er level"
Dsing rman8 $ou issue the command Jbackup incremental level nJ
#racle vG and belo* RMA( *ill back up empt$ blocks8 oracle v!0"% RMA( *ill not back up
empt$ blocks
%) Suppor' scenarios
7hen the database crashes8 $ou no* have a backup" 9ou restore the backup and
then recover the database" Also8 donHt forget to take a backup of the control
file *henever there is a schema change
"
RC"#R$ SC!ARI"S
(ote) All online datafiles must be at the same point in time *hen completing recover$>
There are several kinds of recover$ $ou can perform8 depending on the t$pe of failure and the
kind of backup $ou have" -ssentiall$8 if $ou are not running in archive log mode8 then $ou can
onl$ recover the cold backup of the database and $ou *ill lose an$ ne* data and changes made
since that backup *as taken" If8 ho*ever8 the database is in Archivelog mode $ou *ill be able to
restore the database up to the time of failure" There are three basic t$pes of recover$)
1. "n&ine B&ock Recovery.
This is performed automaticall$ b$ #racle":pmon) #ccurs *hen a process dies *hile changing a
buffer" #racle *ill reconstruct the buffer using the online redo logs and *rites it to disk"
/. 0+read Recovery.
This is also performed automaticall$ b$ #racle" #ccurs *hen an instance crashes *hile having
the database open" #racle applies all the redo changes in the thread that occurred since the last
time the thread *as checkpointed"
1. -edia Recovery.
This is reBuired *hen a data file is restored from backup" The checkpoint count in the data files
here are not eBual to the check point count in the control file"
(o* letHs eKplain a little about Redo vs Dndo"
Redo information is recorded so that all commands that took place can be repeated during
recover$" Dndo information is recorded so that $ou can undo changes made b$ the current
transaction but *ere not committed" The Redo <ogs are used to Roll 'or*ard the changes made8
both committed and non, committed changes" Then from the Dndo segments8 the undo
information is used to
rollback the uncommitted changes"
Media 'ailure and Recover$ in (oarchivelog Mode
In this case8 $our onl$ option is to restore a backup of $our #racle files" The files $ou need are
all datafiles8 and control files" 9ou onl$ need to restore the pass*ord file or parameter files if
the$ are lost or are corrupted"
Media 'ailure and Recover$ in Archivelog Mode
In this case8 there are several kinds of recover$ $ou can perform8 depending on *hat has been
lost" The three basic kinds of recover$ are)
!" Recover database , here $ou use the recover database command and the database must be
closed and mounted" #racle *ill recover all datafiles that are online"
%" Recover tablespace , use the recover tablespace command" The database can be open but the
tablespace must be offline"
&" Recover datafile , use the recover datafile command" The database can be open but the
specified datafile must be offline"
(ote) 9ou must have all archived logs since the backup $ou restored from8 or else $ou *ill not
have a complete recover$"
a) Poin' in 0i,e recovery(
A t$pical scenario is that $ou dropped a table at sa$ noon8 and *ant to recover it" 9ou *ill have
to restore the appropriate datafiles and do a point,in,time recover$ to a time +ust before noon"
!o'e( $ou *ill lose an$ transactions that occurred after noon" After $ou have recovered until
noon8 $ou must open the database *ith resetlogs" This is necessar$ to reset the log numbers8
*hich *ill protect the database from having the redo logs that *erenHt used be applied"
The four incomplete recover$ scenarios all *ork the same)
Recover database until time H!GGG,!%,0!)!%)00)00H>
Recover database until cancel> :$ou t$pe in cancel to stop)
Recover database until change n>
Recover database until cancel using backup controlfile>
(ote) 7hen performing an incomplete recover$8 the datafiles must be online" Do a select 5 from
vLrecover?file to find out if there are an$ files *hich are offline" If $ou *ere to perform a
recover$ on a database *hich has tablespaces offline8 and the$ had not been taken offline in a
normal state8 $ou *ill lose them *hen $ou issue the open resetlogs command" This is because the
data file needs recover$ from a point before the resetlogs option *as used"
*) Recovery 2i'+ou' con'ro& %i&e
If $ou have lost the current control file8 or the current control file is inconsistent *ith files that
$ou need to recover8 $ou need to recover either b$ using a backup control file command or create
a ne* control file" 9ou can also recreate the control file based on the current one using the
H;<= backup control file to traceH command *hich *ill create a script for $ou to run to create a
ne* one" Recover database using backup control file command must be used *hen using a
control file other that the current" The database must then be opened *ith
resetlogs option"
c) Recovery o% ,issin3 da'a%i&e 2i'+ ro&&*ack se3,en's
The trick$ part here is if $ou are performing online recover$" #ther*ise $ou can +ust use the
recover datafile command" (o*8 if $ou are performing an online recover$8 $ou *ill need to
create a ne* undo tablespace to be used" #nce the old tablespace has been recovered it can be
dropped once an$ uncommitted transactions have rolled back"
d) Recovery o% ,issin3 da'a%i&e 2i'+ou' undo se3,en's
There are three *a$s to recover in this scenario8 as mentioned above"
!" recover database>
%" recover datafile Hc)MorantMdatabaseMusr!orcl"oraH>
&" recover tablespace user?data>
e) Recovery 2i'+ ,issin3 on&ine redo &o3s
Missing online redo logs means that someho* $ou have lost $our redo logs before the$ had a
chance to archived" This means that crash recover$ cannot be performed8 so media recover$ is
reBuired instead" All datafiles *ill need to be restored and rolled for*arded until the last
available archived log file is applied" This is thus an incomplete recover$8 and as such8 the
recover
database command is necessar$"
As al*a$s8 *hen an incomplete recover$ is performed8 $ou must open the database *ith
resetlogs"
(ote) the best *a$ to avoid this kind of a loss8 is to mirror $our online log files"
%) Recovery 2i'+ ,issin3 arc+ived redo &o3s If $our archives are missing8 the onl$ *a$ to
recover the database is to restore from $our latest backup" 9ou *ill have lost an$ uncommitted
transactions *hich *ere recorded in the archived redo logs" Again8 this is *h$ #racle strongl$
suggests mirroring $our online redo logs and duplicating copies of the archives"
3) Recovery 2i'+ rese'&o3s op'ion
Reset log option should be the last resort8 ho*ever8 as *e have seen from above8 it ma$ be
reBuired due to incomplete recoveries" :recover using a backup control file8 or a point in time
recover$)" It is imperative that $ou backup up the database immediatel$ after $ou have opened
the database *ith reset logs" It is possible to recover through a resetlogs8 and made easier *ith
#racle .!08 but easier
to restore from the backup taken after the resetlogs
+) Recovery 2i'+ corrup'ed undo se3,en's.
If an undo segment is corrupted8 and contains uncommitted s$stem data $ou ma$ not be able to
open the database"
The best alternative in this situation is to recover the corrupt block using the RMA(
blockrecover command neKt best *ould be to restore the datafile from backup and do a complete
recover$"
If a backup does not eKist and If the database is able to open :non s$stem ob+ect) The first step is
to find out *hat ob+ect is causing the rollback to appear corrupted" If *e can determine that8 *e
can drop that ob+ect"
So4 +o2 do 2e %ind ou' i% i'5s ac'ua&&y a *ad o*6ec'7
!" Make sure that all tablespaces are online and all datafiles are online" This can be checked
through via the vLrecover?file vie*"
%" Put the follo*ing in the init"ora)
event @ J!00!2 trace name conteKt forever8 level !0J
This event *ill generate a trace file that *ill reveal information about the transaction #racle is
tr$ing to roll back and most importantl$8 *hat ob+ect #racle is tr$ing to appl$ the undo to"
(ote) In #racle vG and above this information can be found in the alert log"
top and start the database"
&" Check in the director$ that is specified b$ the user?dump?dest parameter :in the init"ora or
sho* parameter command) for a trace file that *as generated at startup time"
1" In the trace file8 there should be a message similar to) error recover$ tK:N8N) ob+ect N"
TO:N8N) refers to transaction information"
The ob+ect N is the same as the ob+ect?id in s$s"dba?ob+ects"
2" Dse the follo*ing Buer$ to find out *hat ob+ect #racle is tr$ing to perform recover$ on"
select o*ner8 ob+ect?name8 ob+ect?t$pe8 status
from dba?ob+ects *here ob+ect?id @ >
E" Drop the offending ob+ect so the undo can be released" An eKport or rel$ing on a backup ma$
be necessar$ to restore the ob+ect after the corrupted undo segment is released"
i) Recovery 2i'+ Sys'e, C&ock c+an3e.
9ou can end up *ith duplicate timestamps in the datafiles *hen a s$stem clock changes" This
usuall$ occurs *hen da$light saving comes into or out of the picture" In this case8 rather than a
point in time recover$8 recover to a specif$ log or C(
6) Recovery 2i'+ ,issin3 Sys'e, 'a*&espace.
The onl$ option is to restore from a backup"
k) -edia Recovery o% o%%&ine 'a*&e8space
7hen a tablespace is offline8 $ou cannot recover datafiles belonging to this tablespace using
recover database command" The reason is because a recover database command *ill onl$
recover online datafiles" ince the tablespace is offline8 it thinks the datafiles are offline as *ell8
so even if $ou recover database and roll for*ard8 the datafiles in this tablespace *ill not be
touched" Instead8 $ou need to perform a recover tablespace command" Alternativel$8 $ou could
restored the datafiles from a cold backup8 mount the database and select from the vLdatafile vie*
to see if an$ of the datafiles are offline" If the$ are8 bring them online8 and then $ou can perform
a recover database command"
l) Recover$ of Read,#nl$ tablespaces
If $ou have a current control file8 then recover$ of read onl$ tablespaces is no different than
recovering read,*rite files" The issues *ith read,onl$ tablespaces arise if $ou have to use a
backup control file" If the tablespace is in read,onl$ mode8 and hasnHt changed to read,*rite since
the last backup8 then $ou *ill be able to media recover$ using a backup control file b$ taking the
tablespace offline" The reason here is that *hen $ou are using the backup control file8 $ou must
open the database *ith resetlogs" And *e kno* that #racle *ont let $ou read files from before a
resetlogs *as done" Ao*ever8 there is an eKception *ith read,onl$ tablespaces" 9ou *ill be able
to take the datafiles online after $ou have opened the database"

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close