0% found this document useful (0 votes)
121 views97 pages

Oracle Recovery Manager: Deepak Chauhan

Uploaded by

Kiran Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views97 pages

Oracle Recovery Manager: Deepak Chauhan

Uploaded by

Kiran Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 97

Oracle Recovery Manager

Deepak Chauhan
Oracle Recovery Manager (RMAN)

•Overview of RMAN
• Recovery Catalog
• RMAN Set-up
• Database Backups with RMAN
• Database Recovery with RMAN

Dec 8, 2021 L3 Admin


RMAN Overview – What is RMAN

• What is RMAN ?

• “Recovery Manager (RMAN) is an Oracle


tool that allows you to back up, copy,
restore, and recover datafiles, control files,
and archived redo logs”

Dec 8, 2021 L3 Admin


RMAN Overview – What is RMAN

• Generic multi-OS backup utility


• Included with Oracle Server
• GUI or command-line mode
• Optional recovery catalog
• Allows backup scripting and automation
• Uses server sessions to do backup and recovery tasks
• Limited reporting capabilities

Dec 8, 2021 L3 Admin


RMAN Overview – What is RMAN

• RMAN (9i ONLY) can automatically backup


– Parameter files
– Control files

• RMAN does NOT backup


– Online redo logs
– Transported tablespaces (before read-write)

Dec 8, 2021 L3 Admin


RMAN Overview–Backup&Restore

• At it’s simplest
• RMAN> backup database;

• RMAN> restore database;


• RMAN> recover database;

Dec 8, 2021 L3 Admin


RMAN Overview - Benefits

• Incremental backups
• Recovery changes to objects created nologging
• (by applying incremental backups)
• Test / verify / check backups
• Automatic parallelization of backups / recovery

Dec 8, 2021 L3 Admin


RMAN Overview - Benefits

• Compress backups of datafiles


• (only blocks written to are included in backup)
• Block level recovery ** 9i
• Duplicate database

Dec 8, 2021 L3 Admin


RMAN – Backups - Compression

• RMAN performs compression


• only writes used blocks
• For every 4 contiguous unused blocks, RMAN writes one
compression block
• DB_FILE_DIRECT_IO_COUNT determines buffer size (eg if value
is 32K, then RMAN writes one compression block for each 128K of
contiguous unused input blocks)

Dec 8, 2021 L3 Admin


RMAN Overview – Remote Target

• RMAN can backup databases on remote database instances,


called “target” databases
• RMAN uses server sessions to connect to target
• MUST use password authentication connection to target
database

Dec 8, 2021 L3 Admin


RMAN Overview - Architecture

Oracle8i Recovery Manager User's Guide and Reference


Release 2 (8.1.6)

Dec 8, 2021 L3 Admin


Oracle Recovery Manager (RMAN)

• Overview of RMAN

•Recovery Catalog
• RMAN Set-up
• Database Backups with RMAN
• Database Recovery with RMAN

Dec 8, 2021 L3 Admin


RMAN Repository

• “The RMAN repository is the collection of metadata about


your target databases that RMAN uses to conduct its backup,
recovery, and maintenance operations.”

• Can be in either recovery catalog or exclusively in the control


file of target database (limits RMAN functionality).

Dec 8, 2021 L3 Admin


RMAN Repository

• Repository contents include information on:


• Backup sets and backup pieces
• Datafile, controlfile copies
• Archived redo logs and their copies
• Tablespaces and datafiles on target database
• Stored scripts

Dec 8, 2021 L3 Admin


RMAN Recovery Catalog

• Recovery catalog is optional


• Advantages:
• Allows you to store scripts of common tasks
• Allows more reporting options
• Disadvantages:
• Must backup the backup database
• Additional overhead maintenance

Dec 8, 2021 L3 Admin


RMAN Repository – Control File

• Appropriate for small databases


• Does not support
• stored scripts
• restore / recovery when control file lost
• Two types of records in control file:
• Circular reuse
• Non-circular reuse records

Dec 8, 2021 L3 Admin


RMAN Repository – Catalog

• Supports:
• stored scripts
• restore / recovery when control file lost
• more advanced reporting
• Appropriate for managing several databases
• Typical implementation
• Separate RMAN schema for each database

