oracle8 advanced backup recovery

76
IOUG-A Live99 Mini-Lessons: Oracle8 Advanced Backup, Restore and Recovery Issues ®

Upload: alokmishra4533

Post on 23-Oct-2015

10 views

Category:

Documents


1 download

DESCRIPTION

Oracle advanced backup recovery

TRANSCRIPT

Page 1: Oracle8 Advanced Backup Recovery

IOUG-A Live99 Mini-Lessons: Oracle8 Advanced Backup, Restore

and Recovery Issues

IOUG-A Live99 Mini-Lessons: Oracle8 Advanced Backup, Restore

and Recovery Issues

®®

Page 2: Oracle8 Advanced Backup Recovery

I-I-22 Copyright Oracle Corporation, 1999. All rights reserved.®

Mini-Lesson OverviewMini-Lesson Overview

• Redo generation and recovery concepts

• Internal recovery structures

• Recovery diagnostics

• Object point-in-time recovery

• Redo generation and recovery concepts

• Internal recovery structures

• Recovery diagnostics

• Object point-in-time recovery

Page 3: Oracle8 Advanced Backup Recovery

I-I-33 Copyright Oracle Corporation, 1999. All rights reserved.®

Redo Generation andRecovery Concepts

Redo Generation andRecovery Concepts

• Identify transactional properties

• Explain the implementation of the redo generation architecture

• Explain recovery concepts

• Recover from failure

• Identify transactional properties

• Explain the implementation of the redo generation architecture

• Explain recovery concepts

• Recover from failure

Page 4: Oracle8 Advanced Backup Recovery

I-I-44 Copyright Oracle Corporation, 1999. All rights reserved.®

Transactional PropertiesTransactional Properties

• In order to maintain consistency at both the database and the transaction level, Oracle must enforce the four ACID properties:

– Atomicity

– Consistency

– Isolation

– Durability

• In order to maintain consistency at both the database and the transaction level, Oracle must enforce the four ACID properties:

– Atomicity

– Consistency

– Isolation

– Durability

Page 5: Oracle8 Advanced Backup Recovery

I-I-66 Copyright Oracle Corporation, 1999. All rights reserved.®

Transaction DurabilityTransaction Durability

Once a transaction has committed it must survive failures.Once a transaction has committed it must survive failures.

Page 6: Oracle8 Advanced Backup Recovery

I-I-77 Copyright Oracle Corporation, 1999. All rights reserved.®

Aim of RecoveryAim of Recovery

• Restore a database to a consistent state in the event of an outage.

• There are two outage classes:

– Planned outages

– Unplanned outages

• Restore a database to a consistent state in the event of an outage.

• There are two outage classes:

– Planned outages

– Unplanned outages

Page 7: Oracle8 Advanced Backup Recovery

I-I-88 Copyright Oracle Corporation, 1999. All rights reserved.®

Logging Transactional ChangesLogging Transactional Changes

Logging methods:

• Physical logging

• Logical logging

• Physiological logging

Logging methods:

• Physical logging

• Logical logging

• Physiological logging

Page 8: Oracle8 Advanced Backup Recovery

I-I-99 Copyright Oracle Corporation, 1999. All rights reserved.®

Logging Transactional ChangesLogging Transactional Changes

LogicalLogical PhysiologicalPhysiological PhysicalPhysical(after images)(after images)

Insert operation

Delete operation

dba A: delete op,insert op

dba B: delete op,insert op

dba C: delete op,insert op

A B C

A B C

Index B

Index C

Table A

Page 9: Oracle8 Advanced Backup Recovery

I-I-1010 Copyright Oracle Corporation, 1999. All rights reserved.®

Redo ArchitectureRedo Architecture

Physiological logging is achieved by coordinating:

– SGA: buffer cache, redo log buffer

– Physical Devices: datafiles, redo log files (online and archived)

– Background processes:LGWR, DBWR,(CKPT,ARCH)

Physiological logging is achieved by coordinating:

– SGA: buffer cache, redo log buffer

– Physical Devices: datafiles, redo log files (online and archived)

– Background processes:LGWR, DBWR,(CKPT,ARCH)

Page 10: Oracle8 Advanced Backup Recovery

I-I-1111 Copyright Oracle Corporation, 1999. All rights reserved.®

Recovery ImplementationRecovery Implementation

The fundamental structures involved in the recovery mechanism are:

– System commit numbers (SCN)

– Redo byte address (RBA)

– Change vectors and redo records

– Redo log files

– Redo threads

– Checkpoint structures

The fundamental structures involved in the recovery mechanism are:

– System commit numbers (SCN)

– Redo byte address (RBA)

– Change vectors and redo records

– Redo log files

– Redo threads

– Checkpoint structures

Page 11: Oracle8 Advanced Backup Recovery

I-I-1313 Copyright Oracle Corporation, 1999. All rights reserved.®

Physiological LoggingPhysiological Logging

SGA

Redolog files

Volatile Volatile block block

versionversion

VolatileVolatileredoredo

versionversion

DurableDurableredoredo

versionversion

PersistentPersistentblockblock

versionversion

Buffercache

