RMAN Restore and Recovery

Slides:



Advertisements
Similar presentations
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Backup and Recovery Copyright System Managers LLC 2008 all rights reserved.
Advertisements

ITEC474 Control File Maintenance
Backup and recovery Basics of Backup and restoration Types of recovery Defining strategy Starting up and shutting down 80/20 rule SLA’s.
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
Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.
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.
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.
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.
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.
Oracle9i Database Administrator: Implementation and Administration
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.
Introduction to Oracle Backup and Recovery
Using RMAN to Perform Recovery
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.
20 Copyright © 2004, Oracle. All rights reserved. Database Recovery.
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.
CHAPTER 2 Implementing a Database. Introduction to Creating Databases After you’ve installed the Oracle software, the next logical step is to create a.
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.
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.
9 Copyright © 2004, Oracle. All rights reserved. Flashback Database.
Chapter 8Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 8 Complete Recovery with Recovery Manager.
6 Copyright © 2006, Oracle. All rights reserved. Flashback.
15 Copyright © Oracle Corporation, All rights reserved. RMAN Incomplete Recovery.
Week 3 Lecture 1 The Redo Log Files and Diagnostic Files.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
10 Copyright © Oracle Corporation, All rights reserved. User-Managed Backups.
Overview of Oracle Backup and Recovery Darl Kuhn, Regis University.
12 Copyright © Oracle Corporation, All rights reserved. User-Managed Complete Recovery.
18 Copyright © 2004, Oracle. All rights reserved. Backup and Recovery Concepts.
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.
16 Copyright © 2005, Oracle. All rights reserved. Performing Database Recovery.
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.
18 Copyright © 2004, Oracle. All rights reserved. Recovery Concepts.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
9 Copyright © 2004, Oracle. All rights reserved. Incomplete Recovery.
14 Copyright © 2007, Oracle. All rights reserved. Backup and Recovery Concepts.
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.
23 Copyright © 2004, Oracle. All rights reserved. Preferring the Past: Flashback.
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.
RMAN Maintenance.
Recovery Catalog Creation and Maintenance
Oracle9i Database Administrator: Implementation and Administration
Performing Tablespace Point-in-Time Recovery
Database Recovery.
Performing Tablespace Point-in-Time Recovery
Duplicating a Database
Performing User-Managed Backup and Recovery
Performing Database Recovery
Chapter 5 The Redo Log Files.
Presentation transcript:

RMAN Restore and Recovery Chapter 19 RMAN Restore and Recovery

Introduction to RMAN Restore and Recovery Prior two chapters prepares you to be able to perform perhaps the most critical DBA tasks: restore and recovery of a damaged mission critical database. Good news is that RMAN automates much of the restore and recovery process.

Determining Media Recovery Required Media recovery error is thrown when Oracle can’t read or write to a critical database file: ORA-01157: cannot identify/lock data file 1 - see DBWR trace file ORA-01110: data file 1: '/u02/oracle/oradata/E64208/system01.dbf'

Performing Media Recovery Determine what files need to be restored. Depending on the damage, set your database mode to nomount, mount, or open. Use the RESTORE command to retrieve files from RMAN backups. Use the RECOVER command for datafiles requiring recovery. Open your database.

Using Data Recovery Advisor Listing failures: RMAN> list failure; Suggesting corrective action: RMAN> advise failure 665; Running commands to repair failures: RMAN> repair failure;

Using RMAN to Shutdown/Startup You can use RMAN to shutdown and startup your database. Many times during a restore and recovery scenario, it’s easier to use RMAN top stop/start your database. RMAN> shutdown immediate; RMAN> ..... RMAN> startup;

Previewing Backups Used for Recovery Use the RESTORE...PREVIEW command to list the backups and archive redo log files that RMAN will use to restore and recover database datafiles. The RESTORE...PREVIEW does not actually restore any files. RMAN> restore database preview; RMAN> restore database preview summary;