Dec 8, 2021 L3 Admin


RMAN Repository - Catalog

• Create a small database for RMAN


• Simple to manage / upgrade
• Can store information for several target databases
• Must backup frequently
• Store repository in existing databases
• Less administration if already backing up existing
databases
• Need at least TWO databases to backup each other

Dec 8, 2021 L3 Admin


RMAN Repository - Resync

• Recovery catalog obtains critical metadata from target


database control file.
• Control file employs a circular reuse system and backup and
copy records eventually get overwritten.
• Must resynchronize catalog to capture information from
control file so catalog remains current and information is not
lost (overwritten).

Dec 8, 2021 L3 Admin


Oracle Recovery Manager (RMAN)

• Overview of RMAN
• Recovery Catalog

•RMAN Set-up
• Database Backups with RMAN
• Database Recovery with RMAN

Dec 8, 2021 L3 Admin


RMAN - Repository User Set-up

• SQL> create tablespace rcat datafile


• 2 'c:\ora9i\oradata\oemrep\rcat.dbf' size 10m;
• Tablespace created.

• SQL> create user rman identified by rman


• 2 temporary tablespace temp
• 3 default tablespace rcat quota unlimited on rcat;

• SQL> grant connect, resource to rman;


• Grant succeeded.

• SQL> grant recovery_catalog_owner to rman;


• Grant succeeded.

Dec 8, 2021 L3 Admin


RMAN - Repository Catalog Set-up

• C:\>rman
• Recovery Manager: Release 9.2.0.1.0 - Production
• Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

• RMAN> connect catalog rman/rman@oemrep


• connected to recovery catalog database
• recovery catalog is not installed

• RMAN> create catalog;


• recovery catalog created

• RMAN> connect target sys/sys@btu1


• connected to target database: BTU1 (DBID=2890569725)
• RMAN> register database;

• database registered in recovery catalog


• starting full resync of recovery catalog
• full resync complete

Dec 8, 2021 L3 Admin


RMAN Repository – Packages

• PL/SQL Packages

DBMS_RCVCAT Maintain recovery catalog create catalog


information

DBMS_RCVMAN Query recovery catalog or create catalog


control file

DBMS_BACKUP_RES Interfaces with OS to provide catproc.sql


TORE I/O services for backup and
dbmsbkrs.sql
recovery
prvtbkrs.plb

Dec 8, 2021 L3 Admin


Oracle Recovery Manager (RMAN)

• Overview of RMAN
• Recovery Catalog
• RMAN Set-up

•Database Backups with RMAN


• Database Recovery with RMAN

Dec 8, 2021 L3 Admin


Types of Database Recovery

• Object Recovery (Imports)


• Instance Recovery
• Media Recovery
– Online Redo
– Datafiles
– Controlfiles
– Operating System Files (init.ora)

Dec 8, 2021 L3 Admin


Objects RMAN Backs Up

• Backup objects are:


• whole database (control file and all datafiles)
• tablespace
• datafile
• control file
• archivelog files
• operating system files (9i)

Dec 8, 2021 L3 Admin


RMAN – Backups

• To do backups:
• target database must be open or mounted
• if mounted, must NOT have been abnormally terminated (for consistent
backup)
• control file must be current
• NORACHIVELOG – database must be shutdown cleanly before backup
• ARCHIVELOG – database can be open or closed

Dec 8, 2021 L3 Admin


RMAN – Backups

• To do backups:
1. Allocate channel(s) to create server sessions (optional in 9i)
2. Run script “backup”
3. Check output

Dec 8, 2021 L3 Admin


RMAN – Backups

8i RMAN> run {
allocate channel c1 type disk;
backup database;}

9i RMAN> backup database;

Dec 8, 2021 L3 Admin


RMAN – Backups - Errors

• Two types of errors


• I/O errors (reading files or writing backup pieces), cause the system to abort
the jobs.
• Corrupt block

• Retains all successful backup sets before abort


• All RMAN errors will have RMAN-00569 error stack banner

Dec 8, 2021 L3 Admin


RMAN – Backups – Errors

• RMAN> backup database;