Redo logRedo logbufferbuffer

Datafiles

Page 12: Oracle8 Advanced Backup Recovery

I-I-1414 Copyright Oracle Corporation, 1999. All rights reserved.®

Recovery AlgorithmsRecovery Algorithms

A number of algorithms need to interact:

– Page fix

– Write ahead logging

– Log force at commit

– Online log switching

– Checkpointing

A number of algorithms need to interact:

– Page fix

– Write ahead logging

– Log force at commit

– Online log switching

– Checkpointing

Page 13: Oracle8 Advanced Backup Recovery

I-I-1515 Copyright Oracle Corporation, 1999. All rights reserved.®

Page Fix RulePage Fix Rule

• Lock a page (buffer) prior to reading or modifying.

• Generate redo prior to modifying the page.

• Maintain page consistency and isolation.

• Lock a page (buffer) prior to reading or modifying.

• Generate redo prior to modifying the page.

• Maintain page consistency and isolation.

Page 14: Oracle8 Advanced Backup Recovery

I-I-1616 Copyright Oracle Corporation, 1999. All rights reserved.®

Write-Ahead LoggingWrite-Ahead Logging

Write ahead logging guarantees:

– Before DBWR writes a data block buffer, LGWR must have written the necessary redo records to the log files.

– Before a block buffer is changed in the buffer cache, redo must have been written to the log buffer.

Write ahead logging guarantees:

– Before DBWR writes a data block buffer, LGWR must have written the necessary redo records to the log files.

– Before a block buffer is changed in the buffer cache, redo must have been written to the log buffer.

Page 15: Oracle8 Advanced Backup Recovery

I-I-1717 Copyright Oracle Corporation, 1999. All rights reserved.®

Log Force at CommitLog Force at Commit

A commit:

• Signals a completed transaction

• Forces redo entries to disk

– Group commits

• Does not write data blocks

– No datablock force at commit

A commit:

• Signals a completed transaction

• Forces redo entries to disk

– Group commits

• Does not write data blocks

– No datablock force at commit

Page 16: Oracle8 Advanced Backup Recovery

I-I-1818 Copyright Oracle Corporation, 1999. All rights reserved.®

Online Log SwitchingOnline Log Switching

Not enough space in the current log; need to find a suitable candidate amongst the other online logs

– Not active

– Checkpoint complete

– Archiving not required

Not enough space in the current log; need to find a suitable candidate amongst the other online logs

– Not active

– Checkpoint complete

– Archiving not required

Page 17: Oracle8 Advanced Backup Recovery

I-I-1919 Copyright Oracle Corporation, 1999. All rights reserved.®

CheckpointsCheckpoints

• Points in the redo stream before which all dirty blocks have been written to disk.

• Checkpoints occur in several contexts:

– Thread checkpoint

– Database checkpoint

– Datafile checkpoint

– Mini checkpoint (DDL based)

• Points in the redo stream before which all dirty blocks have been written to disk.

• Checkpoints occur in several contexts:

– Thread checkpoint

– Database checkpoint

– Datafile checkpoint

– Mini checkpoint (DDL based)

Page 18: Oracle8 Advanced Backup Recovery

I-I-2121 Copyright Oracle Corporation, 1999. All rights reserved.®

Redo StreamRedo Stream

The logical life of a database is between two resetlogs points.The logical life of a database is between two resetlogs points.

TimeTime

1. 2. 3.

RedoRedologslogs Log LogLog

Data

Log

Data

Page 19: Oracle8 Advanced Backup Recovery

I-I-2222 Copyright Oracle Corporation, 1999. All rights reserved.®

Recovery MechanismsRecovery Mechanisms

Oracle provides three types of recovery mechanisms:

– Block level recovery

– Thread recovery

– Media recovery

Oracle provides three types of recovery mechanisms:

– Block level recovery

– Thread recovery

– Media recovery

Page 20: Oracle8 Advanced Backup Recovery

I-I-2323 Copyright Oracle Corporation, 1999. All rights reserved.®

Redo Generation andRecovery Concepts - Summary

Redo Generation andRecovery Concepts - Summary

• ACID properties

• Physiological logging

• Write ahead logging

• Checkpoints

• Instance/crash/thread recovery

• ACID properties

• Physiological logging

• Write ahead logging

• Checkpoints

• Instance/crash/thread recovery

Page 21: Oracle8 Advanced Backup Recovery

I-I-2424 Copyright Oracle Corporation, 1999. All rights reserved.®

Internal Recovery StructuresInternal Recovery Structures

• Explain

– Change vectors and redo records

– Redo byte addresses

– Redo threads

• Understand

– Redo log buffer and checkpoints

– Control file data structures

• Explain

– Change vectors and redo records

– Redo byte addresses

– Redo threads

• Understand

– Redo log buffer and checkpoints

– Control file data structures

Page 22: Oracle8 Advanced Backup Recovery

I-I-2525 Copyright Oracle Corporation, 1999. All rights reserved.®

System Change/Commit NumbersSystem Change/Commit Numbers

• They describe the committed version of a database

• SCN components:

– Base (4 bytes)

