intro to rman
TRANSCRIPT
-
8/6/2019 Intro to RMAN
1/41
Oracles Backup and Recovery Tool
Recovery MANager
-
8/6/2019 Intro to RMAN
2/41
-
8/6/2019 Intro to RMAN
3/41
RMAN creates backups and restores Oracle database files to tape or disk
Datafiles
Controlfiles
Parameter files
Archive logs
RMAN will perform consistent and inconsistent database backups
Consistent backups must be performed with the target database shut down
Inconsistent (hot) backups require the target database is in archivelog mode
Inconsistent backups require logical recovery using archivelogs
RMAN manages information about generated backup media files
Backup information is stored in control files
Backup information optionally stored in an RMAN repository catalog
RMAN can perform point-in-time restoration
3
-
8/6/2019 Intro to RMAN
4/41
RMAN can create imagecopiesusable by user-scripted restore procedures
RMAN can create backupsetsinstead of traditional image copies
RMAN uses disk or tape channels to read and write to disk or tape media
Exact c i s f targ t ata as fil s
RMAN rmits r starta l acku s if y u hav a s cific tim win w within
which acku s ar rmitt
RMAN ta vic s r ly n 3r
arty M ia Manag r s ftwar
4
RMAN has a c mman -lin int rfac (rman) an is als int grat with Gri C ntr l
-
8/6/2019 Intro to RMAN
5/41
Backup set media options
Backup Sets are logical groupings of backed-up database files
Backup sets can be written to disk or tapeBackup sets can be compressed by omitting unchanged blocks
Tape backup sets can be encrypted (via Oracle Secure Backup)
Tape backups mustuse backup sets
5
Backup sets have a unique ID and may have a TAG for RMAN identification
Backup sets consist of one or more individual files called backuppieces.
Backup piece files contain the data blocksfrom a backup
RMAN recovery using Backup Sets
The recovery process identifies the target SCN or date to which to recover
Needed blocks are retrieved from the appropriate backup set pieces
Data files are reconstructed from the needed blocks
Backup Sets
-
8/6/2019 Intro to RMAN
6/41
6
-
8/6/2019 Intro to RMAN
7/41
Channels
A stream of data to a device using one server session
Server session performs the backup, restore and recovery
Channels can be configured with device-specific settings
Channels are automatically allocated, or manually allocated
RUN {
ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
BACKUP DATABASE PLUS ARCHIVELOG;
}
BACKUP DATAFILE 3;
RESTORE TABLESPACE users;
7
-
8/6/2019 Intro to RMAN
8/41
Two types of device type disk and sbt
RMAN has an open AP
I for communicatingwith Tape and other media manager
software
RMAN sends labeled streams of bytes to the
media manager during backup
The labeled streams are returned by themedia manager during RMAN restore
operations
RMAN> CONFIGURE DEVICE TYPE sbt PARALLELISM 1;
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO sbt;
RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt PARMS
'ENV=(NSR_SERVER=bksvr1)';RMAN> BACKUP DATABASE;
Media Manager vendors have specific
installation instructions that vary by vendor
Refer to vendors for detailed installation
and use instructions
8
-
8/6/2019 Intro to RMAN
9/41
Backup Set
ImageCopy
RMAN-proprietary storage of backed-up data blocks
Consist of a Backup Set identifier plus associated backup set files or pieces
Can only be restoredusing RMAN
Equivalent to file copies of original database files
RMAN considers user-managed backups as Image Copies
ContainALL data blocks no compression
9
-
8/6/2019 Intro to RMAN
10/41
Backup sets or image copies can be labeled with a text TAG
RMAN commands can select backup sets or copies using the TAG
TAGs are visible in RMAN list or report output
BACKUP AS COPY COPY OF DATABASE FROMTAG=full_cold_copy TAG=new_full_cold_copy;
BACKUP AS COPY DATABASE TAG=full_cold_copy;
10
-
8/6/2019 Intro to RMAN
11/41
Full backup
Incremental backup
Backup ofallspecified database file blocks
Independent of when database files were last backed up
Not used in incremental backup strategies
Backup of blocks changed since last incremental backup
SCN used to identify changed blocks
Level 0 incremental backup
Level 1 incremental backup
Full backup is
equivalent to
incremental level 0
11
-
8/6/2019 Intro to RMAN
12/41
Level 0 incremental backups
Backup ofallblocks in specified database files
Independent of when files were last backed up
Base for subsequent Level 1 backups
12
-
8/6/2019 Intro to RMAN
13/41
Differential backup
Contain all blocks changed after the most
recent incremental backup at level 1 or 0
Level 1 incremental backups
Cumulative backup
Contain all blocks changed after the most
recent incremental backup at level 0Cumulative backups become much larger over time
Cumulative backups are quicker to restore
Differential backups remain smaller and quicker to perform
Differential backups are slower to restore requiring changes
in multiple earlier incremental backups
13
-
8/6/2019 Intro to RMAN
14/41
RMAN can use a Block Change Tracking file to identify changed blocks
RMAN can report, validate, remove or protect backup files
RMAN can throttle disk I/O rate during backup and restore
RMAN can limit the number and size of backup set files
RMAN performance controls
Bitmap file created automatically by Level 0 backup if configured
RMAN can now avoid rescanning database files for changed blocks
(blocks with newer SCN than in previous backup sets)
Loss of change tracking file is harmless recreated by next Level 0
RMAN will create a missing Level 0 backup automatically when
asked to perform a Level 1 backup
RMAN and missing Level 0 backups
Change Tracking file can introduce database overhead
you need to evaluate if it is worth the extra performance hit
14
-
8/6/2019 Intro to RMAN
15/41
RMAN can backup and restore your Flash Recovery Area
RMAN can use and manage ASM files
RMAN can clone (duplicate) databases using the AUXILIARY connection
RMAN can switch an instance to use a copyof a database or datafiles
RMAN actions can be scripted and scheduled using cron or dbms_job
15
-
8/6/2019 Intro to RMAN
16/41
RMAN does not automatically enforce your retention policies
RMAN does not automatically delete expired backup files
RMAN does not automatically detect missing backup files
RMAN does not backup any other types of files
Oracle code tree
Other operating system files
Alert logs and traces
Oracle Wallet files
RMAN is not upward or downward version compatible You must backup 10g databases with 10g RMAN!
You can only backup 9i databases with 9i RMAN!
10g and 9i cant share a repository!
16
-
8/6/2019 Intro to RMAN
17/41
Level 0 CumulativeIncremental (Full) - Day 1
Level 1 CumulativeIncremental - Day2
Level 1 CumulativeIncremental - Day 3
All blocks backed up
Restorable to Day 1
Contains only blocks changed sinceLevel 0 on Day 1
Restorable to Day 2 using Level 0 Day1 and Level 1 Day 2
Contains only blocks changed since
Level 0 on Day 1Restorable to Day 3 using Level 0 Day1 and Level 1 Day 3
Increasing backup set size and backup duration
Faster recovery
17
-
8/6/2019 Intro to RMAN
18/41
Level 0 DifferentialIncremental (Full) - Day 1
Level 1 DifferentialIncremental - Day 2
Level 1 DifferentialIncremental - Day 3
ll l cks acke u
est ra le t Day 1
C ntains nly l cks change sinceLevel 0 n Day 1
est ra le t Day 2 using Level 0 Day1 an Level 1 Day 2
C ntains nly l cks change sinceLevel 1 n Day 2
est ra le t Day 3 using Level 0 Day1 an Level 1 Day2 an Level 1 Day 3
C nsistent acku set size an acku urati n
Sl wer rec very using m re acku sets
18
-
8/6/2019 Intro to RMAN
19/41
C. Daily Level 1 Differential Incremental backup
A. Monthly Full Level 0 Incremental backup
B. Weekly Level 1 Cumulative Incremental backup
Advantages
RMAN doesnt have to apply more than a few days worth of
differential backups to the latest cumulative backup and the original
level 0 backup
No more than 1 day of redo logs need to be applied during recovery
Disadvantages
May not meet with your MTTR target (Mean-Time-to-Recovery)
RuleofThumb:
You should perform a new Level 0 backup
once >50% of blocks have changed
19
-
8/6/2019 Intro to RMAN
20/41
Allocating multiple channels for a device type allows parallel completion of
RMAN tasks
Manual channel allocation has to happen inside a RUN { } block
Device types can be configured for automatic allocation of parallel channels
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
Multiple channels can be used to write to multiple devices simultaneously
If a channel fails, surviving channels will attempt to complete the restore job
RUN{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
ALLOCATE CHANNEL c2 DEVICE TYPE sbt;
ALLOCATE CHANNEL c3 DEVICE TYPE sbt;
BACKUP DATAFILE 5,6,7;
} 20
-
8/6/2019 Intro to RMAN
21/41
21
-
8/6/2019 Intro to RMAN
22/41
Two Steps:
RESTORE
RECOVER
Missing files are restored from the blocks in backup sets OR
Image copies are copied to the original (or new) file locations
Unmodified files not modified can be skipped by RMAN automatically
Recovery must be performed for incomplete backups
Archive logs are applied to the database
RMAN uses the record of available backups in the RMAN repository to select
the best available backups for use in the restore operation.
The most recent backup available, or the most recent backup satisfying any
UNTIL clause specified in the RESTORE command, is always the preferred choice
If two backups are from the same point in time, RMAN prefers image copies
over backup sets because RMAN image copy restores are faster
22
-
8/6/2019 Intro to RMAN
23/41
23
-
8/6/2019 Intro to RMAN
24/41
script
Reusable lists of RMAN commands
Stored on the file system or in the RMAN respository
Not the Control file!
LOCAL scripts used by a single database instance
GLOBAL scripts shared by database instances in repository
# create recovery catalog script to back up database and archived logs
CREATE SCRIPT backup_whole
COMMENT "backup whole database and logs"
{
BACKUP INCREMENTAL LEVEL 0 TAG b_whole_l0
DATABASE PLUS ARCHIVELOG;
}
# creates recovery catalog script to back up database and archived logs
CREATEGLOBAL SCRIPT global_backup_db
COMMENT "backup any database from the recovery catalog, with logs"
{ BACKUP DATABASE PLUS ARCHIVELOG;
}
24
-
8/6/2019 Intro to RMAN
25/41
host
Execute a command on the local host from within RMAN
host dd if=/orabak/tools.dbf of=/oradata/tools.dbf
25
-
8/6/2019 Intro to RMAN
26/41
sql
Execute a SQL command on the Target database within RMAN
sql alter system archive log current;
26
Select statements not supported
-
8/6/2019 Intro to RMAN
27/41
list / report
crosscheckvalidate
delete
27
-
8/6/2019 Intro to RMAN
28/41
list / reportLIST BACKUP OF DATABASE ARCHIVELOG ALL; # lists known backups of db files and logs
LIST COPY; # lists only image copies
LIST BACKUP; # lists all RMAN backup media
REPORT NEED BACKUP; # report which database files need backup
List all backup sets and pieces known by RMAN
May not represent actual files available on disk
28
-
8/6/2019 Intro to RMAN
29/41
crosscheckCROSSCHECK BACKUPSET; # crosschecks backup sets on disk and SBT
CROSSCHECK BACKUP; # crosscheck all RMAN backup media
Verifies existence of known backup file sets and pieces in
the RMAN repository
Marks backup file sets and pieces as expired if they
exceed retention policies
CROSSCHECK doesnt physically delete anything!
RMAN backup files have four possible states in the repositoryAVAILABLE
UNAVAILABLE
EXPIRED
OBSOLETE
29
-
8/6/2019 Intro to RMAN
30/41
validateBACKUP VALIDATE DATABASE ARCHIVELOG ALL;
RESTORE CONTROLFILE VALIDATE;
RESTORE ARCHIVELOG ALL VALIDATE;
RESTORE DATAFILE 4,5,6 VALIDATE;
Verifies existence and availability of database file media
Checks for corrupted blocks and reports them in
V$DATABASE_BLOCK_CORRUPTION
Damaged backup file media maybe repaired using Block
Media Recovery
30
-
8/6/2019 Intro to RMAN
31/41
deleteDELETE BACKUP TAG='before_upgrade'; # delete backup based on tag
DELETE NOPROMPT ARCHIVELOG ALL; # delete all archivelogs
DELETE EXPIRED BACKUP; # delete expired after crosscheck
DELETE BACKUP; # deleteALL backups
Remove any or all database backup file media from disk/tapeand RMAN repository
Can remove obsolete media no longer needed to recover
under retention policies
31
-
8/6/2019 Intro to RMAN
32/41
32
-
8/6/2019 Intro to RMAN
33/41
It is easier to show RMAN (and not just talk about it endlessly )
rman target system/pswd@sid1
rman target system/pswd@sid1 catalog rman/pswd@rmansid
rman target system/pswd@sid1 catalog rman/pswd@rmansid auxiliary system/pswd@sid2
rman
rman>> connect target system/pswd@sid1
33
-
8/6/2019 Intro to RMAN
34/41
backupdatabase;
Uses default device type setting (SBT or Disk)Creates device channels according to parallelism setting
Creates image copies or backup sets
Might not backup controlfile automatically!
Doesnt backup archivelogs
-
8/6/2019 Intro to RMAN
35/41
Inconsistentdatabase backupincluding
archivelogs
-
8/6/2019 Intro to RMAN
36/41
show controlfileautobackup
configurecontrolfileautobackupon
-
8/6/2019 Intro to RMAN
37/41
show {parameter|ALL}
configure {parameter}clear
configure {parameter} {newsetting}
-
8/6/2019 Intro to RMAN
38/41
restoreand recover
-
8/6/2019 Intro to RMAN
39/41
RMAN 11gFeatures
Parallel backup of regions of BIG datafiles
New encryption algorithm
Data Recovery Advisor 11g
Online backup of standby databases
Virtual, secure and mergeable RMAN catalogs
Encrypted disk backup sets
-
8/6/2019 Intro to RMAN
40/41
40
-
8/6/2019 Intro to RMAN
41/41
OracleDatabaseBackupandRecovery Basics10g Release 2 (10.2)http://download.oracle.com/docs/cd/B19306_01/backup.102/b14192/bkup004.htm#sthref385
OracleDatabaseBackupandRecovery Advanced User'sGuide 10g Release 2 (10.2)http://download-east.oracle.com/docs/cd/B14117_01/server.101/b10734/toc.htm
OracleDatabaseBackupandRecovery Reference10g Release 2 (10.2)http://download-west.oracle.com/docs/cd/B19306_01/backup.102/b14194/toc.htm
Freeman & Hart, Oracle9iRMANBackup & Recovery,Oracle Press
(useful 3rd party mediamanager chapters)http://www.mhprofessional.com/product.php?cat=7&isbn=0072226625
41