Você está na página 1de 41

Simple steps to

Implement RMAN
Nanak Sawlani
Jesse Crew
ZLB Behring
ZLB Behring Intro

ZLB Behring is a global leader in the


plasma therapeutics industry.
The company's broad portfolio of life-
saving therapeutics are used in the
treatment of individuals with
hemophilia, immune deficiency
disorders and inherited emphysema.
www.zlbbehring.com

2004 2
Agenda

„ RMAN Overview
„ RMAN Catalog setup
„ Backup procedure and examples
„ Recovery examples
„ RMAN Reporting
„ Maintenance of catalog
„ Questions and Answers

2004 3
RMAN will not back up

„ Oracle software
„ Configuration files (tnsnames,sqlnet etc)

„ Pre9i, init.ora will not be back up

(9i allows backup of parameter file, spfile only)


„ RMAN will not perform logical backup

(you can use export and import)


„ /oratab and other system Oracle-related file
(startup and shutdown scripts,like /etc/rc3.d..)

2004 4
RMAN limitations

„ Cannot use compressed archivelog files


„ Cannot use one script for multiple databases
„ Reporting is not easier for multiple databases
„ Catalog maintenance is not easier in previous
versions.
„ Error messages are difficult to read

2004 5
RMAN Architecture

ta rg e t ta rg e t h o m e
DB R M A N b in a r y RMAN
s erver proc es s es C a ta lo g
--
c h a n n e ls T arg e t
v e rs io n
m e d ia c o m p a tib le
m anagem ent r e p o s it o r y
la y e r

2004 6
Steps to backup using RMAN

„ Install and configure Media Management software


„ Link MML to Oracle
„ Create catalog
„ Register target database in the catalog
„ Backup the database

2004 7
Media Management Layer

„ MML manages the reading and writing of file to


and from tape.
„ MML is needed only if backing up to tape
„ Example of Linking Veritas Netbackup
$ORACLE_HOME/lib
ln –s <install_path>/netbackup/bin/libobk.so.l libobk.so
make –f ins_rdbms.mk ioracle
„ Define Class configuration in the Netbackup

2004 8
Use of Catalog

„ Catalog is the metadata about the backups


„ Catalog is needed if you wish to store scripts
„ Catalog allows you to restore a DB from previous
incarnation
„ Catalog offers enterprise-wide repository
„ Reporting is easier
„ By default, RMAN uses NOCATALOG option

2004 9
Catalog creation/setup

„ Catalog database should be separate then target

Create tablespace rcvcat


Create user rman
Grant role recovery_catalog_owner
rman rcvcat user/passwd@dbname
RMAN >create catalog tablespace “rcvcat”

2004 10
Target database

„ Target database server needs to have an entry in


the tnsnames.ora for the Catalog database
„ Create backup user in the target database
‹ grant sysdba privilege
„ Register the database
RMAN> connect catalog user/passwd@dbname
RMAN> connect target user/passwd@dbname
register database;

2004 11
RMAN terms

„ backup sets
‹ Logical grouping of backup files
„ Backup piece
‹ A physical binary file created by RMAN
„ Channel is the server process
‹ 4 channels (four parallel streams)write or read to one tape
‹ Channels can be allocated for TAPE or DISK
„ Backup Retention Policy
‹ How long you want to keep the backups

2004 12
Incremental backup (levels)

„ Level 0: incremental base backup


„ Level 1: RMAN backs up the blocks that have
changed since the last backup
„ Level 2 and so on…

2004 13
HOT backup
„ It does not use begin backup/end backup
„ using RMAN for running hot backup does not impact
the volume of redo logging
„ RMAN reads the data blocks directly from the data file
and uses an internal oracle mechanism (read –
consistency) exactly as a normal SQL statement.

2004 14
Hot backup example
run {
allocate channel t1 type 'SBT_TAPE';
backup
tag hot_db_bk_level0
filesperset 1
format 'bk_%s_%p_%t'
(database);
sql 'alter system archive log current';
backup filesperset 5
format 'al_%s_%p_%t'
(archivelog all delete input);
}
2004 15
Cold backup using RMAN

„ Even for a cold backup, database needs to be


MOUNTED

2004 16
Cold backup example
run {
# Cold database level 0 backup
allocate channel t1 type 'SBT_TAPE';
allocate channel t2 type 'SBT_TAPE';
allocate channel t3 type 'SBT_TAPE';
allocate channel t4 type 'SBT_TAPE';
backup incremental level 0
tag cold_db_bk_level0
filesperset 1
format 'bk_%s_%p_%t'
(database);
sql 'alter database open';
}
2004 17
RMAN Commands

„ resync catalog
‹ Reads the control file and synchronizes the catalog with database
backup information
„ Crosscheck
‹ Checks repository to ensure physical file exists
e.g If you manually remove archive log file using OS command
‹ Crosscheck command does not delete OS file or record from
repository.

2004 18
Restore

„ Once the restore of data files is complete, recovery


can be done via RMAN, SQL*Plus or Server
Manager
„ Restore validate database
‹ Checks the backup set to ensure database is recoverable

2004 19
Restore all datafiles example

connect target ‘user/passwd@TARGETDB'


connect rcvcat ‘rman/passwd@catalogDB'
run {
# Restore all data files
allocate channel t1 type 'SBT_TAPE';
allocate channel t2 type 'SBT_TAPE';
allocate channel t3 type 'SBT_TAPE';
allocate channel t4 type 'SBT_TAPE';
restore (database);
}

2004 20
Point in time recovery

