Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

Database Recovery

Copyright 2008, Oracle. All rights reserved.

Objectives

'ser man) R!A" $*I (! $omplete Incomplete $ontrol file RO +,#

After completing this lesson, you should be able to: Perform complete or incomplete user-managed recovery Identify situations here incomplete recovery is necessary Perform complete or incomplete recovery by using R!A" Perform incomplete recovery based on time, #$", log se%uence, restore points, or the cancel method Recover an automatically bac&ed up control file 'se (nterprise !anage to perform recovery Recover read-only tablespaces
5-2 Copyright 2008, Oracle. All rights reserved.

Recovery !ethods
+here are t o methods for performing recovery: 'ser-managed recovery
-iles must be maintained and moved into place manually) 'se #.*/Plus commands)

R!A" recovery
-iles are managed automatically) 'se R!A" functionality including all repository maintenance and reporting capabilities) +his can be done by using (nterprise !anager) Oracle $orporation recommends using this method)

5-3

Copyright 2008, Oracle. All rights reserved.

'ser-!anaged Recovery: RECOVER $ommand


Restore all database files from a bac&up and then recover the database: Restore the damaged data files from a bac&up and then recover the data files: Or:
SQL> RECOVER DATAFILE 2> '/or d t /indx!"#db$'

SQL> RECOVER DATABASE

SQL> RECOVER TABLESPACE index_tbs

5-4

Copyright 2008, Oracle. All rights reserved.

R!A" Recovery: RESTORE and RECOVER $ommands

'ser man) 0 R!A" $*I (! $omplete Incomplete $ontrol file RO +,#

r%n& s'( )ALTER TABLESPACE in*_tbs OFFLI+E I,,EDIATE)RESTORE TABLESPACE in*_tbsRECOVER TABLESPACE in*_tbs DELETE ARC.IVELO/s'( )ALTER TABLESPACE in*_tbs O+LI+E)0

5-5

Copyright 2008, Oracle. All rights reserved.

Recovery 'sing (nterprise !anager

'ser man) R!A" $*I 0 (! $omplete Incomplete $ontrol file RO +,#

1ith the (nterprise !anager Recovery 1i2ard, you can create and run an R!A" script to perform the recovery)

R,A+> RECOVER DATABASE 1


5Copyright 2008, Oracle. All rights reserved.

$omplete 3ersus Incomplete Recovery


+here are t o types of recovery: $omplete recovery brings the database up to the present, including all committed data changes made to the point in time hen the recovery as re%uested)
$omplete recovery Incomplete recovery Restore from this bac&up !issing transactions after incomplete recovery Recovery tas& started at this time +ime of crash

Incomplete recovery brings the database up to a specified point in time in the past, before the recovery operation as re%uested)
Copyright 2008, Oracle. All rights reserved.

5-!

$omplete Recovery Process


Archived log Archived log Online Redo log $hanges applied Database opened

'ser man) R!A" $*I (! 0 $omplete Incomplete $ontrol file RO +,#

'ndo applied

9 8
Restored data files

5 4
Recovered data files

6
Data files containing committed and uncommitted transactions
Copyright 2008, Oracle. All rights reserved.

5-8

Incomplete Recovery Process


Archived log Archived log Online Redo log

'ser man) R!A" $*I (! $omplete 0 Incomplete $ontrol file RO +,#

$hanges applied to point in time ;PI+<

Database opened

'ndo applied

9 8
Restored data files from as far bac& as necessary

5 4
PI+-recovered data files

6
Data files containing committed and uncommitted +ransactions up to PI+
Copyright 2008, Oracle. All rights reserved.

5-"

$%co&plete 'ecovery (%otes o%ly slide)

5 - #0

Copyright 2008, Oracle. All rights reserved.

#ituations Re%uiring Incomplete Recovery


$omplete recovery fails because of a missing archived log file) One or more unarchived redo log files and a data file are lost) "on-multiple=ed online redo log files are lost)

5 - ##

Copyright 2008, Oracle. All rights reserved.

+ypes of Incomplete Recovery


+here are four types of incomplete recovery: +ime-based recovery $ancel-based recovery $hange-based recovery *og se%uence recovery

5 - #2

Copyright 2008, Oracle. All rights reserved.

