The Oracle Recovery Manager (RMAN)

Slides:



Advertisements
Similar presentations
LA Oracle Users Group Succeeding with RMAN Tim Gorman Principal SageLogix, Inc.
Advertisements

INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Backup and Recovery Copyright System Managers LLC 2008 all rights reserved.
Introduction to Oracle Administration Glen Parker University of South Florida BbWorld 07 Boston, MA.
ITEC474 Control File Maintenance
CERN - IT Department CH-1211 Genève 23 Switzerland t Backup & Recovery with RMAN LCG 3D Workshop, Bologna June 12 th, 2007 Jacek Wojcieszuk.
DBA 101 Bootcamp New DBA Series Backup 101 April 12, 20111Paper #352.
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
INTRODUCTION TO ORACLE Lynnwood Brown President System Managers LLC Data Loading & Backup And Recovery Lecture 5 Copyright System Managers LLC 2003 all.
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.
Harvard University Oracle Database Administration Session 11 Database Recovery.
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.
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.
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.
13 Copyright © Oracle Corporation, All rights reserved. RMAN Complete Recovery.
PPOUG, 05-OCT-01 Agenda RMAN Architecture Why Use RMAN? Implementation Decisions RMAN Oracle9i New Features.
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.
Using Recovery Manager ® Connie Dialeris, Server Technologies Last Updated: 8 th July 1997.
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.
15 Copyright © 2005, Oracle. All rights reserved. Performing Database Backups.
Backup & Recovery Backup and Recovery Strategies on Windows Server 2003.
RMAN: Your New Best Friend for Backup and Recovery Ruth Gramolini ORACLE DBA Vermont Department of Taxes.
15 Copyright © 2007, Oracle. All rights reserved. Performing Database Backups.
A Guide to Oracle9i1 Database Instance startup and shutdown.
17 Copyright © Oracle Corporation, All rights reserved. Recovery Catalog Creation and Maintenance.
15 Copyright © Oracle Corporation, All rights reserved. RMAN Incomplete Recovery.
IT Database Administration Section 09. Backup and Recovery Backup: The available options Full Consistent (cold) Backup Database shutdown, all files.
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.
6 Copyright © 2007, Oracle. All rights reserved. Performing User-Managed Backup and Recovery.
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.
19 Copyright © 2004, Oracle. All rights reserved. Database Backups.
Control File Information The database name The timestamp of database creation The names and locations of associated datafiles and redo log files Tablespace.
RMAN Maintenance.
Sharing experience on RMAN backups ...
RMAN Maintenance.
Recovery Catalog Creation and Maintenance
Configuring Recovery Manager
Duplicating a Database
Using the RMAN Recovery Catalog
RAC Backup and Recovery Lab
Performing Database Recovery
Presentation transcript:

The Oracle Recovery Manager (RMAN)

Objectives At the end of this module the student will understand the following tasks and concepts. Understand the basic functionality of the Oracle Recovery Manager. Understand how to perform basic backup and recovery operations using RMAN.

Intro to RMAN Oracle Recovery Manager Backup and Restore Client Complete or Partial Backups Full or Incremental Backups Detects corrupted blocks and reports them Automatically tracks new tablespaces and datafiles Does unused block compression Employs binary compression for disk backups Can test backups without restoring them RMAN is a client side backup and restore utility that works in conjunction with the Oracle database engine and performs a number of different types of backups including the following: Complete backups backup all of the data in the database. Partial backups are used to only backup a part of the database such as a tablespace or just a datafile. A full backup saves the entire contents of the object being backed up. An incremental backup only backs up the data that has changed since the last backup. Can compress the data in order to save space on disk.

The RMAN Recovery Catalog Used to store repository records Stores RMAN scripts Can be stored in its own tablespace on a separate server Can use the controlfiles if a recovery catalog database is not available

Recovery Catalog Options RMAN defaults to the NOCATALOG connect option Uses the target database controlfile for storing recovery metadata Useful for simple backup and recovery options for a single database With the CATALOG connect option, a Recovery Catalog may be used A Recover Catalog is a centralized recovery metadata repository Useful for simple to complex backup and recovery options for multiple databases on multiple servers

Issues with Using Controlfiles for RMAN Metadata RMAN records will eventually “age out” of the control file and the records will be reused Use the CONTROLFILE_RECORD_KEEP_TIME init.ora parameter to control the retention period (default is 7 days) Rebuilding the control file will result in RMAN record loss The command “alter database backup controlfile to trace;” does not backup RMAN records Use “alter database backup controlfile to ‘<location>’;” instead to create a binary controlfile copy that maintains RMAN records