Validating Backup Files Before Restoring Instruct RMAN to verify that the files exist and check the file headers, the use the RESTORE...VALIDATE HEADER command like so:   RMAN> restore database validate header; Further instruct RMAN to verify the integrity of blocks within backup files required to restore the database datafiles via the RESTORE...VALIDATE command: RMAN> restore database validate;

Testing Media Recovery Instruct RMAN to verify the recovery process via the RECOVER...TEST command: RMAN> connect target / RMAN> startup mount; RMAN> restore tablespace users; RMAN> recover tablespace users test;

Restoring Entire Database Using Current Control File This example assumes that you haven’t lost the control files as part of the media failure: RMAN> connect target / RMAN> startup mount; RMAN> restore database; RMAN> recover database; RMAN> alter database open;

Restoring Entire Database Using Backup Control File This example assumes that you have lost the current control files as part of the media failure: RMAN> connect target / RMAN> startup nomount; RMAN> restore controlfile from autobackup; RMAN> alter database mount; RMAN> restore database; RMAN> recover database; RMAN> alter database open resetlogs;

Restoring Tablespace While Database is Open Do this is you have an isolated tablespace that needs its datafiles to be restored and recovered: RMAN> connect target / RMAN> sql 'alter tablespace users offline immediate'; RMAN> restore tablespace users; RMAN> recover tablespace users; RMAN> sql 'alter tablespace users online';

Restoring Tablespace While Database in Mount Mode You can also restore tablespace datafiles while the database is in mount mode: RMAN> connect target / RMAN> shutdown immediate; RMAN> startup mount; RMAN> restore tablespace system; RMAN> recover tablespace system; RMAN> alter database open;

Restoring Read-Only Tablespaces RMAN will restore read-only tablespaces along with the rest of the database when you issue a RESTORE DATABASE command: RMAN> restore database; This is different in versions prior to 11g where you had to specify that read-only tablespaces were restored.

Restoring Temporary Tablespaces RMAN doesn’t backup temporary tablespaces. Starting with Oracle Database 10g, you don’t have to restore or re-create missing locally managed temporary tablespace tempfiles. When you open your database for use, Oracle automatically detects and re-creates locally managed temporary tablespace tempfiles.

Restoring Datafile While Database Is Open Use the RESTORE DATAFILE and RECOVER DATAFILE commands to restore and recover at the datafile level. When your database is open, you’re required to take offline any datafiles you’re attempting to restore and recover. RMAN> sql 'alter database datafile 32, 33 offline'; RMAN> restore datafile 32, 33; RMAN> recover datafile 32, 33; RMAN> sql 'alter database datafile 32, 33 online';

Restoring Datafile While Database Is Not Open You can only restore the system datafile while the database is not open: RMAN> connect target / RMAN> shutdown abort; RMAN> startup mount; RMAN> restore datafile 1; RMAN> recover datafile 1; RMAN> alter database open;

