The What, How and Why of ORACLE RMAN

Slides:



Advertisements
Similar presentations
Copyright © 2009 Rolta International, Inc., All Rights Reserved ID#: S RMAN 11g New Features R1 and R2 Michael R. Messina, Management Consultant.
Advertisements

LA Oracle Users Group Succeeding with RMAN Tim Gorman Principal SageLogix, Inc.
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Backup and Recovery Copyright System Managers LLC 2008 all rights reserved.
Shell Canada Limited Session: Compelling Reasons to Use Oracle9i R2 RMAN Wayne Linton Oracle Database Administrator Shell Canada Limited Session.
CERN - IT Department CH-1211 Genève 23 Switzerland t Backup & Recovery with RMAN LCG 3D Workshop, Bologna June 12 th, 2007 Jacek Wojcieszuk.
1 Chapter 15 Duplicating Databases and Transporting Data.
1 Getting The Most Out of RMAN By: Charles Pfeiffer CIO, Remote Control DBA (888)
5 Copyright © 2006, Oracle. All rights reserved. Database Recovery.
Database Backup and Recovery
RMAN Restore and Recovery
Backup and Recovery Part 1.
Chapter 12 Performing Incomplete Recovery. Background Viewed as one of the more difficult chapters to write Thought it was important to put in material.
CERN IT Department CH-1211 Genève 23 Switzerland t Backup configuration best practices Jacek Wojcieszuk, CERN IT-DM Distributed Database.
Oracle’s Backup and Recovery Tool
Configuring Recovery Manager
4 Copyright © 2008, Oracle. All rights reserved. Configuring Backup Specifications.
Chapter 5 Configuring the RMAN Environment. Objectives Show command to see existing settings Configure command to change settings Backing up the controlfile.
CHAPTER 5 Managing Control Files, Online Redo Logs, and Archiving.
Backup & Recovery with RMAN
9 Copyright © Oracle Corporation, All rights reserved. Oracle Recovery Manager Overview and Configuration.
CHAPTER 17 Configuring RMAN. Introduction to RMAN RMAN was introduced in Oracle 8.0. RMAN is Oracle’s tool for backup and recovery. RMAN is much more.
The Oracle Recovery Manager (RMAN)
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
CHAPTER 18 RMAN Backups and Reporting. Introduction to RMAN Backups and Reporting The focus of this chapter is backups of: Datafiles Control files Archived.
Agenda  Overview  Configuring the database for basic Backup and Recovery  Backing up your database  Restore and Recovery Operations  Managing your.
Oracle backup and recovery strategy
Introduction to Oracle Backup and Recovery
Using RMAN to Perform Recovery
Backup Infrastructure – Additional Information Gordon D. Brown, RAL Carlos Fernando Gamboa, BNL 3D Workshop, CNAF, Bologna, Italy 13 th June 2007.
NoCOUG Feb. 8, RMAN in the Trenches: To Go Forward, We Must Backup Philip Rice Univ. of California Santa Cruz.
CHAPTER 16 User-Managed Backup and Recovery. Introduction to User Managed Backup and Recovery Backup and recover is one of the most critical skills a.
13 Copyright © Oracle Corporation, All rights reserved. RMAN Complete Recovery.
Oracle Recovery Manager (RMAN) 10g : Reloaded
PPOUG, 05-OCT-01 Agenda RMAN Architecture Why Use RMAN? Implementation Decisions RMAN Oracle9i New Features.
Oracle Recovery Manager (RMAN) 10g : Reloaded Tammy Bednar Sr. Product Manager Oracle Corporation Session id:
Recovery Manager Overview Target Database Recovery Catalog Database Enterprise Manager Recovery Manager (RMAN) Media Options Server Session.
SRUTHI NAGULAVANCHA CIS 764, FALL 2008 Department of Computing and Information Sciences (CIS) Kansas State University -1- Back up & Recovery Strategies.
5 Copyright © 2004, Oracle. All rights reserved. Using Recovery Manager.
5 Copyright © 2008, Oracle. All rights reserved. Using RMAN to Create Backups.
Chapter 7 Making Backups with RMAN. Objectives Explain backup sets and image copies RMAN Backup modes’ Types of files backed up Backup destinations Specifying.
11 Copyright © Oracle Corporation, All rights reserved. RMAN Backups.
Backup and Recovery Protects From Data Loss. Backup and Recovery Protects From Data Loss Provides for Media Recovery.
11 Copyright © Oracle Corporation, All rights reserved. RMAN Backups.
Chapter 9 Scripting RMAN. Background Authors felt that scripting was a topic not covered well Authors wanted to cover both Unix/Linux and Windows environments.
Backup & Recovery Backup and Recovery Strategies on Windows Server 2003.
16 Copyright © 2007, Oracle. All rights reserved. Performing Database Recovery.
11g(R1/R2) Data guard Enhancements Suresh Gandhi
15 Copyright © 2007, Oracle. All rights reserved. Performing Database Backups.
9 Copyright © 2004, Oracle. All rights reserved. Flashback Database.
17 Copyright © Oracle Corporation, All rights reserved. Recovery Catalog Creation and Maintenance.
15 Copyright © Oracle Corporation, All rights reserved. RMAN Incomplete Recovery.
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
3 Copyright © 2006, Oracle. All rights reserved. Using Recovery Manager.
10 Copyright © Oracle Corporation, All rights reserved. User-Managed Backups.
Overview of Oracle Backup and Recovery Darl Kuhn, Regis University.
2 Copyright © 2007, Oracle. All rights reserved. Configuring for Recoverability.
2 Copyright © 2006, Oracle. All rights reserved. Configuring Recovery Manager.
8 Copyright © 2007, Oracle. All rights reserved. Using RMAN to Duplicate a Database.
3 Copyright © 2007, Oracle. All rights reserved. Using the RMAN Recovery Catalog.
10 Copyright © 2007, Oracle. All rights reserved. Using RMAN Enhancements.
9 Copyright © 2004, Oracle. All rights reserved. Incomplete Recovery.
What is Flashback? Technology that allows you to revert the database to a point in time in the past Several versions of flashback available Different types.
RMAN Maintenance.
Sharing experience on RMAN backups ...
RMAN Maintenance.
Configuring Recovery Manager
Duplicating a Database
Configuring Backup Settings
RAC Backup and Recovery Lab
Performing Database Recovery
Presentation transcript:

The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009

Who am I Maxym Kharchenko, maxym@softcomputer.com a Scorpio … Used to be database internals developer Anyone else heard about: dbVista/Raima/Birdstep/RDM? Have known RMAN since release 8 … closely … ORACLE Certified Master … RMAN was a big part of the exam … shh …

What is it that DBA does ? DBA is someone, who … Keeps the database running … “If your program doesn’t stop producing 10 Gb of archived logs every minute, the system will die in 30 minutes … Just FYI …” … Reasonably fast … “You might think of using WHERE clause in that SQL” … Protects the data … “How many tables did you say your script drop by mistake?” … and keeps it reasonably secure “Sorry, the CEO asked NOT to make his salary world viewable” … Etc etc etc

Recover that data OR die! All DBA responsibilities are important But NONE is as important as … Be able to recover data when necessary ! People might (reasonably) tolerate: System slowness Lack of security Even downtime … But … if you lose production data and CANNOT recover it  you are really, really screwed ! Nobody will care about the reasons One strike and you are out!

ORACLE Backup and Recovery are NOT for the average Joe … Let’s face it – ORACLE backups and recoveries are complex … Making a mistake is easy … if you do NOT understand what you are doing … … and sometimes even if you do … Successful database recovery test means: A guaranteed future recovery ? -- Backup data files Get tbs list/exclude not needed FOR i IN ‘all tablespaces’ DO ALTER tablespace $I BEGIN BACKUP; Get the list of tbs files Copy tbs files ALTER TABLESPACE $I END BACKUP; DONE -- Backup archived logs Get the list of ARC destinations Copy archived logs Problems: Control file is not backed up (minor) There is no check whether the files were copied successfully, are recoverable etc (not so minor) Last archived log is NOT backed up (major!) How to perform a ‘disaster’ recovery Backup Backup Backup 1 2 3 4 5 6 7 8 9 10 11 12 13

Why DBAs make mistakes (with backups) ? There are 2 major reasons: Junior DBAs  the problem is complexity You need to know a lot and experience a lot Some things will only come with experience It is EASY to make a mistake if you don’t know enough … Senior DBAs  the problem is that the process is too mundane Repeating the same 40 operations over and over is boring People tend to optimize the work and skip the unnecessary steps Documentation is often ignored It is even EASIER to make a mistake if you know too much …

Coming of ‘R-man’ To recover the data in all cases … guaranteed, you need to: Know it all Remember everything The (sad) conclusion is: No human will be able to do it … That is why, we need a ROBOT

The WHAT of RMAN

