RMAN

Document Sample
RMAN Powered By Docstoc
					Backup and Recovery Enhancements

12
Copyright © 2004, Oracle. All rights reserved.

Objectives
After completing this lesson, you should be able to do the following: • Simplify file management for all recovery-related files • Reduce restore time by applying incremental backups to data file image copies • Simplify recovery after opening the database with the RESETLOGS option • Speed backup times by creating faster incremental backups • Minimize load requirements by specifying limits in backup time windows • Save storage space by writing compressed backup sets
12-2 Copyright © 2004, Oracle. All rights reserved.

Oracle Database 10g Solution: Self-Managing Database
Database Control Storage management Application and SQL management Monitor Fix Backup and recovery management Alert System resource management

Automatic management Advise Space management Common infrastructure

12-3

Copyright © 2004, Oracle. All rights reserved.

New Backup and Recovery Strategy
Oracle Database 10g offers a new flash backup and recovery strategy: • Disk economics are now competitive to those of tape.
– Large enough and cheap enough for backups

• •

Disk is better than tape.
– Random access to any data in milliseconds

Backup and recovery go from hours to minutes.

1000x
1980s disk 200 MB
12-4

increase

Current disk 200 GB

Copyright © 2004, Oracle. All rights reserved.

Flash Backup and Recovery
A unified storage location for all recovery files and recovery-related activities in an Oracle database: • This is a centralized location of control file backups, archive logs, flashback logs, and database backups. • The flash recovery area can be defined as a directory, file system, or ASM disk group. • A single flash recovery area can be shared by more than one database.

Database area
12-5

Flash recovery area

Copyright © 2004, Oracle. All rights reserved.

Defining Flash Recovery Area Using Database Control

12-6

Copyright © 2004, Oracle. All rights reserved.

Defining a Flash Recovery Area Using SQL
• The flash recovery area is defined by setting the following initialization parameters:
– DB_RECOVERY_FILE_DEST_SIZE: Sets the disk limit, expressed in bytes – DB_RECOVERY_FILE_DEST: Sets the location for the flash recovery area

•

These parameters are dynamic and can be altered or disabled.
SQL> 2 SQL> 2 ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 4G; ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/oracle/frec_area';

12-7

Copyright © 2004, Oracle. All rights reserved.

Flash Recovery Area Space Management
Disk limit is reached and a new file needs to be written into the flash recovery area Space pressure occurs Warning issued to user RMAN updates list of files that may be deleted 1 2 Backup files to be deleted
Copyright © 2004, Oracle. All rights reserved.

Database file backup 1 2 3 4

Flash recovery area

Files no longer required on disk are deleted

12-8

Backing Up Data Files to a Flash Recovery Area

RMAN backup process

Database area

Flash recovery area

12-9

Copyright © 2004, Oracle. All rights reserved.

Modifying the Flash Recovery Area

12-10

Copyright © 2004, Oracle. All rights reserved.

Backing Up the Flash Recovery Area

RMAN> BACKUP RECOVERY FILES;
12-11 Copyright © 2004, Oracle. All rights reserved.

New Flash Recovery Area View

SQL> SELECT name, space_limit AS quota, 2 space_used AS used, 3 space_reclaimable AS reclaimable, 4 number_of_files AS files 5 FROM v$recovery_file_dest ; NAME QUOTA USED RECLAIMABLE FILES ----------------- ----- ---- ----------- ----/oracle/frec_area 2G 16M 0 6

12-12

Copyright © 2004, Oracle. All rights reserved.

New Flash Recovery Area Columns
•

IS_RECOVERY_DEST_FILE
– Indicates if the file was created in the flash recovery area – Values: YES / NO – Tracked in V$CONTROLFILE, V$LOGFILE, V$ARCHIVED_LOG, V$DATAFILE_COPY, V$DATAFILE, V$BACKUP_PIECE

•

BYTES
– Size of the file – Tracked in V$BACKUP_PIECE

12-13

Copyright © 2004, Oracle. All rights reserved.

Best Practices for the Database and Flash Recovery Area
• Use OMF for the database area:
– Simplifies the administration of database files – Puts database files, control files, and online logs in the database area

•

Use the flash recovery area for recovery-related files:
– Simplifies location of database backups – Automatically manages the disk space allocated for recovery files – No changes needed for existing scripts – Puts database backups, archive logs, and control file backups in the flash recovery area

12-14

Copyright © 2004, Oracle. All rights reserved.

Changes in SQL Statement Behavior
Using OMF and a flash recovery area changes the default file location placement of the following SQL commands: • ALTER DATABASE
– ADD LOGFILE and ADD STANDBY LOGFILE – DROP LOGFILE – RENAME FILE

• •

CREATE CONTROLFILE CREATE DATABASE

12-15

