Backup and Recovery Strategies_1

Embed Size (px)

Citation preview

  • Oracle8i - Backup and Recovery Strategies

    I N S T R U C T O R G U I D E

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Oracle8iBackup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • ORACLE8I - BACKUP AND RECOVERY STRATEGIES

    Course Edition: 2.0For software version: Enterprise Edition 8.1.7

    ACKNOWLEDGEMENTS

    Project Team

    Curriculum Developer and Technical Writer: Michael Culp Print Designer: Isolina Salgado DevelopmentAssisstance: Robert G. Freeman and Victor V. Tischuk

    Project Support

    Acquisition Editor: Nicole Heinsler Quality Analyst: Lance Anderson

    Administration

    Senior Director of Content and Content Development: William O. Ingle Director of Certication: MikeGrakowsky Director of Design and Web Development: Joy Insinna Manager of Ofce Productivity andApplied Learning: Cheryl Russo Manager of Databases, ERP, and Business Skills: Mark Onisk Directorof Business Development: Kent Michels Instructional Design Manager: Susan L. Reber Manager ofPublishing Services: Michael Hoyt

    NOTICESDISCLAIMER: While Element K Press LLC takes care to ensure the accuracy and quality of these materials, we cannot guarantee their accuracy, and all materials areprovided without any warranty whatsoever, including, but not limited to, the implied warranties of merchantability or tness for a particular purpose. The name used in the datales for this course is that of a ctitious company. Any resemblance to current or future companies is purely coincidental. We do not believe we have used anyones name increating this course, but if we have, please notify us and we will change the name in the next revision of the course. Element K is an independent provider of integratedtraining solutions for individuals, businesses, educational institutions, and government agencies. Use of screenshots or another entitys product name or service in this bookis for editorial purposes only. No such use should be construed to imply sponsorship or endorsement of the book by, nor any afliation of such entity with Element K.

    TRADEMARK NOTICES: Element K and the Element K logo are trademarks of Element K LLC. Oracle is a registered trademark of Oracle Corporation in the U.S. and othercountries; the Oracle products and services discussed or described may be trademarks of Oracle Corporation for more information about Oracle trademarks please refer towww.oracle.com/html?trademark.html. All other product names and services used throughout this book may be common law or registered trademarks of theirrespective proprietors.

    Copyright 2002 Element K Content LLC. All rights reserved. Screenshots used for illustrative purposes are the property of the software proprietor. This publication, or anypart thereof, may not be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, storage in an information

    This book conveys no rights in the software or other products about which it was written; all use or licensing of such software or other products is the responsibility of theuser according to terms and conditions of the owner. Do not make illegal copies of books or software. If you believe that this book, related materials, or any other Element Kmaterials are being reproduced or transmitted without permission, please call 1-800-478-7788.

    ii Oracle8i - Backup and Recovery Strategies

    Course Number: NH79152 (0767IGEE)

    retrieval system, or otherwise, without express written permission of Element K, 500 Canal View Boulevard, Rochester, NY 14623, (585) 240-7500, (800) 434-3466. Element KPress LLCs World Wide Web site is located at www.elementkcourseware.com.

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • ORACLE8I - BACKUP AND RECOVERY STRATEGIES

    About This Course . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi

    Lesson 1: Introduction to Oracle Backup and Recovery . . . . . . . . . . . . . . . . . . . . . 1

    Lesson 2: Oracle RDBMS Backup and Recovery Fundamentals. . . . . . . . . . . . . . . . 7

    Lesson 3: Physical Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

    Lesson 4: Complete Physical Recovery of an Oracle Database . . . . . . . . . . . . . . . . 71

    Lesson 5: Oracle Incomplete Recovery and Miscellaneous Recovery Topics. . . . . . . 95

    Lesson 6: Oracle Logical Backups (Exp/Imp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

    Lesson 7: Oracle Troubleshooting Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

    Lesson 8: RMAN Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

    Lesson 9: Backing Up Databases With RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

    Lesson 10: Recover and Restore Oracle with RMAN. . . . . . . . . . . . . . . . . . . . . . . 197

    Lesson 11: Management of RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

    Lesson 12: Oracle Standby Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

    Appendix A: Using SQL*Plus to Sign onto a Database . . . . . . . . . . . . . . . . . . . . . . 241

    Appendix B: Removing a Database on NT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243

    Appendix C: Removing Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

    Glossary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

    Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

    CONTENTOVERVIEW

    Contents iii

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • ORACLE8I - BACKUP AND RECOVERY STRATEGIES

    CONTENTSAbout This Course . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiCourse Setup Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiiHow To Use This Book. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

    LESSON 1: INTRODUCTION TO ORACLE BACKUP AND RECOVERYTopic 1A Backup and Recovery Administration Responsibilities . . . . 2

    Task 1A-1 Reviewing Backup and Recovery Administration . . . . . . . . . . 2

    Topic 1B Defining a Backup Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Task 1B-1 Gathering Backup Strategy Requirements . . . . . . . . . . . . . . . 4

    Create and Test the Plan, Then Submit to Management for Approval . 4

    Topic 1C Planning for Disaster Recovery . . . . . . . . . . . . . . . . . . . . . . . . 5Lesson Review 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    LESSON 2: ORACLE RDBMS BACKUP AND RECOVERY FUNDAMENTALSTopic 2A Oracle Data Dictionary Management Views . . . . . . . . . . . . . . 9

    Task 2A-1 Oracle Data Dictionary Views . . . . . . . . . . . . . . . . . . . . . . . 9

    Topic 2B Oracle Internals Fundamental Concepts. . . . . . . . . . . . . . . . . 11Task 2B-1 Understanding the Database and the Instance . . . . . . . . . . . 11

    Starting the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Task 2B-2 Understanding the Startup and Shutdown Process . . . . . . . . . 15

    Instance and Media Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Task 2B-3 Oracle Recovery Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    Memory and Internal Structures in Oracle . . . . . . . . . . . . . . . . . . . . . . 16Task 2B-4 Understanding Oracle Memory and Internal Structures . . . . . . 18

    Oracle Internal Storage Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Task 2B-5 Understanding Oracle Internal Structures . . . . . . . . . . . . . . . 20

    Topic 2C Oracle Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Task 2C-1 Understanding Oracle System Processes . . . . . . . . . . . . . . . . 22

    Checkpoints and the CKPT Process in Oracle . . . . . . . . . . . . . . . . . . . . 23Task 2C-2 Understanding Checkpoints and the CKPT Process . . . . . . . . . 24

    Oracle User and Server Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

    CONTENTS

    iv Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Task 2C-3 Understanding User and Server Processes. . . . . . . . . . . . . . . 25

    Topic 2D Oracle External Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25Task 2D-1 Working with Redo Logs and Archived Redo Logs . . . . . . . . . 27

    Oracle Control Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28Task 2D-2 Working with Control Files. . . . . . . . . . . . . . . . . . . . . . . . . 28

    Oracle Database Datafiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Task 2D-3 Working with Database Datafiles . . . . . . . . . . . . . . . . . . . . 30

    Other Oracle Files having Backup Considerations. . . . . . . . . . . . . . . . . 31Task 2D-4 Working with Other Database Related Files . . . . . . . . . . . . . 31

    Apply Your Knowledge 2-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    Topic 2E ARCHIVELOG and NOARCHIVELOG Mode . . . . . . . . . . . . . . . . . 32Task 2E-1 Understanding ARCHIVELOG Mode. . . . . . . . . . . . . . . . . . . . 33

    Enable and Disable ARCHIVELOG Mode . . . . . . . . . . . . . . . . . . . . . . . . . 33Task 2E-2 Working with ARCHIVELOG Mode . . . . . . . . . . . . . . . . . . . . 33

    The ARCH Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Task 2E-3 Administering the ARCH Process. . . . . . . . . . . . . . . . . . . . . 38

    Apply Your Knowledge 2-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Lesson Review 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

    LESSON 3: PHYSICAL BACKUPSTopic 3A Oracle File Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

    Task 3A-1 Locate Files that Require Backup . . . . . . . . . . . . . . . . . . . 46

    Topic 3B Physical Backup Options in Oracle . . . . . . . . . . . . . . . . . . . . . 48Task 3B-1 Understand Oracle Backup Basics . . . . . . . . . . . . . . . . . . . . 49

    Topic 3C Performing Cold Backups in Oracle. . . . . . . . . . . . . . . . . . . . . 50Preparing the Database for a Cold Backup . . . . . . . . . . . . . . . . . . . . . . 50Executing a Cold Backup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

    Task 3C-1 Do a Cold Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

    Topic 3D Performing Hot Backups in Oracle . . . . . . . . . . . . . . . . . . . . . 52Starting the Hot Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    Task 3D-1 Starting a Hot Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . 54Apply Your Knowledge 3-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54Finishing the Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

    Task 3D-2 Doing a Hot Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Resetting Tablespace Backup Status after a Crash During a HotBackup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

    Task 3D-3 Reset the Tablespace Backup Status after a Crash During a HotBackup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

    Topic 3E Additional Oracle Backup Considerations . . . . . . . . . . . . . . . 60Task 3E-1 Create Control File Backups . . . . . . . . . . . . . . . . . . . . . . . . 61

    Backing Up the Parameter and Password File. . . . . . . . . . . . . . . . . . . . 63

    CONTENTS

    Contents v

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Task 3E-2 Backup the Parameter and Password File . . . . . . . . . . . . . . . 63Backing Up Archived Redo Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

    Task 3E-3 Backing Up Archived Redo Logs . . . . . . . . . . . . . . . . . . . . . 63Read Only Tablespace Backup Considerations. . . . . . . . . . . . . . . . . . . . 64

    Task 3E-4 Read Only Tablespace Backup Considerations . . . . . . . . . . . . 64Logging versus Nologging Operations . . . . . . . . . . . . . . . . . . . . . . . . . 64

    Task 3E-5 Logging versus Nologging Operations . . . . . . . . . . . . . . . . . 65Apply Your Knowledge 3-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65Lesson Review 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

    LESSON 4: COMPLETE PHYSICAL RECOVERY OF AN ORACLE DATABASETopic 4A Recovery 101. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

    Apply Your Knowledge 4-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73Oracle Recovery Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74Apply Your Knowledge 4-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75Recovery Views Available in Oracle. . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

    Task 4A-1 Using Recovery Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77NOARCHIVELOG Operations and Limitations . . . . . . . . . . . . . . . . . . . . . 78

    Task 4A-2 NOARCHIVELOG Operations . . . . . . . . . . . . . . . . . . . . . . . . 78ARCHIVELOG Operations and Limitations . . . . . . . . . . . . . . . . . . . . . . . 78

    Task 4A-3 Using ARCHIVELOG Mode. . . . . . . . . . . . . . . . . . . . . . . . . . 79Closed versus Open Database Recovery . . . . . . . . . . . . . . . . . . . . . . . . 80

    Task 4A-4 Closed and Open Database Recovery . . . . . . . . . . . . . . . . . . 81

    Topic 4B Closed Database Recoveries. . . . . . . . . . . . . . . . . . . . . . . . . . . 81Task 4B-1 Recovering from a Cold Backup in NOARCHIVELOG Mode . . . . 82

    Recovery of the System Tablespace . . . . . . . . . . . . . . . . . . . . . . . . . . . 83Task 4B-2 Recovery after Losing the System Tablespace with the Data-

    base In ARCHIVELOG Mode . . . . . . . . . . . . . . . . . . . . . . . . 83

    Topic 4C Open Database Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85Task 4C-1 Open Database Recovery Concepts . . . . . . . . . . . . . . . . . . . 85

    Recovery of a Database Datafile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86Task 4C-2 Recovery from Losing a Datafile. . . . . . . . . . . . . . . . . . . . . 87

    Recovery of a Tablespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90Task 4C-3 Recovering a Lost Tablespace. . . . . . . . . . . . . . . . . . . . . . . 91

    Lesson Review 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

    LESSON 5: ORACLE INCOMPLETE RECOVERY AND MISCELLANEOUSRECOVERY TOPICSTopic 5A Incomplete Recovery of an Oracle Database . . . . . . . . . . . . . 96

    Task 5A-1 Incomplete Recovery Basics. . . . . . . . . . . . . . . . . . . . . . . . 100

    CONTENTS

    vi Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Time-Based Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100Task 5A-2 Performing a Time-Based Recovery in Oracle . . . . . . . . . . . . 101

    Change Based Recovery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102Task 5A-3 Performing a Change Based Recovery in Oracle. . . . . . . . . . . 103

    Cancel Based Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104Task 5A-4 Performing a Cancel Based Recovery in Oracle . . . . . . . . . . . 105

    Topic 5B Other Database Recovery Considerations . . . . . . . . . . . . . . . .106Task 5B-1 Recovery of Control Files. . . . . . . . . . . . . . . . . . . . . . . . . . 109

    Recovery from Loss of Datafiles with Rollback Segments . . . . . . . . . . 110Recovering a Datafile when You Dont Have a Backup. . . . . . . . . . . . . 110

    Task 5B-2 Recovering a Datafile without Any Backup. . . . . . . . . . . . . . 110Recovery from Losing Online Redo Logs. . . . . . . . . . . . . . . . . . . . . . . . 112

    Task 5B-3 Recovering from the Losing Online Redo Logs . . . . . . . . . . . 113Restoring Oracle Files to a Different Location . . . . . . . . . . . . . . . . . . . 113

    Task 5B-4 Restoring an Oracle Database Datafile to a Different Location. 113Recovery Involving a Read Only Tablespace. . . . . . . . . . . . . . . . . . . . . 115

    Task 5B-5 Recovering Databases with Read Only Tablespaces . . . . . . . . 115Lesson Review 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

    LESSON 6: ORACLE LOGICAL BACKUPS (EXP/IMP)Topic 6A Logical Backups and Oracles Export Utility (Exp) . . . . . . . .118

    Task 6A-1 Comparing Physical and Logical Backups . . . . . . . . . . . . . . . 119Oracles Export (Exp) Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

    Task 6A-2 Understand Oracle Exp Features . . . . . . . . . . . . . . . . . . . . . 123Performing a Table-Level Export of the Oracle Database . . . . . . . . . . . 123

    Task 6A-3 Perform a Table-Level Database Export . . . . . . . . . . . . . . . . 124Performing a User-Level Export of the Oracle Database . . . . . . . . . . . . 125

    Task 6A-4 Do a User-Level Database Export . . . . . . . . . . . . . . . . . . . . 125Performing a Full Export of the Oracle Database . . . . . . . . . . . . . . . . . 125

    Task 6A-5 Do a Full Database Export . . . . . . . . . . . . . . . . . . . . . . . . . 126Direct Path Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

    Task 6A-6 Using Direct Path Mode with Exp . . . . . . . . . . . . . . . . . . . . 128

    Topic 6B Oracles Import Utility (Imp) . . . . . . . . . . . . . . . . . . . . . . . . .128Task 6B-1 Recovering with Imp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

    Recovering a Table with the Imp Utility. . . . . . . . . . . . . . . . . . . . . . . . 132Task 6B-2 Recovering a Table with Imp . . . . . . . . . . . . . . . . . . . . . . . 132

    Recovering a User-Level Export with the Imp Utility. . . . . . . . . . . . . . 133Task 6B-3 Recover a User Level Export with Imp. . . . . . . . . . . . . . . . . 133

    Understanding Tablespace Point-in-Time Recovery . . . . . . . . . . . . . . . 134Task 6B-4 Understanding Tablespace Point-in-Time Recovery. . . . . . . . . 134

    CONTENTS

    Contents vii

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Topic 6C Incremental Exports and Imports . . . . . . . . . . . . . . . . . . . . . .135Task 6C-1 Perform a Complete or Base, Cumulative, and an Incremental

    Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136Recovery from an Incremental Export. . . . . . . . . . . . . . . . . . . . . . . . . . 138

    Task 6C-2 Recovery from an Incremental Export . . . . . . . . . . . . . . . . . 138Lesson Review 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

    LESSON 7: ORACLE TROUBLESHOOTING UTILITIESTopic 7A Oracle Problem Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . .144

    Task 7A-1 Using DBV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145Oracle Checksum Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146Oracle Logs and Trace Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

    Task 7A-2 Looking at Oracle Logs and Trace Files . . . . . . . . . . . . . . . . 148Using DBMS_REPAIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

    Task 7A-3 Using the DBMS_REPAIR Package . . . . . . . . . . . . . . . . . . . . 150

    Topic 7B LogMiner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150Task 7B-1 Using LogMiner The Basics . . . . . . . . . . . . . . . . . . . . . . 151

    Setting Up LogMiner for Use. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151Task 7B-2 Setting Up LogMiner . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

    Mining Those Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153Task 7B-3 Mining Logs with LogMiner . . . . . . . . . . . . . . . . . . . . . . . . 155

    Analyzing LogMiner Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157Task 7B-4 Review the Results of LogMiner . . . . . . . . . . . . . . . . . . . . . 158

    Lesson Review 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

    LESSON 8: RMAN ARCHITECTURETopic 8A Starting with RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162

    Task 8A-1 Understanding RMAN Features . . . . . . . . . . . . . . . . . . . . . . 163Basic RMAN Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

    Task 8A-2 Understanding RMAN Architecture . . . . . . . . . . . . . . . . . . . 166RMAN Backup Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

    Task 8A-3 Understanding RMAN Backup Types. . . . . . . . . . . . . . . . . . . 168Task 8A-4 Understanding RMAN Commands. . . . . . . . . . . . . . . . . . . . . 175

    Topic 8B Setting Up RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176Task 8B-1 Creation and Connection of the Recovery Catalog . . . . . . . . . 177

    Register the Database with the Recovery Catalog . . . . . . . . . . . . . . . . 178Task 8B-2 Registering a Database with the RMAN Recovery Catalog . . . . 179

    Resyncing the Recovery Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180Task 8B-3 Resyncing the Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

    Lesson Review 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

    CONTENTS

    viii Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • LESSON 9: BACKING UP DATABASES WITH RMANTopic 9A RMAN Backups. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184

    Task 9A-1 RMAN Full Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186Current Control File Backups. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187Incremental Backups in RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

    Task 9A-2 RMAN Incremental Backups . . . . . . . . . . . . . . . . . . . . . . . . 188Tablespace and Datafile Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

    Task 9A-3 Performing Tablespace and Database Datafile Backups withRMAN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

    Topic 9B Other RMAN Backup Topics . . . . . . . . . . . . . . . . . . . . . . . . . . .191Task 9B-1 RMAN Image Copies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

    Cleanup Deleting RMAN Backup Sets. . . . . . . . . . . . . . . . . . . . . . . . 192Task 9B-2 Delete RMAN Backup Sets . . . . . . . . . . . . . . . . . . . . . . . . . 192

    ARCHIVELOG Backups with RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193Task 9B-3 Archivelog Backups with RMAN . . . . . . . . . . . . . . . . . . . . . 193

    Recovery Catalog Database Backups. . . . . . . . . . . . . . . . . . . . . . . . . . . 194Lesson Review 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

    LESSON 10: RECOVER AND RESTORE ORACLE WITH RMANTopic 10A Recovering the Oracle Database . . . . . . . . . . . . . . . . . . . . . . .198

    Task 10A-1 Recover the Database from a Full or Incremental Backup . . . . 199Recovering Tablespaces and Datafiles . . . . . . . . . . . . . . . . . . . . . . . . . 200

    Task 10A-2 Recovering Individual Tablespaces and Datafiles . . . . . . . . . . 200

    Topic 10B Other Types of Recoveries with RMAN . . . . . . . . . . . . . . . . . .202Datafile Relocation During Restores . . . . . . . . . . . . . . . . . . . . . . . . . . . 202Recovering Archived Redo Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

    Task 10B-1 Recovering Archived Redo Logs with RMAN . . . . . . . . . . . . . 203

    Topic 10C Other RMAN Recovery Topics . . . . . . . . . . . . . . . . . . . . . . . . . .204Task 10C-1 Performing Incomplete Recoveries . . . . . . . . . . . . . . . . . . . 204

    Resetting the Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206Task 10C-2 Resetting the Database. . . . . . . . . . . . . . . . . . . . . . . . . . . 206

    Recovering the Recovery Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207Lesson Review 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

    LESSON 11: MANAGEMENT OF RMANTopic 11A Managing RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210

    Task 11A-1 Understanding Database Data Dictionary Views and RMAN . . . 213Apply Your Knowledge 11-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214Reports in RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

    CONTENTS

    Contents ix

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Task 11A-2 Using Reports in RMAN. . . . . . . . . . . . . . . . . . . . . . . . . . . 215Lists in RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

    Task 11A-3 Using Lists in RMAN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218Cleanup RMAN Crosscheck and Change Commands . . . . . . . . . . . . . 219

    Task 11A-4 Using the Crosscheck and Change Commands in RMAN. . . . . . 219

    Topic 11B RMAN Stored Scripts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .221Task 11B-1 Creating Stored Scripts in Oracle . . . . . . . . . . . . . . . . . . . . 222

    Maintenance of Stored Scripts in RMAN . . . . . . . . . . . . . . . . . . . . . . . . 222Task 11B-2 Maintaining Our Stored Script . . . . . . . . . . . . . . . . . . . . . . 223

    Lesson Review 11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

    LESSON 12: ORACLE STANDBY DATABASETopic 12A Standby Database Basics and Setup . . . . . . . . . . . . . . . . . . . .228

    Standby Database Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228Task 12A-1 Prepare the Standby Database . . . . . . . . . . . . . . . . . . . . . . 231

    Standby Database Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234Task 12A-2 Setup Automated Refresh (Managed Recovery Mode) . . . . . . . 235

    Topic 12B Using the Standby Database . . . . . . . . . . . . . . . . . . . . . . . . . .237Task 12B-1 Setup the Standby Database as a Read Only Database . . . . . . 238

    Starting and Stopping the Standby Database. . . . . . . . . . . . . . . . . . . . 238Task 12B-2 Starting and Stopping Standby Databases . . . . . . . . . . . . . . 238

    Failing Over to the Standby Database . . . . . . . . . . . . . . . . . . . . . . . . . 238Task 12B-3 Opening the Standby Database . . . . . . . . . . . . . . . . . . . . . 239

    Lesson Review 12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240

    APPENDIX A: USING SQL*PLUS TO SIGN ONTO A DATABASEUsing SQL*Plus to Sign onto a Database . . . . . . . . . . . . . . . . . . . . . . . . . .241

    APPENDIX B: REMOVING A DATABASE ON NTRemoving a Database onNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243

    APPENDIX C: REMOVING ORACLERemoving Oracle Databases and Software. . . . . . . . . . . . . . . . . . . . . . . . .245

    Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .247

    Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257

    CONTENTS

    x Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • INTRODUCTIONWelcome to the New Horizons training team.

    Our goal is to provide you with the best computer training available and weknow exactly what that takes. Our corporate heritage is based in training. In fact,we use our Student Manuals every day, in classes just like yours, so you can beconfident that the material has been tested and proven to be effective.

    If you have any suggestions on how we can improve our products or services,please contact us.

    ABOUT THIS COURSEOracle8i is the latest version of Oracles flagship database product. As a DBA,you will be expected to know how to backup and recover the Oracle databasesunder your control. This course will provide you with the knowledge and compe-tency level to do this. This course will also serve as a preparatory class for takingthe Oracle8i Oracle Certified Professional (OCP) Backup and Recovery Exam.

    Course PrerequisitesTo ensure your success, we recommend you first take the following New Hori-zons course or have equivalent knowledge:

    comfortable with the following concepts and skills: Basic Oracle database architecture, including the Oracle processes, database

    datafiles, control files, and redo logs. How to use SQL*Plus and Server Manager to manage the database and

    query tables within it. How to startup and shutdown the Oracle database. How to create, modify, and drop tablespaces, tables, and indexes within the

    database. Using basic SQL commands such as SELECT, UPDATE, INSERT, and

    DELETE. How to create an Oracle database. Know the locations of the Oracle software, of OFA (Optimal Flexible Archi-

    tecture), and where Oracle puts database related files on the hard disk whenfollowing the OFA standards.

    ABOUT THISCOURSE

    About This Course xi

    NH79 166 Oracle8i - Architecture and Administration (Second Edition)If you have not taken Oracle8i - Architecture and Administration , you should be

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Course ObjectivesWhen youre done working your way through this book, youll be able to:

    Prepare backup, recovery, and disaster plans. Describe the internal workings of the Oracle database as they pertain to

    backup and recovery. Describe the backup procedures for both hot and cold backups and then per-

    form those backups (without RMAN). Perform complete and incomplete database recoveries and full, tablespace,

    and datafile recoveries with the database open and closed (without RMAN). List and describe the benefits and use of the Oracle Export/Import utility,

    and use Oracle Export/Import utilities to perform an export from an Oracledatabase and an import into an Oracle database.

    Use the Oracle troubleshooting utilities including DBV and the DBMS_REPAIR package.

    Describe the basic RMAN architecture. Perform required setup procedures in preparation for using RMAN. Perform full, incremental, tablespace and datafile backups using RMAN. Perform full, tablespace and datafile recoveries using RMAN. Create stored scripts and generate reports and lists in RMAN. Setup an Oracle standby database, enable archived redo log processing on

    the standby database, and enable the standby database in read only mode oractivate it for full use.

    COURSE SETUP INFORMATION

    Hardware and Software RequirementsTo run this course, you will need:

    Each machine (Instructor and Student) should meet this minimum hardwarerequirement:

    Pentium II 266 Processor or faster.

    xii Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • At least 128 megabytes (MB) of Random Access Memory (RAM) and anoptional 128 MB of virtual memory.

    A minimum of 10 gigabytes (GB) of available hard disk space for the Sys-tem and Oracle partitions.

    256k Cache 4x CD-ROM drive Network adapter and cabling. All student machines should be networked

    together. SVGA monitor Mouse or compatible pointing device. 3.5 inch floppy or other removable read-write media. Each machine (Instructor and Student) should have the following software

    installed: Microsoft Windows NT 4.0 Workstation with service pack 5 or higher. Oracle8i Enterprise Edition 8.1.7 (This installation will include both Server

    and Client). WinZip 7.0 or better.

    Class RequirementsIn order for the class to run properly, perform the procedures described below.

    1. As you prepare for the installation of the Oracle software, it is expected thatyou will have your computer configured with the previously outlinedrequirements.

    Be sure that your hard drives are partitioned into at least two partitions. Onepartition should be designated as the C drive for the operating systemsoftware. The system drive should be at least 2 GB in size and formatted aseither FAT or NTFS. The second partition should be designated as the Ddrive and reserved for the Oracle installation. This drive needs to be at least8 GB and formatted as either FAT or NTFS.

    2. Once the computers operating system is fully installed and configured, startup Windows NT and log on as Administrator.

    Insert the Oracle8i (8.1.7) Enterprise Edition CD in the CD-ROM drive. TheCD will automatically run, and you will see the initial Oracle8i Welcomescreen displayed. Click Install/Deinstall Products, and the Oracle UniversalInstaller will begin loading. You will then see the splash screen for theOracle Universal Installer.

    3. Once the installer loads, you will see the Welcome screen. Click Next.

    4. The File Locations screen prompts you to enter the paths for the source anddestination. The source should show E:\stage\products.jar. If destinationdoesnt already show it, set the destination name to OraHome81 and the pathto D:\oracle\ora81. Click Next. You will see a progress meter appear brieflyon the screen and then disappear.

    5. The Available Products screen asks you to select a product to install. SelectOracle8i Enterprise Edition 8.1.7.0.0, and then click Next.

    Your disk drive should beformatted into at least twodisk partitions. The rstpartition should be 2 GB andshould be assigned to theoperating system (either FATor NTFS), and is typically theC: drive. The secondpartition should be 8 GB andshould be assigned to loadthe Oracle software and theinstall of the Oracledatabases (either FAT orNTFS) and is typically the D:drive.

    It is strongly recommendedthat you make a backup ofthe Oracle8i database oneach system before youstart the class. You can usethis backup to keep thingsmoving should a studentbe unable to recover hisdatabases in one of themany recovery exercises.

    This course will refer to theD:\oracle drive. In reality, youmay be using the D: drive,the E: drive, or some otherdrive letter. If your Oraclepartition is declared a letterother than D:, you will needto replace our referenceswith the appropriate driveletter for your system.

    About This Course xiii

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • 6. The Installation Types screen asks you to select an installation type. ChooseTypical, and then click Next. You will see a progress meter on the top rightas the installer processes the request.

    7. The Database Identification screen asks you to fill in the database name andthe system identifier. If there is already information filled in, make sure thatit matches the information below. If the fields are blank, use these values: Global Database Name: oracle8i.world System Identifier (SID): oracle8i

    Click Next.

    8. The Summary screen provides you with a summary of the installation set-tings you have selected. Review the settings, and then click Install.

    9. The Install screen shows a progress meter as Oracle is installed. Long pausesin the progress of the meter are normal.

    Note: A long pause when the progress meter reaches 100% is normal.

    The Database Configuration Assistant will automatically launch and begincreating the database. You will see a progress meter as the database iscreated.

    Once the database has finally been created, you will see a box providingsome final information before closing. You will see the global databasename, SID, and the passwords for both the SYS and SYSTEM accounts. Thepasswords shown are default passwords and should be changed immediatelyfor security reasons. Click OK to close the box.

    10. Click Exit to exit the installer and choose Yes when it asks for confirmation.

    11. Now make sure that the database has started up. Click StartSettingsControl Panel. From the Control Panel, double-click on the Services icon.

    12. Scroll down to find the service named OracleServiceOracle8i.

    If the service is not all ready started, highlight it by clicking on it with themouse and click Start.

    You will see a message that the system is attempting to start the service.Once the service is started, the database is ready for use.

    13. Once the service has successfully started, click on Close. Close the ControlPanel window to return to the desktop.

    14. To change the SYS password, Select StartProgramsOracle -OraHome81Application DevelopmentSQL*Plus. Enter the user nameSYS, and the password change_on_install. The password will disguise itselfas asterisks. Click OK.

    The entire installationprocess could take upwards

    of 30 to 45 minutes.

    Note that the right arrow, ,indicates that you are

    moving into a sub-menufrom the START menu.

    xiv Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • 15. At the SQL*Plus prompt, type password, and press [Enter]. You will beprompted for the old password, and then the new password twice. Enter theold password, change_on_install, and press [Enter]. Enter the new passwordas oracle, and then press [Enter]. When prompted, enter the new passwordagain and press [Enter]. If the password was successfully changed, the win-dow will return to just the SQL*Plus prompt.The SYS user has complete access to all objects and settings in the database.It is the most powerful user in the system, and therefore, the passwordshould be protected at all costs. While the password you just used, oracle, issufficient for our purposes, it is way too obvious for real productiondatabases. It is recommended that you choose a password that you will notforget, but cannot be easily guessed. You should also change the passwordfor the SYSTEM account. For our database we will leave that password asmanager.

    Creating another NewDatabase onNTCreate a second database called RECOVER using the database configurationassistant. The database configuration assistant (DCA) is a graphical, wizard like,utility provided by Oracle to ease the process of database creation. Unfortunately,DCA is a memory hog. DCA tends to sometimes lock up if you do not haveenough memory available (real + virtual) on your system. Also, when it creates adatabase using the default options (there are several options available for DCAincluding creation of a default database and creation of a customized database), ittends to create them with certain memory requirements that are, not always prac-tical for the system you are using.

    As a result of the problems with DCA, it is very important that your system isconfigured as required for this course in terms of memory. Also, make sure youfollow the database creation instructions very carefully as they are listed below,as these have been tested. If, later on, you want to create a database with some ofthe options (such as intermedia), then you may do so.To create a database with the database configuration assistant, it is recommendthat you choose the custom option so that you can tailor the database options andparticularly the memory allocations, to the system you are creating the databaseon. In the instructions below, you will create a database called RECOVER, sincethat is the name of the new database you will create in the Oracle Troubleshoot-ing Utilities lesson. So, follow these steps to create a database with the databaseconfiguration assistant:

    1. Shut down any operating databases on the NT box. This will free upmemory for the Database configuration assistant.

    Database CongurationAssistant:Oracle utility that provides awizard like interface to theDBA, used for databasecreation and removal.

    About This Course xv

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • 2. Start the Database configuration assistant (DCA) from the Start menu. SelectStart Programs Oracle-orahome81 Database Administration Data-base Configuration Assistant.

    3. Choose the option to create a database and click Next.

    4. Select Custom and click on Next.

    5. Choose Multipurpose, the bottom option. Then click on Next.

    6. Click on Next again, accepting the default number of concurrent users. Ifyou are creating a database that will have more concurrent users, you mightincrease this number.

    7. Select the Dedicated Server Mode option and press Next.

    8. On the next screen you have many different Oracle options. Click on eachbox to remove the checkmark from it. You do not want to install theseoptions for the purpose of this course. Click on Next to continue after allcheckmarks are removed from the boxes.

    9. On the next screen, enter the global database name. For the purposes of thislesson the name would be RECOVER.world. Note the database name isfilled in for you as is the proper location for the init.ora file. Modify thecompatible parameter, choosing 8.1.0 from the drop down box. Click onNext when you have completed these steps.

    10. Accept the default values on the next screen, which lists the control file set-tings, and click on Next.

    11. You now have the option to change tablespace settings. Accept all defaultsand click on Next.

    12. On the next screen, which lists the redo log locations and sizes, accept thedefaults and click on Next.

    13. The next screen gives you an option to enable archive log. Click on Next toaccept the default setting.

    14. The next screen is important. Here, you can change the settings of the SGA,and thus reduce initial memory requirements. One reported bug in DCA isthat because it takes up so much memory, that when it tries to create thedatabase it fails because the combination of the memory it uses and thedefault database memory requirements will simply be to much for the typicalsystem, and this will cause DCA to appear to lock up. Carefully look at thesettings in this window and determine if you should change them. You canalways increase memory later. For the purposes of the exercises in thiscourse you will accept the defaults.

    15. The next screen will appear prompting you for trace file locations. Acceptthe defaults and click on Next.

    16. You are provided with an option to save the creation commands out to ascript file or create the database now. You are interested in creating the data-base now, click on that option if it is not already highlighted and click onFinish.

    OraHome81 is the name ofthe ORACLE_HOME you

    dened when you installedthe software on your

    machine. It may actually bedifferent on your individualmachine depending on how

    you installed the Oracleproduct.

    xvi Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • 17. An alert will appear warning you that DCA is about to create the databaseand that it will take some time. Click on Yes to continue the database cre-ation process.

    18. Another dialogue box will appear, indicating that the database has beencreated. Click on OK to close the dialogue box and exit the DCA. Once youhave done this your new database will be up and running and you can con-nect to it through SQL*Plus.

    19. Remove the Oracle8i Enterprise Edition installation CD, and restart yourcomputer.

    To make Oracle8i the default database, follow these steps:

    20. Start the Registry Editor. Start Run and type in regedit.

    21. Go to HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0 andlook for the key ORACLE_SID.

    22. Double click on it and change the value from RECOVER to ORACLE8I,then exit.

    To apply Oracle8i update patches, follow these steps:

    23. Apply patches 8.1.7.2.0 and 8.1.7.2.2 from the Oracle Website (metalink.oracle.com).

    24. Do these steps ONLY after the patches have been installed.

    a. Look in D:\Oracle\ora81\RDBMS\admin for the file dbmslmd.sql andopen it.

    b. Replace the number 513 with the number 700 and save the file.(There should be two instances.)

    c. Open a DOS prompt. Type in svrmgrl to run server manager and thenconnect as internal.

    d. Type in @d:\oracle\ora81\rdbms\admin\dbmslmd.sql and press [Enter]and then exit.

    To change the location of the Archive Redo Logs perform the following steps:

    25. Modify the init.ora file in the D:\oracle\admin\oracle8i\pfile directory byincluding the following parameter: log_archive_dest_1= location=D:\Oracle\oradata\oracle8i\archive

    26. Open SQL*Plus and perform a SHUTDOWN IMMEDIATE and then aSTARTUP.

    This will take awhile.

    About This Course xvii

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • To install the student files for this class, perform the following procedures:

    1. Login to NT as Administrator and insert the CD ROM that accompanies thiscourse book into the E: drive.

    2. Choose StartRun, enter E:\079152\079152sf.zip into the Open: field, andpress OK.

    3. Once the self-extracting WinZip file opens up, confirm or change, that it willwrite your files to the C: drive and choose Unzip.

    4. WinZip will confirm that it was successful. Click OK.

    Close the WinZip extractor and remove the CD from the drive.

    To install the Oracle Documentation, perform the following procedures:

    1. Double-click on My Computer. Double-click on the D drive. Choose FileNewFolder. Name the folder Installs. Double-click on the Installs folder toopen it.

    2. Inside the Installs folder, choose FileNewFolder. Name this folderOracle817Docs. Double-click on the Oracle817Docs folder to open it.

    3. Insert the Oracle8i Online Documentation CD for version 8.1.7. The Autorunscreen will automatically appear. Click Explore CD. A window will openshowing the contents of the CD.

    4. In the CD window, choose EditSelect All. This will highlight all of thefiles in the folder.

    5. Choose EditCopy. Go back to the D:\Installs\Oracle817Docs window.Right-click in the window and select Paste from the drop-down menu. Theentire contents of the documentation CD will copy into this folder. Once thefiles are done being copied. Close all windows on the desktop, and removethe CD-ROM from the drive.

    6. From the Windows Desktop, select StartProgramsOracle InstallationProductsUniversal Installer. You should see the initial splash screen whilethe Oracle Installer initializes.

    7. After the installer is loaded, you will see the initial Welcome screen. ClickNext.

    8. The File Locations screen will ask you the source to install from, and thedestination to install to. If your screen does not already say so, change theSource to show the path: D:\Installs\Oracle817Docs\stage\products.jar.The products.jar file contains a list of all available components from thisinstallation source.

    If not already there, set the Destination for this installation. The OracleHome name should be OraHome81, and type in the Destination path asD:\Oracle\Ora81. Once this is entered, click Next.

    9. You should see a page showing a summary of the installation options youjust chose. After reviewing your installation options, click Install.

    There are no real studentles required for this course.

    What we do offer are thepowerpoint overheads as

    learning aids. If you do notcare to have the powerpoint

    les installed on yourcomputer, you do not need

    to complete these steps.

    xviii Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • 10. Once the installation is complete, you will see one final screen showing aconfirmation message. Click Exit. You will be asked if you really want toexit. Click Yes to confirm.

    You have just installed the Oracle Documentation into your existingconfiguration.

    HOW TO USE THIS BOOKYou can use this book as a learning guide, a review tool, and a reference.

    As a Learning GuideEach lesson covers one broad topic or set of related topics. Lessons are arranged

    you acquire in one lesson are used and developed in subsequent lessons. For thisreason, you should work through the lessons in sequence.

    We organized each lesson into explanatory topics and step-by-step activities. Top-

    activities allow you to apply this theory to practical hands-on examples.

    You get to try out each new skill on a specially prepared sample file. This savesyou typing time and allows you to concentrate on the technique at hand. Throughthe use of sample files, hands-on activities, illustrations that give you feedback atcrucial steps, and supporting background information, this book provides you

    and easily.

    As a Review ToolAny method of instruction is only as effective as the time and effort you are will-ing to invest in it. For this reason, we encourage you to spend some timereviewing the books more challenging topics and activities.

    As a ReferenceYou can use the Concepts sections in this book as a first source for definitions ofterms, background information on given topics, and summaries of procedures.

    About This Course xix

    in order of increasing proficiency with Oracle8i - Backup and Recovery ; skills

    ics provide the theory you need to master Oracle8i - Backup and Recovery ,

    with the foundation and structure to learn Oracle8i - Backup and Recovery quickly

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • xx Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Introduction to OracleBackup and Recovery

    OverviewIn this lesson, you will identify the requirements for a backup and recoveryplan. You will take a look at the DBAs role in the backup and recovery ofan Oracle database. You will discuss preparing a backup and recovery planfor your own Oracle databases. Just as important as the backup and recoveryplan, you will also examine the disaster recovery plan.

    ObjectivesIn order to prepare a backup and recovery plan, you will:

    1A Describe the DBAs responsibilities in regards to backup and recov-ery of a database.In this topic, you will learn about the DBAs role in backup and recoveryof an Oracle database. You will learn the elements to consider when cre-ating a backup and recovery plan, how to define a backup strategy, andhow to plan for a disaster.

    1B Define and create a backup strategy for an Oracle database.This topic will teach you how to identify the requirements that make up afunctional database backup and recovery specification.

    1C Demonstrate the need for the creation of a disaster plan.After finishing this topic, you will understand why you should prepare adisaster plan and what the basic tenants of a disaster plan are. You willthen demonstrate those needs and prepare the disaster plan.

    Data Filesnone

    Lesson Time30 Minutes

    LESSON

    1

    Lesson 1: Introduction to Oracle Backup and Recovery 1

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Topic 1ABackup and Recovery AdministrationResponsibilitiesIt is the critical responsibility of a database administrator (DBA) to ensure thatthe databases are: Available for use as often as possible. Recoverable in the event of failure.

    There is probably no more important duty of the DBA than the duty of planningfor failures, and preparing a method of recovering from them in such a way thatthe enterprise data is preserved. Part of this planning includes the execution ofbackups on the database and the testing of those backups to ensure they work. Inplanning a backup and recovery strategy, the DBA also needs to consider thedatabases availability requirements.

    Backup and recovery planning starts at creation. Even as the hardware and infra-structure is being designed and installed, hardware and software redundancyshould be considered. The DBA should be involved in all facets of the design ofthe database, the applications that will use the database, and the related hardwareand software that will comprise the infrastructure. They should also work closelywith management, developers, and other staff members to perform a thoroughanalysis of the various requirements of the enterprise solution.

    TASK 1A-1:Reviewing Backup and Recovery Administration

    1. What is one of the primary duties of the DBA?

    Assure availability and recoverability of the database.

    Topic 1BDefining a Backup StrategyIn defining a complete backup strategy, consider these three requirements: Business Operational Technical

    Business RequirementsThe Business requirements that should be considered include:

    Business Requirements

    2 Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • What is the database recovery requirement in the event of a failure? This isknown as the mean-time-to-recover (MTTR). It is the DBAs responsibility toensure the database is recoverable as quickly as possible. This recovery win-dow is a critical factor in the creation of the database backup and recoveryplan.

    Based on the infrastructure and database options to be used, the DBA shoulddo his best to devise a backup and recovery plan that reduces the mean-time-between-failure (MTBF). This implies that the DBA should consider thedesign of the database and infrastructure and how it will contribute to areduction in the likelihood of outage or failure of a component.

    Also, as the administrator of a database, you need to constantly keep up-to-datewith changing business and technology developments.

    Operational RequirementsThe Operational requirement considerations include questions about the nature ofthe database operations. In this light, the DBA should consider issues such asdatabase availability requirements; if the database is involved in a 24/7 operationor if outage time is allowed for backup and maintenance purposes? Businessrequirements also factor into the operational requirements, because they impactthe choices available in terms of MTTR and the options that can be employed toreduce MTBF. Other operational requirements may include off-site storage ofbackup media and overall documentation of the backup and recovery plan.

    Another operational consideration involves planned database activity. If the data-base is to be updated with great frequency, you might want to tailor the backupsof that database, or its archived redo logs (archived redo logs may be backed upwith greater frequency than the database backup) to coincide with those high vol-ume times. Also, the growth of the database can impact the backup and recoveryplan as time goes on because growth of the database will cause backups to takelonger and longer. Another operational consideration for backup and recovery isthe question of availability of data from another source. It might be easier torecover the data from another source than it will be to recover the data from abackup.

    Technical RequirementsWhen preparing the database backup and recovery plan, the DBA must considersuch technical requirements as physical backups (cold or hot) versus logical back-ups of the database. Other considerations might include the type of hardware thedatabase is running on and if it has the capacity to handle the proposed backupplan. The configuration of the database must be considered, as should the avail-able infrastructure resources. Redundancy, network bandwidth, and hardwarecapabilities also need to be clearly understood by the DBA when studying thetechnical requirements of the backup and recovery plan.

    Mean-Time-To-Recover:Time it will take to recover adatabase in the event of afailure.

    Mean-Time-Between-Failure:The likely period of timebetween failures on a givensystem. This can be reducedby redundancy and otherfactors such as better qualityhardware.

    Operational Requirements

    24/7, meaning 24 hours aday and 7 days a week.

    Technical Requirements

    Lesson 1: Introduction to Oracle Backup and Recovery 3

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • TASK 1B-1:Gathering Backup Strategy Requirements

    1. List the three sets of requirements that should be gathered before creat-ing a backup and recovery plan.

    Business, Operational, and Technical.

    2. What considerations should be included when collecting the Businessrequirements for a backup and recovery plan? What is the maximum acceptable recovery window (mean-time-to-

    recover) for the database in the event of failure? Given the databases physical structure, including hardware, what is the

    mean-time-between-failure? What is the operational requirement of the database? How can you test the backup and recovery strategy?

    3. List some of the Operational requirements for an Oracle database thatshould be considered when creating a backup strategy. The transactional volume of work going on in the database, the volume

    of data in the database, and number of transactions occurring through-out the day and during the backup period.

    What is the nature of the data? Can it be recreated from other sources? How robust do you need your recovery scheme to be? Do you require

    24/7 uptime, or is some outage allowable?

    4. List some of the Technical requirements for an Oracle database thatshould be considered when creating a backup strategy. What Oracle architecture are you using? Physical versus logical backups, and offline (cold) versus online (hot)

    backups. Available disk space for the different backup configurations. Database configuration options.

    Create and Test the Plan, Then Submit to Managementfor ApprovalWith these requirements in mind, the DBA can create the backup and recoveryplan, as well as a disaster recovery plan (disaster recovery will be discussed laterin this lesson). Once the backup and recovery plan has been created, it must betested. The testing of the backup and recovery plan is the only way to validatethat it meets the business requirements, in particular the MTTR. Especially withnew systems, factors such as software interaction, vendor support, and enterpriseexpertise can be critical factors in an efficient recovery from a failure.

    Having tested the plan and confirmed that it meets the various requirements ofthe enterprise, the DBA should present the plan to management for final approval.

    4 Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Topic 1CPlanning for Disaster RecoveryDisasters are events that no one thinks will really happen to them until they do.People who live in places where disasters regularly occur, generally believe indisaster recovery planning or they move elsewhere. Dont discount a dis-gruntled employee as a potential disaster either. Make sure that your databasesare secure, and when an employee leaves, make sure that all the access thatemployee had is terminated. As a DBA, it is your responsibility to consider andprepare for any possibility.

    So, whats involved in disaster recovery planning? First, management must acceptthe likelihood of disaster and be behind the disaster recovery planning process. Aplan should be developed that carefully analyzes the potential disasters and howto deal with them. Issues such as off-site storage of database backups, personnelcontact in the event of off-hours emergencies, personnel safety, and hardwarerecovery and procurement should be dealt with before the disaster occurs.

    SummaryBackup and recovery is not something that just happens. It is clear that ittakes a great deal of planning and careful consideration. Implementation of abackup and recovery plan should consider the whole Enterprises needs.This consideration includes study of such questions as: how long can anoutage be if you need to recover? and what data do you actually need torecover? Disaster recovery is an often overlooked, but critical element in thebackup and recovery plan. In the day of e-commerce, systems and data aremore critical than ever. It is the DBAs responsibility to respond to theseneeds and insure that the company is made aware of these critical issues.

    Lesson Review1A True or False: A primary duty of the DBA is to ensure the database is

    available and recoverable.

    True.

    What is the purpose of creating a backup and recovery strategy?

    To protect the database from failure, to increase availability, to reduce thelikelihood of failure.

    1B What is one of the principle responsibilities of the DBA?

    Ensuring the database is recoverable and available.

    Lesson 1: Introduction to Oracle Backup and Recovery 5

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • What are the three different categories that need to be considered whencreating a backup and recovery plan?

    Business, Operational, and Technical.

    1C Why is disaster recovery planning critical?

    During a disaster, it is much harder to recover operations. Multiple thingscan affect the ability to restart operations. With a plan in place, and alter-nate backup and recovery strategies in place, recovery during a disaster canbe much easier.

    6 Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Oracle RDBMS Backup andRecovery Fundamentals

    OverviewBefore you can put together a backup and recovery plan you need to under-stand the inner workings of an Oracle database. This lesson will prepare youwith the foundation you need to understand Oracle backup and recovery.Specifically you will learn about certain data dictionary views that will beavailable to assist you, the difference between a database and an instance,and the internal and external components of an Oracle database.

    ObjectivesIn order to be prepared to learn about Oracle backup and recovery you will:

    2A Use the data dictionary views to help manage the Oracle databaseand better manage backup and recovery situations.You will learn about many of the Oracle data dictionary views available,and you will learn how to use these views to locate important databaseinformation that can be used for backup and recovery.

    2B Define the internal components of an Oracle database and describetheir functions.You will learn about the internal components of an Oracle database; thiswill include an understanding of the distinction between a database andan instance, and the memory structures used within the database.

    2C List and describe the Oracle processes and their purposes for backupand recovery.You will review the various Oracle processes and the purpose they havein relation to the Oracle database.

    2D Locate and describe the purpose of the external structures of anOracle database.You will review the external structures associated with Oracle includingredo logs, control files, database datafiles, and archived redo logs. Youwill also learn how to find the location of these structures by querying theOracle database.

    2E List the benefits of ARCHIVELOG mode, its additional administra-tive requirements, and how to switch the database in and out ofARCHIVELOG mode.

    Data Filesnone

    Lesson Time3 hours, 30 minutes

    LESSON

    2

    Lesson 2: Oracle RDBMS Backup and Recovery Fundamentals 7

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • You will learn about ARCHIVELOG mode, its benefits, and its additionaladministrative requirements. You will also learn how to switch the data-base between ARCHIVELOG and NOARCHIVELOG mode.

    8 Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Topic 2AOracle Data Dictionary Management ViewsThe data dictionary views provide a great deal of database information to theDBA, including information the DBA will require to perform backup andrecovery.

    The main views that you will be dealing with will fall into two categories: DBA_ views, which also come in ALL_ and USER_ categories. V$ views.Typically, the DBA views contain database object information whereas the V$database views generally contain instance and database statistical information. Touse the various views, query them with a SQL statement as any other Oracletable or view. For example, there is a DBA_DATA_FILES view that provides agreat deal of information on database datafiles. To query this view, issue the fol-lowing SQL command:SELECT file_name, file_id, tablespace_nameFROM dba_data_files;

    Figure 2-1: The DBA_DATA_FILES view.

    This view, and many other views will be discussed throughout this course. If youneed a reference showing all of the views available to the DBA, use the Oracle8iReference Guide . It contains a list of all the administrative views, and whatinformation they provide.

    TASK 2A-1:Oracle Data Dictionary Views

    Objective: To issue and view a query from both the V$ and DBA_ views.1. Log in to SQL*Plus as SYSTEM/manager as sysdba.

    The DBA_DATA_FILES view

    Notice the le_name, theassociated le_id, and thetablespace_name in thisexample.

    Lesson 2: Oracle RDBMS Backup and Recovery Fundamentals 9

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • 2. Now that you are connected to the database, query a data dictionary table soyou can familiarize yourself with the process. First, query at the v$databaseview. At the SQL*Plus prompt, issue the following command:SELECT * FROM v$database;

    When you queried the v$database view, what did you see?The name of the database, when the database was created, and other gen-eral database information.

    3. Look at another data dictionary table. First, format your output by issuingthe following command: SET lines 132 and then issue the command:SELECT username, account_status,TO_CHAR(created, 'mm/dd/yyyy hh24:mi:ss')FROM dba_users;

    What did you see when you queried the dba_users view?

    Information about database users.4. Exit from SQL*Plus.

    10 Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Topic 2BOracle Internals Fundamental ConceptsCommonly, people new to Oracle mistakenly think an instance and a database areone and the same. Which is not the case. An Oracle instance is a collection ofprocesses and memory that is required to run the Oracle product. When you issuea STARTUP NOMOUNT command to Oracle, you are starting the instance. AnOracle database, in its simplest form, is the collection of data dictionary tablesand related application tables, indexes, and other objects. Also, a database couldbe considered to be the collection of physical datafiles that comprise the instancethat is mounted and opened by an Oracle instance. One way to describe the dif-ference between an instance and a database is this: the database contains theactual data; the instance facilitates the addition, change, removal, and extractionof that data.

    TASK 2B-1:Understanding the Database and the Instance

    1. What is the difference between an instance and a database in Oracle?

    An instance is the collection of Oracle processes and memory. A database isthe collection of datafiles that is mounted and opened by the instance. Thedatabase contains the actual data; the instance facilitates the addition andextraction of that data.

    2. List the parts of the database that are part of the instance.

    a. Oracle processes

    b. Allocated memory

    c. System tablespace datafile

    d. Redo logs

    Starting the DatabaseThe process of starting and stopping the Oracle database involves three differentstages:

    Instance:Collection of Oracleprocesses and systemmemory allocated to theinstance.

    Database:A collection of datadictionary tables and relatedapplication tables, indexes,and other objects.

    Lesson 2: Oracle RDBMS Backup and Recovery Fundamentals 11

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • 1. nomount2. mount3. open

    Figure 2-2 displays each phase of startup and what occurs during that phase.

    Figure 2-2: The three stages in starting a database.

    Nomount:First of three stages the

    database goes through onstartup and shutdown. It is in

    this stage that the init.oraparameter le is opened andthe control le locations are

    determined. The SGA isallocated and the instance is

    started.

    Mount:Second of three stages thedatabase goes through on

    startup and shutdown. In thisstage, the control les areopened and the redo loglocations are determined.Also, the database datale

    locations are determined butthey are not opened. The

    instance is mounted at thisstage, but the database is not

    opened.

    Open:Final of three stages the

    database goes through onstartup and shutdown. Theonline redo logs and the

    database datales are openedduring this stage. Instance

    recovery is applied ifrequired, and the database isopened for use. The database

    can also be opened forrestricted use, by enabling a

    restricted session.

    Starting a Database

    12 Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Nomount StageThe nomount stage is the first stage of opening the database. As Oracle movesthrough the nomount stage, the init.ora parameter file is read, the control file islocated, the SGA is initialized and the background processes are started. You canforce Oracle into nomount stage only by issuing a STARTUP NOMOUNTcommand. Once the nomount stage is complete, the instance will have started.

    Mount StageThe mount stage is the second stage of opening the database. As Oracle proceedsthrough the mount stage, the control file is opened and read, and the location ofthe online redo logs and datafiles is determined, though the actual presence ofthese files is not checked until the open stage of startup of the Oracle database.Finally, as part of the mount stage, the instance is mounted and an instance ischanged to a database.

    Open StageDuring the open stage the database opens the database datafiles and the onlineredo logs. Oracle will also begin to perform instance recovery at this point,though, recovery with the online redo logs may continue even after the databasehas been opened. Once the open stage has completed, the database will be openfor use. If Oracle is not able to recover the database properly, it may requiremedia recovery. If this is the case, the database will not open. Media recoverywill be discussed later in this course.

    One additional feature of opening a database is that it can be opened inRESTRICTED mode. This mode, enabled by the STARTUP RESTRICT clauseor the ALTER SYSTEM ENABLE RESTRICTED SESSION SQL command,can allow the DBA to open the database, but restrict user access.

    Figure 2-3: A database opening and making it through each of these three stages.

    Shutdown of the Oracle DatabaseWhen the DBA wishes to shutdown the database he can choose from four varia-tions on the SHUTDOWN command. The four options are: SHUTDOWN or SHUTDOWN NORMAL

    SHUTDOWN TRANSACTIONAL

    SHUTDOWN IMMEDIATE

    SHUTDOWN ABORT

    init.ora:Parameter le used to deneOracle memory, directory,and functional settings.

    Control File:Database le that stores thedatabases physical andstatus information.

    System (or Shared)Global Area (SGA):Area of shared memoryallocated by an Oracleinstance for use by theOracle database.

    Online Redo Logs:Database les that contain arecord of all databasechanges that are used fordatabase recovery. These arethe source for archived redologs.

    SHUTDOWN andSHUTDOWN NORMAL aresynonymous terms. Throughthis course we will use theterm SHUTDOWN to refer toboth operations.

    Lesson 2: Oracle RDBMS Backup and Recovery Fundamentals 13

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Depending on which shutdown option the DBA selects, Oracle will go through atleast one of three shutdown steps. You will note as you look at these three stepsthat they are very much like the reverse of the steps used when opening thedatabase. The three stages include:1. Database Close2. Dismount3. Instance Shutdown

    When shutting down a database, Oracle stops all user access to the database. Themethod Oracle uses to stop user access depends on the SHUTDOWN option theDBA selects. If the DBA selects the SHUTDOWN option, Oracle will prevent otherusers from signing in and will wait for all Oracle users to sign-off the databasebefore beginning the shutdown process.

    As with SHUTDOWN, when SHUTDOWN TRANSACTIONAL is issued, Oracle willdeny all new connection requests. However, with SHUTDOWNTRANSACTIONAL, Oracle will wait for any running transactions to complete,then will automatically disconnect the user sessions and shut down the database.This is considered a safe method of shutting down the database, without havingto wait for users to disconnect voluntarily. Any users that are disconnected willreceive an error if they try to execute another transaction, but any currently run-ning transactions are allowed to complete. This shutdown mode is slightly morerude than SHUTDOWN because users are disconnected immediately withoutwarning.

    With the SHUTDOWN IMMEDIATE command, Oracle will not wait for users todisconnect from the database and will log them off forcibly. The users transac-tions will be rolled back and a normal shutdown process will proceed. Thisshutdown mode is similar to SHUTDOWN TRANSACTIONAL. The only differenceis that transactions are rolled back instead of allowed to complete. WhileSHUTDOWN IMMEDIATE may be considered somewhat rude, it is actually themost widely used of the shutdown modes.

    The SHUTDOWN ABORT command is the command of last resort. When used, theOracle instance is terminated with no graceful shutdown at all. The SHUTDOWNABORT basically is a crash of all the Oracle processes. If you issue aSHUTDOWN ABORT, none of the three stages of shutdown occurs; therefore,nothing is shutdown normally. After a SHUTDOWN ABORT, the database willhave to perform instance recovery, at a minimum. While a SHUTDOWN ABORTcan be unavoidable at times, it should be only used as a shutdown of last resort.

    As the database close stage proceeds as a result of a SHUTDOWN or SHUTDOWNIMMEDIATE command, the database buffer cache and the redo log buffer areflushed. The control file and the database datafiles are synchronized through acheckpoint. As the close stage progresses, the stop SCN is recorded in the controlfile and the database instance lock is released.

    As Oracle proceeds through the dismount and instance shutdown stages, the con-trol files are closed, and the instance is stopped at which point the database isshutdown.

    Close:First of three stages of a

    normal database shutdown.During the close process, a

    checkpoint occurs. Thedatabase datales and the

    control les aresynchronized, and the stop

    SCN is written to the controlle.

    Dismount:Second of three stages of anormal database shutdown.The control les are closed.

    Instance Shutdown:Third and nal stage of a

    normal database shutdown.The instance is shutdown,memory is deallocated andthe instance processes are

    shutdown normally.

    Database Buffer Cache:A memory structure in the

    SGA used to store andmanipulate blocks of data

    from the database datales.

    Redo log buffer:A memory structure in the

    SGA used to buffer redo forthe LGWR process.

    14 Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Figure 2-4: An Oracle database after having been shutdown.

    TASK 2B-2:Understanding the Startup and Shutdown Process

    1. Which shutdown command would you use if you want to shutdown anOracle database and wait for users to disconnect from the database?

    SHUTDOWN

    Which shutdown option would you use if the database appears to have aserious problem and will not shutdown normally?

    SHUTDOWN ABORT

    2. The three stages the instance/database goes through during startup arecalled Nomount, Mount, and Open.

    3. Sign on to SQL*Plus as SYSTEM/manager as sysdba.

    4. At the SQL*Plus prompt, issue the SHUTDOWN ABORT command to shut-down the database. The database will report that it has shutdown.

    5. Issue the STARTUP command. This will cause the database to start backup. Understand that since you did a SHUTDOWN ABORT in the previousstep, the database will need to do instance recovery. Fortunately this is auto-matic and the database doesnt show that its performing instance recovery.

    6. Now do an orderly shutdown. Issue the SHUTDOWN IMMEDIATEcommand. Again, the database will shutdown. This time it will be anorderly shutdown and no instance recovery will be required when yourestart.

    7. Start the database back up by issuing the STARTUP command.

    8. Exit from SQL*Plus.

    Instance and Media RecoveryThere are two primary types of recovery that occur in an Oracle database; theseare:

    Lesson 2: Oracle RDBMS Backup and Recovery Fundamentals 15

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Instance recovery Media recovery

    Instance recovery is automatic and occurs when you start the database after a pre-vious crash caused by software or hardware failure, or a SHUTDOWN ABORT.Instance recovery occurs after Oracle mounts the database, and can continue evenbeyond the opening of the instance. During instance recovery, Oracle will applythe online redo logs to update the database. Any uncommitted database transac-tions are rolled back after all of the redo is applied.

    If recovery requires redo that is not available in the current online redo logs (forexample, in the case where a database datafile is being recovered), then mediarecovery is required. Media recovery requires manual interaction. Generally, whenstarting the Oracle instance, if the database requires media recovery, an error willappear after the mount stage of starting the database (it is possible that errors willbe generated before the end of the mount stage in cases where the init.ora or thecontrol file have been lost). Once the DBA instructs Oracle to perform mediarecovery, Oracle will apply the archived redo logs, to complete recovery of theinstance. There are options other than complete recovery available when doingmedia recovery, which will be covered in more detail later in this course.

    TASK 2B-3:Oracle Recovery Types

    1. True or False: Media recovery is automatic when the Oracle instance isstarted.

    False, media recovery is started manually by the DBA.

    2. What can cause Oracle to require instance recovery?

    Database crash, software failure, or SHUTDOWN ABORT.3. Media recovery requires application of archived redo logs.

    4. What is the purpose of redo?

    It is used to reconstruct changes to the database during recovery.

    Memory and Internal Structures in OracleThe primary Oracle memory structure is the SGA. The SGA is an area of sharedmemory that is used by the Oracle processes to store a variety of information.The SGA is primarily divided into three required memory allocations and someoptional memory areas. These allocations and their purposes are: Database buffer cache Storage location of data blocks from database

    datafiles. These datafile blocks are read into the database buffer cache byuser processes. These blocks are used by user processes to insert, update ordelete data in the Oracle database. The DBWR process then will write theseblocks back out to the database datafiles at prescribed times. The size of thedatabase buffer cache is determined by calculating the product of the data-

    Instance Recovery:Automatic recovery of an

    Oracle instance following asoftware or hardware failure,or a SHUTDOWN ABORT. Aninstance recovery does notrequire DBA intervention.

    Media Recovery:Manual recovery of a

    database that is required ifthe online redo logs cannotbe used to make the Oracle

    database datales consistent.

    Transaction:Dened as a unit of work

    beginning with the rst SQLstatement (at sign-on, or

    since a commit) andconsisting of one or more

    SQL statements lasting untila commit (implied or

    commanded) or a rollback.Generally a transaction is

    committed or rolled back asa group.

    Redo (Redo Entry):Also known as a redo record.

    It is a group of changevectors that describe a singleatomic change made to thedatabase. This data is used

    to reconstruct changes madeto the database during

    recovery.

    16 Oracle8i - Backup and Recovery Strategies

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • base block size, determined by the db_block_size init.ora parameter andthe db_block_buffers init.ora parameter.

    Redo log buffer Buffer for redo entries to be written to the redo logs bythe LGWR process. This memory structure is sized by the Oracle init.oraparameter log_buffer.

    Shared pool A collection of memory structures including the data dictio-nary cache and the library cache. It is in these structures that data dictionaryinformation is cached and user SQL code is parsed. This parameter is sizedusing the shared_pool_size in the Oracle init.ora parameter file.

    Java pool A new structure in the SGA added in Oracle8i that is associatedwith Java in Oracle. The Java pool is an optional part of the Oracle SGAand can be disabled by setting the init.ora parameter java_pool_size to0. The Java pool is sized to 20m by default.

    Large pool A new structure in the SGA added in Oracle8. This memorystructure is used by RMAN for backup and recovery purposes, and otherdatabase processes such as multi-threaded server. The large pool is a derivedvalue by default, and is set via the large_pool_size init.ora parameter.

    You can see the current allocations of the SGA by issuing the SHOW SGAcommand. This command will display the various memory allocations to theSGA.

    Figure 2-5: The SHOW SGA command.

    Rollback segments are another internal structure in the Oracle database. These arecreated by the DBA when the database is created. The rollback segments are seg-ments that consist of extents and are created with the CREATE ROLLBACKSEGMENT statement.

    Rollback segments are used to store the before image of any changed and uncom-mitted block. They provide the means with which Oracle can provide a consistentview of the database. When a query is executed and a block is needed that hasbeen changed but not committed, Oracle will find the previous image of thatblock in a rollback segment assigned to that block. There, Oracle can find theconsistent image of that block before the change was made and present thatimage to the user issuing the query. Once the change in the block is committed,Oracle will release the rollback segment entry, as it is technically no longerneeded (though other transactions that are running may still need that rollbacksegment block). Rollback segments are critical during instance and media recov-ery because they are used to store consistent images of uncommitted changesduring the roll forward process; these images are used to roll back any changesduring the rollback portion of instance or media recovery.

    Redo Log Buffer:Area of memory that is partof the Oracle SGA. Containsbuffered redo entries waitingfor LGWR to process them.

    Shared Pool:Area of shared memory thatcontains several structuresincluding the library cachethat is used to store SQL andPL/SQL code, and the datadictionary cache that is usedto cache data dictionaryobjects.

    Large pool:Area of shared memory inthe SGA that is used byRMAN for backup andrecovery. It is also used byother Oracle processes suchas multi-threaded server andDBWR I/O-slaves (both ofwhich are beyond the scopeof this course).

    Rollback Segment:Oracle segments used tostore the before image ofany changed anduncommitted block.

    Lesson 2: Oracle RDBMS Backup and Recovery Fundamentals 17

    DO N

    OT D

    UPLIC

    ATE

    Inst

    ruct

    or E

    dition

  • Another internal Oracle database structure particularly pertinent to backup andrecovery is the System Change Number (SCN). The SCN is an internal timestamp that Oracle uses to define a committed version of the database at a givenpoint. Every committed transaction (and sometimes groups of transactions,depending on volume) is assigned an SCN that is unique to that transaction. As auser makes changes to a database, he does so as part of a transaction. That trans-action is complete when the user commits the work, executes some form of DataDefinition Language (DDL) that does an implied commit such as a CREATETABLE statement (or any DDL), or if the user rolls back the transaction with theROLLBACK command. Once Oracle has returned from the commit command, thetransaction is guaranteed to be recoverable if you need to recover the database.

    The SCN can be seen somewhat like Oracles internal clock, but it is not a clockin the truest sense of the word because there is no relationship between the SCNassigned and the actual time. Oracle uses the SCN to ensure consistency of thedatabase and to perform recovery when required. SCNs and their impacts forrecovery will be discussed in much more detail throughout this course.

    TASK 2B-4:Understanding Oracle Memory and Internal Structures

    1. Name the three required structures of the SGA.

    Database buffer cache, redo log buffer, and shared pool.2. True or False: The database buffer cache is a configurable memory

    structure in Oracle.

    True. The database buffer cache size is defined in the init.ora of thedatabase.

    3. True or False: The large pool can, optionally, have uses during backupand recovery.

    True. The large pool can be used by RMAN during backup and restoreoperations.

    4. Which memory structure in the SGA is used to store database datablocks?

    The database buffer cache.5. Which memory structure in the SGA is used to buffer output to the redo

    logs?

    The redo log buffer.6. What is the purpose of the system change number?

    The system change number is used to define the state of a committed Oracledatabase at a given point.

    System Change Number(SCN):

    Oracle int