Transcript Document

Using Recovery Manager
Copyright © 2006, Oracle. All rights reserved.
Objectives
Commands
BACKUP
Block C.T.
Inc. Update
LIST
REPORT
DELETE
After completing this lesson, you should be able to do
the following:
• Use the RMAN BACKUP command to create backup
sets and image copies
• Manage the backups and image copies taken with
RMAN
3-2
Copyright © 2006, Oracle. All rights reserved.
Issuing Recovery Manager Commands
•
Interactive client
– Enter commands at RMAN prompt.
– Use when performing analysis, or when running
reports or stored scripts.
•
Batch mode
– Use with automated jobs.
– Specify a command file when starting RMAN.
– Specify the log file name to capture session log.
•
Pipe interface
– Specify the PIPE command-line argument.
– Use to communicate data between sessions or
between RMAN and an external application.
3-3
Copyright © 2006, Oracle. All rights reserved.
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 a
stand-alone or a job command.
3-5
Copyright © 2006, Oracle. All rights reserved.
Job Commands: Example
Job commands appear inside a RUN command block:
RMAN>
2>
3>
4>
5>
6>
7>
3-6
RUN {
BACKUP AS BACKUPSET
FORMAT '/u01/db01/backup/%d_%s_%p'
DURATION 10:00 MINIMIZE LOAD
(DATABASE);
SQL 'alter system archive log current';
}
Copyright © 2006, Oracle. All rights reserved.
RMAN Commands: Overview
RESTORE
RECOVER
FLASHBACK
BACKUP
SPFILE
Stored
scripts
Target
database
REPORT
LIST
Control
file
Archived
log files
3-7
Enterprise
Manager
RMAN
Catalog maintenance
CROSSCHECK
DELETE…EXPIRED
CHANGE
Copyright © 2006, Oracle. All rights reserved.
Catalog
database
BACKUP Command
RMAN> BACKUP AS BACKUPSET
2>
FORMAT '/BACKUP/df_%d_%s_%p.bus'
3>
TABLESPACE hr_data;
3-9
Data file
1
Data file
1
Data file
2
Data file
2
Data file
3
Data file
3
Tablespace
HR_DATA
Backup
set
Copyright © 2006, Oracle. All rights reserved.
Commands
> BACKUP
Block C.T.
Inc. Update
LIST
REPORT
DELETE
Backup Constraints
3-10
•
•
•
The database must be mounted or open.
You cannot back up online redo logs.
Only “clean” backups are usable in
NOARCHIVELOG mode.
•
Only “current” data file backups are usable in
ARCHIVELOG mode.
Copyright © 2006, Oracle. All rights reserved.
Parallelization of Backup Sets
For performance, allocate multiple channels and
assign files to specific channels.
Data file
1
Data file
4
Data file
5
Channel
MML
Data file
2
Data file
3
Data file
9
Channel
MML
Data file
6
Data file
7
Data file
8
Backup
piece 2
Channel
MML
3-11
Backup
piece 1
Copyright © 2006, Oracle. All rights reserved.
Backup
Piece 3
Compressed Backups
RMAN> BACKUP AS
2> COMPRESSED BACKUPSET
3> DATABASE;
Compressed
backup files
Database files
RMAN>
2>
3>
4>
3-13
CONFIGURE DEVICE TYPE
DISK PARALLELISM 2
BACKUP TYPE TO
COMPRESSED BACKUPSET;
Copyright © 2006, Oracle. All rights reserved.
Image Copy
RMAN>
2>
3>
RMAN>
4>
5>
BACKUP AS COPY
DATAFILE '/ORADATA/users_01_db01.dbf'
FORMAT '/BACKUP/users01.dbf';
BACKUP AS COPY
ARCHIVELOG LIKE 'arch_1060.arc'
FORMAT 'arch_1060.bak';
Copy of data file 3
Data file 3
Data file 3
Copy of archived log
Archived
log file
3-14
Archived
log file
Copyright © 2006, Oracle. All rights reserved.
Tags for Backups and Image Copies
A tag is a logical name assigned to a backup set or
image copy.
3-16
month_full_backup
week_full_backup
Data files
1,3
Data file
3
Data files
2,4
Data file
4
Backup set
Backup set
Copyright © 2006, Oracle. All rights reserved.
BACKUP Command Options
•
•
•
•
•
•
•
•
3-17
Check for physical block corruptions.
Scan for logical corruptions and physical
corruptions.
Set a threshold on the number of detected
corruptions allowed before aborting.
Validate the target input files before performing a
backup operation.
Duplex the backup set.
Overwrite an existing backup set or image copy.
Pass control of the data transfer between storage
devices and the data files on disk to the media
management layer.
Encrypt the backup files.
Copyright © 2006, Oracle. All rights reserved.
Backing Up Archived Redo Logs
•
•
•
•
Online redo log file switch is automatic.
Archived log failover is performed.
You can specify a range of archived redo logs to
back up.
Backup sets of archived redo log files cannot
contain any other type of file.
RMAN> BACKUP
2>
FORMAT '/disk1/backup/ar_%t_%s_%p'
3>
ARCHIVELOG FROM SEQUENCE=234
4>
DELETE INPUT;
3-19
Copyright © 2006, Oracle. All rights reserved.
Whole Database Backup
RMAN> BACKUP DATABASE
PLUS ARCHIVELOG;
Archived log
file copies
3-21
Data file
copies
Control
file
Copyright © 2006, Oracle. All rights reserved.
SPFILE
RMAN Backup Types
•
•
•
•
3-22
A full backup contains all used
data file blocks.
A level 0 incremental backup is
equivalent to a full backup that
has been marked as level 0.
A cumulative level 1
incremental backup contains
only blocks modified since the
last level 0 incremental
backup.
A differential level 1
incremental backup contains
only blocks modified since the
last incremental backup.
Full, or "level 0
incremental backup"
Cumulative
incremental backup
Differential
incremental backup
Copyright © 2006, Oracle. All rights reserved.
Differential Versus Cumulative
•
•
A differential incremental backup contains all
blocks changed since the last incremental backup.
A cumulative incremental backup contains all
blocks changed since the last level 0 incremental
backup.
Level 0
Lvl
0
Day Sun
3-24
Level 0
1
1
1c
1
Mon
Tue
Wed
Thu
Copyright © 2006, Oracle. All rights reserved.
1c
Fri
1
0
Sat Sun
Block Change Tracking
Commands
BACKUP
> Block C.T.
Inc. Update
LIST
REPORT
DELETE
The backup process can be streamlined by enabling
block change tracking, which:
• Records changed blocks in a change tracking file
• Is used automatically by RMAN, if enabled
• Optimizes incremental backups by avoiding full
data file scans during backup
List of changed
blocks
CTWR
Redo
generation
1011001010110
0001110100101
1010101110011
SGA
3-25
Change
tracking
file
Redo log
Copyright © 2006, Oracle. All rights reserved.
Enabling Block Change Tracking
SQL>
2>
3>
4>
3-26
ALTER DATABASE ENABLE
BLOCK CHANGE TRACKING
USING FILE '/mydir/rman_change_track.f'
REUSE;
Copyright © 2006, Oracle. All rights reserved.
Incrementally Updating
Backups
Image copy
of data file
Incremental
backup files
RMAN> RECOVER COPY OF
2> DATAFILE {n|'file_name'}
3> WITH TAG 'incr_upd_df1';
Image copy of data file
updated to a more
recent state
Recovered data file
3-27
Copyright © 2006, Oracle. All rights reserved.
Commands
BACKUP
Block C.T.
> Inc. Update
LIST
REPORT
DELETE
LIST Command
•
List backup sets and copies of data files:
Commands
BACKUP
Block C.T.
Inc. Update
> LIST
REPORT
DELETE
RMAN> LIST BACKUP OF DATABASE;
RMAN> LIST BACKUP OF DATAFILE
2>
"/db01/ORADATA/u03/users01.dbf";
•
List backup sets and copies of any data file for a
specified tablespace:
RMAN> LIST COPY OF TABLESPACE "SYSTEM";
•
List backup sets and copies containing archive
logs for a specified range:
RMAN> LIST COPY OF DATABASE ARCHIVELOG
2> FROM TIME='SYSDATE-7';
3-28
Copyright © 2006, Oracle. All rights reserved.
REPORT Command
•
•
Produces a detailed analysis of
the repository
Produces reports to answer:
– What are the data files in the
database?
– Which files need a backup?
– Which backups can be
deleted?
– Which files are unrecoverable?
3-29
Copyright © 2006, Oracle. All rights reserved.
Commands
BACKUP
Block C.T.
Inc. Update
LIST
> REPORT
DELETE
REPORT NEED BACKUP Command
•
•
•
Lists all data files that require a backup
Assumes that the most recent backup is used
during a restore
Provides four options:
–
–
–
–
•
3-30
Incremental
Days
Redundancy
Recovery window
Uses the current retention policy configuration if
no options are specified
Copyright © 2006, Oracle. All rights reserved.
REPORT NEED BACKUP: Examples
•
Files that need more than three incremental
backups for recovery:
RMAN> REPORT NEED BACKUP incremental 3;
•
Files that have not been backed up for three days:
RMAN> REPORT NEED BACKUP days 3;
•
Backup needed if there are not two or more
backups already:
RMAN> REPORT NEED BACKUP redundancy 2;
•
Backup needed to recover to three days ago:
RMAN> REPORT NEED BACKUP
2>
recovery window of 3 days;
3-31
Copyright © 2006, Oracle. All rights reserved.
REPORT OBSOLETE and
DELETE OBSOLETE
•
Commands
BACKUP
Block C.T.
Inc. Update
LIST
REPORT
> DELETE
Find all recovery files that are deemed obsolete
according to the current retention policy settings:
RMAN> REPORT OBSOLETE;
•
List the obsolete recovery files, if no more than
two backup copies are needed:
RMAN> REPORT OBSOLETE REDUNDANCY 2;
•
Delete the backup set with a backup set key of 4:
RMAN> DELETE BACKUPSET 4;
•
Delete the recovery files considered obsolete,
because they have more than two backups:
RMAN> DELETE OBSOLETE REDUNDANCY 2;
3-32
Copyright © 2006, Oracle. All rights reserved.
Managing Backups with EM
Navigation aid:
Database home page > Maintenance > Manage Current Backups
3-33
Copyright © 2006, Oracle. All rights reserved.
RMAN Dynamic Views
•
•
•
•
•
•
•
•
•
•
3-34
V$ARCHIVED_LOG
V$BACKUP_CORRUPTION
V$BACKUP_DEVICE
V$BACKUP_FILES
V$BACKUP_PIECE
V$BACKUP_REDOLOG
V$BACKUP_SET
V$BACKUP_SPFILE
V$COPY_CORRUPTION
V$RMAN_CONFIGURATION
Copyright © 2006, Oracle. All rights reserved.
Monitoring RMAN Backups
•
•
•
•
3-36
Correlate server sessions with channels by using
the SET COMMAND ID command.
Query V$PROCESS and V$SESSION to determine
which sessions correspond to which RMAN
channels.
Query V$SESSION_LONGOPS to monitor the
progress of backups and copies.
Use an operating system utility to monitor the
process or threads.
Copyright © 2006, Oracle. All rights reserved.
Summary
In this lesson, you should have learned how to:
• Use the RMAN BACKUP command to create backup
sets and image copies
• List backups and image copies taken with RMAN
• Report and delete obsolete RMAN backups
3-38
Copyright © 2006, Oracle. All rights reserved.
Practice Overview: Backing Up
Your Database
This practice covers the following topics:
• Enabling archival of redo logs for a database
• Using RMAN to display the database structure
• Using Recovery Manager to back up data files and
the control file
• Using Recovery Manager to make image copies of
data files
• Creating a compressed backup of a database
• Scheduling a backup job
3-39
Copyright © 2006, Oracle. All rights reserved.