Copyright © 2004, Oracle. All rights reserved.

Full Notes Page

12-16

Copyright © 2004, Oracle. All rights reserved.

Recovering with Incrementally Updated Backups
RMAN can now recover image copies using incremental backup files: • Image copies are updated with all changes up to incremental backup SCN. • Incremental backup reduces the time required for media recovery. • There is no need to perform an image copy after the incremental restoration.
Incremental backup files Image copy of data file RMAN> RECOVER COPY OF 2> DATAFILE {n|'file_name'}

Recovered data file
Copyright © 2004, Oracle. All rights reserved.

12-17

Fast Incremental Backup
• • Optimizes incremental backups
– Tracks which blocks have changed since last backup

Oracle Database 10g has integrated change tracking:
– A new change tracking file is introduced. – Changed blocks are tracked as redo is generated. – Database backup automatically uses the changed block list.
CTWR

List of changed blocks Redo generation

1011001010110 0001110100101 1010101110011

Change tracking file Redo log

SGA
12-18

Copyright © 2004, Oracle. All rights reserved.

Enabling Fast Incremental Backup Using Database Control

12-19

Copyright © 2004, Oracle. All rights reserved.

Enabling Fast Incremental Backup Using SQL
• Setting block change tracking manually:
ALTER DATABASE {ENABLE|DISABLE} BLOCK CHANGE TRACKING [USING FILE '...']

•

Moving the block change tracking file name:
ALTER DATABASE RENAME FILE '...' TO '...'

12-20

Copyright © 2004, Oracle. All rights reserved.

Monitoring Block Change Tracking

SQL> SELECT filename, status, bytes 2 FROM v$block_change_tracking; SQL> 2 3 4 5 5 6 7 8
12-21

SELECT file#, avg(datafile_blocks), avg(blocks_read), avg(blocks_read/datafile_blocks) * 100 AS PCT_READ_FOR_BACKUP, avg(blocks) FROM v$backup_datafile WHERE used_change_tracking = 'YES' AND incremental_level > 0 GROUP BY file#;
Copyright © 2004, Oracle. All rights reserved.

Oracle-Suggested Strategy

12-22

Copyright © 2004, Oracle. All rights reserved.

RMAN Command Changes
• Use the BACKUP command to:
– Create image copies RMAN> BACKUP AS COPY DATABASE; – Create backup sets – RMAN> BACKUP AS BACKUPSET DATABASE;

•

Set a default disk backup type:
RMAN> CONFIGURE DEVICE TYPE DISK 2> BACKUP TYPE TO COPY;

12-23

Copyright © 2004, Oracle. All rights reserved.

Backup Type Enhancements Using Database Control

12-24

Copyright © 2004, Oracle. All rights reserved.

Backup Maintenance

RMAN> CATALOG BACKUPPIECE 'file_name';

12-25

Copyright © 2004, Oracle. All rights reserved.

Backing Up the Entire Database

RMAN> BACKUP DATABASE;

12-26

Copyright © 2004, Oracle. All rights reserved.

Backing Up Individual Tablespaces
RMAN> CONFIGURE DEFAULT 2> DEVICE TYPE TO DISK; RMAN> BACKUP 2> TABLESPACE system;
Tablespace data files Backup database files

RMAN> BACKUP COPY OF 2> TABLESPACE system;
Copy of the backup database files
12-27 Copyright © 2004, Oracle. All rights reserved.

Backing Up Data Files and Control Files
RMAN> BACKUP DATAFILE 4;
Data file Backup data file

RMAN> BACKUP COPY OF 2> DATAFILE 4;
Copy of backup data file

RMAN> BACKUP CURRENT 2> CONTROLFILE;
Control file Backup control file

RMAN> BACKUP CONTROLFILECOPY 2> ‘filename’;
12-28 Copyright © 2004, Oracle. All rights reserved.

Implementing Fast Recovery
RMAN> SWITCH DATABASE TO COPY;
Before switch operation After switch operation

Flash Recovery Area

Database files

Flash Recovery Area

The backup files are used as they are. They must be image copies rather than backup sets.

12-29

Copyright © 2004, Oracle. All rights reserved.

Automated Instance Creation and TSPITR

12-30

Copyright © 2004, Oracle. All rights reserved.

Auxiliary Location in EM

12-31

Copyright © 2004, Oracle. All rights reserved.

Creating Compressed Backups

RMAN> BACKUP AS COMPRESSED BACKUPSET DATABASE; RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 2 2> BACKUP TYPE TO COMPRESSED BACKUPSET;
12-32 Copyright © 2004, Oracle. All rights reserved.

Monitoring Compressed Backups

12-33

Copyright © 2004, Oracle. All rights reserved.

Simplified Recovery Through RESETLOGS
• Database can be opened immediately after RESETLOGS.
– No longer need to take a FULL backup