run {
set until time '2002-05-22:09:45:00';
allocate channel t1 type 'SBT_TAPE';
allocate channel t2 type 'SBT_TAPE';
restore (database);
recover database;
sql 'alter database open resetlogs';
}

2004 21
Storing scripts in Catalog

„ Create script or replace script


create script backup_full
{backup database plus archivelog}
„ Executing a stored script
‹ run {execute script full_bak;}
„ To view stored script
‹ print script full_bak
„ To delete stored script
‹ delete script full_bak;

2004 22
RMAN and Backup of control files

„ In 9i, configure control file autobackup on


‹ Control file will be backed up whenever backup or copy is issued
„ Backup current control file
‹ Manually backup control file

2004 23
Catalog maintenance

„ Backup catalog database


‹ You can use RMAN to backup catalog database
‹ Full export
‹ Cold backup
„ Periodically remove the expired backup
‹ Delete expired backup
„ crosscheck
„ If you perform incomplete recovery and open
database with resetlogs option,
‹ issue reset database command in rman catalog

2004 24
RMAN Reporting

„ List
‹ list backup
‹ list backup summary
‹ list expired backup
„ Report
‹ report obsolete
‹ report schema- reports the tablespace and associated data files
‹ report schema at time ‘sysdate-7’
‹ Report need backup days=3
„ show all
‹ To see the configuration setting

2004 25
How to remove database from Catalog

„ Removing Database is done via SQL*Plus


„ Login to catalog database
‹ SQL> select db_id from v$database;
‹ select db_key,db_id from db where db_id=output from previous
query;
‹ execute dbms_rcvcat.unregisterdatabase(db_key,db_id)

Note: Once removed from catalog, RMAN can no longer recover the
database

2004 26
OEM Interface

„ You can use OEM GUI to perform backup and


recovery
„ OEM will execute the jobs at the target site
„ OEM will use the rman executables of the target
database
„ OEM has
‹ Backup wizard
‹ Maintenance wizard
‹ Recovery wizard

2004 27
Monitoring RMAN jobs

„ v$session_longops
‹ Provides progress report on RMAN backup and restore
„ v$session_wait
‹ Lists the events for which sessions are waiting
‹ It only lists RMAN events and not media manager events
„ RMAN views
‹ rc_database database registered in the catalog
‹ rc_tablespace all tablespaces registered in the catalog
‹ rc_datafile all data files registered in the catalog
‹ rc-stored_script scripts stored in the catalog

2004 28
Components of RMAN session

„ RMAN process itself


„ Catalog connection
„ Initial connection to the target database- default
channel
„ Polling connection to the target
„ One target connection corresponding to each
allocated channel

2004 29
Version support Matrix

„ Metalink note 73431.1


Target RMAN Catalog
Database executables database
8.1.7 8.1.x 8.1.x
8.1.7.4 8.1.7.4 8.1.x
9.0.1 9.0.1 8.1.x

9.2.0 >=9.0.1.3 8.1.x


10.1.0 >=9.0.1.3 >=9.0.1

2004 30
Catalog upgrade

„ Login to the Catalog database


SQL> select * from rcver;
„ Point to the latest RMAN executables

RMAN > upgrade catalog

2004 31
Check corruption

„ backup validate database


„ Query V$DATABSE_BLOCK_CORRUPTION (9i)
„ And v$backup_corruption

2004 32
RMAN can be used to

„ Create duplicate database


„ Create Standby database
„ Environment copy – very useful in SAP
implementation

2004 33
Tuning RMAN

„ Parallel channel settings – using channels


effectively
„ Multiplexing
‹ filesperset – how many files be included in a backup set
‹ maxopenfiles – how many data files RMAN can read in parallel

2004 34
Running SQL commands

„You can run SQL commands from the RMAN


prompt
RMAN> sql “alter system switch logfile”;

„Run Host commands also


RMAN> host “ls”;

2004 35
Known problems and Bugs

„ RMAN uses the large pool during backup and


recovery; so properly sizing the large pool is
prudent (Note 73354.1)

„ the RMAN executable must be compatible with the


target / auxiliary database.

„ Note:227398.1- Known RMAN Bugs in Oracle9i

2004 36
Good practice

„ Ensure NLS_LANG is set appropriately


„ Reporting from Veritas is limited
„ You might have to create some scripts to check the
log file (specially for multiple databases)
„ Verify backups and perform test recoveries
periodically

2004 37
RMAN in 10g

RMAN in 9i
„ can re-start the failed backups or restores

„ Trial restore

RMAN in 10g
„ Disk based recovery

„ Removal of obsolete backup is simpler

„ Compression of backups

2004 38
Summary

„ RMAN Overview
„ RMAN Catalog setup
„ Backup procedure and examples
„ Recovery examples
„ Maintenance of catalog
„ There is more
‹ Trial recovery
‹ Re-starting of failed backups and restores
‹ RMAN in RAC environment
‹ Restoring on another server

2004 39
Resources

„ sample RMAN scripts


$ORACLE_HOME/rdbms/demo/*.rcv
„ ‘Oracle9i RMAN backup and Recovery’ by
Robert Freeman and Matthew hart
„ metalink.oracle.com

„ Technical repository on www.ioug.org

„ Oracle RMAN pocket reference by D. Kuhn & S.


Schulze
„ Veritas has lot of sample scripts

2004 40
Thank you

Neither ZLB Behring or the author guarantee this document to


be error-free. Please provide comments/questions to

Nanak.Sawlani @zlbbehring.com
Jesse.Crew @zlbbehring.com

Special Thanks to
„ Rich Bernat, ChevronTexaco Corp

„ William Gioioso, Vanguard

2004 41