• Starting backup at 02-07-18
• using target database controlfile instead of recovery catalog
• allocated channel: ORA_DISK_1
• channel ORA_DISK_1: sid=12 devtype=DISK
• channel ORA_DISK_1: starting full datafile backupset
• channel ORA_DISK_1: specifying datafile(s) in backupset
• including current SPFILE in backupset
• including current controlfile in backupset
• RMAN-00571: ===========================================================
• RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
• RMAN-00571: ===========================================================
• RMAN-03009: failure of backup command on ORA_DISK_1 channel at 07/18/2002 07:05:12
• ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode

Dec 8, 2021 L3 Admin


RMAN – Backups – Fix Errors

• RMAN> shutdown immediate;


• . . . Oracle instance shut down
• RMAN> startup mount
• connected to target database (not started)
• Oracle instance started
•. . .

• RMAN> sql 'alter database archivelog';


• sql statement: alter database archivelog

• RMAN> sql 'alter database open';


• sql statement: alter database open

Dec 8, 2021 L3 Admin


RMAN – Backups – Fix Errors

• RMAN> backup database;


• Starting backup at 02-07-18
• allocated channel: ORA_DISK_1
• channel ORA_DISK_1: sid=11 devtype=DISK
• channel ORA_DISK_1: starting full datafile backupset
• channel ORA_DISK_1: specifying datafile(s) in backupset
• including current SPFILE in backupset
• including current controlfile in backupset
• input datafile fno=00001 name=C:\ORA9I\BTU1\SYSTEM01.DBF
• input datafile fno=00002 name=C:\ORA9I\BTU1\UNDOTBS01.DBF
• input datafile fno=00004 name=C:\ORA9I\BTU1\INDX01.DBF

Dec 8, 2021 L3 Admin


RMAN – Backups – Fix Errors

• input datafile fno=00006 name=C:\ORA9I\BTU1\USERS01.DBF


• input datafile fno=00003 name=C:\ORA9I\ORADATA\BTU1\EXAMPLE01.DBF
• input datafile fno=00005 name=C:\ORA9I\BTU1\TOOLS01.DBF
• channel ORA_DISK_1: starting piece 1 at 02-07-18
• channel ORA_DISK_1: finished piece 1 at 02-07-18
• piece handle=C:\ORA9I\DATABASE\02DTS31C_1_1 comment=NONE
• channel ORA_DISK_1: backup set complete, elapsed time: 00:00:47
• Finished backup at 02-07-18

Dec 8, 2021 L3 Admin


RMAN - Backups - Corrupt Blocks

• Copies datafile blocks ALREADY identified as corrupt into backup


• Newly corrupt Blocks handled in two ways:
– If maxcorrupt = 0, aborts job
– If maxcorrupt > 0, then writes block with reformatted header to indicate corrupt
AND updates control file
– If # of new corruptions > maxcorrupt, aborts job

Dec 8, 2021 L3 Admin


RMAN - Backups - Corrupt Blocks

run {
set maxcorrupt for datafile 2 to 1; ….
}

• Control file holds corrupt block address and corruption type


• To access control file corruption records, use
• V$BACKUP_CORRUPTION
• Or V$COPY_CORRUPTION

Dec 8, 2021 L3 Admin


RMAN – Backups Multiplexed

• Oracle multiplexes datafile blocks in the same backup set.


• Multiplexing limited by filesperset parameter
• Can explicitly partition datafiles into backup sets
• RMAN can automatically select partitioning

Dec 8, 2021 L3 Admin


RMAN – Backups Multiplexed

• Multiplexing can “Keep a high performance sequential output device


streaming by including a sufficient number of datafiles in the backup”
• Prevents saturating single datafile with too many read requests
• Limit read rate with set limit channel:
run { allocate channel c1 type disk;
set limit channel c1 readrate=50; …}

Dec 8, 2021 L3 Admin


RMAN – Backups Multiplexed

File 1 1 2
3 1
2
Server 3 1
File 2
Session 2
1
2 3
1 2
File 3

Dec 8, 2021 L3 Admin


RMAN – Backups Multiplexed

run {
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup (datafile 1,2,3 filesperset =3 channel c1)
(datafilecopy ‘/u02/oraplay/babette/users.dbf’
filesperset =1 channel c2)
(archivelog from logseq 40 until logseq 45 channel c3);}

Dec 8, 2021 L3 Admin