– Wrap (2 bytes)

• Used for concurrency control, redo log ordering, and recovery.

• They describe the committed version of a database

• SCN components:

– Base (4 bytes)

– Wrap (2 bytes)

• Used for concurrency control, redo log ordering, and recovery.

Page 23: Oracle8 Advanced Backup Recovery

I-I-2626 Copyright Oracle Corporation, 1999. All rights reserved.®

Change VectorsChange Vectors

• They describe a single change to one data block

• Contain information required to move the block from one consistent state to the next

– DBA, SCN, SEQ and the operation

• Always created before modifying a data block buffer

• They describe a single change to one data block

• Contain information required to move the block from one consistent state to the next

– DBA, SCN, SEQ and the operation

• Always created before modifying a data block buffer

Page 24: Oracle8 Advanced Backup Recovery

I-I-2727 Copyright Oracle Corporation, 1999. All rights reserved.®

Change Vector Header ExampleChange Vector Header Example

• TYP Change type

• CLS Block class

• AFN Absolute file number

• DBA Relative DBA

• TYP Change type

• CLS Block class

• AFN Absolute file number

• DBA Relative DBA

CHANGE#1 TYP:0 CLS:15AFN:2 DBA:0x00800002SCN:0x0000.0000e4d0 SEQ:1 OP:5.2

Page 25: Oracle8 Advanced Backup Recovery

I-I-2828 Copyright Oracle Corporation, 1999. All rights reserved.®

Change Vector Header ExampleChange Vector Header Example

• SCN System commit number

• SEQ Sequence number

• OP Operation code

• SCN System commit number

• SEQ Sequence number

• OP Operation code

CHANGE#1 TYP:0 CLS:15AFN:2 DBA:0x00800002SCN:0x0000.0000e4d0 SEQ:1 OP:5.2

Page 26: Oracle8 Advanced Backup Recovery

I-I-2929 Copyright Oracle Corporation, 1999. All rights reserved.®

Redo RecordsRedo Records

• Describe an atomic database change

• Consist of one or more change vectors

• Generated before modifying a buffer

• Recovery guarantees all or no changes occur when applying a redo record

• Ordered by SCNs

• Describe an atomic database change

• Consist of one or more change vectors

• Generated before modifying a buffer

• Recovery guarantees all or no changes occur when applying a redo record

• Ordered by SCNs

Page 27: Oracle8 Advanced Backup Recovery

I-I-3030 Copyright Oracle Corporation, 1999. All rights reserved.®

Redo Record ExampleRedo Record Example

REDO RECORD - Thread:1RBA:0x000065.00000002.0010 LEN:0x02f0 VLD:0x01SCN scn:0x0000.0000e4d3 05/12/98 15:19:54

CHANGE #1 TYP:0 CLS:15 AFN:2 DBA:0x00800002 SCN:0x0000.0000e4d0 SEQ:1 OP:5.2CHANGE #2 TYP:0 CLS:16 AFN:2 DBA:0x0080006d SCN:0x0000.0000e4ce SEQ:1 OP:5.1CHANGE #3 TYP:2 CLS:1 AFN:12 DBA:0x03000003 SCN:0x0000.0000e4b2 SEQ:1 OP:11.11CHANGE #4 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:5.19

Page 28: Oracle8 Advanced Backup Recovery

I-I-3131 Copyright Oracle Corporation, 1999. All rights reserved.®

Redo Byte Address (RBA)Redo Byte Address (RBA)

• Identifies the start of a redo record within a log file or archive file

• Points to a specific location in a particular redo thread

• Components: log sequence number, block address, and byte offset within that block

• Stored in datafile headers and in each datafile entry in the control file

• Identifies the start of a redo record within a log file or archive file

• Points to a specific location in a particular redo thread

• Components: log sequence number, block address, and byte offset within that block

• Stored in datafile headers and in each datafile entry in the control file

Page 29: Oracle8 Advanced Backup Recovery

I-I-3232 Copyright Oracle Corporation, 1999. All rights reserved.®

Redo LogsRedo Logs

• Datablock changes are made by creating:

– A change vector for the change.

– A redo record for a set of change vectors.

• Redo records are saved to a redo log.

• Redo records in a log are ordered by SCN.

• Redo log header contains:

– Low SCN

– Next SCN

• Datablock changes are made by creating:

– A change vector for the change.

– A redo record for a set of change vectors.

• Redo records are saved to a redo log.

• Redo records in a log are ordered by SCN.

• Redo log header contains:

– Low SCN

– Next SCN

Page 30: Oracle8 Advanced Backup Recovery

I-I-3333 Copyright Oracle Corporation, 1999. All rights reserved.®

CheckpointsCheckpoints

• Points in the redo where all write operations of committed transactions have been written to disk

• Database, thread, and datafile checkpoint information must be stored

• Help to determine where recovery should start

• Points in the redo where all write operations of committed transactions have been written to disk

• Database, thread, and datafile checkpoint information must be stored

• Help to determine where recovery should start

Page 31: Oracle8 Advanced Backup Recovery

I-I-3434 Copyright Oracle Corporation, 1999. All rights reserved.®

