Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

18
Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen

Transcript of Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Page 1: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Backup and Recovery (2)

Oracle 10g

CAP364 1Hebah ElGibreen

Page 2: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Outline

Introduction Backup and Recovery, Why? Principle of Backup and Recovery Backup Recovery

Recovery Commands Forms of Data Recovery (Choosing the Right Strategy) Flashback Technology Flash Recovery Area Enterprise Manager:

Perform Recovery Configure Recovery Settings

Practice

CAP364 2Hebah ElGibreen

Page 3: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Recovery Commands: Overview

The two most important Recovery Manager commands for repairing a database are RESTOR and RECOVER.

The words restore and recover have specialized technical meanings for the database administrator. The word restore refers to the operation of replacing a

damaged or missing file from a backup copy.

The word recover refers to the process of replaying transactions recorded in the redo logs and making the database usable again.

CAP364 3Hebah ElGibreen

Page 4: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Recovery Commands: Overview

When attempts to open a database, Recovery is caused when the database files are not synchronized on shutdown.

After the instance is open, Restore is needed if the instance failed, this happens in case of the loss of:

Any control file A data file belonging to the system or undo tablespaces. An entire redo log group.

CAP364 4Hebah ElGibreen

Page 5: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Recovery Commands: Instance Recovery

Instance Recovery Phases:1. Data files out of sync.

2. Roll forward (redo).

3. Committed and noncommitted data in files.

4. Roll back (undo).

5. Only committed data in files.

CAP364 5Hebah ElGibreen

Database

Undo

Instance

Backgroundprocesses

Data fileSCN: 99

Data fileSCN: 129

Data fileSCN: 140

Control fileSCN: 143

Control fileSCN: 143

Redo loggroupSCN 74-101

Redo loggroupSCN 102-143

SGA

Page 6: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Recovery Commands: Restore

Loss of a Control File: If a control file is lost or corrupted, the instance normally aborts, and you must perform the following steps:

1. Shutdown the instance, if it is still open.

2. Restore the missing control file by copying an existing control file.

You can copy one of the remaining control files to some other location and update the instances parameter file to point to the new location.

OR, you can delete the reference to the missing control file from the initialization parameter file (Oracle recommends must have at least two control files at all times).

3. Start the instance.

Control filesCAP364 6Hebah ElGibreen

Page 7: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Recovery Commands: Restore

Loss of a Redo Log File: If a member of a redo log file group is lost, as long as the group still has at least one member, then:

1. Determine whether there is a missing log file by examining the alert log.

2. Restore the missing file by first dropping the lost redo log member.

3. Then add a new member to replace the lost redo log member.

4. If the media failure is due to the loss of a disk drive or controller, rename the missing file.

5. If the group has already been archived, or if you are in NoArchiveLog mode, you may choose to solve the problem by clearing the log group to re-create the missing file or files.

CAP364 7Hebah ElGibreen

Page 8: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Recovery Commands: Restore

Loss of a Data File in NOARCHIVELOG Mode: If the database is in NOARCHIVELOG mode, and any data file is lost, perform the following tasks:

1. Shut down the instance if it is not already down.

2. Restore the entire database, including all data and control files, from the backup.

3. Open the database.

4. Have users reenter all changes made since the last backup.

User User UserUser User

CAP364 8Hebah ElGibreen

Page 9: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Recovery Commands: Restore

Loss of a Noncritical Data File in ARCHIVELOG Mode:

With the database in ArchiveLog mode, the loss of any data file not belonging to the SYSTEM or UNDO tablespaces only affects objects that are in the missing file. The rest of the database remains available for users to continue work.

Because the database is in ArchiveLog mode, recovery up to the time of the last commit is possible and users are not required to reenter any data.

Users

CAP364 9Hebah ElGibreen

Page 10: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Recovery Commands: Restore