RMAN Makes Things Simple 1 ALTER DATABASE BEGIN BACKUP; Get the list of database files (optional) Exclude read only/unneeded Copy database files Check that copy is successful ALTER DATABASE END BACKUP; ALTER SYSTEM SWITCH ARCHIVE LOG CURRENT; Get the list of ARC destinations Copy archived logs ALTER DATABASE BACKUP CONTROLFILE TO …; Copy controlfile Copy parameter/spfile/password file Simple basic commands Scripted complex commands backup full database plus archivelog;

2 RMAN is a Detail Junkie EXECUTES: Every single step in the procedure … … Including implied (‘switch that log’) … REMEMBERS: What backups to keep, remove … Special cases (i.e. KEEP FOREVER) KEEPS TRACK AND VALIDATES: Is my data recoverable from backups ? Are my backups ‘good’ ? But also execution logs, reports, lists ADVISES AND MAKES DECISIONS: What to backup ? How to recover ?

RMAN has Advanced Tools 3 Incremental Backups Compressed Backups Encrypted Backups Block Recovery Backup Flow Control Etc …

RMAN Manages Binary Metadata 4 Create ‘test’ copy of DB excluding historical data DB (“Data”) DB Copy Backup Repository (”Metadata”) Create logical standby database Standby DB Copy full database … A part of a database … A bunch of tablespaces Make a copy into a standby Latest data … as of any point in the past within the recovery window Transport tablespace online or plug it back into the target database as TSPITR Create a “pluggable” copy of tbs “Lab_main” As of 1 am yesterday Lab_main TBS

The HOW of RMAN

RMAN configuration in a nutshell Recovery Catalog Auxiliary Database AUX Output location Auxiliary Channels RMAN Backup Repository RMAN is a client program Target Database AND THEN Channels

RMAN backup – Data Copies RMAN Backup as copy Recovery from copy A A A A B B B B Cataloging external copy Upsides: Fast backup and recovery Downsides: 1. Lots of disk space 2. Not too flexible 3. RMAN – Can only be disk based Copy switch A A A B B B

RMAN backup – Backupsets Backup as backupset Backups can be smaller: Incremental, Compressed (some) Backups can be faster: Incremental with B.C.T. (some) Recoveries can be faster: Incremental vs. ARC (some) Backup operations can be optimized Zero block, UNDO optimization System can be less affected Native RMAN, MINIMIZE LOAD Can backup directly to “tape” B3 A1 A3 A2 A1 A3 B2 B1 B3 B1 A2 B2 Recovery from backupset NULL compression (up until 9i) – Do NOT backup non-formatted blocks above HWM Unused block compression (10g R2) – Do NOT backup unused blocks below HWM Undo optimization 11g – Do NOT backup UNDO that is NOT needed for recovery (i.e. already committed transacitons) B3 A1 A3 A2 A1 A3 B2 B1 B3 B1 A2 B2 Full backup and recovery will be slower

+ = How to be Incremental Full Incremental cumulative Incremental Sunday Monday Tuesday Wednesday Thursday 10 5 Incremental cumulative Sunday (level 0) Mon (1c) Tue (1c) Thu (1c) Wed (1c) 13 11 7 Incremental Sunday (level 0) Mon (1) Tue (1) Wed (1) Thu (1) 15 11 8 Incrementally updated Sunday (copy/level 0) Mon (1) + Monday (copy/level 0) = Tue (1) Tuesday (copy/level 0) 12 6 Notice that the time of backupset backup only increases IU is the combination of backupset level 1 backup and copy recovery

Speeding Up Incremental Backups Incremental backup - Regular 1 2 3 4 5 6 7 8 9 10 11 12 Backup Repository Datafile 5 Incremental backup – with block change tracking 1 2 3 4 5 6 7 8 9 10 11 12 Backup Repository Datafile 5 B.C.T log

RMAN – Making a Backup RMAN> run { allocate channel ch1 type sbt parms 'ENV=(TDPO_OPTFILE=/opt/tsm/tdpo.opt)' rate=100M allocate channel ch2 type sbt parms 'ENV=(TDPO_OPTFILE=/opt/tsm/tdpo.opt)' rate=100M; backup incremental level 0 database format '%d_s%s_p%p_%T.bkpdf'; backup archivelog all format '%d_s%s_p%p_%T.bkpal'; delete noprompt archivelog all until time "sysdate-2/24"; backup current controlfile format '%d_s%s_p%p_%T.bkpcf'; release channel ch1; release channel ch2; } RMAN> backup incremental level 0 database plus archivelog;