Checkpoint StructureCheckpoint Structure

• Checkpoint SCN

• Time that the SCN was allocated

• Thread which issued the checkpoint

• RBA where the SCN was allocated

• Enabled thread bit vector (bitvec)

• Checkpoint SCN

• Time that the SCN was allocated

• Thread which issued the checkpoint

• RBA where the SCN was allocated

• Enabled thread bit vector (bitvec)

Page 32: Oracle8 Advanced Backup Recovery

I-I-3535 Copyright Oracle Corporation, 1999. All rights reserved.®

Generic Control File HeaderGeneric Control File Header

• Database components:Database entry x$kccdiCheckpoint progress records x$kcccpRedo thread records x$kccrtLog file records x$kccleData file records x$kccfeLog file history records x$kcclh

• TSPIT recovery information:Tablespace records x$kccts

• Database components:Database entry x$kccdiCheckpoint progress records x$kcccpRedo thread records x$kccrtLog file records x$kccleData file records x$kccfeLog file history records x$kcclh

• TSPIT recovery information:Tablespace records x$kccts

Page 33: Oracle8 Advanced Backup Recovery

I-I-3636 Copyright Oracle Corporation, 1999. All rights reserved.®

RMAN related information:

– Offline range records x$kccor

– Archived log records x$kccal

– Backup set records x$kccbs

– Backup piece records x$kccbp

– Backup datafile records x$kccbf

RMAN related information:

– Offline range records x$kccor

– Archived log records x$kccal

– Backup set records x$kccbs

– Backup piece records x$kccbp

– Backup datafile records x$kccbf

Generic Control File HeaderGeneric Control File Header

Page 34: Oracle8 Advanced Backup Recovery

I-I-3737 Copyright Oracle Corporation, 1999. All rights reserved.®

RMAN related information:

– Backup log records x$kccbl

– Datafile copy records x$kccdc

– Backup datafile x$kccfccorruption records

– Datafile copy x$kcccccorruption records

– Deletion records x$kccdl

RMAN related information:

– Backup log records x$kccbl

– Datafile copy records x$kccdc

– Backup datafile x$kccfccorruption records

– Datafile copy x$kcccccorruption records

– Deletion records x$kccdl

Generic Control File HeaderGeneric Control File Header

Page 35: Oracle8 Advanced Backup Recovery

I-I-3838 Copyright Oracle Corporation, 1999. All rights reserved.®

Internal Recovery Structures - Summary

Internal Recovery Structures - Summary

• Explain

– Change vectors and redo records

– Redo byte addresses

– Redo threads

• Understand

– Redo log buffer and checkpoints

– Control file data structures

• Explain

– Change vectors and redo records

– Redo byte addresses

– Redo threads

• Understand

– Redo log buffer and checkpoints

– Control file data structures

Page 36: Oracle8 Advanced Backup Recovery

I-I-3939 Copyright Oracle Corporation, 1999. All rights reserved.®

Recovery DiagnosticsRecovery Diagnostics

• Approach and resolve database recovery issues correctly

• Dump and interpret file diagnostics

• Identify recovery-related v$ views

• Explain recovery-related error messages

• Approach and resolve database recovery issues correctly

• Dump and interpret file diagnostics

• Identify recovery-related v$ views

• Explain recovery-related error messages

Page 37: Oracle8 Advanced Backup Recovery

I-I-4040 Copyright Oracle Corporation, 1999. All rights reserved.®

Gather Diagnostics InformationGather Diagnostics Information

• The alert log gives a good summary of what has happened.

• Search for relevant trace files

• File header information from v$ views

• Dump file headers in the event the control files are unreliable

– using backup controlfile

• The alert log gives a good summary of what has happened.

• Search for relevant trace files

• File header information from v$ views

• Dump file headers in the event the control files are unreliable

– using backup controlfile

Page 38: Oracle8 Advanced Backup Recovery

I-I-4141 Copyright Oracle Corporation, 1999. All rights reserved.®

V$ Views: Database InformationV$ Views: Database Information

V$DATABASE

• Externalizes database information from the controlfile

• CONTROLFILE_TYPE = CURRENTfor a current controlfile

V$DATABASE

• Externalizes database information from the controlfile

• CONTROLFILE_TYPE = CURRENTfor a current controlfile

Page 39: Oracle8 Advanced Backup Recovery

I-I-4242 Copyright Oracle Corporation, 1999. All rights reserved.®

V$ Views: Controlfile InformationV$ Views: Controlfile Information

V$CONTROLFILE

• Controlfile names

V$CONTROLFILE

• Controlfile names

Page 40: Oracle8 Advanced Backup Recovery

I-I-4343 Copyright Oracle Corporation, 1999. All rights reserved.®

V$ Views: Datafile InformationV$ Views: Datafile Information

V$DATAFILE

• Most information is from the controlfile

• Status of the datafiles to be recovered

• CREATION_CHANGE# :SCN at which the datafile is created

• BYTES: datafile size expected by Oracle

V$DATAFILE

• Most information is from the controlfile

• Status of the datafiles to be recovered

• CREATION_CHANGE# :SCN at which the datafile is created