RMAN – Channel Allocation

• Must allocate a channel before execute backup / recovery


commands. (configurable in 9i)
• Each channel starts server session on target database
• Each allocated channel establishes connection from RMAN to
target database

• RMAN> run { allocate channel c1 type disk; ..}


• RMAN> allocate channel for maintenance c1;

Dec 8, 2021 L3 Admin


RMAN – Channel Allocation

• Channel Control Options can be used to:


• Control O/S resources RMAN uses
• Affect degree of parallelism for backup
• Limit I/O bandwidth consumption
• Limit size of backup pieces
• Limit number of currently open files
• Send vendor specific commands to media manager

Dec 8, 2021 L3 Admin


RMAN – Channel Allocation

• Controlling Parallelization
• RMAN executes commands serially and handles
parallelization internally.
• To have parallelization, use multiple channels and a
SINGLE copy command.

Dec 8, 2021 L3 Admin


RMAN – Channel Allocation

• Example 1 – NO Parallelization
• run {
• allocate channel c1 type disk;
• allocate channel c2 type disk;
• allocate channel c3 type disk;
• copy datafile 2 to '/u01/backup/tools.dbf’;
• copy datafile 3 to /u01/backup/users.dbf’;
• copy datafile 4 to /u01/backup/temp.dbf’;}

Dec 8, 2021 L3 Admin


RMAN – Channel Allocation

• Example 2 –WITH Parallelization


• run {
• allocate channel c1 type disk;
• allocate channel c2 type disk;
• allocate channel c3 type disk;
• copy datafile 2 to '/u01/backup/tools.dbf’,
• datafile 3 to /u01/backup/users.dbf’,
• datafile 4 to /u01/backup/temp.dbf’;}

Dec 8, 2021 L3 Admin


RMAN – Channel Configuration

• RMAN> configure default device type to disk;

• new RMAN configuration parameters:


• CONFIGURE DEFAULT DEVICE TYPE TO DISK;
• new RMAN configuration parameters are successfully stored
• released channel: ORA_DISK_1

• RMAN> configure device type disk parallelism 2;

• RMAN> configure channel 2 device type disk format 'C:\mydata\%U' ;

Dec 8, 2021 L3 Admin


RMAN – Channel Configuration

• RMAN> backup database;


• Starting backup at 02-07-18
• allocated channel: ORA_DISK_1
• channel ORA_DISK_1: sid=11 devtype=DISK
• allocated channel: ORA_DISK_2
• channel ORA_DISK_2: sid=13 devtype=DISK
• channel ORA_DISK_1: starting full datafile backupset
• channel ORA_DISK_1: specifying datafile(s) in backupset
• input datafile fno=00002 name=C:\ORA9I\BTU1\UNDOTBS01.DBF
• input datafile fno=00004 name=C:\ORA9I\BTU1\INDX01.DBF
• input datafile fno=00006 name=C:\ORA9I\BTU1\USERS01.DBF
• input datafile fno=00003 name=C:\ORA9I\ORADATA\BTU1\EXAMPLE01.DBF
• channel ORA_DISK_1: starting piece 1 at 02-07-18
• channel ORA_DISK_2: starting full datafile backupset

Dec 8, 2021 L3 Admin


RMAN – Channel Configuration

• channel ORA_DISK_2: specifying datafile(s) in backupset


• including current SPFILE in backupset
• including current controlfile in backupset
• input datafile fno=00001 name=C:\ORA9I\BTU1\SYSTEM01.DBF
• input datafile fno=00005 name=C:\ORA9I\BTU1\TOOLS01.DBF
• channel ORA_DISK_2: starting piece 1 at 02-07-18
• channel ORA_DISK_1: finished piece 1 at 02-07-18
• piece handle=C:\ORA9I\DATABASE\03DTS5AA_1_1 comment=NONE
• channel ORA_DISK_1: backup set complete, elapsed time: 00:00:20
• channel ORA_DISK_2: finished piece 1 at 02-07-18
• piece handle=C:\MYDATA\04DTS5AA_1_1 comment=NONE
• channel ORA_DISK_2: backup set complete, elapsed time: 00:00:45
• Finished backup at 02-07-18

Dec 8, 2021 L3 Admin