RMAN – The Beauty of Stored Parameters RMAN> show all; CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS; CONFIGURE BACKUP OPTIMIZATION ON; CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE'; CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO 'autocf_%d_%F'; CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 2 BACKUP TYPE TO BACKUPSET; CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'ENV=(TDPO_OPTFILE=/opt/tsm/tdpo.opt)' FORMAT '%d_s%s_p%p_%T.bkpset'; CONFIGURE CHANNEL 1 TYPE 'SBT_TAPE' RATE 100M; CONFIGURE CHANNEL 2 TYPE 'SBT_TAPE' RATE 100M;

Disk or Tape ? RMAN> backup device type DISK full database plus archivelog; RMAN> backup device type SBT full database plus archivelog; Sunday: RMAN> backup device type SBT incremental level 0 database plus archivelog; Monday: RMAN> backup device type DISK incremental level 1 database; RMAN> backup device type SBT archivelog all; Gotcha for IU backups RMAN> backup incremental level 0 database plus archivelog; RMAN> backup recovery area;

RMAN - Recovering Your Data set dbid 2226857552; startup force nomount restore spfile from autobackup; shutdown immediate startup nomount restore controlfile from autobackup; alter database mount; # (optional): catalog start with '…'; # Find latest available SCN, i.e. from v$archived_log restore database until scn 1234567; recover database until scn 1234567; alter database open resetlogs; Restore and recover RMAN> restore spfile from '/ora05/flash/DEV10/autobackup/ 2008_12_21/o1_mf_s_674071460_4nxlvpdk_.bkp'; RMAN> restore controlfile from autobackup db_recovery_file_dest='/ora05/flash' db_name='orcl';

Block Recovery # First of all - find which blocks are corrupted 1. Alert log 2. RMAN> backup validate check logical datafile N; SQL> SELECT * FROM v$database_block_corruption; 3. RMAN> backup check logical datafile N; 4. UNIX> dbv data_file # Then, repair it like this: RMAN> blockrecover datafile X block Y; # Or, like this: RMAN> blockrecover corruption list;

RMAN – How to Maintain Backups Remove/Create Flash Recovery Area Repository Repository Database Database Recovery Window Flash Recovery Area + TDP Repository Repository Database Database

FRA Sizing Considerations Remove/Create Repository Database Flash Recovery Area FRA is a primary backup, collection of ‘recent backups’ located close to a database Huge difference whether TDP is used or not. Repository Database

FRA – How Large ? FRA size depends on: FRA Components FRA size depends on: Size and volatility of FRA components Backup Retention Backup Method Level 0 Level 1 Flashback Archivelog FRA: How backup method can affect size Database FRA: Disk FRA: Disk THEN Tape FRA: Compressed backups FRA: Level 0 - TAPE, Level 1 - DISK

Is your database recoverable ? RMAN> list backup of database summary; RMAN> list backup of database by file; RMAN> report need backup database; RMAN> report unrecoverable database; RMAN> restore database preview; RMAN> recover database test; RMAN> crosscheck backup; RMAN> crosscheck copy; Catch: crosscheck with SBT device RMAN> backup incremental level 0 check logical database; SQL> SELECT * FROM v$database_block_corruption; RMAN> restore database validate check logical; SQL> SELECT * FROM v$database_block_corruption;

RMAN - Managing Your Binary Metadata duplicate target database to testdb skip tablespace tbs1 until time ‘sysdate-1’ logfile group 1 (‘/testdb/redo01.arc’) size 100M reuse, group 2 (‘/testdb/redo01.arc’) size 100M reuse; DB Aux DB (“Copy”) Duplicate Backup Repository (”Metadata”) Aux DB Transport transport tablespace lab tablespace destination '/tbs' auxiliary destination '/aux' until time 'sysdate-1'; Gotchas: 1. Time has to exist 2. Connect triggers and default tablespaces 3. TSPITR without recovery catalog – only once TTS TBS Aux DB TSPITR recover tablespace users, tools auxiliary destination '/aux' until time 'sysdate-1'; TTS TBS

RMAN Extras Database command console ASM data manager Datafile platform conversion Script processor A few features worth mentioning: Load is done on the server, which means client can disconnect while load continues Load jobs can be suspended and resumed on demand It is much easier to set limits on data load, I.e. ‘do not load indexes’ You can transfer data without creating intermediate dump file

The WHY of RMAN

Why use RMAN? RMAN utility: Can simplify many backup and recovery operations Performing them faster and, in many cases, better than ‘regular’ backup tools Let’s you do some cool things with ORACLE Helps avoid mistakes But most importantly, RMAN allows a DBA to be LAZY (in a good way) And spend your valuable time on other cool things in ORACLE Because, let’s admit it … backups ARE … … boring … ;-) FLASHBACK ANY TABLE privilege is required to flashback tables

Any Questions ?