• BYTES: datafile size expected by Oracle

Page 41: Oracle8 Advanced Backup Recovery

I-I-4444 Copyright Oracle Corporation, 1999. All rights reserved.®

V$ Views: Datafile InformationV$ Views: Datafile Information

V$RECOVER_FILE

• Files in need of media recovery

• ONLINE: file status; shown as RECOVER in V$DATAFILE

• CHANGE# :SCN of first redo to start recovery

• See also V$RECOVERY_LOG

V$RECOVER_FILE

• Files in need of media recovery

• ONLINE: file status; shown as RECOVER in V$DATAFILE

• CHANGE# :SCN of first redo to start recovery

• See also V$RECOVERY_LOG

Page 42: Oracle8 Advanced Backup Recovery

I-I-4545 Copyright Oracle Corporation, 1999. All rights reserved.®

V$ Views: Datafile InformationV$ Views: Datafile Information

V$DATAFILE_HEADER

• Externalizes file_hdrs dump information

• Derived from the file header itself

• Status of the datafile

V$BACKUP

• Datafiles in hot backup mode

V$DATAFILE_HEADER

• Externalizes file_hdrs dump information

• Derived from the file header itself

• Status of the datafile

V$BACKUP

• Datafiles in hot backup mode

Page 43: Oracle8 Advanced Backup Recovery

I-I-4646 Copyright Oracle Corporation, 1999. All rights reserved.®

V$ Views: Online Redo Log Information

V$ Views: Online Redo Log Information

V$LOGFILE

• Names and statuses of online logs

• Information from the controlfile

V$LOG

• Online log information

• Information from the controlfile

V$LOGFILE

• Names and statuses of online logs

• Information from the controlfile

V$LOG

• Online log information

• Information from the controlfile

Page 44: Oracle8 Advanced Backup Recovery

I-I-4747 Copyright Oracle Corporation, 1999. All rights reserved.®

V$ Views: Offline Redo Log Information

V$ Views: Offline Redo Log Information

V$RECOVERY_LOG

• Archived logs required to recover the database

• ARCHIVE_NAME: name of archive log

• SEQUENCE# : log sequence number

V$LOG_HISTORY

• Externalizes the controlfile log history table

V$RECOVERY_LOG

• Archived logs required to recover the database

• ARCHIVE_NAME: name of archive log

• SEQUENCE# : log sequence number

V$LOG_HISTORY

• Externalizes the controlfile log history table

Page 45: Oracle8 Advanced Backup Recovery

I-I-4848 Copyright Oracle Corporation, 1999. All rights reserved.®

V$ Views: Server-Managed Recovery Information

V$ Views: Server-Managed Recovery Information

• V$RECOVERY_STATUS, V$RECOVERY_PROGRESS

• V$BACKUP_DEVICE

• V$DATAFILE_COPY

• V$BACKUP_CORRUPTION, V$COPY_CORRUPTION

• V$BACKUP_SET, V$BACKUP_PIECE

• V$BACKUP_DATAFILE, V$BACKUP_REDOLOG

• V$RECOVERY_STATUS, V$RECOVERY_PROGRESS

• V$BACKUP_DEVICE

• V$DATAFILE_COPY

• V$BACKUP_CORRUPTION, V$COPY_CORRUPTION

• V$BACKUP_SET, V$BACKUP_PIECE

• V$BACKUP_DATAFILE, V$BACKUP_REDOLOG

Page 46: Oracle8 Advanced Backup Recovery

I-I-4949 Copyright Oracle Corporation, 1999. All rights reserved.®

File Structure and Header AnalysisFile Structure and Header Analysis

• Dump controlfile, datafile headers, and redo log headers

• Generic dump information

• Controlfile dump

• Datafile headers dump

• Redo log headers dump

• Dump controlfile, datafile headers, and redo log headers

• Generic dump information

• Controlfile dump

• Datafile headers dump

• Redo log headers dump

Page 47: Oracle8 Advanced Backup Recovery

I-I-5050 Copyright Oracle Corporation, 1999. All rights reserved.®

Dumping HeadersDumping Headers

• Controlfile header dump:SVRMGR> alter session set events 'immediate

2> trace name controlf level N';

• Datafile header dump:SVRMGR> alter session set events 'immediate

2> trace name file_hdrs level N';

• Redo log header dump:SVRMGR> alter session set events 'immediate 2> trace name redohdr level N';

• Controlfile header dump:SVRMGR> alter session set events 'immediate

2> trace name controlf level N';

• Datafile header dump:SVRMGR> alter session set events 'immediate

2> trace name file_hdrs level N';

• Redo log header dump:SVRMGR> alter session set events 'immediate 2> trace name redohdr level N';

Page 48: Oracle8 Advanced Backup Recovery

I-I-5151 Copyright Oracle Corporation, 1999. All rights reserved.®

File Dump LevelsFile Dump Levels

Level 1: Generic file header

Level 2: = Level 1+ database information+ checkpoint progress records

Level > 2: = Level 2+ reuse record section

CALL SUPPORT FOR GUIDANCE!

Level 1: Generic file header