RMAN – Channel Configuration

•To clear:
• configure default device type clear;
• configure device type disk clear;
• configure channel 2 device type disk clear;

• RMAN> configure channel 2 device type disk clear;

• old RMAN configuration parameters:


• CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT 'C:\mydata\%U';
• old RMAN configuration parameters are successfully deleted
• released channel: ORA_DISK_2
• released channel: ORA_DISK_1

Dec 8, 2021 L3 Admin


RMAN – Media Management

• To use tape storage for backups, Oracle requires a media


manager.

• “A media manager is a utility that loads, labels, and unloads


sequential media such as tape drives for the purpose of
backing up and recovering data.”

• Typically need to relink Oracle to install

Dec 8, 2021 L3 Admin


RMAN – Media Management

• Oracle publishes a media management API that third-party


vendors use to build software that works with RMAN

• To use RMAN to backup to tape, use:


• run {
• allocate channel c1 type ‘sbt_tape’;
• …}

Dec 8, 2021 L3 Admin


RMAN – Media Management

• Tapes may become unavailable


• RMAN can perform crosschecks to determine backup
pieces are still available
• RMAN> crosscheck backup;

• Missing backups will be marked “EXPIRED”


• Crosschecks keep media management catalog and RMAN
repository synchronized

Dec 8, 2021 L3 Admin


RMAN – Media Management

Oracle8i Recovery Manager User's Guide and Reference


Release 2 (8.1.6)

Dec 8, 2021 L3 Admin


RMAN Stored Scripts

• “A stored script is a set of RMAN commands that is enclosed


in braces and stored in the recovery catalog.”
• Allow you to develop, test and save commands.
• Minimize potential for operator errors.
• Each script relates to ONE target database only.
• Can view stored scripts
• select * from rc_stored_script;

Dec 8, 2021 L3 Admin


RMAN Stored Scripts

• To create a stored script:


RMAN> create script b_whole_l0 {
# backup entire database
allocate channel c1 type disk;
backup
incremental level 0
format /u01/backup/b_t%t_s%s_p%p’
(database);
sql ‘ALTER SYSTEM ARCHIVE LOG CURRENT’;
backup (archivelog all delete input); }

Dec 8, 2021 L3 Admin


RMAN Stored Scripts

•To run a stored script:


RMAN> run {
execute b_whole_l0 ;
}

Dec 8, 2021 L3 Admin


RMAN – Backup Sets

• “A backup set is a complete set of backup pieces that constitute a full or


incremental backup of the objects specified in the backup command.”

Dec 8, 2021 L3 Admin


RMAN – Backup Sets

• Each backup creates a backup set


• - composed of one or more backup pieces.
• Files cannot be split across different backup sets
• Archive log and Datafiles NEVER in same set.
• RMAN-specific format

Dec 8, 2021 L3 Admin


RMAN – Backup Sets

• Backup sets are stored on disk or tape ( ‘sbt_tape’)


• Cannot archive directly to tape but can backup archived redo logs to tape and
then delete
• Backup piece filenames
• Substitution variables to generate unique names
• Specify format
• Allow RMAN determine unique name (%U)

Dec 8, 2021 L3 Admin


RMAN – Backup Sets

• Number and size of backup sets depends on:


• number of input files specified or implied
• number of channels allocated (each non-idle channel will create at least one
backup set)
• filesperset (limits number of files per backup set)
• setsize (limits backup set overall size)

Dec 8, 2021 L3 Admin


RMAN – Lists and Reports

• To get information on backups and copies:


• list – lists contents of RMAN repository
• report – more detailed analysis

• Output can be directed to screen or log file

Dec 8, 2021 L3 Admin


RMAN – Lists and Reports

• List used to list:


– Backups of specific list of datafiles (or datafiles that are members
of specific list of tablespaces)
– Image copies of specific list of datafiles (or members of specific list
of tablespaces)
– Incarnations of specific database
– Backups of archived redo logs with specific name and /or within
specific range

Dec 8, 2021 L3 Admin


RMAN – Lists and Reports

• RMAN> list backup

• List of Backup Sets