Loss of a System-Critical Data File in ARCHIVELOG Mode: If a data file is lost or corrupted, and that file belongs to the SYSTEM or UNDO tablespace:

1. The instance may or may not shut down automatically. If it does not, use SHUTDOWN ABORT to bring the instance down.

2. Mount the database

3. Restore and recover the missing data file

4. Open the database

Users

CAP364 10Hebah ElGibreen

Page 11: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Forms of Data Recovery (Choosing the Right Strategy)

Datafile Media Recovery. Complete, Incomplete and Point-In-Time Recovery. Crash Recovery.

CAP364 11Hebah ElGibreen

Page 12: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Forms of Data Recovery (Choosing the Right Strategy) Datafile Media Recovery: Restore Datafiles, Apply Redo.

Several situations force you to perform media recovery: To restore a lost or damaged datafile, SPFILE or control file To restore a datafile that its changes were recorded in the redo logs but not in this

datafile.

For a datafile to be available for media recovery, one of two things must be true: The database that the datafile belongs to must not be open; The specific datafile needing recovery must be offline, if the database is open.

A datafile that needs media recovery cannot be brought online until media recovery has been completed.

CAP364 12Hebah ElGibreen

Page 13: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Forms of Data Recovery (Choosing the Right Strategy) Complete, Incomplete and Point-In-Time Recovery.

Occasionally, you need to return a database to its state at a past point in time. For example, to undo the effect of a user error, such as dropping or deleting the contents of a table,

you may want to return the database to its contents before the delete occurred.

Point-in-time recovery is one possible response to a data loss caused by, for instance, a user error or logical corruption that goes unnoticed for some time.

Point-in-time recovery is also your only option if you have to perform a recovery and discover that you are missing an archived log covering time between the backup you are restoring from and the target SCN for the recovery.

Without the missing log, you have no record of the updates to your datafiles during that period.

Your only choice is to recover the database from the point in time of the restored backup, then abandon all changes in or after the missing log.

CAP364 13Hebah ElGibreen

Page 14: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Forms of Data Recovery (Choosing the Right Strategy) Crash Recovery: Automatic Recovery After Instance Failure.

Archived logs are never used during crash recovery, and datafiles are never restored from backup. It uses only the online redo log files and current online datafiles.

There are a number of important differences between the crash and media recovery:1. Media recovery must be explicitly invoked by a user.

2. Media recovery applies needed changes to datafiles that have been restored from backup, not to online datafiles left over after a crash.

3. Media recovery must use archived logs as well as the online logs, to find changes reaching back to the time of the datafile backup.

CAP364 14Hebah ElGibreen

Page 15: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Flashback Technology

Oracle Flashback Technology is an alternatives to Point-in-Time Recovery.

Oracle Flashback Technology provides a set of features that provide useful alternatives to support Viewing past states of data,

Winding data back and forth in time, without requiring you to restore large portions of your database from backup or perform point-in-time recovery.

CAP364 Hebah ElGibreen 15

Page 16: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Flash Recovery Area

The flash recovery area is a space set aside on the disk to contain archived logs, backups, flashback logs, mirrored control files, and mirrored redo logs.

Flash recovery area automates management of backup-related files. Using a flash recovery area minimizes the need to manually manage disk

space for your backup-related files and balance the use of space among the different types of files.

Monitor the flash recovery area to: Configure flashback logging. Size the recovery area. View current space consumption.

CAP364 16Hebah ElGibreen

Page 17: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

Enterprise Manager

Oracle 10g… Perform Recovery Configure Recovery Settings

CAP364 17Hebah ElGibreen

Page 18: Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.

References

“Beginning Oracle Database 11g Administration: From Novice to Professional”, By Iggy Fernandez, Apress.

Backup and Recovery Basics 10g Release 2, By Antonio Romero, Lance Ashdown, Oracle® Database, 2005.

Oracle Database 10g: Administration Workshop I, student guide.

CAP364 18Hebah ElGibreen