Level 2: = Level 1+ database information+ checkpoint progress records

Level > 2: = Level 2+ reuse record section

CALL SUPPORT FOR GUIDANCE!

Page 49: Oracle8 Advanced Backup Recovery

I-I-5252 Copyright Oracle Corporation, 1999. All rights reserved.®

Recovery Diagnostics - SummaryRecovery Diagnostics - Summary

• Approach and resolve database recovery issues correctly

• Dump and interpret file diagnostics

• Identify recovery-related v$ views

• Explain recovery-related error messages

• Approach and resolve database recovery issues correctly

• Dump and interpret file diagnostics

• Identify recovery-related v$ views

• Explain recovery-related error messages

Page 50: Oracle8 Advanced Backup Recovery

I-I-5353 Copyright Oracle Corporation, 1999. All rights reserved.®

Object Point-in-Time RecoveryObject Point-in-Time Recovery

Explain:

• Explain the requirement for object point in time recovery (PITR)

• Explain Oracle7 object PITR

– much better alternative to using EXP/IMP

• Explain Oracle8 tablespace point in time recovery (TSPITR)

Explain:

• Explain the requirement for object point in time recovery (PITR)

• Explain Oracle7 object PITR

– much better alternative to using EXP/IMP

• Explain Oracle8 tablespace point in time recovery (TSPITR)

Page 51: Oracle8 Advanced Backup Recovery

I-I-5454 Copyright Oracle Corporation, 1999. All rights reserved.®

Requirements for Object PIT Recovery

Requirements for Object PIT Recovery

Reclaim an object in an earlier state.For example, following:

• Drop table

• Truncate table

• Erroneous data changes

Reclaim an object in an earlier state.For example, following:

• Drop table

• Truncate table

• Erroneous data changes

Page 52: Oracle8 Advanced Backup Recovery

I-I-5555 Copyright Oracle Corporation, 1999. All rights reserved.®

Object PITR in Oracle7Object PITR in Oracle7

• Object PITR works at the object level.

• The user is responsible for checking integrity constraints.

• Recovery time depends on export/import table performance.

• Object PITR works at the object level.

• The user is responsible for checking integrity constraints.

• Recovery time depends on export/import table performance.

Page 53: Oracle8 Advanced Backup Recovery

I-I-5656 Copyright Oracle Corporation, 1999. All rights reserved.®

Oracle7: First StepOracle7: First Step

1.1. Restore a subset of the primary database to a separate location:

– SYSTEM tablespace datafiles

– RBS tablespace datafiles

– At least one controlfile

– All datafiles holding extents from the required table

– leave space for online redo log files

1.1. Restore a subset of the primary database to a separate location:

– SYSTEM tablespace datafiles

– RBS tablespace datafiles

– At least one controlfile

– All datafiles holding extents from the required table

– leave space for online redo log files

Page 54: Oracle8 Advanced Backup Recovery

I-I-5757 Copyright Oracle Corporation, 1999. All rights reserved.®

Oracle7: Other StepsOracle7: Other Steps

2.2. Mount the subset database, drop unneeded files, rename needed data files and redo files

3. Use standard recovery techniques to recover the subset database to a PIT.

3.3. Alter database open resetlogs.

4.4. Export the table from the subset database.

5.5. Import the table back into the primary database.

2.2. Mount the subset database, drop unneeded files, rename needed data files and redo files

3. Use standard recovery techniques to recover the subset database to a PIT.

3.3. Alter database open resetlogs.

4.4. Export the table from the subset database.

5.5. Import the table back into the primary database.

Page 55: Oracle8 Advanced Backup Recovery

I-I-5858 Copyright Oracle Corporation, 1999. All rights reserved.®

Object PITR Alternatives in Oracle8Object PITR Alternatives in Oracle8

• Use the Oracle7 method

• Use the new tablespace point-in-time recovery feature (TSPITR)

– This recovers whole tablespaces rather than individual objects

• Use the Oracle7 method

• Use the new tablespace point-in-time recovery feature (TSPITR)

– This recovers whole tablespaces rather than individual objects

Page 56: Oracle8 Advanced Backup Recovery

I-I-5959 Copyright Oracle Corporation, 1999. All rights reserved.®

TSPITR WarningsTSPITR Warnings

• TSPITR is complicated, and should not be attempted without practice.

• Ensure you understand all the implications before using it.

• TSPITR is complicated, and should not be attempted without practice.

• Ensure you understand all the implications before using it.

Page 57: Oracle8 Advanced Backup Recovery

I-I-6060 Copyright Oracle Corporation, 1999. All rights reserved.®

TSPITR BasicsTSPITR Basics

• The tablespace is recovered to PIT on a clone database.

• The datafiles from the tablespace are copied to the primary database.

• The primary database is then modified to accept these datafiles using new EXP/IMP features

– EXP data dictionary info from subset

– IMP data dictionary info back into primary

• The tablespace is recovered to PIT on a clone database.

• The datafiles from the tablespace are copied to the primary database.

• The primary database is then modified to accept these datafiles using new EXP/IMP features

– EXP data dictionary info from subset