Why Use a Recovery Catalog? Offers a single enterprise-wide repository for maximum flexibility Allows the use of stored RMAN scripts Allows you to restore a database from a previous incarnation (period before RESETLOGS) Easier to handle the loss of a control file Allows creation of reports on the target database at previous points in time Maintains consistent RMAN channel configuration default values

Invoking RMAN With a recovery catalog Using the controlfile Example %ORACLE_HOME%\bin\rman TARGET / CATALOG user/passwd@service Example %ORACLE_HOME%\bin\rman TARGET / CATALOG sys/ora123@orcl Using the controlfile %ORACLE_HOME%\bin\rman TARGET SYS/passwd@service %ORACLE_HOME%\bin\rman TARGET SYS/ora123@orcl

Creating a Recovery Catalog Create a Recovery Catalog Tablespace CREATE TABLESPACE "RECOV_CAT" LOGGING DATAFILE ‘C:\oracle\product\10.2.0\oradata\orcl\ RECOV_CAT.dbf' SIZE 100M

Creating a Recovery Catalog Create the rman schema CREATE USER rman IDENTIFIED BY cat TEMPORARY TABLESPACE temp DEFAULT TABLESPACE recov_cat QUOTA UNLIMITED ON recov_cat; Grant RECOVERY_CATALOG to the rman schema rman GRANT RECOVERY_CATALOG_OWNER TO rman;

Creating a Recovery Catalog Connect to Oracle with either SQLPlus or RMAN sqlplus rman/cat@orcl %ORACLE_HOME%\bin\rman TARGET / CATALOG rman/cat@orcl Run the CREATE CATALOG script to create the recovery catalog RMAN> CREATE CATALOG The recovery catalog can be created from within rman itself. Use the CREATE CATALOG command. C:\%ORACLE_HOME%\bin\rman TARGET / CATALOG rman/cat@orcl Recovery Manager: Release 10.1.0.2.0 - Production Copyright (c) 1995, 2004, Oracle. All rights reserved. connected to target database: ORCL (DBID=1057038121) connected to recovery catalog database recovery catalog is not installed RMAN> CREATE CATALOG; recovery catalog created You can also use the CREATE CATALOG command with the TABLESPACE qualifier. RMAN> CREATE CATALOG TABLESPACE 'RECOV_CAT'; RMAN>

Validating the Recovery Catalog Connect into the Oracle database as rman and select from user_tables sqlplus rman/cat@orcl SELECT table_name from user_tables Connect into RMAN $ORACLE_HOME/bin/rman TARGET / CATALOG rman/cat@orcl Note “connected to recovery catalog database” C:\ sqlplus rman/cat@orcl SQL*Plus: Release 10.1.0.2.0 - Production on Sun Jun 20 08:55:54 2004 Copyright (c) 1982, 2004, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production With the Partitioning, OLAP and Data Mining options SQL> SELECT table_name FROM user_tables; TABLE_NAME ------------------------------ RCVER FB TSATT TS CKP DBINC CONF NODE DB RSR XAL C:\ $ORACLE_HOME/bin/rman TARGET / CATALOG rman/cat@orcl Recovery Manager: Release 10.1.0.2.0 - Production Copyright (c) 1995, 2004, Oracle. All rights reserved. connected to target database: ORCL (DBID=1057038121) connected to recovery catalog database RMAN>

Connecting with RMAN Connect into the target database using SYS Connect into the recovery catalog using rman Connect into both the target database and recovery catalog using both %ORACLE_HOME%\bin\rman TARGET sys/ora123@orcl CATALOG rman/cat@orcl C:\ $ORACLE_HOME\bin\rman TARGET sys/ora123@orcl CATALOG rman/cat@orcl Recovery Manager: Release 10.1.0.2.0 - Production Copyright (c) 1995, 2004, Oracle. All rights reserved. connected to target database: ORCL (DBID=1057038121) connected to recovery catalog database RMAN>