• ===================
• BS Key Type LV Size Device Type Elapsed Time Completion Time
• ------- ---- -- ---------- ----------- ------------ ---------------
• 1 Full 194M DISK 00:00:47 02-07-18
• BP Key: 1 Status: AVAILABLE Tag: TAG20020718T072220
• Piece Name: C:\ORA9I\DATABASE\02DTS31C_1_1
• SPFILE Included: Modification time: 02-07-17
• List of Datafiles in backup set 1
• File LV Type Ckp SCN Ckp Time Name
• ---- -- ---- ---------- -------- ----
• 1 Full 100039 02-07-18 C:\ORA9I\BTU1\SYSTEM01.DBF
• 2 Full 100039 02-07-18 C:\ORA9I\BTU1\UNDOTBS01.DBF
• 3 Full 100039 02-07-18 C:\ORA9I\ORADATA\BTU1\EXAMPLE01.DBF
• 4 Full 100039 02-07-18 C:\ORA9I\BTU1\INDX01.DBF
• 5 Full 100039 02-07-18 C:\ORA9I\BTU1\TOOLS01.DBF
• 6 Full 100039 02-07-18 C:\ORA9I\BTU1\USERS01.DBF

Dec 8, 2021 L3 Admin


RMAN – Lists and Reports

• BS Key Type LV Size Device Type Elapsed Time Completion Time


• ------- ---- -- ---------- ----------- ------------ ---------------
• 2 Full 66M DISK 00:00:20 02-07-18
• BP Key: 2 Status: AVAILABLE Tag: TAG20020718T080113
• Piece Name: C:\ORA9I\DATABASE\03DTS5AA_1_1
• List of Datafiles in backup set 2
• File LV Type Ckp SCN Ckp Time Name
• ---- -- ---- ---------- -------- ----
• 2 Full 101983 02-07-18 C:\ORA9I\BTU1\UNDOTBS01.DBF
• 3 Full 101983 02-07-18 C:\ORA9I\ORADATA\BTU1\EXAMPLE01.DBF
• 4 Full 101983 02-07-18 C:\ORA9I\BTU1\INDX01.DBF
• 6 Full 101983 02-07-18 C:\ORA9I\BTU1\USERS01.DBF

• BS Key Type LV Size Device Type Elapsed Time Completion Time


• ------- ---- -- ---------- ----------- ------------ ---------------
• 3 Full 127M DISK 00:00:43 02-07-18
• BP Key: 3 Status: AVAILABLE Tag: TAG20020718T080113
• Piece Name: C:\MYDATA\04DTS5AA_1_1

Dec 8, 2021 L3 Admin


RMAN – Lists and Reports

• SPFILE Included: Modification time: 02-07-17


• List of Datafiles in backup set 3
• File LV Type Ckp SCN Ckp Time Name
• ---- -- ---- ---------- -------- ----
• 1 Full 101990 02-07-18 C:\ORA9I\BTU1\SYSTEM01.DBF
• 5 Full 101990 02-07-18 C:\ORA9I\BTU1\TOOLS01.DBF

Dec 8, 2021 L3 Admin


RMAN – Lists and Reports

• Report used to list:


– Which datafiles not been backup up lately
– Which backups and copies can be deleted
– Which datafiles need backup because less than X number of
backups available
– Which datafiles are not recoverable
– Which backups are orphaned (not direct ancestors of current
database incarnation)

Dec 8, 2021 L3 Admin


RMAN – Incremental Backups

Full Backups all used blocks in the datafiles


specified.
(Full backup differs from whole database
backup. A whole backup includes ALL datafiles
AND controlfile)
Skips unused blocks

Incremental Backup includes only those blocks that have


changed since previous incremental backup.
Requires incremental level 0 as basis.
EXCLUDES full backups.

Dec 8, 2021 L3 Admin


RMAN – Incremental Backups

• Advantages
• Saves tape / disk space
• Saves bandwidth when backing up over network
• Recover changes to objects created NOLOGGING
• Disadvantages
• Increase recovery time

Dec 8, 2021 L3 Admin


RMAN – Incremental Backups

• How incremental backups work


1. Each datablock contains SCN
2. RMAN reads SCN of each datablock by reading entire input
file
3. RMAN compares SCN of each datablock with checkpoint
SCN of parental incremental backup
4. If datablock SCN > parent SCN, then RMAN copies the
block