• •

No changes are required to existing scripts. Usage scenarios:
– Incomplete recovery – Recovery using backup control file
t1 t2 Incomplete recovery performed t3 t4 t5

Backup taken

Open with RESETLOGS

Whole backup

Recovery needed

12-34

Copyright © 2004, Oracle. All rights reserved.

Recovery Through RESETLOGS: Changes

LOG_ARCHIVE_FORMAT="LOG%t_%s_%r.arc" SQL> SELECT recid, thread#, sequence#, 2 resetlogs_change#, resetlogs_time 3 FROM v$log_history; SQL> SELECT recid, file#, 2 resetlogs_change#, resetlogs_time 3 FROM v$offline_range; SQL> SELECT incarnation#, resetlogs_id, 2 prior_incarnation#, status 3 FROM v$database_incarnation;
12-35 Copyright © 2004, Oracle. All rights reserved.

Recovering Data Files Not Backed Up

Backup of data files Archive log files Missing data file

RMAN> RESTORE DATABASE;

Restored data files
12-36 Copyright © 2004, Oracle. All rights reserved.

Dropping a Database

RMAN> DROP DATABASE [INCLUDING BACKUPS];

Backup and archive log files RMAN Database with RMAN repository Database files

12-37

Copyright © 2004, Oracle. All rights reserved.

Automatic Channel Failover

RMAN backup process

RMAN backup process

12-38

Copyright © 2004, Oracle. All rights reserved.

Enhanced RMAN Scripts

RMAN scripts

RMAN catalog

Global scripts

Text scripts Database 2 Database 1

12-39

Copyright © 2004, Oracle. All rights reserved.

Setting Duration and Throttling Option
Copy database in 10 hours with minimum impact Back up tablespace in 4 hours Backup as many files as possible in 4 hours

RMAN> BACKUP AS COPY 2> DURATION 10:00 3> MINIMIZE LOAD DATABASE ; RMAN> BACKUP DURATION 4:00 2> FILESPERSET 1 3> TABLESPACE USERS ; RMAN> BACKUP 2> DURATION 4:00 PARTIAL 3> FILESPERSET 1 DATABASE ;

12-40

Copyright © 2004, Oracle. All rights reserved.

Placing All Files in Online Backup Mode
• • Single command for entire database
– No need for individual tablespace commands

Database must be:
– In ARCHIVELOG mode – Mounted and open

•

Required only when not using RMAN for online backups
SQL> ALTER DATABASE BEGIN BACKUP;

12-41

Copyright © 2004, Oracle. All rights reserved.

How Does File Status Affect BEGIN BACKUP?
SQL> ALTER DATABASE BEGIN BACKUP;

Read-only Nonexistent OFFLINE ONLINE ONLINE ONLINE ONLINE

Skip and continue Skip and continue Skip and continue

12-42

Copyright © 2004, Oracle. All rights reserved.

How Does File Status Affect BEGIN BACKUP?
SQL> ALTER DATABASE BEGIN BACKUP;

Failed verification

ORA-01128 ORA-01146

User backup

In transition to read-only

ORA-01232

RMAN backup

ORA-01253

12-43

Copyright © 2004, Oracle. All rights reserved.

Changes to the END BACKUP Command
• • Single command for entire database Database can be mounted or open.
SQL> ALTER DATABASE END BACKUP;

ONLINE Read-only

ONLINE

ONLINE

ONLINE

Nonexistent

Offline normal

Skip and continue Skip and continue Skip and continue

12-44

Copyright © 2004, Oracle. All rights reserved.

How Does File Status Affect END BACKUP?

SQL> ALTER DATABASE END BACKUP;

ONLINE

ONLINE OFFLINE

ONLINE

Not in backup

Warning and continue

Warning and continue

12-45

Copyright © 2004, Oracle. All rights reserved.

Summary
In this lesson, you should have learned how to: • Use the flash recovery area to simplify file management for all recovery-related files • Apply incremental backups to data file image copies to speed recovery time • Create faster incremental backups by using the block change tracking file • Specify limits for specified backup time windows • Use enhanced RMAN commands to simplify backup and recovery operations • Use compressed backup sets to save storage space
12-46 Copyright © 2004, Oracle. All rights reserved.

Practice 12 Overview
This practice covers the following topics: • Setting up a flash recovery area and managing space • Enabling block change tracking • Using Oracle Suggested Strategy for backups • Using optimized incremental backups • Recovering with incrementally updated backups • Performing RMAN channel failover

12-47

Copyright © 2004, Oracle. All rights reserved.

12-48

Copyright © 2004, Oracle. All rights reserved.


				
DOCUMENT INFO
Shared By:
Categories:
Tags: rman
Stats:
views:275
posted:8/29/2009
language:English
pages:48