Registering a Target Database in the Recovery Catalog Connect into RMAN Run register database Validate with report schema RMAN> register database; database registered in recovery catalog starting full resync of recovery catalog full resync complete RMAN> report schema; Report of database schema File K-bytes Tablespace RB segs Datafile Name ---- ---------- -------------------- ------- ------------------- 1 450560 SYSTEM YES C:\oracle\product\10.1.0\oradata\orcl\system01.dbf 2 25600 UNDOTBS1 YES C:\\oracle\product\10.1.0\oradata\orcl\undotbs01.dbf 3 215040 SYSAUX NO C:\oracle\product\10.1.0\oradata\orcl\sysaux01.dbf 4 5120 USERS NO C:\oracle\product\10.1.0\oradata\orcl\users01.dbf 5 153600 EXAMPLE NO C:\\oracle\product\10.1.0\oradata\orcl\example01.dbf 6 102400 RECOV_CAT NO C:\oracle\product\10.1.0\oradata\orcl\RECOV_CAT.dbf RMAN>

RMAN Information The show command displays information about the RMAN configuration show all – displays everything The list command displays information about previous backups list backup – displays a list of backups The report commands creates RMAN reports on operations RMAN> show all; RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE MAXSETSIZE TO UNLIMITED; # default CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘C:\oracle\product\10.1.0\db_1\dbs\snapcf_orcl.f'; # default

RMAN Configuration Configure Devices Configure Channels sbt device is the media manager Veritas Legato Local disk can be used Configure Channels Used to perform the backups

Configuring Devices Setup default devices Configure media manager CONFIGURE DEFAULT DEVICE TYPE TO sbt; Configure disk backup CONFIGURE DEFAULT DEVICE TYPE TO DISK; It can also be setup to use compressed savesets CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET;

Configuring Channels Channel is the device path to the backup media With a disk device, this is the path CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘C:\oracle\backup\ora_df%t_s%s_s%p';

Configuring Controlfile Backups Controlfiles can be set to auto backup whenever a backup occurs by setting autobackup on. CONFIGURE CONTROLFILE AUTOBACKUP on;

Performing Backups There are a number of different ways to do backups BACKUP DATABASE BACKUP TABLESPACE ‘USERS’; BACKUP INCREMENTAL LEVEL 0 DATABASE; BACKUP CURRENT CONTROLFILE; C:\ %ORACLE_HOME%\bin\rman TARGET sys/ora123@orcl CATALOG rman/cat@orcl Recovery Manager: Release 10.1.0.2.0 - Production Copyright (c) 1995, 2004, Oracle. All rights reserved. connected to target database: ORCL (DBID=1057038121) connected to recovery catalog database RMAN> backup database; Starting backup at 20-JUN-04 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=256 devtype=DISK channel ORA_DISK_1: starting compressed full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=C:\oracle\product\10.1.0\oradata\orcl\system01.dbf input datafile fno=00003 name=C:\oracle\product\10.1.0\oradata\orcl\sysaux01.dbf input datafile fno=00005 name=C:\oracle\product\10.1.0\oradata\orcl\example01.dbf input datafile fno=00006 name=C:\oracle\product\10.1.0\oradata\orcl\RECOV_CAT.dbf input datafile fno=00002 name=C:\oracle\product\10.1.0\oradata\orcl\undotbs01.dbf input datafile fno=00004 name=C:\oracle\product\10.1.0\oradata\orcl\users01.dbf channel ORA_DISK_1: starting piece 1 at 20-JUN-04 channel ORA_DISK_1: finished piece 1 at 20-JUN-04 piece handle=C:\oracle\backup\ora_df529320857_s3_s1 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:02:35 including current controlfile in backupset including current SPFILE in backupset piece handle=C:\oracle\backup\ora_df529321013_s4_s1 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04 Finished backup at 20-JUN-04 RMAN> MAN> BACKUP TABLESPACE 'USERS'; using channel ORA_DISK_1 piece handle=C:\oracle\backup\ora_df529321875_s5_s1 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

RAC Backups Backup from one node Remember to backup all archive log threads (representing each node) – all should be visible from any node

Example RMAN Offline Backup Script Here is an example for a disk-based online backup: set CMDFILE=C:\TEMP\rman_cmdfile.bat echo shutdown immediate; >> %CMDFILE% echo startup mount; >> %CMDFILE% echo allocate channel c1 device type disk format ‘C:\oracle\admin\mydb\backup\mydb_U%’; >> %CMDFILE% echo allocate channel c2 device type disk format ‘E:\oracle\admin\mydb\backup\mydb_U%’; >> %CMDFILE% echo backup database; >> %CMDFILE% echo alter database open, >> %CMDFILE% echo exit; >> %CMDFILE% %ORACLE_HOME%\bin\rman target mydb/password cmdfile=%CMDFILE%