Restoring Datafiles to Non-Default Locations Sometimes a failure will occur that renders the disks associated with a mount point inoperable. In situations like this, you will need to restore and recover the datafiles to a different location from where they originally resided. RMAN> connect target / RMAN> startup mount; RMAN> run{ 2> set newname for datafile 32 to '/ora02/dbfile/O11R2/mvdata01.dbf'; 3> set newname for datafile 33 to '/ora02/dbfile/O11R2/mvindex01.dbf'; 4> restore datafile 32, 33; 5> switch datafile all; # Updates repository with new datafile location. 6> recover datafile 32, 33; 7> alter database open; 8> }

Performing Block Level Recovery Block-level corruption is rare and is usually caused by some sort of I/O error. However, if you do have an isolated corrupt block within a large datafile, it’s nice to have the option of performing a block-level recovery. Block-level recovery is useful when a small number of blocks are corrupt within a datafile. Block recovery is not appropriate if the entire datafile needs media recovery. RMAN> recover datafile 5 block 20;

Restoring Archive Redo Logs to the Default Location RMAN will automatically restore any archived redo log files that it needs during a recovery process. You normally don't need to manually restore archived redo log files. However, if you need to, you can restore all via: RMAN> restore archivelog all;

Restoring Archive Redo Logs to the Non-Default Location Sometimes the default location may not be available (due to media failure) or it may not have enough room. Use SET ARCHIVELOG DESTINATION RMAN> run{ 2> set archivelog destination to '/ora01/archtemp'; 3> restore archivelog from sequence 68 force; 4> }

Restoring the Spfile RMAN allows you to restore the spfile You may have one of the following scenarios: You accidentally set a value in the spfile that keeps your instance from starting. You accidentally deleted the spfile. You are required to see what it looked like at some time in the past. If you are using a recovery catalog, it’s a fairly simple procedure to restore the spfile: RMAN> connect target / RMAN> connect catalog rmancat/foo@rcat RMAN> startup nomount; RMAN> restore spfile;

Restoring a Control File Using a Recovery Catalog If you lose all of your control files, then you’ll need to restore one from a backup: RMAN> connect target / RMAN> connect catalog rcat/rcat@recov RMAN> startup nomount; RMAN> list backup of controlfile;

Restoring a Control File Using an Autobackup Restore If you’re using the autobackup of the control file feature, it’s fairly simple to restore a control file: RMAN> connect target / RMAN> startup nomount; RMAN> restore controlfile from autobackup;

Performing Time-Based Recovery Incomplete Recovery Time based is appropriate when you have a specific time in the past you’d like to reset the database to: RMAN> connect target / RMAN> startup mount; RMAN> restore database until time 2> "to_date('04-sep-2010 14:00:00', 'dd-mon-rrrr hh24:mi:ss')"; RMAN> recover database until time RMAN> alter database open resetlogs;

Performing Log Sequenced-Based Recovery Incomplete Recovery Use this type of incomplete recovery when you’re missing an archive log or required online redo log: RMAN> connect target / RMAN> startup mount; RMAN> restore database until sequence 45; RMAN> recover database until sequence 45; RMAN> alter database open resetlogs;

Performing Change/SCN-Based Incomplete Recovery If you know the SCN number to which you’d like to restore to in the past, then use SCN-based incomplete recovery: RMAN> connect target / RMAN> startup mount; RMAN> restore database until scn 95019865425; RMAN> recover database until scn 95019865425; RMAN> alter database open resetlogs;

Restoring to a Restore Point RMAN also allows you to restore back to a restore point: RMAN> connect target / RMAN> startup mount; RMAN> restore database until restore point MY_RP; RMAN> recover database until restore point MY_RP; RMAN> alter database open resetlogs;

Table Level Restore New in Oracle Database 12c, table level restore Allows you to use RMAN to restore a table based on SCN, time, or log sequence number Consider using flashback table to restore a table instead of RMAN table level restore

Flashing Back a Table Flashback to before drop (uses recyclebin) Flashback to prior point in time (uses undo)

Flashback Database Another form of incomplete recovery Often used as a mechanism to set a database back to a prior state Prior to an application upgrade, create a restore point, if the application upgrade goes bad, flashback database to the restore point

Restoring and Recovering to Different Server Create an RMAN backup on the originating database. Copy RMAN backup to the destination server. All steps after this step are performed on the destination database server. Ensure that Oracle is installed. Source the required OS variables. Create an init.ora file for the database to be restored. Create any required directories for datafiles, control files, and dump/trace files. Startup the database in NOMOUNT mode. Restore a control file from the RMAN backup. Startup the database in MOUNT mode. Make the control file aware of the location of the RMAN backups. Rename and restore the datafiles to reflect new directory locations. Recover the database. Set the new location for the online redo logs. Open the database. Add tempfile. Rename the database.

Summary RMAN automates most of the restore and recovery tasks. Very flexible in ways to perform complete and incomplete recovery. Arguably restore and recovery are the most critical skills a DBA can posses.