Les 02 Config Rec

25
2 Copyright © 2007, Oracle. All rights reserved. Configuring for Recoverability

description

sql

Transcript of Les 02 Config Rec

Page 1: Les 02 Config Rec

2Copyright © 2007, Oracle. All rights reserved.

Configuring for Recoverability

Page 2: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 2

Objectives

After completing this lesson, you should be able to:

• Invoke RMAN and set and list simple configurations

• Configure your database in ARCHIVELOG mode

• Configure multiple archive log file destinations to increase availability

• Specify a retention policy

• Configure the Flash Recovery Area

• Describe the benefits of using the Flash Recovery Area

Page 3: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 3

Purpose of Backup and Recovery Functionality

Backup and recovery functionality is needed for the following:

• Data protection– Media failure– User errors– Application errors

• Data preservation

• Data transfer

Page 4: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 4

Typical Backup and Recovery Tasks

To be able to recover from data loss problems with minimal down time, you should be prepared to do the following:

• Configure the database for recoverability.

• Define a backup schedule.

• Plan and test different types of failure scenarios.

• Monitor and troubleshoot the backup and recovery environment.

• Restore data from backups.

• Recover transactions to a desired point in time.

Page 5: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 6

Oracle Backup and Recovery Solutions

These Oracle utilities and features provide the tools necessary to maintain a recoverable system:

• Recovery Manager (RMAN)– Incremental backups– Block media recovery– Unused block compression– Binary compression– Backup encryption

• Data Pump

Page 6: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 7

Using Recovery Manager

$ rman target /

RMAN> BACKUP DATABASE;Starting backup at 10-JUN-07..RMAN> LIST BACKUP;BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ------- ----------- ------------ ---------------1 Full 1.06G DISK 00:01:49 10-JUN-07..RMAN> DELETE OBSOLETE;..Do you really want to delete the above objects (enter YES or NO)? YESdeleted archived log..

Page 7: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 9

Types of RMAN Commands

RMAN commands are of the following types:

• Stand-alone command:– Is executed individually at the RMAN prompt– Cannot appear as subcommands within RUN

• Job command:– Must be within the braces of a RUN command– Is executed as a group

Some commands can be executed as either astand-alone or a job command.

Page 8: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 10

Job Commands: Example

Job commands appear inside a RUN command block:

RMAN> RUN2> {3> ALLOCATE CHANNEL c1 DEVICE TYPE DISK4> FORMAT "/disk2/%U";5> BACKUP AS BACKUPSET DATABASE;6> SQL 'alter system archive log current'; 7> }

Deallocated after theRUN block completes

Execution of entire block startswhen this line is entered.

Page 9: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 11

Configuring Your Database for Backup and Recovery Operations

• Operate the database in ARCHIVELOG mode.

• Configure the Flash Recovery Area.

Archiver(ARCn)

Archivedredo log files

Online redo log files

Archivedredo log files

Control filebackups

Data file backups

Page 10: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 12

ARCHIVELOG Mode

Archiver(ARCn)

Archivedredo log files

Online redo log files

Page 11: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 13

Configuring ARCHIVELOG Mode

To place the database in ARCHIVELOG mode, perform the following steps:

• Using Enterprise Manager– Select the “ARCHIVELOG Mode” check box. – Click Apply. The database can be set to ARCHIVELOG mode

only from the MOUNT state.– Click Yes when asked whether you want to restart the

database.

• Using SQL commands– Mount the database.– Issue the ALTER DATABASE ARCHIVELOG command.– Open the database.

Page 12: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 15

Configuring Archive Log Destinations

Online redo log files Archived

redo log files

Archivedredo log files

Online redo log files

Archivedredo log files

LOG_ARCHIVE_DEST_n

LOG_ARCHIVE_DESTLOG_ARCHIVE_DUPLEX_DEST

• Local and remote destinations:

• Local-only destinations:

Page 13: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 17

Guaranteeing Archive Log Success

Online redo log files

LOG_ARCHIVE_MIN_SUCCEED_DEST = 2

Standby1

1

2

3

Page 14: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 19

Specifying a Backup Destination

Backups can be written to:

• Disk directory

• Tape, using Oracle Secure Backup

• Media Management Library– Tape– Disk or tape, using proxy copy

• Flash Recovery Area: Disk area set aside for backup and recovery and flashback database purposes

Page 15: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 21

Specifying a Retention Policy

• Retention policy: Describes which backups will be kept and for how long

• Two types of retention policies:– Recovery window: Establishes a period of time within which

point-in-time recovery must be possible

– Redundancy: Establishes a fixed number of backups that must be kept

• Retention policies are mutually exclusive.

BackupSYSDATE

Recoverywindow

Backup 1SYSDATE

Backup 2

Page 16: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 23

A Recovery WindowRetention Policy: Example

Now

Recovery window of 7 days

Log 200

Backup B

Log 300

Backup C

Log 400Log 100

Backup A

Log 500

Backup B and archive logs 201 through 500 are required to satisfy this retention policy.

Backup

Backup

Obsolete

Not Obsolete

Page 17: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 24

Using a Flash Recovery Area

• Permanent items:– Multiplexed copies of the

current control file– Multiplexed copies of online redo logs

• Transient items:– Archived redo logs– Data file copies– Control file copies– Control file autobackups– Backup pieces– Flashback logs

Database

Flash Recovery Area

Page 18: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 26

Defining a Flash Recovery Area

• The Flash Recovery Area is defined by setting both of the following initialization parameters:

– DB_RECOVERY_FILE_DEST_SIZE: Sets the disk limit – DB_RECOVERY_FILE_DEST: Sets the location for the Flash

Recovery Area

• These parameters are dynamic.

Page 19: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 27

Defining a Flash Recovery Area Using Enterprise Manager

Page 20: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 28

Flash Recovery Area Space Management

Space limit is reached and a new file needs to be written

into the Flash Recovery Area.

12

Backup filesto be deleted

Database filebackup

1234

Warning issued to user

Flash Recovery

Area

Space pressure occurs.

RMAN updateslist of files thatmay be deleted.

Files that are no longer

required ondisk areDeleted.

Page 21: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 30

Flash Recovery Area Space Usage

• Configure the retention policy to the minimum value appropriate for your database.

• Back up the archive log files regularly and delete the files upon completion of the backup.

• Use the RMAN REPORT OBSOLETE and DELETE OBSOLETE commands to remove backups and file copies that are not required.

Page 22: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 32

Monitoring the Flash Recovery Area

Page 23: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 33

Benefits of Using a Flash Recovery Area

Using the Flash Recovery Area for recovery-related files:

• Simplifies the location of database backups

• Automatically manages the disk space allocated for recovery files

Page 24: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 34

Summary

In this lesson, you should have learned how to:

• Invoke RMAN and set and list simple configurations

• Configure your database in ARCHIVELOG mode

• Configure multiple archive log file destinations to increase availability

• Specify a retention policy

• Configure the Flash Recovery Area

• Describe the benefits of using the Flash Recovery Area

Page 25: Les 02 Config Rec

Copyright © 2007, Oracle. All rights reserved.2 - 35

Practice 2 Overview: Configuring for Recoverability

This practice covers the following topics:

• Placing the database in ARCHIVELOG mode

• Verifying that the Flash Recovery Area is configured

• Using RMAN to connect to the target database