Dec 8, 2021 L3 Admin


RMAN – Incremental Backups

• Differential Incremental Backups


• Back up all blocks that have changed since the most
recent backup at level N or lower
• Least data to backup
• Cumulative Incremental Backups
• Back up all blocks that have changed since the most
recent backup at level N – 1 or lower
• Less backups to restore

Dec 8, 2021 L3 Admin


RMAN – Incremental Backups

• Differential Incremental Backups (Level N)


• Backup
• Level 0 2 2 2 1 2 2
0
• Day Sun Mon Tue Wed Thu Fri Sat
Sun

Dec 8, 2021 L3 Admin


RMAN – Incremental Backups

• Cumulative Incremental Backups (Level N –1)


• Backup
• Level 0 2 2 2 1 2 2
0
• Day Sun Mon Tue Wed Thu Fri Sat
Sun

Dec 8, 2021 L3 Admin


RMAN – Incremental Backups

• Incremental Backup Strategy


• Base on MTTR (Mean Time to Recovery)
• Take level 0 backups when >=50% data changed

• SELECT file#, incremental_level, completion_time,


• blocks, datafile_blocks
• FROM v$backup_datafile
• WHERE incremental_level > 0
• AND blocks / datafile_blocks > .5
• ORDER BY completion_time;

Dec 8, 2021 L3 Admin


RMAN – Image Copies

• Contains single datafile, archivelog or control file that can


be used as-is for recovery
• Created by
• RMAN copy command
• O/S utility, such as cp

Dec 8, 2021 L3 Admin


RMAN – Image Copies

• RMAN Image copies


• Validates blocks (V$COPY_CORRUPTION)
• Records copy in control file
• Can use ‘switch’ to replace existing file

run { allocate channel c1 type disk;


copy datafile 1 to ‘/u01/back/system.dbf’;}

Dec 8, 2021 L3 Admin


RMAN – Image Copies

• When using O/S copy, must use “ALTER TABLESPACE BEGIN


BACKUP”
• If O/S copy reads block currently being written, then the
blocks is fractured.
• Oracle compares block header and footer information during
recovery to determine if a block is fractured.
• NEVER get fractured blocks with RMAN

Dec 8, 2021 L3 Admin


RMAN – O/S Image Copies

• Can catalog O/S copies to use in RMAN


• Must catalog prior to ‘switch’ or ‘restore’
• O/S copy made with database closed
• O/S copy made with database open AND using “ALTER
TABLESPACE BEGIN BACKUP” to avoid fractured blocks

Dec 8, 2021 L3 Admin


RMAN – O/S Image Copies

• Can catalog and uncatalog datafile, archivelog, or


control file copies, using:

• catalog datafilecopy ‘/u01/back/users.dbf’ level = 0;


• catalog controlfilecopy ‘/u01/back/control1.ctl’;

• change datafilecopy ‘/u01/back/users/dbf’ uncatalog;


• change archivelog ‘/u01/arch/arch123.rdo’ uncatalog;

Dec 8, 2021 L3 Admin


RMAN – Restore Files

• Can use RMAN to restore:


• Datafiles
• Control files (current or copies)
• Archived redo logs
• Must restore from backup sets because stored in RMAN
proprietary format that is not useable as is
• Image copies can be used as is.

Dec 8, 2021 L3 Admin


RMAN – Restore Files

• RMAN automates restoring files


• Uses recovery catalog or target control file to determines
most appropriate backup or datafile copy to use. Also
considers channels specified.
• Copies to either default location or new location
• (use ‘set newname’ and ‘switch’)
• Records restore in control file

Dec 8, 2021 L3 Admin


RMAN – Restore Files

• Constraints:
• Restore must be on STARTED instance
• (not mounted in the event control file is lost).
• Database closed or tablespace / datafile offline
• Overwrites existing file or uses new file
• Cannot restore from files created on a different host

Dec 8, 2021 L3 Admin


Oracle Recovery Manager (RMAN)

• Overview of RMAN
• Recovery Catalog
• RMAN Set-up
• Database Backups with RMAN

•Database Recovery with RMAN

Dec 8, 2021 L3 Admin


RMAN – Recover Files

• “Media recovery is the application of online or archived redo