– IMP data dictionary info back into primary

Page 58: Oracle8 Advanced Backup Recovery

I-I-6161 Copyright Oracle Corporation, 1999. All rights reserved.®

TSPITR LimitationsTSPITR Limitations

• Cannot

– undo drop tablespace

– recover a tablespace that has been dropped and recreated with the same name

– remove datafiles added to a tablespace

• Cannot

– undo drop tablespace

– recover a tablespace that has been dropped and recreated with the same name

– remove datafiles added to a tablespace

Page 59: Oracle8 Advanced Backup Recovery

I-I-6262 Copyright Oracle Corporation, 1999. All rights reserved.®

TSPITR Dependency RulesTSPITR Dependency Rules

•All objects must be fully contained:

– Tables/clusters and their indexes

– Partitioned objects

– indexes enforcing PK/FK relationships

– All elements of a LOB (segment, index, and locator)

•view TS_PITR_OBJECTS_TO_BE_DROPPED for checking

•All objects must be fully contained:

– Tables/clusters and their indexes

– Partitioned objects

– indexes enforcing PK/FK relationships

– All elements of a LOB (segment, index, and locator)

•view TS_PITR_OBJECTS_TO_BE_DROPPED for checking

Page 60: Oracle8 Advanced Backup Recovery

I-I-6363 Copyright Oracle Corporation, 1999. All rights reserved.®

TSPITR Dependency RulesTSPITR Dependency Rules

• Tablespaces should not contain:

– Replicated master tables.

– Tables with VARRAY columns.

– Nested tables.

– Tables with external BFILEs

– Snapshot logs, snapshot tables.

– Index-only tables

• view TS_PITR_CHECK for dependency checks

• Tablespaces should not contain:

– Replicated master tables.

– Tables with VARRAY columns.

– Nested tables.

– Tables with external BFILEs

– Snapshot logs, snapshot tables.

– Index-only tables

• view TS_PITR_CHECK for dependency checks

Page 61: Oracle8 Advanced Backup Recovery

I-I-6464 Copyright Oracle Corporation, 1999. All rights reserved.®

Steps Involved in TSPITRSteps Involved in TSPITR

• Prepare primary database.

• Prepare, configure and start clone database in nomount mode.

• Prepare clone database for recovery, recover and open clone database.

• Export clone database, move datafiles to primary database, and import into primary database.

• Prepare primary database.

• Prepare, configure and start clone database in nomount mode.

• Prepare clone database for recovery, recover and open clone database.

• Export clone database, move datafiles to primary database, and import into primary database.

Page 62: Oracle8 Advanced Backup Recovery

I-I-6565 Copyright Oracle Corporation, 1999. All rights reserved.®

Prepare Primary DatabasePrepare Primary Database

alter system archive log current;

alter rollback segment <name> offline;

alter tablespace <name> offline;

alter system archive log current;

alter rollback segment <name> offline;

alter tablespace <name> offline;

Page 63: Oracle8 Advanced Backup Recovery

I-I-6666 Copyright Oracle Corporation, 1999. All rights reserved.®

Prepare Clone DatabasePrepare Clone Database

• Restore the auxiliary set.

• Restore the recovery set.

• Restore the controlfiles.

• Restore the auxiliary set.

• Restore the recovery set.

• Restore the controlfiles.

Page 64: Oracle8 Advanced Backup Recovery

I-I-6767 Copyright Oracle Corporation, 1999. All rights reserved.®

Configure Clone DatabaseConfigure Clone Database

Configure the parameter file for the clone database (initclone.ora).

• CONTROL_FILES:Must point to the new location

• LOCK_NAME_SPACE: Set to CLONE

• DB_FILE_NAME_CONVERT

• LOG_FILE_NAME_CONVERT

Configure the parameter file for the clone database (initclone.ora).

• CONTROL_FILES:Must point to the new location

• LOCK_NAME_SPACE: Set to CLONE

• DB_FILE_NAME_CONVERT

• LOG_FILE_NAME_CONVERT

Page 65: Oracle8 Advanced Backup Recovery

I-I-6868 Copyright Oracle Corporation, 1999. All rights reserved.®

Start Clone DatabaseStart Clone Database

All datafiles will be offline.All datafiles will be offline.

startup nomount pfile=initclone.ora;

alter database mount clone database;

Page 66: Oracle8 Advanced Backup Recovery

I-I-6969 Copyright Oracle Corporation, 1999. All rights reserved.®

Prepare Clone Database for Recovery

Prepare Clone Database for Recovery

• If any files need renaming:

• For all files in the recovery set and auxiliary set:

• If any files need renaming:

• For all files in the recovery set and auxiliary set:

alter database datafile 'name' online

alter database rename file 'name'

select name,status from v$datafile

Page 67: Oracle8 Advanced Backup Recovery

I-I-7070 Copyright Oracle Corporation, 1999. All rights reserved.®

Recover and Open Clone DatabaseRecover and Open Clone Database

• Recover to a point in time:

• Open clone database:

• Recover to a point in time:

• Open clone database:

recover database using backup controlfileuntil {cancel|change <scn>|time '...'}

