11 Copyright © 2004, Oracle. All rights reserved. Dealing with Database Corruption.

Slides:



Advertisements
Similar presentations
18 Copyright © Oracle Corporation, All rights reserved. Transporting Data Between Databases.
Advertisements

INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Backup and Recovery Copyright System Managers LLC 2008 all rights reserved.
17 Copyright © 2005, Oracle. All rights reserved. Performing Flashback.
Chapter 14 Handling Online Redo Log Failures. Background RMAN doesn’t back up online redo logs You don’t use RMAN to recover from online redo log failures.
Acknowledgments Byron Bush, Scott S. Hilpert and Lee, JeongKyu
10 Copyright © 2009, Oracle. All rights reserved. Managing Undo Data.
5 Copyright © 2006, Oracle. All rights reserved. Database Recovery.
Database Backup and Recovery
RMAN Restore and Recovery
Backup and Recovery Part 1.
Configuring Recovery Manager
4 Copyright © 2008, Oracle. All rights reserved. Configuring Backup Specifications.
9 Copyright © Oracle Corporation, All rights reserved. Oracle Recovery Manager Overview and Configuration.
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
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
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.
7 Copyright © 2006, Oracle. All rights reserved. Dealing with Database Corruption.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
5 Copyright © 2004, Oracle. All rights reserved. Using Recovery Manager.
5 Copyright © 2008, Oracle. All rights reserved. Using RMAN to Create Backups.
11 Copyright © Oracle Corporation, All rights reserved. RMAN Backups.
11 Copyright © Oracle Corporation, All rights reserved. RMAN Backups.
15 Copyright © 2005, Oracle. All rights reserved. Performing Database Backups.
Preface 1 Introduction Course Objectives 1-2 How DBAs Spend Their Time 1-3 Oracle Database 10g Manageability Goals 1-4 Database Management Challenges 1-5.
Backup & Recovery Backup and Recovery Strategies on Windows Server 2003.
16 Copyright © 2007, Oracle. All rights reserved. Performing Database Recovery.
4 Copyright © 2006, Oracle. All rights reserved. Recovering from Noncritical Losses.
9 Copyright © 2004, Oracle. All rights reserved. Flashback Database.
Copyright © Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
Backup and Recovery Overview Supinfo Oracle Lab. 6.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
6 Copyright © 2006, Oracle. All rights reserved. Flashback.
15 Copyright © Oracle Corporation, All rights reserved. RMAN Incomplete Recovery.
7 Copyright © 2005, Oracle. All rights reserved. Managing Undo Data.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
3 Copyright © 2006, Oracle. All rights reserved. Using Recovery Manager.
10 Copyright © Oracle Corporation, All rights reserved. User-Managed Backups.
Chapter 1Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 1 Backup and Recovery Overview MSCD642 Backup and Recovery.
© 2006 Northgate Information Solutions plc and its associated companies. All rights reserved. Slide 1.
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.
18 Copyright © 2004, Oracle. All rights reserved. Recovery Concepts.
7 Copyright © Oracle Corporation, All rights reserved. Instance and Media Recovery Structures.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
6 Copyright © Oracle Corporation, All rights reserved. Backup and Recovery Overview.
10 Copyright © 2007, Oracle. All rights reserved. Using RMAN Enhancements.
19 Copyright © 2004, Oracle. All rights reserved. Database Backups.
13 Copyright © 2007, Oracle. All rights reserved. Using the Data Recovery Advisor.
20 Copyright © 2006, Oracle. All rights reserved. Best Practices and Operational Considerations.
9 Copyright © 2004, Oracle. All rights reserved. Incomplete Recovery.
14 Copyright © 2007, Oracle. All rights reserved. Backup and Recovery Concepts.
4 Copyright © 2004, Oracle. All rights reserved. Managing the Oracle Instance.
23 Copyright © 2004, Oracle. All rights reserved. Preferring the Past: Flashback.
RMAN Maintenance.
RMAN Maintenance.
Database Administration
Maximum Availability Architecture Enterprise Technology Centre.
Dealing with Database Corruption
Dealing with Database Corruption
Performing Database Recovery
Presentation transcript:

11 Copyright © 2004, Oracle. All rights reserved. Dealing with Database Corruption

11-2 Copyright © 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to: Describe causes of database corruption: –Hardware –Software Detect database corruption using: – ANALYZE – dbverify – DB_BLOCK_CHECKING – DBMS_REPAIR Repair corruptions using RMAN

11-3 Copyright © 2004, Oracle. All rights reserved. What Is Block Corruption? Whenever a block is read or written, a consistency check is performed: –Block version –DBA (data block address) value in cache as compared to the DBA value in the block buffer –Block-checksum, if enabled There are two types of block corruption: –Media corrupt –Soft corrupt

11-4 Copyright © 2004, Oracle. All rights reserved. Block Corruption Symptoms: ORA-1578 ORA-01578: “ORACLE data block corrupted (file # %s, block # %s)” This error is generated when a corrupted data block is found. The error always returns the absolute file number and block number. Check the alert.log file.

11-5 Copyright © 2004, Oracle. All rights reserved. DBVERIFY Utility Only works on data files; redo log files cannot be checked. Checks block consistency. Can be used while the database is open. $ dbv file=/u01/oradata/users01.dbf \ blocksize=8192

11-6 Copyright © 2004, Oracle. All rights reserved. Interpreting DBVERIFY Page number is the block number in the data file. If head and tail do not match, DBVERIFY re-reads the block. If they match, an influx block is reported, otherwise a corruption is signaled. DBVERIFY - Verification complete Total Pages Examined : 640 Total Pages Processed (Data) : 88 Total Pages Failing (Data) : 0 Total Pages Processed (Index): 18 Total Pages Failing (Index): 0... Total Pages Empty : 406 Total Pages Marked Corrupt : 0 Total Pages Influx : 0

11-7 Copyright © 2004, Oracle. All rights reserved.

11-8 Copyright © 2004, Oracle. All rights reserved. The ANALYZE Command Performs a logical block check Does not mark blocks as soft corrupt; only reports them Validates index and table entries SQL> ANALYZE TABLE table_name VALIDATE 2 STRUCTURE CASCADE; SQL> ANALYZE INDEX index_name VALIDATE 2 STRUCTURE;

11-9 Copyright © 2004, Oracle. All rights reserved. Initialization Parameter DB_BLOCK_CHECKING Can be set by using the ALTER SESSION or ALTER SYSTEM DEFERRED command Controls whether the database performs block checking for data blocks Default value is FALSE Is helpful in preventing memory and data corruption

11-10 Copyright © 2004, Oracle. All rights reserved. How to Handle Corruptions Check the alert log and operating system log file. Use available diagnostic tools to find out the type of corruption. Determine whether the error persists by running checks multiple times. Recover data from the corrupted object if necessary.

11-11 Copyright © 2004, Oracle. All rights reserved. How to Handle Corruptions Resolve any hardware issues: –Memory boards –Disk controllers –Disks Recover or restore data from the corrupt object if necessary.

11-12 Copyright © 2004, Oracle. All rights reserved. Using Flashback for Logical Corruption DBA USER Undo SQL or Flashback Table Corrupt data found Flashback Versions Query Flashback Transaction Query

11-13 Copyright © 2004, Oracle. All rights reserved. The DBMS_REPAIR Package Available procedures: CHECK_OBJECT FIX_CORRUPT_BLOCKS DUMP_ORPHAN_KEYS REBUILD_FREELISTS SEGMENT_FIX_STATUS SKIP_CORRUPT_BLOCKS ADMIN_TABLES

11-14 Copyright © 2004, Oracle. All rights reserved. Using DBMS_REPAIR 1.Detect and report corruptions. 2.Evaluate the costs and benefits of DBMS_REPAIR. SET SERVEROUTPUT ON DECLARE num_corrupt INT; BEGIN num_corrupt := 0; DBMS_REPAIR.CHECK_OBJECT ( schema_name => ‘HR', object_name => 'DEPARTMENTS', repair_table_name => 'REPAIR_TABLE', corrupt_count => num_corrupt); END;

11-15 Copyright © 2004, Oracle. All rights reserved.

11-16 Copyright © 2004, Oracle. All rights reserved. Using DBMS_REPAIR 3.Make objects usable. SET SERVEROUTPUT ON DECLARE num_fix INT; BEGIN num_fix := 0; DBMS_REPAIR.FIX_CORRUPT_BLOCKS ( schema_name => 'HR', object_name => 'DEPARTMENTS', object_type => DBMS_REPAIR.TABLE_OBJECT, repair_table_name => 'REPAIR_TABLE', fix_count => num_fix); END;

11-17 Copyright © 2004, Oracle. All rights reserved. Using DBMS_REPAIR 4.Repair corruptions and rebuild lost data. SET SERVEROUTPUT ON DECLARE num_orphans INT; BEGIN num_orphans := 0; DBMS_REPAIR.DUMP_ORPHAN_KEYS ( schema_name => 'SCOTT', object_name => 'PK_DEPT', object_type => DBMS_REPAIR.INDEX_OBJECT, repair_table_name => 'REPAIR_TABLE', orphan_table_name => 'ORPHAN_KEY_TABLE', key_count => num_orphans); DBMS_OUTPUT.PUT_LINE('orphan key count: ' || TO_CHAR(num_orphans)); END;

11-18 Copyright © 2004, Oracle. All rights reserved. Block Media Recovery (BMR) BMR lowers the mean time to recover (MTTR). BMR increases availability during media recovery. –The data file remains online during recovery –Only blocks being recovered are inaccessible BMR is invoked through RMAN via the BLOCKRECOVER command. –Restores individual blocks from available backups –Coordinates with the server to have them recovered Tape

11-19 Copyright © 2004, Oracle. All rights reserved. The BLOCKRECOVER Command BMR is implemented through the RMAN BLOCKRECOVER command. BLOCKRECOVER identifies the backups containing the blocks to recover. The command reads the backups and accumulates requested blocks into in-memory buffers. BLOCKRECOVER manages the block media recovery session by reading the archive logs from backup if necessary. RMAN> BLOCKRECOVER DATAFILE 6 BLOCK 3;

11-20 Copyright © 2004, Oracle. All rights reserved. RMAN BMR Interface The list of corrupted database blocks is stored in the V$DATABASE_BLOCK_CORRUPTION view. The CORRUPTION LIST clause specifies the recovery of all blocks that are listed in this view. RMAN lists corruptions in backup sets and proxy copies in two views: – V$BACKUP_CORRUPTION – V$COPY_CORRUPTION RMAN> BLOCKRECOVER CORRUPTION LIST 2> RESTORE UNTIL TIME 'sysdate – 10';

11-21 Copyright © 2004, Oracle. All rights reserved. Examples of BLOCKRECOVER Recovering a group of corrupt blocks Limiting block media recovery by type of restore Limiting block media recovery by backup tag Limiting block media recovery by time, SCN, or log sequence

11-22 Copyright © 2004, Oracle. All rights reserved.

11-23 Copyright © 2004, Oracle. All rights reserved. Which Object Is Corrupted? Table: The data in the corrupted block is lost –Drop the table and re-create it, and import data from an export dump –Use SQL or PL/SQL to pull data out of the table into a newly created table Index: Drop and recreate the index

11-24 Copyright © 2004, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Describe causes of database corruption: –Hardware –Software Detect database corruption using: – ANALYZE – dbverify – DB_BLOCK_CHECKING – DBMS_REPAIR Repair corruptions using RMAN

11-25 Copyright © 2004, Oracle. All rights reserved. Practice 11 Overview: Dealing with Database Corruption This practice covers the following topics: Using dbverify to detect database corruption Performing block media recovery with RMAN

11-26 Copyright © 2004, Oracle. All rights reserved.