Example RMAN Online Backup Script Here is an example for a disk-based online backup: set CMDFILE=C:\TEMP\rman_cmdfile.bat echo allocate channel c1 device type disk format ‘C:\oracle\admin\mydb\backup\mydb_U %’; >> %CMDFILE% echo allocate channel c2 device type disk format ‘E:\oracle\admin\mydb\backup\mydb_U %’; >> %CMDFILE% echo configure controlfile autobackup on; >> %CMDFILE% echo backup database plus archivelog; >> %CMDFILE% echo exit; >> %CMDFILE% %ORACLE_HOME%\bin\rman target mydb/password cmdfile=%CMDFILE%

Performing Restores First preview the restore RESTORE DATABASE PREVIEW; RESTORE TABLESPACE users PREVIEW; RESTORE DATAFILE 3 PREVIEW; Preview allows you to see a report before the restore takes place RMAN> restore database preview; Starting restore at 20-JUN-04 using channel ORA_DISK_1 List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 52 Full 525M DISK 00:02:25 20-JUN-04 BP Key: 56 Status: AVAILABLE Compressed: NO Tag: TAG20040620T093416 Piece Name: C:\oracle\backup\ora_df529320857_s3_s1 List of Datafiles in backup set 52 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 Full 422738 20-JUN-04 C:\oracle\product\10.1.0\oradata\orcl\system01.dbf 2 Full 422738 20-JUN-04 C:\oracle\product\10.1.0\oradata\orcl\undotbs01.dbf 3 Full 422738 20-JUN-04 C:\oracle\product\10.1.0\oradata\orcl\sysaux01.dbf 5 Full 422738 20-JUN-04 C:\oracle\product\10.1.0\oradata\orcl\example01.dbf 6 Full 422738 20-JUN-04 C:\oracle\product\10.1.0\oradata\orcl\RECOV_CAT.dbf 70 Full 1M DISK 00:00:01 20-JUN-04 BP Key: 73 Status: AVAILABLE Compressed: NO Tag: TAG20040620T095115 Piece Name: C:\oracle\backup\ora_df529321875_s5_s1 List of Datafiles in backup set 70 4 Full 423358 20-JUN-04 C:\oracle\product\10.1.0\oradata\orcl\users01.dbf Finished restore at 20-JUN-04 RMAN> restore database preview summary; List of Backups =============== Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag ------- -- -- - ----------- --------------- ------- ------- ---------- --- 52 B F A DISK 20-JUN-04 1 1 NO TAG20040620T093416 70 B F A DISK 20-JUN-04 1 1 NO TAG20040620T095115 RMAN>

Performing Restores Performing the Restore RESTORE DATABASE; RESTORE TABLESPACE users; RESTORE DATAFILE 3;

Validating Backups Backups can be validated with restore validate RESTORE DATABASE VALIDATE; RESTORE CONTROLFILE VALIDATE; RESTORE TABLESPACE users VALIDATE; RESTORE ARCHIVELOG ALL VALIDATE; RMAN> restore database validate; Starting restore at 20-JUN-04 using channel ORA_DISK_1 channel ORA_DISK_1: starting validation of datafile backupset channel ORA_DISK_1: restored backup piece 1 piece handle=C:\oracle\backup\ora_df529320857_s3_s1 tag=TAG20040620T093416 channel ORA_DISK_1: validation complete piece handle=C:\oracle\backup\ora_df529321875_s5_s1 tag=TAG20040620T095115 Finished restore at 20-JUN-04 RMAN>

Example of Complete Recovery Using an RMAN Online Backup Here is an example recovery from an online backup (followed by an immediate backup): Set ORACLE_SID=mydb %ORACLE_HOME%\bin\rman target mydb/password Rman> startup nomount; Rman> set DBID = <enter your DBID>; Rman> restore spfile from autobackup; Rman> restore controlfile from autobackup; Rman> alter database mount; Rman> restore database; Rman> recover database; Rman> alter database open resetlogs; Rman> shutdown immediate; Rman> startup mount; Rman> backup database; Rman> quit

Review Name one disadvantage of using a Control File to store RMAN meta-data If you have a recovery catalog, describe how you connect to RMAN and the target database What is the device name used for a media manager? What keywords are used to designate devices to be used for backups?

Summary RMAN Concepts RMAN Functionality