logs or incremental backups to a restored datafile in order to
update it to the current time or some other specified time”
• RMAN can automatically perform media recovery and apply
incremental backups
• Can only recover current datafiles
• Catalog must be used to do control file recovery

Dec 8, 2021 L3 Admin


RMAN – Recover Files

• To recover files
1) use ‘set until’ to perform incomplete recovery based on
time, SCN or log sequence (if do this, must open database
RESETLOGS)
2) Restore necessary files using restore
3) Recover necessary files using recover

Dec 8, 2021 L3 Admin


RMAN – Recover Files

• Example
• run {
• allocate channel c1 type disk;
• set until SCN = 3219;
• restore database;
• recover database;}

Dec 8, 2021 L3 Admin


Media Recovery Scenarios

• Operating in Noarchivelog mode


• Complete vs Incomplete
• All datafiles lost
• Control files lost / damaged
• Tablespace Point-in-Time Recovery (TSPITR)
• Corrupt Block

Dec 8, 2021 L3 Admin


Database Recovery with RMAN

• Default Restore Choices:


– RMAN chooses restoring incremental backup over restoring datafile
and applying redo logs
– For overlapping incrementals, RMAN selects incremental covering
longest period of time
– If no incremental backups, RMAN searches for archived redo log. If
no longer on disk, searches in backup sets and restores them.

Dec 8, 2021 L3 Admin


Database Recovery with RMAN

• Scenario 1
• Loss of RMAN catalog (eg drop tablespace, etc)
• Can partially reconstruct catalog from current control
file or control file backups.

Dec 8, 2021 L3 Admin


Database Recovery with RMAN

• Scenario 2
• Problems writing to tape
• sbttest - stand-alone utility to test media management
software
• sbtio.log – tape errors should be written here.

Dec 8, 2021 L3 Admin


RMAN – Integrity Checks

• “Oracle prohibits any attempts to perform operations that


result in unusable backup files or corrupt restored datafiles”

• (compare this with taking OS copies of the datafiles but


forgetting to put in hot backup mode)

Dec 8, 2021 L3 Admin


RMAN – Integrity Checks

• Oracle performs integrity checks to:


• Prevent restoring backups from previous incarnations of the
database
• Ensure incremental backups applied in order
• Prohibit access datafiles being restored / recovered
• Allow only one restore to datafile at a time
• Prohibit backup of unrecovered backups
• Control information stored in backups to ensure corrupt
backups detected

Dec 8, 2021 L3 Admin


RMAN – Database Duplication

• RMAN allows you to duplicate production database on the


SAME host or different host.
• If using different host, can change directory structure if use
‘set newname’ or init.ora parameter:
DB_FILE_NAME_CONVERT

Dec 8, 2021 L3 Admin


RMAN – Database Duplication

• RMAN restores the target datafiles to duplicate database and


does incomplete recovery all available archived redo log and
incremental backups
• RMAN opens duplicate database with RESETLOGS
• RMAN generates new, unique DB identifier for duplicate
database (can’t do when clone database)
• Allows you to register duplicate database in same recovery
catalog (can’t do when clone database)

Dec 8, 2021 L3 Admin


RMAN – Corruption Checks

• Server session doing backup able to detect many types of


corrupt blocks.
• Each new corrupt block encountered is recorded in control file
and alert.log
• RMAN ignores previously encountered corrupt blocks
• RMAN re-formats header of newly corrupt block to identify
media corruption

Dec 8, 2021 L3 Admin


RMAN – Corruption Checks

• At end of backup, RMAN records corruption info in control file


and recovery catalog
• Access corruption information via:
• V$BACKUP_CORRUPTION
• V$COPY_CORRUPTION

• RMAN can also check for logical corruption and logs in alert
log and server session trace

Dec 8, 2021 L3 Admin


Mixing RMAN with OS Backups

• OS Backups
• hot or cold datafile copies
• controlfile copies
• Register datafile or controlfile copies with RMAN
• RMAN restore will be able to use OS backups.

Dec 8, 2021 L3 Admin


Mixing RMAN with OS Backups

• Potential Problems
• If delete archivelog files, need to open resetlogs in
order to resynchronize database with RMAN

Dec 8, 2021 L3 Admin

You might also like