*ypes o+ $%co&plete 'ecovery (%otes o%ly slide)

5 - #3

Copyright 2008, Oracle. All rights reserved.

Performing 'ser-!anaged Incomplete Recovery


Recover a database until time:

SQL> RECOVER DATABASE 2+TIL 2 TI,E '2!!34"24"56"26"!6!7'-

Recover a database until cancel:

SQL> RECOVER DATABASE 2+TIL CA+CEL-

Recover using the bac&up control file:

SQL> RECOVER DATABASE 2 2+TIL TI,E '2!!34"24"56"26"!6!7' 7 2SI+/ BAC82P CO+TROLFILE-

5 - #4

Copyright 2008, Oracle. All rights reserved.

Performing 'ser-!anaged Incomplete Recovery


+o perform user-managed incomplete recovery, follo these steps: 8) #hut do n the database) 7) Restore data files) 6) !ount the database) 9) Recover the database) 5) Open the database ith the RESETLO/S option)

5 - #5

Copyright 2008, Oracle. All rights reserved.

'ser-!anaged +ime-,ased Recovery: (=ample


+his is the scenario: A job ran in error, and its effects have to be undone) +his happened 85 minutes ago, and there has been little database activity since then) >ou decide to perform incomplete recovery to restore the database bac& to its state as of 85 minutes ago)
SQL> : ;< SQL> SQL> SQL>
5-#

S.2TDO9+ I,,EDIATE /BAC82P/=#db$/%!"/db!"/ORADATA START2P ,O2+T RECOVER DATABASE 2+TIL TI,E '2!!34""42>6""6556!!'ALTER DATABASE OPE+ RESETLO/SCopyright 2008, Oracle. All rights reserved.

'ser-!anaged +ime-,ased Recovery #teps ;notes only slide<

5 - #!

Copyright 2008, Oracle. All rights reserved.

'ser-!anaged $ancel-,ased Recovery: (=ample


+he scenario is the same as the one for the time-based e=ample, e=cept for these findings: Redo logs are not multiple=ed) One of the online redo logs is missing) +he missing redo log is not archived) +he redo log contained information from 88:69 a)m) + enty-si= minutes of data are lost) 'sers can reenter their data manually)

5 - #8

Copyright 2008, Oracle. All rights reserved.

'ser-!anaged $ancel-,ased Recovery: (=ample


Recover the database as follo s: 8) #hut do n the database) 7) Restore all data files from the most recent bac&up) 6) >ou already have a valid bac&up, so mount the database) 9) (=ecute RECOVER DATABASE 2+TIL CA+CEL) 5) (=ecute ALTER DATABASE OPE+ RESETLO/S to open the database)

5 - #"

Copyright 2008, Oracle. All rights reserved.

Performing Incomplete Recovery by 'sing R!A"


8) 7) 6) 9) !ount the database) Allocate multiple channels for paralleli2ation) Restore all data files) Recover the database by using 2+TIL TI,E, 2+TIL SEQ2E+CE, or 2+TIL SC+) 5) Open the database by using RESETLO/S)

5 - 20

Copyright 2008, Oracle. All rights reserved.

+ime-,ased Recovery 'sing R!A": (=ample


R,A+> 2> 7> 5> 3> R2+ & SET 2+TIL TI,E ? '2!!34""42>6""6556!!'RESTORE DATABASERECOVER DATABASEALTER DATABASE OPE+ RESETLO/S- 0

5 - 2#

Copyright 2008, Oracle. All rights reserved.

*i&e-,ased 'ecovery -si%g '.A/0 12a&ple (%otes o%ly slide)

5 - 22

Copyright 2008, Oracle. All rights reserved.

*og #e%uence Recovery 'sing R!A": (=ample


R,A+> 2> 7> 5> 3> D> E> R2+ & SET 2+TIL SEQ2E+CE "2! T.READ "ALTER DATABASE ,O2+TRESTORE DATABASERECOVER DATABASE- @ re;o*ers tAro%BA (oB ""C ALTER DATABASE OPE+ RESETLO/S0

5 - 23

Copyright 2008, Oracle. All rights reserved.

Incomplete Recovery 'sing (nterprise !anager

5 - 24

Copyright 2008, Oracle. All rights reserved.

Incomplete Recovery and the Alert *og


+he follo ing are some best practices regarding the alert log in incomplete recovery scenarios: $hec& the alert log before and after recovery) *oo& for error information, hints, and #$"s) $onfirm that steps in the recovery process ere successful)