alter database open resetlogs

Page 68: Oracle8 Advanced Backup Recovery

I-I-7171 Copyright Oracle Corporation, 1999. All rights reserved.®

Prepare for Clone Database ExportPrepare for Clone Database Export

Query TS_PITR_CHECK to check that you have no dependency problems (references out or into the recovery set).

Query TS_PITR_CHECK to check that you have no dependency problems (references out or into the recovery set).

Page 69: Oracle8 Advanced Backup Recovery

I-I-7272 Copyright Oracle Corporation, 1999. All rights reserved.®

Export Clone DatabaseExport Clone Database

• EXP has extra parameters for TSPITR– POINT_IN_TIME_RECOVER=Y

– RECOVERY_TABLESPACES=list

• The export must be run as sys,or you will get error ORA-23903.

• Example:

• EXP has extra parameters for TSPITR– POINT_IN_TIME_RECOVER=Y

– RECOVERY_TABLESPACES=list

• The export must be run as sys,or you will get error ORA-23903.

• Example:

% exp sys/<pwd> point_in_time_recover=y \ recovery_tablespaces='TS_A','TS_B'

Page 70: Oracle8 Advanced Backup Recovery

I-I-7373 Copyright Oracle Corporation, 1999. All rights reserved.®

Move Datafiles to Primary DatabaseMove Datafiles to Primary Database

• Shut down clone database.

• Alter all recovery set tablespaces offline in the primary database.

• Copy all the recovery set datafiles from the clone to the primary database.

– Take the tablespaces offline first.

• Shut down clone database.

• Alter all recovery set tablespaces offline in the primary database.

• Copy all the recovery set datafiles from the clone to the primary database.

– Take the tablespaces offline first.

Page 71: Oracle8 Advanced Backup Recovery

I-I-7474 Copyright Oracle Corporation, 1999. All rights reserved.®

Import into Primary DatabaseImport into Primary Database

• IMP has an extra parameter for TSPITRPOINT_IN_TIME_RECOVER=Y

• Example:

• IMP has an extra parameter for TSPITRPOINT_IN_TIME_RECOVER=Y

• Example:

% imp sys/<pwd> \ point_in_time_recover=y

Page 72: Oracle8 Advanced Backup Recovery

I-I-7575 Copyright Oracle Corporation, 1999. All rights reserved.®

Complete the TSPITRComplete the TSPITR

• Configure the primary database:

– Bring all recovery set tablespaces online, rebuild indexes / constraints, gather statistics.

• Backup the recovery set tablespaces on the primary database.

– Media recovery will not work through TSPITR.

• Discard the clone database.

• Configure the primary database:

– Bring all recovery set tablespaces online, rebuild indexes / constraints, gather statistics.

• Backup the recovery set tablespaces on the primary database.

– Media recovery will not work through TSPITR.

• Discard the clone database.

Page 73: Oracle8 Advanced Backup Recovery

I-I-7676 Copyright Oracle Corporation, 1999. All rights reserved.®

TSPITR of Individual PartitionsTSPITR of Individual Partitions

TSPITR cannot recover individual partitions. Use the following steps:

• Convert the partition to a normal table.

• Use TSPITR to recover that table.

• Swap the table back into the partition on the primary database.

• Correct any partition indexes.

TSPITR cannot recover individual partitions. Use the following steps:

• Convert the partition to a normal table.

• Use TSPITR to recover that table.

• Swap the table back into the partition on the primary database.

• Correct any partition indexes.

Page 74: Oracle8 Advanced Backup Recovery

I-I-7777 Copyright Oracle Corporation, 1999. All rights reserved.®

Point in Time Recovery - SummaryPoint in Time Recovery - Summary

• Explain the requirement for object point in time recovery (PITR).

• Explain Oracle7 object PITR

– proven, relatively simple

• Explain Oracle8 tablespace point in time recovery (TSPITR)

– new and relatively complex

– good for large volumes of data

• Explain the requirement for object point in time recovery (PITR).

• Explain Oracle7 object PITR

– proven, relatively simple

• Explain Oracle8 tablespace point in time recovery (TSPITR)

– new and relatively complex

– good for large volumes of data

Page 75: Oracle8 Advanced Backup Recovery

I-I-7878 Copyright Oracle Corporation, 1999. All rights reserved.®

Mini-Lesson - SummaryMini-Lesson - Summary

• Redo generation and recovery concepts

• Internal recovery structures

• Recovery diagnostics

• Object point-in-time recovery

• Redo generation and recovery concepts

• Internal recovery structures

• Recovery diagnostics

• Object point-in-time recovery

Page 76: Oracle8 Advanced Backup Recovery

I-I-7979 Copyright Oracle Corporation, 1999. All rights reserved.®

ReferencesReferences

• Oracle8 Backup and Recovery Guide

• Oracle8 Backup and Recovery Handbook

– Rama Velpuri and Anand Adkoli

• ?/rdbms/doc/README.pit

• Oracle8 Backup and Recovery Guide

• Oracle8 Backup and Recovery Handbook

– Rama Velpuri and Anand Adkoli

• ?/rdbms/doc/README.pit