5 - 25

Copyright 2008, Oracle. All rights reserved.

Restore Points
A restore point: #erves as an alias for an #$" or a specific point in time Is stored in the control file $an be used ith:
RECOVER DATABASE FLAS.BAC8 DATABASE FLAS.BAC8 TABLE

be$ore_(o d

8 7
5-2

SQL> CREATE RESTORE POI+T be$ore_(o d-

R,A+> RECOVER DATABASE 2+TIL RESTORE POI+T be$ore_(o dCopyright 2008, Oracle. All rights reserved.

Incomplete Recovery: ,est Practices


Plan for and practice scenarios ahead of time) Investigate and verify that incomplete recovery is necessary) -ollo all steps carefully) +a&e hole database bac&ups before and after recovery) Al ays verify that the recovery as successful) +a&e advantage of restore points)

5 - 2!

Copyright 2008, Oracle. All rights reserved.

$%co&plete 'ecovery ,est 3ractices (%otes o%ly slide)

5 - 28

Copyright 2008, Oracle. All rights reserved.

Recovering a $ontrol -ile Autobac&up


R,A+> RESTORE CO+TROLFILE TO 2> '/or d t /;t($i(e#b F' FRO, A2TOBAC82PRecovery !anager ;R!A"<

'ser man) R!A" $*I (! $omplete Incomplete 0 $ontrol file RO +,#

-lash recovery area RECOVER DATABASE-

$ontrol file Database

ALTER DATABASE OPE+ RESETLO/S-

5 - 2"

Copyright 2008, Oracle. All rights reserved.

'ecoveri%g a Co%trol 4ile A5to6ac75p (%otes o%ly slide)

5 - 30

Copyright 2008, Oracle. All rights reserved.

$reating a "e

$ontrol -ile

#>#+(!

'#(R#

Parameter file
#>#A': I"D(:

Redo log file 8A

Redo log file 8,

Pass ord file


'"DO +(!P

Redo log Redo log file 7A file 7, $ontrol files

SQL> ALTER DATABASE BAC82P CO+TROLFILE TO TRACE-

5 - 3#

Copyright 2008, Oracle. All rights reserved.

$reating a "e

$ontrol -ile

5 - 32

Copyright 2008, Oracle. All rights reserved.

/
$ase 8

Recovering Read-Only +ablespaces


Read-only

'ser man) R!A" $*I (! $omplete Incomplete $ontrol file 0 RO +,#

/
$ase 7 Read-only Read? rite

/
$ase 6 Read? rite Read-only
$ontrol file / bac&up to be used for recovery if current one lost

,ac&up

$hange +ablespace #tate

$rash and perform recovery

5 - 33

Copyright 2008, Oracle. All rights reserved.

'ecoveri%g 'ead-O%ly *a6lespaces (%otes o%ly slide)

5 - 34

Copyright 2008, Oracle. All rights reserved.

Read-Only +ablespace Recovery Issues


#pecial considerations must be ta&en for read-only tablespaces hen: Re-creating a control file Renaming data files 'sing a bac&up control file

5 - 35

Copyright 2008, Oracle. All rights reserved.

'ead-O%ly *a6lespace 'ecovery $ss5es (%otes o%ly slide)

5-3

Copyright 2008, Oracle. All rights reserved.

#ummary
In this lesson, you should have learned ho to: Perform complete or incomplete user-managed recovery Perform complete or incomplete recovery by using R!A" Identify situations here incomplete recovery is necessary Perform incomplete recovery based on time, #$", log se%uence, restore points, or the cancel method Recover a control file autobac&up 'se (nterprise !anage to perform recovery Recover read-only tablespaces
5 - 3! Copyright 2008, Oracle. All rights reserved.

Practice Overvie : Performing Incomplete Recovery


+his practice covers the follo ing topics: Point-in-time recovery using R!A" Recovery from the loss of control files

5 - 38

Copyright 2008, Oracle. All rights reserved.

You might also like