ChapterOnRMAN

94
Covers Oracle 10g Releases 1 and 2 Learn to install the right software and create databases, users, and objects Learn to use Partitioning, Job Scheduling, SSL, ASM, RMAN, and advanced features Go inside the Windows Registry, Services, and UNIX file permissions Oracle Database 10g From Nuts to Soup First Edition (Build 030) Written by Mark Johnson Owner and Principal Database Engineer Remington Database Solutions, LLC

Transcript of ChapterOnRMAN

Page 1: ChapterOnRMAN

Covers Oracle 10g Releases 1 and 2

Learn to install the right software and create databases, users, and objects

Learn to use Partitioning, Job Scheduling, SSL, ASM, RMAN, and advanced features

Go inside the Windows Registry, Services, and UNIX file permissions

Oracle Database 10g From Nuts to Soup

First Edition (Build 030)

Written by Mark Johnson Owner and Principal Database Engineer Remington Database Solutions, LLC

Page 2: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup

First Edition

Mark Johnson Owner and Principal Database Engineer

Remington Database Solutions, LLC

Page 3: ChapterOnRMAN

Published By:

Remington Database Solutions, LLC Mark Johnson, Owner 21397 Fitzgerald Drive, Ashburn, VA 20147-5814, U.S.A. http://www.RemiData.com/

Orders: Orders may be placed on-line at the Publisher’s URL, which is listed above. Volume discounts are available to employers purchasing copies for their employees, and to libraries; volume discounts are not available to individuals.

Feedback: Errors and omissions can be submitted to The Publisher via email at [email protected]. The Publisher does not offer compensation for submissions. All submissions become property of the publisher. Submissions may be used or discarded without notice to or recognition of the submitting party.

Registration

Persons and organizations are asked to register when purchasing this book. Registration requires a valid email address. Notices of free updates and error corrections will only be sent to registered customers; notices and error corrections will not posted on The Publisher’s web site.

Privacy Customer information is kept private. It is never, sold, distributed, or shared. Sales information is kept for 30 days to support billing. Non-sales customer data, such as email addresses, are kept indefinitely by the Publisher and are used exclusively by the Publisher. For example, to notify customers of updates and error corrections.

Legal Notices Copyright © 2006 by Mark Johnson. All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system, without written permission from The Publisher, except for the inclusion of brief quotations in a review. This book may not be sold in part of whole without express written permission from The Publisher. All trademarks used herein remain the property of their original owners.

Contacting the Author If you would like to arrange for the Author to assist with Oracle activities at your organization, you may do so at the publisher’s address noted above. Mr. Johnson offers a range of services including: consulting, studies, database engineering, PL/SQL programming, and Oracle administration.

Page 4: ChapterOnRMAN

This book is dedicated to the memory of the students and faculty of Virginia Tech whose lives were lost on April 16, 2007. And In loving memory of my mother-in-law, Dr. Margaret S. Murray, “Mimi”.

Page 5: ChapterOnRMAN
Page 6: ChapterOnRMAN

Table of Contents

Table of Contents Chapter 1: Introductions................................................................................................ 47

About this Book ........................................................................................................ 48 About the Title .......................................................................................................... 48 Covered Versions of Oracle....................................................................................... 49 Audience................................................................................................................... 49 Organization.............................................................................................................. 49 Disclaimers ............................................................................................................... 50 About the Author ...................................................................................................... 50

Chapter 2: What Is a Database....................................................................................... 51

Database Defined ...................................................................................................... 52 Goals of Databases .................................................................................................... 52

Data Independence ................................................................................................ 53 Minimize Redundancy........................................................................................... 53 Remove Programmer Ownership ........................................................................... 54

History of Databases ................................................................................................. 54 Types of Databases.................................................................................................... 56

Hierarchical........................................................................................................... 56 Network ................................................................................................................ 56 Relational .............................................................................................................. 56 Object-Oriented..................................................................................................... 57 Object-Relational .................................................................................................. 58

E. F. Codd’s 12 Rules for Relational Data Bases ....................................................... 59 Rule 0: Unnamed Rule ......................................................................................... 60 Rule 1: The Information Rule ................................................................................ 60 Rule 2: Guaranteed Access Rule............................................................................ 60 Rule 3: Systematic Treatment of Null Values ........................................................ 60 Rule 4: Dynamic On-Line Catalog Based on the Relational Model ........................ 61 Rule 5: Comprehensive Data Sub-language Rule ................................................... 61 Rule 6: View Updating Rule.................................................................................. 61 Rule 7: High-level Insert, Update, and Delete........................................................ 61 Rule 8: Physical Data Independence ...................................................................... 61 Rule 9: Logical Data Independence ....................................................................... 61 Rule 10: Integrity Independence ............................................................................ 62 Rule 11: Distribution Independence....................................................................... 62 Rule 12: Non-Subversion Rule .............................................................................. 62

Normalization and Normal Forms ............................................................................. 62 First Normal Form (1NF) ...................................................................................... 63 Second Normal Form (2NF) .................................................................................. 63 Third Normal Form (3NF) ..................................................................................... 63 Boyce-Codd (BCNF)............................................................................................. 63 Fourth Normal Form (4NF) ................................................................................... 63 Fifth Normal Form (5NF) ...................................................................................... 64

Page 7: ChapterOnRMAN

Table of Contents

Types of Database Objects ........................................................................................ 64 Tables and Columns .............................................................................................. 64

Creating Tables ................................................................................................. 65 Altering Tables .................................................................................................. 66 Rows Represent Data......................................................................................... 67 About Table Segments....................................................................................... 67 About Extents.................................................................................................... 68

External Tables...................................................................................................... 70 Creating External Tables ................................................................................... 70 Describing External Tables................................................................................ 71 Finding External Tables..................................................................................... 71

Index-Organized Tables (IOT)............................................................................... 72 The INCLUDING and OVERFLOW Clauses.................................................... 73 IOT Mapping Tables ......................................................................................... 75 IOT Dictionary Views ....................................................................................... 75

Keys and Constraints............................................................................................. 76 Primary Key Constraints.................................................................................... 76 Foreign Key Constraints .................................................................................... 78 Unique Key Constraints..................................................................................... 79 Not Null Constraints.......................................................................................... 80 Check Constraints.............................................................................................. 80

Indexes.................................................................................................................. 81 Triggers................................................................................................................. 82

Creating Triggers On The Fly ............................................................................ 83 Triggers on Views ............................................................................................. 84 Triggers on Schemas ......................................................................................... 84 Triggers at the Database Level........................................................................... 85 A Problem with Timestamps.............................................................................. 86

Sequence Generators ............................................................................................. 86 Replication Notes for Sequences........................................................................ 88 RAC Notes for Sequences ................................................................................. 89

Synonyms.............................................................................................................. 90 Public Synonyms............................................................................................... 90

Views .................................................................................................................... 92 Permissions for Views ....................................................................................... 93

Packages, Procedures, and Functions..................................................................... 94 Database Links ...................................................................................................... 95

Creating Database Links .................................................................................... 96 Using Database Links ........................................................................................ 97 Make DB Links “Neat” with Synonyms............................................................. 97 Using Database Links for Streams Replication .................................................. 98 Database Link Pitfalls........................................................................................ 98

Database Languages and Command Types ................................................................ 98 Data Modeling and Database Design ....................................................................... 100

Terminology and Concepts.................................................................................. 101

Page 8: ChapterOnRMAN

Table of Contents

Entity Types .................................................................................................... 101 Entities ............................................................................................................ 101

Supertype Entities........................................................................................ 101 Parent and Child Entities ............................................................................. 101 Associative Entity Types ............................................................................. 102 Entity Instances ........................................................................................... 103

Attributes......................................................................................................... 103 Identifiers & Keys ....................................................................................... 103

Optionality ...................................................................................................... 104 Cardinality....................................................................................................... 104 Relationships ................................................................................................... 105 Normalization.................................................................................................. 106 CASE .............................................................................................................. 107 CRUD ............................................................................................................. 107

Data Modeling and Database Design Tasks ......................................................... 108 Phases ............................................................................................................. 108 Activities ......................................................................................................... 109 Breakdown of Phases and Activities ................................................................ 109

The Conceptual Data Modeling (CDM) Phase ............................................. 109 The Logical Data Modeling (LDM) Phase ................................................... 111 The Physical Data Modeling (PDM) Phase .................................................. 113 The Logical Database Design (LDD) Phase ................................................. 117 The Physical Database Design (PDD) Phase ................................................ 120

Units of Measure ..................................................................................................... 122 The Legacy Standard........................................................................................... 123 The New Standard............................................................................................... 124

Chapter 3: What is Oracle ........................................................................................... 126 Oracle Trivia ....................................................................................................... 126

Oracle, The Company.............................................................................................. 127 The Link Between Oracle and IBM System R ..................................................... 128 Oracle Trivia ....................................................................................................... 129

Oracle, The ORDBMS ............................................................................................ 130 Oracle Version 1.................................................................................................. 130 Oracle Version 2.................................................................................................. 130 Oracle Version 3.................................................................................................. 131 Oracle Version 4.................................................................................................. 131 Oracle Version 5.................................................................................................. 131 Oracle Version 6.................................................................................................. 131 Oracle Version 7.................................................................................................. 131 Oracle Version 8.................................................................................................. 131 Oracle Version 9.................................................................................................. 132 Oracle Version 10................................................................................................ 132 Oracle Version 11................................................................................................ 133

Oracle’s Competition .............................................................................................. 133 Summary of Differences...................................................................................... 133

Page 9: ChapterOnRMAN

Table of Contents

A Quick Story about Product Selection............................................................ 135 SQL Server 2000 Enterprise Edition.................................................................... 135

Scalability and Licensing................................................................................. 136 Physical Characteristics ................................................................................... 137 Logical Characteristics .................................................................................... 140

Sybase ASE 12.5................................................................................................. 141 PostgreSQL......................................................................................................... 143

Chapter 4: The Oracle Database Administrator............................................................ 145

What Do DBAs Do ................................................................................................. 146 The Times Are a Changing...................................................................................... 146 Optional / Preliminary Duties of a DBA .................................................................. 146

Identify Hardware and Operating System Requirements. ..................................... 146 Configure the Hardware and Operating System ................................................... 147

Basic Duties of the DBA ......................................................................................... 147 Design the Physical Database .............................................................................. 148 Update the Physical Data Model.......................................................................... 148 Define Standards and Naming Conventions ......................................................... 149 Install the Oracle Server Software ....................................................................... 149 Define and Manage Database Security................................................................. 150 Monitor and Tune Database Performance ............................................................ 150 Plan and Implement the Backup and Recovery Plan ............................................ 150 Troubleshooting .................................................................................................. 151 Routine Maintenance........................................................................................... 151

Post-Implementation DBA Duties ........................................................................... 152 Capacity Expansion Planning .............................................................................. 152 Programming Assistance ..................................................................................... 152 Data Analysis ...................................................................................................... 153 Upgrades and Migrations..................................................................................... 153 Documentation .................................................................................................... 154 Evaluate New Software ....................................................................................... 155

Chapter 5: Are You Certified ...................................................................................... 156 The Goal ................................................................................................................. 157 Why Get Certified ................................................................................................... 157 Oracle 10g Certification Requirements.................................................................... 158

10g OCA............................................................................................................. 158 10g OCP.............................................................................................................. 159 10g OCM ............................................................................................................ 160 10g Accreditations............................................................................................... 161

Where to Get Training............................................................................................. 161 Scheduling an Exam................................................................................................ 162 Taking an Exam ...................................................................................................... 163 Compare The Oracle9i and 10g OCP Requirements ................................................ 164 Links to More Information ...................................................................................... 165

Page 10: ChapterOnRMAN

Table of Contents

Chapter 6: Oracle10g New Features ............................................................................ 166 Cross-Platform New Features (No-Cost) ................................................................. 167

Automatic Optimizer Statistics Collection ........................................................... 167 Automatic Shared Memory Management (ASMM) ............................................. 168 Bigfile Tablespaces ............................................................................................. 171 Buffer Cache Flushing......................................................................................... 172 Data Pump Import and Export ............................................................................. 173 Data Types (BINARY_FLOAT and BINARY_DOUBLE).................................. 173 Database Password Encryption (Logins).............................................................. 174 DBMS_CRYPTO................................................................................................ 175 DBMS_OUTPUT Unlimited Output.................................................................... 176 Default User Tablespace...................................................................................... 177 DML Error Logging ............................................................................................ 178

Prerequisites .................................................................................................... 179 Limitations ...................................................................................................... 179 Understanding DBMS_ERRLOG.CREATE_ERROR_LOG............................ 180 Creating an Error Log Table ............................................................................ 181 Using DML Error Logging .............................................................................. 182 Dropping DML Error Log Tables .................................................................... 183

Drop Database Command.................................................................................... 183 External Procedure Scheduling ............................................................................ 184 Feature Usage Tracking....................................................................................... 184 Guaranteed Undo Retention................................................................................. 184 HTML DB........................................................................................................... 186

What is HTML DB.......................................................................................... 186 Oracle HTML DB to Be Renamed Oracle Application Express (APEX).......... 187 Installation Process.......................................................................................... 187 Installation Issues ............................................................................................ 189 URLs for Using and Maintaining HTML DB................................................... 190 Getting Started with HTML DB....................................................................... 191 HTML DB Security Issues............................................................................... 191

Memory Corruption Checking ............................................................................. 192 OEM Database Cloning....................................................................................... 192 OEM MetaLink Integration ................................................................................. 192 OEM Oracle Home Cloning ................................................................................ 193 OEM for Net Configuration................................................................................. 193 Online Segment Shrink........................................................................................ 193 Proactive Tablespace Monitoring......................................................................... 195 Recycle Bin......................................................................................................... 195 Redo Logfile Sizing Advisor ............................................................................... 195 Regular Expressions ............................................................................................ 196 Remote Function Calls ........................................................................................ 197 Rename Tablespace ............................................................................................. 197 Row Timestamp .................................................................................................. 197 Scheduler ............................................................................................................ 198

Page 11: ChapterOnRMAN

Table of Contents

SQL*Plus Proxy User Logins .............................................................................. 199 Tablespace Repositories and File Groups............................................................. 201 Temporary Tablespace Groups ............................................................................ 201 Undo Retention Tuning ....................................................................................... 204 Upgrade Information Tools ................................................................................. 204 User Defined Quoting Characters ........................................................................ 205 Versioned Tablespaces ........................................................................................ 206 VPD Column Level Security ............................................................................... 208

Cross-Platform New Features (Additional Cost)...................................................... 209 Automatic Database Diagnostics Monitor (ADDM) ............................................ 209 Active Session History (ASH) ............................................................................. 212 Automatic Workload Repository (AWR)............................................................. 213 RMAN Encrypted Backups ................................................................................. 213 Segment Advisor ................................................................................................. 214

Identifying Candidates for Online Segment Shrink .......................................... 214 Estimating a Segment’s Future Size................................................................. 214

Transparent Data Encryption (TDE) .................................................................... 214 The Wallet and Master Encryption Key ........................................................... 216 The Encryption Key Table............................................................................... 217 TDE Security Issues ........................................................................................ 217 TDE Replication Issues ................................................................................... 218

Undo Tablespace Sizing Advisor......................................................................... 218 New Features for the Windows Platform ................................................................. 220

Large Page Support ............................................................................................. 220 NUMA Support................................................................................................... 221 Windows Fibers Support ..................................................................................... 221 Oracle Database for 64-Bit Windows................................................................... 222

What is Not Supported under 64-Bit Oracle for Windows................................ 222 Enhancements to Existing Features and Options...................................................... 223

DBCA Support for RAC and ASM...................................................................... 223 Flashback ............................................................................................................ 224 Globalization / Unicode....................................................................................... 224 LOB Sizes ........................................................................................................... 224 ODBC Support For Linux ................................................................................... 225 OEM Configuration Using the OUI ..................................................................... 225 Oracle Net Easy Connect..................................................................................... 225 OUI..................................................................................................................... 226 Partitioning Enhancements .................................................................................. 226 RMAN Block Change Tracking........................................................................... 226 RMAN Compressed Backups .............................................................................. 227 Streams Improvements ........................................................................................ 228 VPD Support for Parallel Queries........................................................................ 228 VPD Static Security Polices................................................................................. 229

What 10g Lacks ...................................................................................................... 229 Larger VARCHAR2 Columns ............................................................................. 229

Page 12: ChapterOnRMAN

Table of Contents

Longer Object Names.......................................................................................... 230 An Easy Way to Switch Between Oracle Homes ................................................. 230 A Better Installer and a Fool Proof Un-Installer ................................................... 231 Replicable Sequence Generators.......................................................................... 231

Chapter 7: Oracle Server Software .............................................................................. 233 A Quick Heads Up .................................................................................................. 234 Which Edition of Oracle Should You Use?.............................................................. 234

Enterprise Edition................................................................................................ 234 Standard Edition.................................................................................................. 234 Standard Edition One .......................................................................................... 235 Personal Edition .................................................................................................. 235 Lite Edition ......................................................................................................... 235 Express Edition (XE)........................................................................................... 235

Which Version of Oracle Should You Use .............................................................. 238 About Release Numbers ...................................................................................... 239

Descriptions of Core Features and Options .............................................................. 240 Oracle Database 10g............................................................................................ 240 Oracle Real Application Clusters (RAC) ............................................................. 241 Oracle Advanced Security (ASO) ........................................................................ 241 Oracle Partitioning .............................................................................................. 241 Oracle Spatial...................................................................................................... 242 Oracle Label Security .......................................................................................... 242 Oracle OLAP....................................................................................................... 242 Oracle Data Mining Scoring Engine .................................................................... 242 Oracle Net Listener ............................................................................................. 242 Oracle COM Automation Features ...................................................................... 243 Oracle Connection Manager ................................................................................ 243 Oracle Development Kit ...................................................................................... 243 Oracle Enterprise Manager (OEM) 10g Database Control.................................... 243 Oracle Enterprise Manager (OEM) 10g Grid Control........................................... 245 Oracle Transparent Gateways .............................................................................. 246 iSQL*Plus ........................................................................................................... 246

Descriptions of OEM Options ................................................................................. 247 Oracle Configuration Management Pack.............................................................. 247 Oracle Change Management Pack ....................................................................... 247 Oracle Diagnostics Pack ...................................................................................... 247 Oracle Tuning Pack ............................................................................................. 247

Descriptions of Windows-Specific Install Options................................................... 247 Oracle Windows Documentation ......................................................................... 248 Oracle Services for Microsoft Transaction Server (MTS) .................................... 248 Oracle Administration Assistant for Windows ..................................................... 248 Oracle Counters for Windows Performance Monitor ........................................... 249 Oracle Objects for OLE (OO4O) ......................................................................... 250 Oracle ODBC Driver ........................................................................................... 250 Oracle Provider for OLE DB ............................................................................... 250

Page 13: ChapterOnRMAN

Table of Contents

Oracle Data Provider for .NET ............................................................................ 250 Descriptions of New 10.2 Software ......................................................................... 251

Oracle Audit Vault .............................................................................................. 251 Oracle Content DB .............................................................................................. 252 Oracle Database Vault ......................................................................................... 253

Overview......................................................................................................... 253 Components .................................................................................................... 254 Requirements................................................................................................... 255 Installation....................................................................................................... 256 Administration................................................................................................. 256

Oracle Records DB.............................................................................................. 256 Oracle Secure Backup ......................................................................................... 257 Oracle Secure Enterprise Search (SES)................................................................ 258 Oracle TimesTen In-Memory Database ............................................................... 259

Installing Oracle10g Server ..................................................................................... 260 Get Your Stuff Together...................................................................................... 261 What You Should Know Before You Begin the Installation................................. 261 Pre-Installation Steps........................................................................................... 262 Known Issues Installing 10g................................................................................ 262 Launching the Oracle Universal Installer ............................................................. 263 Step-by-Step Instructions..................................................................................... 264 Full Install: an Example....................................................................................... 272

Post Installation Tasks............................................................................................. 276 Task 1: Install Java Native Compiler (NCOMP) .................................................. 276 Task 2: Install the Latest Patchset ........................................................................ 276 Task 3: Get the Latest Security Patches ............................................................... 279 Task 4: Defrag Your Disks .................................................................................. 280 Task 5: Backup the Server ................................................................................... 281

Un-Installing Oracle Server ..................................................................................... 281 About Silent Installs ................................................................................................ 283 Installing Oracle 10g Express Edition (XE) ............................................................. 284

Chapter 8: Oracle Client Software............................................................................... 291

What Software Constitutes Oracle Client................................................................. 292 Three Enterprise Manager Clients?.......................................................................... 293 Client Installation Packages..................................................................................... 294

Instant Client ....................................................................................................... 294 Administrator ...................................................................................................... 295 Runtime............................................................................................................... 295 Custom................................................................................................................ 296

What Files Need To Be Stored on the Client ........................................................... 297 What Does “Client” Mean, Anyways ...................................................................... 297

A Progression of Client-Server Models................................................................ 297 Thin-Client or Fat................................................................................................ 299

Installing Oracle10g Client...................................................................................... 299 Which CD ........................................................................................................... 299

Page 14: ChapterOnRMAN

Table of Contents

Who Should Install Software ............................................................................... 300 Step-By-Step Instructions .................................................................................... 300

Getting Patches and Critical Updates....................................................................... 307 Un-Installing Oracle Client...................................................................................... 308 Mixing Versions of Oracle Client and Server .......................................................... 310 About Silent Installs ................................................................................................ 310

Chapter 9: Owning Multiple Oracle Homes................................................................. 311 What is an Oracle Home.......................................................................................... 312 What is Multi-Home Oracle .................................................................................... 312 Do Not Mix Software in an Oracle Home................................................................ 313 Why Switch Between Oracle Homes ....................................................................... 313 How To Switch Between Oracle Homes.................................................................. 314

Chapter 10: Understanding System Requirements ....................................................... 317 Do You Need a Server Operating System? .............................................................. 318

Which Windows Operating Systems are Certified to Run Oracle Server .............. 318 About UNIX Operating System Requirements..................................................... 319

System Requirements: How Low Can You Go? ...................................................... 321 Recommended Minimum Hardware ........................................................................ 322

CPU .................................................................................................................... 322 RAM ................................................................................................................... 322 Video .................................................................................................................. 322 Hard Disk............................................................................................................ 323 RAID .................................................................................................................. 323 Other Storage Devices ......................................................................................... 324

Production Minimums............................................................................................. 324 CPU .................................................................................................................... 324 RAM ................................................................................................................... 325 Video .................................................................................................................. 326 Hard Disk............................................................................................................ 326 RAID Considerations .......................................................................................... 327

Living Large - How Big Can I Make My Server? .................................................... 327 RAC Factors ........................................................................................................... 328

Chapter 11: The Oracle Server Architecture ................................................................ 330 Additional ASM Background Processes .................................................................. 330

ASMB..................................................................... Error! Bookmark not defined. ARBn...................................................................... Error! Bookmark not defined. RBAL...................................................................... Error! Bookmark not defined.

Additional File Mapping Processes ......................................................................... 331 FMON..................................................................... Error! Bookmark not defined. FMPUTL................................................................. Error! Bookmark not defined.

The Big Picture ....................................................................................................... 334 Instances and Services............................................................................................. 335 Memory Structures.................................................................................................. 336

Page 15: ChapterOnRMAN

Table of Contents

Granule ............................................................................................................... 336 System Global Area (SGA) Structures................................................................. 338

Database Buffer Cache .................................................................................... 338 Buffer Pools ................................................................................................ 340 The Hit Ratio ............................................................................................... 340

Various nK Buffer Cache................................................................................. 341 Flashback Buffer ............................................................................................. 343 Java Pool ......................................................................................................... 345 Large Pool....................................................................................................... 345 Oracle Storage Management (OSM) Buffer ..................................................... 347 Redo Log Buffer Cache ................................................................................... 347 Shared Pool ..................................................................................................... 348

The Data Dictionary Cache.......................................................................... 348 The Library Cache ....................................................................................... 349 Flashback Database Buffer .......................................................................... 349 Active Session History Buffer...................................................................... 350 Fixed Area................................................................................................... 350 Shared Pool Sizing and Tuning .................................................................... 350

Streams Pool.................................................................................................... 352 Program Global Area (PGA) Structures............................................................... 352

The Stack Space Area...................................................................................... 353 The User Session Data Area ............................................................................ 353 The Cursor State Area ..................................................................................... 353 The Sort Area .................................................................................................. 354

Allocating Memory to SGA and PGA Components ............................................. 354 Background Processes ............................................................................................. 356

The Mandatory Background Processes ................................................................ 356 When Do Background Processes Start ................................................................. 357 SMON................................................................................................................. 358 PMON................................................................................................................. 358 DBWn................................................................................................................. 359 CKPT .................................................................................................................. 360 LGWR ................................................................................................................ 360 ARCn.................................................................................................................. 361 RECO.................................................................................................................. 361 Dnnn ................................................................................................................... 361 Snnn.................................................................................................................... 362 CJQn ................................................................................................................... 362 Jnnn..................................................................................................................... 363 QMNn................................................................................................................. 363 MMAN ............................................................................................................... 363 MMON ............................................................................................................... 364 MMNL................................................................................................................ 365 Pnnn.................................................................................................................... 365 PSPn ................................................................................................................... 365

Page 16: ChapterOnRMAN

Table of Contents

RVWR ................................................................................................................ 365 CTWR................................................................................................................. 366

Additional ASM Background Processes .................................................................. 366 ASMB................................................................................................................. 366 ARBn.................................................................................................................. 366 RBAL.................................................................................................................. 367

Additional Data Pump Background Processes ......................................................... 367 DMnn.................................................................................................................. 367 DWnn.................................................................................................................. 367

Additional File Mapping Processes ......................................................................... 367 FMON................................................................................................................. 368 FMPUTL............................................................................................................. 369

Additional RAC Background Processes................................................................... 369 DIAG .................................................................................................................. 369 LCKn .................................................................................................................. 369 LMON ................................................................................................................ 369 LMD ................................................................................................................... 370 LMSn.................................................................................................................. 370

Additional RAC Foreground Processes ................................................................... 370 GSD .................................................................................................................... 370 GCS .................................................................................................................... 370 GES..................................................................................................................... 370

The Oracle Net Listener Process.............................................................................. 370 Chapter 12: The Oracle Database Files........................................................................ 372

Getting Started ........................................................................................................ 373 Terminology........................................................................................................ 373 The Importance of File Name Suffixes ................................................................ 373 General Restrictions On Database Files ............................................................... 374 RAID .................................................................................................................. 374

Understanding RAID Terminology and Concepts ............................................ 375 What is RAID.............................................................................................. 375 Stripe Width, Stripe Size, and Chunks ......................................................... 375 Concurrency ................................................................................................ 376 Caching ....................................................................................................... 378

Understanding RAID Configurations ............................................................... 379 RAID 0........................................................................................................ 379 RAID 1........................................................................................................ 379 RAID 5........................................................................................................ 380 RAID 0+1.................................................................................................... 382 RAID 1+0 (RAID 10) .................................................................................. 382

Which RAID Is Right ...................................................................................... 383 Multiplexing........................................................................................................ 384

What Is Multiplexing....................................................................................... 384 What Files Can Be Multiplexed ....................................................................... 385 Isolating the Multiplexed Copies of Files......................................................... 385

Page 17: ChapterOnRMAN

Table of Contents

Moving and Renaming Database Files................................................................. 386 Points to Remember......................................................................................... 386 Examples......................................................................................................... 386

Datafiles.................................................................................................................. 387 Purpose ............................................................................................................... 388 Quantity .............................................................................................................. 388 Location and Naming Convention ....................................................................... 389 Size ..................................................................................................................... 390 Storage Considerations ........................................................................................ 392 Backup / Recovery Considerations ...................................................................... 393 Views .................................................................................................................. 394

Undo Files............................................................................................................... 394 Purpose ............................................................................................................... 394 Quantity .............................................................................................................. 395 Location and Naming Convention ....................................................................... 395 Size ..................................................................................................................... 395 Storage Considerations ........................................................................................ 396 Backup / Recovery Considerations ...................................................................... 396 Views .................................................................................................................. 397

Tempfiles ................................................................................................................ 398 Purpose ............................................................................................................... 398 Quantity .............................................................................................................. 398 Location and Naming Convention ....................................................................... 399 Size ..................................................................................................................... 399 Storage Considerations ........................................................................................ 400 Backup / Recovery Considerations ...................................................................... 401 Views .................................................................................................................. 401

Control Files ........................................................................................................... 401 Purpose ............................................................................................................... 402 Quantity .............................................................................................................. 402 Location and Naming Convention ....................................................................... 402 Size ..................................................................................................................... 403 Storage Considerations ........................................................................................ 404 Creating the First Control Files............................................................................ 404 Adding More Control Files.................................................................................. 405 Moving and Renaming Control Files ................................................................... 408 Deleting Control Files ......................................................................................... 409 Backup / Recovery Considerations ...................................................................... 410 Views .................................................................................................................. 411

On-Line Redo Log Files .......................................................................................... 411 Purpose ............................................................................................................... 412 Quantity .............................................................................................................. 413 Location and Naming Convention ....................................................................... 414 Size ..................................................................................................................... 415 Storage Considerations ........................................................................................ 416

Page 18: ChapterOnRMAN

Table of Contents

Backup / Recovery Considerations ...................................................................... 416 Views .................................................................................................................. 417

Archived Redo Log Files......................................................................................... 418 Purpose ............................................................................................................... 419 Quantity .............................................................................................................. 419 Location and Naming Convention ....................................................................... 420 Size ..................................................................................................................... 421 Storage Considerations ........................................................................................ 422 Backup / Recovery Considerations ...................................................................... 423 Retention Considerations..................................................................................... 423

When To Delete Archlogs If Using LogMiner Technologies............................ 424 Views .................................................................................................................. 425

Alert Log................................................................................................................. 426 Export Files............................................................................................................. 428 Export DataPump Files............................................................................................ 428 Flashback Database Log Files ................................................................................. 429 Initialization Parameter File (init.ora)...................................................................... 429 Password File .......................................................................................................... 430 Server Parameter File (SPFILE) .............................................................................. 433 Trace Files .............................................................................................................. 434

Background Process Trace Files .......................................................................... 435 User Process Trace Files...................................................................................... 435 Core Dumps ........................................................................................................ 436

UTL_FILE .............................................................................................................. 436 Specify a File Location using UTL_FILE_DIR ................................................... 437 Specify a File Location using CREATE DIRECTORY........................................ 437

Chapter 13: Oracle Managed Files .............................................................................. 439 What is OMF .......................................................................................................... 440 Configuring Your Database for OMF ...................................................................... 440

Create a SPFILE.................................................................................................. 440 Create OMF Directories ...................................................................................... 440

Understanding What’s New in 10g OMF......................................................... 441 Set the OMF Initialization Parameters ................................................................. 441 Changing the OMF Locations.............................................................................. 442

OMF File Sizes ....................................................................................................... 443 OMF Naming Conventions...................................................................................... 443 Some Examples....................................................................................................... 444

Example 1: Creating a Database ......................................................................... 444 Example 2: Modifying a Tablespace................................................................... 445

Whether or Not to Use Oracle Managed Files.......................................................... 445

Chapter 14: Automatic Storage Management (ASM)................................................... 448 Overview of ASM ................................................................................................... 449 Is There a Trade-Off................................................................................................ 450 Instance Types ........................................................................................................ 450

Page 19: ChapterOnRMAN

Table of Contents

About Disk Groups and Failure Groups................................................................... 451 Do You Need Multiple Disk Groups........................................................................ 452 Mirroring with ASM ............................................................................................... 452 About ASM Instance Failures.................................................................................. 453 Installing ASM........................................................................................................ 453 Creating ASM Instances.......................................................................................... 453

Don’t Cook It ...................................................................................................... 453 Privileges for Creating and Maintaining ASM Instances ...................................... 453 How to Create an ASM Instance.......................................................................... 454

Chapter 15: Oracle Net................................................................................................ 455

Overview of Oracle Net........................................................................................... 456 A Typical Configuration.......................................................................................... 456 The Oracle Listener ................................................................................................. 458

What is the Oracle Listener ................................................................................. 458 Protecting the Oracle Listener.............................................................................. 459 Configuring the Oracle Listener........................................................................... 460 Common Listener Error Messages ....................................................................... 460 What Are Dedicated and Shared Servers.............................................................. 461 Dedicated Server Redirect Connections ............................................................... 462 Dedicated Server Bequeath Connections.............................................................. 462 Shared Server Connections .................................................................................. 462

Configuring Dispatchers .................................................................................. 463 Configuring Shared Servers ............................................................................. 464 When to Use, or Not Use, Oracle Shared Servers............................................. 464

External Procedure Calls ..................................................................................... 466 What is ExtProc............................................................................................... 466 How Do I Get ExtProc..................................................................................... 467 Got Multiple Oracle Homes? ........................................................................... 467 Security Considerations ................................................................................... 468 Configuring the Oracle Listener for ExtProc.................................................... 468 Configuring the TNSNAMES.ORA for ExtProc.............................................. 470

Bequeath Connections ......................................................................................... 471 IPC Connections.................................................................................................. 473

Configuration Files.................................................................................................. 474 Tnsnames.ora and Sqlnet.ora Explained............................................................... 474 Which Tnsnames.ora and Sqlnet.ora Will Oracle Use .......................................... 475 Configuring file Tnsnames.ora ............................................................................ 476

Listener Entries in Tnsnames.ora ..................................................................... 479 IFILE Entries in Tnsnames.ora ........................................................................ 480 Got Heterogeneous Connections? .................................................................... 481 Configuring Oracle Net for Failover ................................................................ 481 Configuring Oracle Net for Load Balancing..................................................... 485

Web Application Load Balancing Tips ........................................................ 486 Configuring File Sqlnet.ora ................................................................................. 487 Configuring File Listener.ora............................................................................... 489

Page 20: ChapterOnRMAN

Table of Contents

What is Listener.ora, and Where is It ............................................................... 489 How to Configure Listener.ora......................................................................... 490 Interpreting Listener.ora .................................................................................. 490 Naming the Listener ........................................................................................ 491 When Does Listener.ora Need DESCRIPTION_LIST ..................................... 491 Securing the Oracle Listener............................................................................ 492 What’s New in File Listener.ora ...................................................................... 492

Log and Trace Files................................................................................................. 493 Port Numbers .......................................................................................................... 494 Naming Methods..................................................................................................... 495

Local Naming...................................................................................................... 495 Directory Naming................................................................................................ 496 Easy Connect Naming ......................................................................................... 496 External Naming ................................................................................................. 497

The Listener Control Utility .................................................................................... 497 Automating LSNRCTL START at System Startup .............................................. 500 Automating LSNRCTL STOP at System Shutdown ............................................ 500

The Oracle Advanced Security Option (ASO) ......................................................... 501 ASO Network Encryption ....................................................................................... 502 ASO Data Integrity ................................................................................................. 503 ASO Secure Socket Layer (SSL) Support................................................................ 504

Configuring SSL Per-Instance ............................................................................. 508 On the UNIX Platform..................................................................................... 509 On the Windows Platform ............................................................................... 511

Using SSL with JDBC Connections..................................................................... 512 Chapter 16: Windows Issues ....................................................................................... 514

Operating System Compatibility.............................................................................. 515 General 64-bit Compatibility Notes ..................................................................... 516 How To Determine If You Have 32-Bit or 64-Bit Windows ................................ 516 Microsoft Vista Compatibility Notes ................................................................... 517

What Is Not Supported on Vista ...................................................................... 518 Getting Oracle 10g for Vista ............................................................................ 518

All About Microsoft Windows Server 2003......................................................... 519 The History of Windows Server 2003.............................................................. 519 The Editions of Windows Server 2003............................................................. 520 Windows Server 2003 Compatibility Notes ..................................................... 521 Maximizing The Process Size .......................................................................... 522 Maximizing The Database Buffer Cache.......................................................... 522

Prepare Your Database ................................................................................ 523 Prepare The Operating System..................................................................... 524 Test and Back-Out As Needed ..................................................................... 525

Operating System Limitations ................................................................................. 525 File System Limitations........................................................................................... 527 CPU ........................................................................................................................ 527 RAM....................................................................................................................... 528

Page 21: ChapterOnRMAN

Table of Contents

Installing 4 GB Might Not Give You 4 GB.......................................................... 529 Processes & Threads ............................................................................................... 530 Services................................................................................................................... 531

Introduction to Windows Services ....................................................................... 531 Service Status: Automatic, Manual, Disabled ...................................................... 532 Oracle’s Services................................................................................................. 533

OracleCCService ............................................................................................. 533 OracleClusterVolumeService........................................................................... 534 OracleCRService ............................................................................................. 534 OracleCSService ............................................................................................. 534 OracleDBConsole<SID> ................................................................................. 535 OracleEVMService.......................................................................................... 535 OracleJobScheduler<SID> .............................................................................. 535 OracleMTSRecoveryService............................................................................ 536 Oracle<HomeName>ClrAgent ........................................................................ 536 Oracle<HomeName>CMAdmin ...................................................................... 536 Oracle<HomeName>CMan ............................................................................. 537 Oracle<HomeName>iSQL*Plus...................................................................... 537 Oracle<HomeName>SNMPPeerEncapsulator ................................................. 538 Oracle<HomeName>SNMPPeerMasterAgent ................................................. 538 Oracle<HomeName>TNS<ListenerName> ..................................................... 539 Oracle<HomeName>ProcessManager ............................................................. 540 OracleService<SID>........................................................................................ 540 Oracle<HomeName>ClrAgent ........................................................................ 541

The Windows Registry............................................................................................ 541 Overview............................................................................................................. 542 General Oracle Server Registry Settings .............................................................. 543

DATA_PUMP_DIR ........................................................................................ 544 MSTOOLS_HELP .......................................................................................... 544 NLS_LANG .................................................................................................... 544

Pitfalls with NLS_LANG ............................................................................ 545 NLS_DATE_FORMAT................................................................................... 546 OLEDB ........................................................................................................... 546 OO4O (oh-oh-four-oh) .................................................................................... 546 ORA_CWD..................................................................................................... 546 ORA_<SID>_ AUTOSTART.......................................................................... 547 ORA_<SID>_LPENABLE.............................................................................. 547 ORA_<SID>_LPSIZE..................................................................................... 547 ORA_<SID>_PFILE ....................................................................................... 548 ORA_<SID>_PWFILE.................................................................................... 549 ORA_<SID>_SHUTDOWN ........................................................................... 549 ORA_<SID>_SHUTDOWN_TIMEOUT ........................................................ 549 ORA_<SID>_SHUTDOWNTYPE.................................................................. 549 ORA_TZFILE ................................................................................................. 550 ORACLE_AFFINITY ..................................................................................... 550

Page 22: ChapterOnRMAN

Table of Contents

ORACLE_BASE............................................................................................. 550 ORACLE_GROUP_NAME ............................................................................ 551 ORACLE_HOME ........................................................................................... 551 ORACLE_HOME_KEY ................................................................................. 551 ORACLE_HOME_NAME .............................................................................. 552 ORACLE_PRIORITY..................................................................................... 552 ORACLE_SID ................................................................................................ 552 OSAUTH_ENFORCE_STRICT...................................................................... 552 OSAUTH_PREFIX_DOMAIN ....................................................................... 553 OSAUTH_X509_NAME................................................................................. 553 RDBMS_ARCHIVE ....................................................................................... 553 RDBMS_CONTROL ...................................................................................... 553 SQLPATH....................................................................................................... 554 TNS_ADMIN.................................................................................................. 554 WaitToKillAppTimeout................................................................................... 555

Registry Keys for Microsoft Transaction Server (MTS)....................................... 556 ORAMTS_CONN_POOL_TIMEOUT............................................................ 556 ORAMTS_SESS_TXNTIMETOLIVE ............................................................ 556 ORAMTS_NET_CACHE_TIMEOUT ............................................................ 556 ORAMTS_NET_CACHE_MAXFREE ........................................................... 556 ORAMTS_OSCREDS_MATCH_LEVEL....................................................... 557

Registry Keys for RAC........................................................................................ 557 Oracle Client Registry Settings............................................................................ 557

Other Environment Variables .................................................................................. 558 CLASSPATH...................................................................................................... 558 LD_LIBRARY_PATH........................................................................................ 558 LOCAL (OBSOLETE)........................................................................................ 559 PATH.................................................................................................................. 559 ORACLE_HOME (NOT RECOMMENDED)..................................................... 560 TNS_ADMIN...................................................................................................... 560

ORADIM ................................................................................................................ 561 The Undocumented “EX” Parameter ................................................................... 562

Starting and Stopping Oracle Server on Windows ................................................... 563 Windows Services ............................................................................................... 564 Net Start and Net Stop......................................................................................... 565 Using SQL*Plus to Startup the Database ............................................................. 565 Using SQL*Plus to Shutdown the Database......................................................... 566

Setting Processor Affinity ....................................................................................... 566 Setting Processor Priority ........................................................................................ 568

Chapter 17: Using Oracle 10g on Sun Solaris .............................................................. 571

Installing One-Off Patches ...................................................................................... 571 The Relationship Between Oracle and Sun .............................................................. 573 Operating System Requirements.............................................................................. 573 The “oracle” User and “dba” Group Accounts......................................................... 574 Shells ...................................................................................................................... 576

Page 23: ChapterOnRMAN

Table of Contents

Permissions ............................................................................................................. 577 Permissions as Three Digit Numbers ................................................................... 577 Setting and Permissions and Owners ................................................................... 578 Four Digit Permissions ........................................................................................ 578

User Profiles ........................................................................................................... 579 Commonly Used Environment Variables............................................................. 580 Sample Korn Shell Profile for Oracle Server ....................................................... 581 Sample C Shell Profile for Oracle Client ............................................................. 582

Got Graphics ........................................................................................................... 583 Semaphores............................................................................................................. 584 Kernel Parameters for Solaris 9 and Earlier ............................................................. 584

Shared Memory Parameters................................................................................. 585 shmsys:shminfo_shmmax ................................................................................ 585 shmsys:shminfo_shmmin................................................................................. 585 shmsys:shminfo_shmmni................................................................................. 585 shmsys:shminfo_shmseg ................................................................................. 585

Semaphore Parameters ........................................................................................ 586 semsys:seminfo_semmap................................................................................. 586 semsys:seminfo_semmni ................................................................................. 586 semsys:seminfo_semmns................................................................................. 586 semsys:seminfo_semmsl.................................................................................. 586 semsys:seminfo_semmnu ................................................................................ 587 semsys:seminfo_semume................................................................................. 587

Miscellaneous Kernel Parameters ........................................................................ 587 noexec_user_stack........................................................................................... 588

Sample Kernel Parameter Entries ........................................................................ 588 Resource Controls for Solaris 10 ............................................................................. 588 Registering Port Numbers ....................................................................................... 590 Launching the Oracle Universal Installer on Solaris ................................................ 591 Installing One-Off Patches ...................................................................................... 592 Helpful UNIX Commands....................................................................................... 593

Projects Commands ............................................................................................. 595 Tips for Using VI .................................................................................................... 597

Cursor Movement Operations.............................................................................. 598 Search and Replace Operations............................................................................ 598 Cut and Paste Commands .................................................................................... 599 Miscellaneous Operations.................................................................................... 599 Exiting VI ........................................................................................................... 600

Building a New Solaris 10 (SPARC) Server ............................................................ 601 Selecting the Hardware........................................................................................ 601

About the T2000 Server................................................................................... 601 Planning the File System ..................................................................................... 602

System Partitions ............................................................................................. 603 Application Partitions ...................................................................................... 603 Plan Your Directory Structure ......................................................................... 604

Page 24: ChapterOnRMAN

Table of Contents

To RAID or Not to RAID ................................................................................ 605 Gathering Installer-Required Facts Before You Begin ......................................... 606 Pick the Installation Media .................................................................................. 606 Installing the Operating System........................................................................... 606 Post-Operating System Installation Punch List .................................................... 607

Verify Network Settings .................................................................................. 607 Set Miscellaneous Kernel Parameters .............................................................. 608 Enable Auto-Mounting of the CD/DVD Drive ................................................. 608

The Alternative............................................................................................ 608 Pre-Oracle Installation Punch List ....................................................................... 609

Verify Sun Packages Required by Oracle......................................................... 609 Create File Systems for Oracle......................................................................... 609 Create the OSDBA Group ............................................................................... 609 Create the Oracle Installation Group (Optional) ............................................... 610 Create the Oracle Operator Group (Optional)................................................... 611 Create the Oracle User..................................................................................... 611 Create the Oracle Project ................................................................................. 613 Enable and Activate the Project ....................................................................... 613 Troubleshooting the Project ............................................................................. 615 Login as Oracle and Optionally Set the Password ............................................ 615 Setup the Oracle User’s Environment .............................................................. 615

Installing the Oracle Database 10g Software........................................................ 616 Steps for Installing Oracle Database 10g.......................................................... 616

Installing Oracle 10g Companion Software.......................................................... 619 Steps for Installing Oracle Companion Software.............................................. 619

Post Installation Considerations........................................................................... 620 Installing Oracle 10g R2 Patchset Software ......................................................... 621

Steps for Installing Oracle Patchsets ................................................................ 621 Post-Patchset Security Issues ........................................................................... 622

Create a Database ................................................................................................ 623

Chapter 18: Initialization Parameters........................................................................... 624 What is an Initialization Parameter .......................................................................... 625

Tuning Parameters............................................................................................... 626 Strings, Numbers, Booleans, Oh My! ...................................................................... 626 Knowing When a Parameter Can Be Modified ........................................................ 627 Initialization Parameter Files and Server Parameter Files ........................................ 629

Maintaining Parameters in a PFILE ..................................................................... 629 Maintaining Parameters in a SPFILE ................................................................... 629

The Parameter Clause ...................................................................................... 630 The COMMENT Clause .................................................................................. 630 The SCOPE Clause.......................................................................................... 630 The SID Clause ............................................................................................... 630 Overriding SPFILE Values at Startup .............................................................. 631 Working with Hidden Parameters .................................................................... 631 Removing Parameters from the SPFILE .......................................................... 631

Page 25: ChapterOnRMAN

Table of Contents

More Information ............................................................................................ 632 Displaying Initialization Parameters and Values ...................................................... 632

Using the SQL*Plus SHOW Command to Inspect Parameters............................. 632 View V$SYSTEM_PARAMETER ..................................................................... 633 View V$PARAMETER ...................................................................................... 633 V$PARAMETER_VALID_VALUES................................................................. 633 View V$SPPARAMETER .................................................................................. 634 Viewing Initialization Parameters in OEM Database Control............................... 634 Special Views for NLS Parameters...................................................................... 635 Viewing Hidden Initialization Parameters............................................................ 635 Are You Using Obsolete Parameters?.................................................................. 636

The Initialization Parameters ................................................................................... 636 Database Naming Parameters .............................................................................. 637

DB_DOMAIN................................................................................................. 637 DB_NAME ..................................................................................................... 637 DB_UNIQUE_NAME..................................................................................... 638 INSTANCE_NAME........................................................................................ 638 RDBMS_SERVER_DN .................................................................................. 638 SERVICE_NAMES......................................................................................... 638

SGA Sizing Parameters ....................................................................................... 639 DB_BLOCK_BUFFERS ................................................................................. 640 DB_CACHE_ADVICE ................................................................................... 641 DB_CACHE_SIZE.......................................................................................... 642 DB_NK_CACHE_SIZE .................................................................................. 642 JAVA_POOL_SIZE ........................................................................................ 643 LARGE_POOL_SIZE ..................................................................................... 643 LOCK_SGA.................................................................................................... 644 SGA_MAX_SIZE ........................................................................................... 644 SGA_TARGET ............................................................................................... 645 SHARED_POOL_SIZE................................................................................... 646 SHARED_POOL_RESERVED_SIZE............................................................. 647 STREAMS_POOL_SIZE ................................................................................ 648 USE_INDIRECT_DATA_BUFFERS.............................................................. 649

PGA Sizing Parameters ....................................................................................... 649 PGA_AGGREGATE_TARGET...................................................................... 649 WORKAREA_SIZE_POLICY........................................................................ 651 SORT_AREA_SIZE........................................................................................ 651 SORT_AREA_RETAINED_SIZE................................................................... 652

Security Parameters............................................................................................. 653 _TRACE_FILES_PUBLIC.............................................................................. 653 AUDIT_FILE_DEST ...................................................................................... 653 AUDIT_SYS_OPERATIONS ......................................................................... 654 AUDIT_SYSLOG_LEVEL ............................................................................. 654 AUDIT_TRAIL............................................................................................... 654 O7_DICTIONARY_ACCESSIBILITY........................................................... 655

Page 26: ChapterOnRMAN

Table of Contents

OS_AUTHENT_PREFIX................................................................................ 656 OS_ROLES..................................................................................................... 656 REMOTE_LOGIN_PASSWORDFILE ........................................................... 657

Oracle 10.1 Databases.................................................................................. 657 Oracle 10.2 Databases.................................................................................. 658

REMOTE_OS_AUTHENT ............................................................................. 659 REMOTE_OS_ROLES ................................................................................... 659

General / Miscellaneous Parameters .................................................................... 659 _RECYCLEBIN.............................................................................................. 659 CLUSTER_DATABASE ................................................................................ 660 COMPATIBLE ............................................................................................... 660 CURSOR_SHARING...................................................................................... 661 DB_BLOCK_CHECKING.............................................................................. 662

Oracle 10.1 Databases.................................................................................. 662 Oracle 10.2 Databases.................................................................................. 662

DB_BLOCK_CHECKSUM ............................................................................ 662 Oracle 10.1 Databases.................................................................................. 662 Oracle 10.2 Databases.................................................................................. 663

DB_BLOCK_SIZE.......................................................................................... 663 DB_FILE_MULTIBLOCK_READ_COUNT.................................................. 664 DB_FILES ...................................................................................................... 665 DB_WRITER_PROCESSES........................................................................... 665 DBWR_IO_SLAVES...................................................................................... 666 GLOBAL_NAMES......................................................................................... 666 INSTANCE_TYPE ......................................................................................... 667 JOB_QUEUE_PROCESSES ........................................................................... 667 LOCAL_LISTENER....................................................................................... 668 OPEN_CURSORS .......................................................................................... 668 PROCESSES................................................................................................... 669 RECYCLEBIN................................................................................................ 670 REMOTE_LISTENER.................................................................................... 670 RESOURCE_LIMIT ....................................................................................... 671 RESOURCE_MANAGER_PLAN................................................................... 671 SESSION_CACHED_CURSORS ................................................................... 671 SESSION_MAX_OPEN_FILES ..................................................................... 672 SESSIONS ...................................................................................................... 672 SPFILE............................................................................................................ 673 TRACE_ENABLED ....................................................................................... 673 TRANSACTIONS........................................................................................... 673

Location Parameters ............................................................................................ 674 AUDIT_FILE_DEST ...................................................................................... 674 BACKGROUND_DUMP_DEST .................................................................... 674 CONTROL_FILES.......................................................................................... 675 CORE_DUMP_DEST ..................................................................................... 676 USER_DUMP_DEST...................................................................................... 676

Page 27: ChapterOnRMAN

Table of Contents

UTL_FILE_DIR.............................................................................................. 677 Redo Log Parameters .......................................................................................... 677

LOG_BUFFER................................................................................................ 677 10.2 Behavior .............................................................................................. 677 10.1 Behavior .............................................................................................. 678

LOG_CHECKPOINT_INTERVAL................................................................. 679 LOG_CHECKPOINT_TIMEOUT................................................................... 679 LOG_CHECKPOINTS_TO_ALERT .............................................................. 680

Optimizer and Statistics Parameters..................................................................... 680 OPTIMIZER_DYNAMIC_SAMPLING.......................................................... 680 OPTIMIZER_MODE ...................................................................................... 681 STATISTICS_LEVEL .................................................................................... 682 TIMED_OS_STATISTICS.............................................................................. 683 TIMED_STATISTICS .................................................................................... 683

Undo Parameters ................................................................................................. 684 UNDO_MANAGEMENT ............................................................................... 684 UNDO_RETENTION ..................................................................................... 684 UNDO_TABLESPACE................................................................................... 685

Materialized View Parameters ............................................................................. 686 QUERY_REWRITE_ENABLED.................................................................... 686 QUERY_REWRITE_INTEGRITY ................................................................. 686

Shared Server Parameters .................................................................................... 687 CIRCUITS ...................................................................................................... 687 DISPATCHERS .............................................................................................. 687 MAX_DISPATCHERS ................................................................................... 688 MAX_SHARED_SERVERS........................................................................... 689 SHARED_SERVER_SESSIONS .................................................................... 690 SHARED_SERVERS...................................................................................... 690

Backup and Recovery Parameters........................................................................ 691 DB_FLASHBACK_RETENTION_TARGET ................................................. 691 DB_RECOVERY_FILE_DEST ...................................................................... 692 DB_RECOVERY_FILE_DEST_SIZE ............................................................ 693 FAST_START_MTTR_TARGET................................................................... 693 FAST_START_PARALLEL_ROLLBACK .................................................... 695 LOG_ARCHIVE_DEST ................................................................................. 695 LOG_ARCHIVE_DEST_N............................................................................. 696

Important note regarding LOG_ARCHIVE_DEST_10 ................................ 697 LOG_ARCHIVE_DEST_STATE_N............................................................... 698

Alternate and Spill Over Destinations for Archlogs...................................... 698 LOG_ARCHIVE_DUPLEX_DEST ................................................................ 703 LOG_ARCHIVE_FORMAT ........................................................................... 703 LOG_ARCHIVE_MAX_PROCESSES ........................................................... 705 LOG_ARCHIVE_MIN_SUCCEED_DEST..................................................... 705 LOG_ARCHIVE_START............................................................................... 705 LOG_ARCHIVE_TRACE .............................................................................. 706

Page 28: ChapterOnRMAN

Table of Contents

REMOTE_ARCHIVE_ENABLE .................................................................... 706 OMF Parameters ................................................................................................. 706

DB_CREATE_FILE_DEST ............................................................................ 706 DB_CREATE_ONLINE_LOG_DEST_N ....................................................... 707

ASM Parameters ................................................................................................. 707 ASM_DISKGROUPS...................................................................................... 708 ASM_DISKSTRING....................................................................................... 708 ASM_POWER_LIMIT.................................................................................... 708

Chapter 19: The Server Parameter File (SPFILE) ........................................................ 709 What is a SPFILE.................................................................................................... 710 RAC Attack ............................................................................................................ 711 When to Use a SPFILE............................................................................................ 711 Why Not Use a SPFILE .......................................................................................... 712 Where to Put Your SPFILE ..................................................................................... 713 Naming Conventions for SPFILEs........................................................................... 714 Creating a SPFILE .................................................................................................. 714 Updating a SPFILE ................................................................................................. 715 Deleting a SPFILE .................................................................................................. 716 Backing up the SPFILE ........................................................................................... 716 The Asterisk............................................................................................................ 716 SPFILEs and Automatic Shared Memory Management ........................................... 717

Chapter 20: Oracle’s Pre-Installed Schemas ................................................................ 719

ANONYMOUS....................................................................................................... 720 CTXSYS................................................................................................................. 720 DIP ......................................................................................................................... 721 DBSNMP................................................................................................................ 721 DIP ......................................................................................................................... 722 DMSYS .................................................................................................................. 722 LBACSYS .............................................................................................................. 722 MDDATA............................................................................................................... 723 MDSYS .................................................................................................................. 723 OLAPSYS............................................................................................................... 723 ORDPLUGINS ....................................................................................................... 723 ORDSYS ................................................................................................................ 724 OUTLN................................................................................................................... 724 SCOTT ................................................................................................................... 724 SI_INFORMTN_SCHEMA .................................................................................... 725 SYS......................................................................................................................... 725 SYSMAN................................................................................................................ 725 SYSTEM ................................................................................................................ 726 TSMSYS................................................................................................................. 726 WMSYS.................................................................................................................. 726 XDB ....................................................................................................................... 727

Page 29: ChapterOnRMAN

Table of Contents

Chapter 21: Creating Oracle10g Databases by Hand.................................................... 728 Why I Don’t Like Using Wizards to Create Databases............................................. 729 When to Use a Wizard............................................................................................. 730 The Tools of My Trade............................................................................................ 730 The Process............................................................................................................. 731

The Process from 30,000 Feet.............................................................................. 731 The Process from 10,000 Feet.............................................................................. 731

Plan the Installation ......................................................................................... 732 Configure the Server........................................................................................ 732 Create the Database ......................................................................................... 733

Scripting the Process ............................................................................................... 734 Plan and Create the Necessary Directories............................................................... 735

Directories for Oracle COTS Software ................................................................ 736 Directories for Oracle Database Admin Files ....................................................... 737 Directories for Oracle Database Files................................................................... 739 Directories for Oracle Archived Redo Log Files .................................................. 740

Using Multiple Archiver Destinations.............................................................. 742 The RAID Effect ............................................................................................. 743 Compressing Archlogs to Save Space .............................................................. 743 Managing and Deleting Archlogs..................................................................... 743

Directories for Oracle Recovery Files .................................................................. 744 Create a Windows Service Using ORADIM ............................................................ 746

Calling ORADIM While Creating a Database...................................................... 748 Create a Password File Using ORAPWD ................................................................ 749

Calling ORAPWD While Creating a Database..................................................... 751 Deploy your Initialization Parameter File ................................................................ 752

Where to Put Your PFILE or SPFILE.................................................................. 752 Deploying PFILE and SPFILE While Creating a Database .................................. 753

The CREATE DATABASE Command ................................................................... 755 A Very Simple Example to Get You Moving....................................................... 755 Components of the CREATE DATABASE Command ........................................ 757

Database Name................................................................................................ 757 The USER SYS Clause.................................................................................... 757 The USER SYSTEM Clause............................................................................ 758 The FORCE LOGGING Clause....................................................................... 758 The DATAFILE Clause................................................................................... 758 The DEFAULT TABLESPACE Clause........................................................... 759 The DEFAULT TEMPORARY TABLESPACE Clause .................................. 760 The SYSAUX DATAFILE Clause .................................................................. 761 The LOGFILE Clause...................................................................................... 762 The FORCE LOGGING Clause....................................................................... 763 The SET DEFAULT BIGFILE/SMALLFILE TABLESPACE Clause ............. 763 The UNDO TABLESPACE Clause ................................................................. 763 The CHARACTER SET Clause ...................................................................... 765 The NATIONAL CHARACTER SET Clause.................................................. 767

Page 30: ChapterOnRMAN

Table of Contents

The ARCHIVELOG Clause............................................................................. 768 The MAXLOGFILES Clause .......................................................................... 768 The MAXLOGMEMBERS Clause.................................................................. 769 Control Files.................................................................................................... 769

Examples............................................................................................................. 769 Example 1: Simple Form ................................................................................ 769 Example 2: With Some Details ....................................................................... 770 Example 3: Enough Detail to Hurt Your Head ................................................ 770

Creating Directories on the Fly................................................................................ 773 Installing the Catalogs ............................................................................................. 773

What Catalogs Are There / Which Ones Do I Need ............................................. 775 Before You Begin, Define A Few Variables ........................................................ 776 Create the Data Dictionary .................................................................................. 777 Install SQL*Plus Extensions................................................................................ 778 Install the Oracle Java Virtual Machine (JVM) .................................................... 778 Install Oracle Text ............................................................................................... 779 Install Oracle XML DB ....................................................................................... 780

The Installation Process ................................................................................... 780 Pre-Requires to Installing XML DB In Your Database..................................... 781 Tips for Windows 2003 SP1 Users .................................................................. 781 Installing XML DB In Your Database.............................................................. 782 Final Points on Installing XML DB ................................................................. 783

Oracle Spatial...................................................................................................... 783 Configuring OEM Database Control........................................................................ 784

First, Gather the Facts.......................................................................................... 784 Second, Understand Your Options....................................................................... 785 Third, Manually Configure OEM Database Control............................................. 786

Manually Configuring Database Control in Oracle 10.1................................... 786 Manually Configuring Database Control in Oracle 10.2................................... 788

Fourth, Disable Unlicensed Functionality ............................................................ 790 Some Post-Configuration Thoughts ..................................................................... 790 Removing Database Control ................................................................................ 791

Removing Database Control in Oracle 10g Release 1 ...................................... 791 Removing Database Control in Oracle 10g Release 2 ...................................... 792

Database Control Port Numbers........................................................................... 793 Administrators and Super Administrators ............................................................ 793 Auto-Starting the Database Control Process ........................................................ 795 Troubleshooting Database Control Setup............................................................. 795

The Floppy Drive Bug for Windows Users ...................................................... 796 Connecting Database Control to Multiple Databases at Once........................... 798

Chapter 22: Creating Oracle 10g Databases by Wizard................................................ 799 What is the DBCA .................................................................................................. 800 What Do I Do with the DBCA................................................................................. 800

Capture scripts for creating databases .................................................................. 801 Configure Database Options ................................................................................ 801

Page 31: ChapterOnRMAN

Table of Contents

Launching the DBCA.............................................................................................. 801 Using the DBCA to Create a New Database from Scratch ....................................... 802 Using the DBCA to Create a Database Template ..................................................... 815 Using the DBCA to Create a New Database from a Template.................................. 815 Pitfalls of the DBCA ............................................................................................... 816

Chapter 23: Polishing Your Windows Database Server ............................................... 818

Disable CPU-Intensive Screen Savers ..................................................................... 819 Unset the Windows Wallpaper ................................................................................ 819 Disable Windows Active Desktop ........................................................................... 820 Adjust Your Anti-Virus Software ............................................................................ 820 Adjust Your Windows Registry Keys ...................................................................... 821

Chapter 24: Database Startup ...................................................................................... 822

What Does Starting the Database Do....................................................................... 823 The Startup Process, a Full Example.................................................................... 823

Tools of the Trade ................................................................................................... 824 Permissions ............................................................................................................. 825 Other Pre-Requisites ............................................................................................... 825 Automating Startup ................................................................................................. 825

Automating Startup on Windows......................................................................... 826 Automating Startup on Solaris............................................................................. 826

Startup Options ....................................................................................................... 828 STARTUP NOMOUNT ...................................................................................... 829 STARTUP MOUNT............................................................................................ 830 STARTUP........................................................................................................... 831 STARTUP EXCLUSIVE .................................................................................... 832 STARTUP FORCE ............................................................................................. 833 STARTUP RESTRICT........................................................................................ 833 STARTUP MIGRATE ........................................................................................ 834 STARTUP UPGRADE........................................................................................ 835 STARTUP PARALLEL (OBSOLETE)............................................................... 835 ALTER DATABASE MOUNT........................................................................... 836 ALTER DATABASE OPEN............................................................................... 836 About Restricted Session..................................................................................... 837

Using ORADIM to Startup Oracle........................................................................... 838 Using RMAN to Startup Oracle............................................................................... 838 Startup Triggers....................................................................................................... 839 RAC Startup Notes.................................................................................................. 839 Startup Errors.......................................................................................................... 839

ORA-01031: insufficient privileges ..................................................................... 839 ORA-01041: internal error. hostdef extension doesn't exist.................................. 840 ORA-01081: cannot start already-running ORACLE - shut it down first.............. 840 ORA-01507: database not mounted ..................................................................... 840 ORA-01033: ORACLE initialization or shutdown in progress ............................. 840 ORA-01034: ORACLE not available................................................................... 841

Page 32: ChapterOnRMAN

Table of Contents

ORA-01219: database not open: queries allowed on fixed tables/views only ....... 841 ORA-12514: TNS:listener does not currently know of service requested in connect descriptor. ........................................................................................................... 841 ORA-12528: TNS:listener: all appropriate instances are blocking new connections............................................................................................................................ 842 ORA-12560: TNS:protocol adapter error............................................................. 842

Chapter 25: Database Shutdown.................................................................................. 843 What Does Shutting Down the Database Do............................................................ 844 Tools of the Trade ................................................................................................... 844 Permissions ............................................................................................................. 844 Other Pre-Requisites ............................................................................................... 845 Automating Shutdown............................................................................................. 846 Shutdown Options................................................................................................... 846

SHUTDOWN...................................................................................................... 846 SHUTDOWN NORMAL .................................................................................... 847 SHUTDOWN TRANSACTIONAL [LOCAL] .................................................... 847 SHUTDOWN IMMEDIATE............................................................................... 847 SHUTDOWN ABORT........................................................................................ 848 ALTER DATABASE CLOSE............................................................................. 848

Using ORADIM to Shutdown Oracle ...................................................................... 849 Using RMAN to Shutdown Oracle .......................................................................... 849 Shutdown Triggers .................................................................................................. 850 RAC Shutdown Notes ............................................................................................. 850

Chapter 26: The Recycle Bin....................................................................................... 851

What is the Recycle Bin .......................................................................................... 852 Enable / Disable the Recycle Bin............................................................................. 852

Oracle 10g Release 1 ........................................................................................... 853 Oracle 10g Release 2 ........................................................................................... 853

Restoring Tables From the Recycle Bin................................................................... 853 Clearing the Recycle Bin......................................................................................... 854 Restrictions on the Recycle Bin ............................................................................... 855

Chapter 27: Optimizer Statistics .................................................................................. 856

What Are Statistics.................................................................................................. 857 What Are Statistics History ................................................................................. 857

Making it Work....................................................................................................... 858 Installation and Configuration Issues ................................................................... 859 Privileges ............................................................................................................ 859

Automatic Statistics Collection for Application Tables............................................ 859 Manual Collection of Statistics on Application Tables............................................. 860

GATHER_DATABASE_STATS ........................................................................ 861 GATHER_SCHEMA_STATS............................................................................. 861 GATHER_TABLE_STATS ................................................................................ 862

GATHER_INDEX_STATS............................................................................. 863

Page 33: ChapterOnRMAN

Table of Contents

GATHER_DICTIONARY_STATS..................................................................... 863 GATHER_SYSTEM_STATS ............................................................................. 864

Default Parameter Values ........................................................................................ 864 OPTIONS............................................................................................................ 865 ESTIMATE_PERCENT...................................................................................... 865 METHOD_OPT .................................................................................................. 866 DEGREE............................................................................................................. 867 GRANULARITY................................................................................................ 867 CASCADE.......................................................................................................... 868 NO_INVALIDATE............................................................................................. 868

Gathering Statistics on Dictionary Tables ................................................................ 869 Fixed Object........................................................................................................ 869 Dynamic (Real) Tables ........................................................................................ 870

Determining When Statistics are Missing ................................................................ 870 Locking Statistics in Place....................................................................................... 872

Using FORCE to Override the Lock .................................................................... 872 Dynamic Sampling of Statistics............................................................................... 873 About Histograms ................................................................................................... 874 Default Statistics Values.......................................................................................... 875 FAQs ...................................................................................................................... 876

Does Automatic Optimizer Statistics Collection use the AWR?........................... 876 Which initialization parameters should I focus on? .............................................. 876 When does job run to collect statistics?................................................................ 876 When does the maintenance window open? ......................................................... 876 What if the maintenance window closes before the job ends? .............................. 876 How do I know if my database has a job to gather statistics? ............................... 876 How do I disable automatic statistics collection? ................................................. 876 How do I resume automatic statistics collection after disabling it?....................... 876 How does automatic statistics collection relate to Oracle 8i and 9i? ..................... 877 What Happened to the Rule Based Optimizer ...................................................... 877

Chapter 28: Automatic Workload Repository (AWR).................................................. 878 Overview ................................................................................................................ 879 AWR Versus STATSPACK.................................................................................... 879 How AWR Works ................................................................................................... 879 Storage Requirements for the AWR......................................................................... 880 Manually Managing AWR Statistics........................................................................ 880

Privileges ............................................................................................................ 880 Altering AWR’s Default Collection and Retention Periods.................................. 881 Creating AWR Baselines ..................................................................................... 882 Dropping AWR Baselines ................................................................................... 883 Creating AWR Snapshots .................................................................................... 884

Specifying the Flush Level .............................................................................. 885 Dropping AWR Snapshots................................................................................... 885 Comparing Baselines........................................................................................... 886 Creating a (STATSPACK-Like) Statistics Report................................................ 887

Page 34: ChapterOnRMAN

Table of Contents

Views for Monitoring AWR Snapshots ................................................................... 887 DBA_HIST_WR_CONTROL ............................................................................. 887 DBA_HIST_BASELINE..................................................................................... 887 DBA_HIST_SNAPSHOT ................................................................................... 888

Chapter 29: Oracle Flashback...................................................................................... 889 What is Oracle Flashback ........................................................................................ 890 Permissions Required for Using Oracle Flashback................................................... 891 Oracle Flashback Database...................................................................................... 892

Flashback Database System Requirements........................................................... 892 Enabling Flashback Database .............................................................................. 893 Disabling Flashback Database ............................................................................. 894 Using Flashback Database ................................................................................... 894 Monitoring Flashback Database Storage Issues.................................................... 896 RAC Considerations for Oracle Flashback Database............................................ 896

Oracle Flashback Drop............................................................................................ 897 Enabling and Disabling Flashback Drop .............................................................. 897 Using Flashback Drop ......................................................................................... 898 A Few Tips for Flashback Drop........................................................................... 900 Implications of Dropping a Tablespace................................................................ 900 Restrictions and Limitations for Flashback Drop ................................................. 901

Oracle Flashback Table ........................................................................................... 902 Flashing Back Related Data................................................................................. 903 Restrictions and Limitations ................................................................................ 904

Oracle Flashback Query .......................................................................................... 904 Oracle Flashback Transaction Query ....................................................................... 905 Oracle Flashback Versions Query............................................................................ 906

Chapter 30: Database Security..................................................................................... 908 Introduction to Database Security............................................................................ 909 Schemas .................................................................................................................. 909

What is a Schema ................................................................................................ 909 Schemas are Swim Lanes .................................................................................... 910 Are Application Schemas the Same as User Schemas .......................................... 910 Creating and Maintaining Schemas...................................................................... 911 Case Matters........................................................................................................ 914 Dropping Schemas .............................................................................................. 915

Users....................................................................................................................... 915 Types of User Accounts ...................................................................................... 915

Ghost Accounts ............................................................................................... 916 Database Users with Database Managed Password .......................................... 916 Database Users with Host Managed Password ................................................. 917 Enterprise Database Users ............................................................................... 919 Schemaless Enterprise Database Users ............................................................ 919

Sample CREATE USER Commands ................................................................... 920 Plain Vanilla.................................................................................................... 920

Page 35: ChapterOnRMAN

Table of Contents

Passwords For Users Identified Externally....................................................... 921 Create a User with an Old Password ................................................................ 921 Create a User Without the CREATE USER Command .................................... 923

Password Verification Functions ............................................................................. 923 Privileges ................................................................................................................ 928

What are Object Privileges .................................................................................. 928 The WITH GRANT OPTION Clause .............................................................. 929

What are System Privileges ................................................................................. 929 The WITH ADMIN OPTION Clause .............................................................. 930

What are the SYSDBA and SYSOPER Privileges ............................................... 930 Privileges Needed to Query the Data Dictionary.................................................. 931 Views for Managing Privileges............................................................................ 932

DBA_COL_PRIVS ......................................................................................... 932 DBA_COL_TAB_PRIVS_RECD.................................................................... 932 DBA_SYS_PRIVS .......................................................................................... 932 DBA_TAB_PRIVS ......................................................................................... 932 ROLE_SYS_PRIVS ........................................................................................ 932 SESSION_PRIVS............................................................................................ 933

Roles....................................................................................................................... 933 What Are Roles ................................................................................................... 933 Quick Tips for Using Roles ................................................................................. 934 Creating, Modifying, and Dropping Roles ........................................................... 934 Granting Roles to Users....................................................................................... 935 The “WITH ADMIN OPTION” Clause ............................................................... 936 Commonly Granted (Pre-Defined) Roles ............................................................. 936

CONNECT...................................................................................................... 937 DBA................................................................................................................ 937 RESOURCE.................................................................................................... 937 SELECT_CATALOG_ROLE.......................................................................... 938 DELETE_CATALOG_ROLE ......................................................................... 938 EXECUTE_CATALOG_ROLE ...................................................................... 938 EXP_FULL_DATABASE............................................................................... 938 IMP_FULL_DATABASE ............................................................................... 939 RECOVERY_CATALOG_OWNER............................................................... 939 HS_ADMIN_ROLE ........................................................................................ 939 AQ_USER_ROLE........................................................................................... 939 AQ_ADMINISTRATOR_ROLE..................................................................... 940

Roles Past, Present, and Future............................................................................ 940 Are Roles the Same as User Groups .................................................................... 940 Using Roles as Labels or Flags ............................................................................ 941 Views for Managing Roles .................................................................................. 941

DBA_ROLES.................................................................................................. 941 DBA_ROLE_PRIVS....................................................................................... 941 ROLE_ROLE_PRIVS ..................................................................................... 942 ROLE_SYS_PRIVS ........................................................................................ 943

Page 36: ChapterOnRMAN

Table of Contents

ROLE_TAB_PRIVS ....................................................................................... 943 SESSION_ROLES .......................................................................................... 944

Restrictions on Grants ......................................................................................... 944 Chapter 31: Introduction to Oracle Auditing................................................................ 946

Introducing Oracle Audit......................................................................................... 947 Changes In 10g.................................................................................................... 947

What is Auditing ..................................................................................................... 947 What Does Oracle Audit By Default........................................................................ 948 What Can Be Audited.............................................................................................. 948

Audit By Access or By Session ........................................................................... 949 Audit Logins and Logoffs.................................................................................... 950 Audit the Auditing System .................................................................................. 950 Audit Security Related Commands ...................................................................... 951 Auditing DDL and DML Commands................................................................... 951

What Data Does Auditing Capture .......................................................................... 952 What Data Does Auditing Not Capture.................................................................... 953 Permissions Needed to Manage Auditing ................................................................ 954 Install Auditing ....................................................................................................... 954 Turn Auditing On and Off ....................................................................................... 955

Step 1: Configure the Database............................................................................ 955 Step 2: Bounce the Database................................................................................ 956 Step 3: Issue AUDIT Commands......................................................................... 956 Example: Auditing Connections .......................................................................... 957

To Audit All Users or Specific Users....................................................................... 957 Auditing SYS and Other SYSDBA Users................................................................ 958 Check Your Audit Settings...................................................................................... 959 Where is Audit Data Stored..................................................................................... 962 Auditing Proxy Users .............................................................................................. 963 Viewing Audit Data ................................................................................................ 964

DBA_COMMON_AUDIT_TRAIL..................................................................... 965 DBA_AUDIT_STATEMENT............................................................................. 965 DBA_AUDIT_OBJECT...................................................................................... 965 DBA_AUDIT_SESSION .................................................................................... 966 DBA_OBJ_AUDIT_OPTS.................................................................................. 967 DBA_PRIV_AUDIT_OPTS................................................................................ 967 DBA_STMT_AUDIT_OPTS .............................................................................. 968

Fine Grained Auditing (FGA).................................................................................. 968 Chapter 32: The Oracle Scheduler ............................................................................... 970

Introduction............................................................................................................. 971 Breaking it Down.................................................................................................... 971

Jobs ..................................................................................................................... 973 Listing Scheduler Jobs ..................................................................................... 973 Running Scheduler Jobs................................................................................... 974 Stopping Scheduler Jobs .................................................................................. 975

Page 37: ChapterOnRMAN

Table of Contents

Disabling and Enabling Scheduler Jobs ........................................................... 976 Dropping Scheduler Jobs ................................................................................. 976 About External Jobs......................................................................................... 977

Job Classes .......................................................................................................... 979 Programs ............................................................................................................. 980

Creating Programs ........................................................................................... 981 Dropping Programs ......................................................................................... 982 Permissions ..................................................................................................... 982

Schedules ............................................................................................................ 982 Creating Schedules .......................................................................................... 983 Dropping Schedules......................................................................................... 983 Listing Schedules ............................................................................................ 984 Permissions ..................................................................................................... 984

Windows ............................................................................................................. 984 Window Groups .................................................................................................. 985 Putting It All Together......................................................................................... 986

Why it is better Than Oracle’s Old Job System........................................................ 987 Configuring the Scheduler....................................................................................... 988

Initialization Parameters ...................................................................................... 988 Permissions ......................................................................................................... 988

Job Log ................................................................................................................... 989 Privileges ................................................................................................................ 991 RAC Considerations................................................................................................ 992 Scheduler Example – A Simple Standalone Job....................................................... 993

Chapter 33: SQL*Plus................................................................................................. 996 What Is SQL*Plus................................................................................................... 997 How Do I Get SQL*Plus ......................................................................................... 998 Installing SQL*Plus ................................................................................................ 998 Rule #1 – How to End a Command in SQL*Plus..................................................... 999 Rule #2 – Formatting is For You, it Does Not Help SQL*Plus ................................ 999 Configuring SQL*Plus .......................................................................................... 1000

Create a Customized Windows Shortcut ............................................................ 1000 Use File GLOGIN.SQL to Set Global Variables in the SQL*Plus Environment. 1002 Use File LOGIN.SQL to Set Local Variables in the SQL*Plus Environment ..... 1002 Tips for Profile Files.......................................................................................... 1002 Use the SET Command to Set the SQL*Plus Environment ................................ 1003

How to Use the SET Command ..................................................................... 1003 Variables You Can Set With the SET Command ........................................... 1004 Storing Your SET Commands, and all Other Variables.................................. 1008 Using SHOW to Display a Variables Current Status ...................................... 1008 An Example of SET and SHOW.................................................................... 1008

Format Columns with the COLUMN Command................................................ 1009 Define a Default Editor...................................................................................... 1011

Starting SQL*Plus................................................................................................. 1012 Hiding Your Identity ......................................................................................... 1013

Page 38: ChapterOnRMAN

Table of Contents

Connecting to a Database ...................................................................................... 1014 Set ORACLE_SID ............................................................................................ 1014 Connect Using the SQL*Plus Command Line Version ...................................... 1018 Connect Via Proxy ............................................................................................ 1021 Security Issues................................................................................................... 1021 Re-Connect Any Time Using CONNECT ......................................................... 1022 Connect Later When Using /NOLOG ................................................................ 1023 Connection Status Messages.............................................................................. 1024

Connecting to a Database With SSL...................................................................... 1025 Substitution Variables ........................................................................................... 1028

&var .................................................................................................................. 1028 &&var ............................................................................................................... 1028 &var1.&var2 ..................................................................................................... 1029 &var1.Something .............................................................................................. 1029

Issuing Commands and Running Scripts................................................................ 1030 Manually Issuing Commands ............................................................................ 1030 Running Scripted Commands ............................................................................ 1031

Issue Operating System Commands from SQL*Plus ............................................. 1034 Accepting Input..................................................................................................... 1035 Save from SQL*Plus to a File ............................................................................... 1037 Fetch Scripts into SQL*Plus Using the GET Command ........................................ 1038 Edit SQL*Plus Command in Your Default Editor.................................................. 1038 SQL*Plus Built-In Editing Commands .................................................................. 1039

DOS Tricks ....................................................................................................... 1041 All About Output .................................................................................................. 1043

Formatting Query Results.................................................................................. 1043 Get the Screen Ready..................................................................................... 1044 Formatting Columns ...................................................................................... 1044 Un-Formatting columns................................................................................. 1046

Saving Output to a File ...................................................................................... 1046 Printing ............................................................................................................. 1047

The CLEAR Command ......................................................................................... 1047 How To Clear Column Formats......................................................................... 1048 How to Clear The SQL Buffer ........................................................................... 1049 How to Clear the Screen.................................................................................... 1049

Changing Your Database Password ....................................................................... 1050 Exiting SQL*Plus.................................................................................................. 1051

Chapter 34: Structured Query Language (SQL) ......................................................... 1052

Introduction to SQL .............................................................................................. 1053 Standards and Compliance .................................................................................... 1054 SELECT................................................................................................................ 1054

Syntax ............................................................................................................... 1054 The SELECT Clause ..................................................................................... 1055 The FROM Clause......................................................................................... 1055 The WHERE Clause ...................................................................................... 1055

Page 39: ChapterOnRMAN

Table of Contents

IN versus EXISTS ..................................................................................... 1056 The ORDER BY Clause ................................................................................ 1056

Security Considerations ..................................................................................... 1057 Selecting Against DUAL................................................................................... 1057 Examples........................................................................................................... 1057

INSERT ................................................................................................................ 1060 Syntax ............................................................................................................... 1061 Security Considerations ..................................................................................... 1062 Examples........................................................................................................... 1062

UPDATE .............................................................................................................. 1062 Syntax ............................................................................................................... 1063 Security Considerations ..................................................................................... 1063 Examples........................................................................................................... 1063

DELETE ............................................................................................................... 1064 Syntax ............................................................................................................... 1064 Security Considerations ..................................................................................... 1065 Examples........................................................................................................... 1065

TRUNCATE ......................................................................................................... 1066 Syntax ............................................................................................................... 1066 Security Considerations ..................................................................................... 1066 Examples........................................................................................................... 1066

CREATE TABLESPACE ..................................................................................... 1067 Syntax ............................................................................................................... 1067 Security Considerations ..................................................................................... 1068 About Locally Managed Extent Sizes ................................................................ 1068 Examples........................................................................................................... 1069 After Thoughts .................................................................................................. 1070

CREATE TABLE ................................................................................................. 1071 Syntax ............................................................................................................... 1071 Security Considerations ..................................................................................... 1073 Examples........................................................................................................... 1073

CREATE TABLE AS SELECT (CTAS) ............................................................... 1074 ALTER TABLE.................................................................................................... 1075

Syntax ............................................................................................................... 1075 Security Considerations ..................................................................................... 1075 Examples........................................................................................................... 1076

RENAME ............................................................................................................. 1076 Syntax ............................................................................................................... 1077 Security Considerations ..................................................................................... 1077 Examples........................................................................................................... 1077

DROP TABLE ...................................................................................................... 1077 Syntax ............................................................................................................... 1077 Security Considerations ..................................................................................... 1078 Examples........................................................................................................... 1078

Add Comments to Your Schema ........................................................................... 1078

Page 40: ChapterOnRMAN

Table of Contents

Working with Dates .............................................................................................. 1079 Intro to Date and Time Data Types .................................................................... 1080 How Oracle Stores Dates and Times.................................................................. 1080 Displaying System Date and Time Data............................................................. 1081 Understanding the Date & Time Format Mask................................................... 1082 Date & Time Conversion Functions................................................................... 1084

TO_CHAR .................................................................................................... 1084 TO_DATE..................................................................................................... 1085

Working with Nulls ............................................................................................... 1085 NULL Values Can Change Query Results ......................................................... 1086 Testing Columns for NULL Values ................................................................... 1087 Functions for Working with NULLs .................................................................. 1087

NVL .............................................................................................................. 1088 NLV2 ............................................................................................................ 1088 NULLIF ........................................................................................................ 1088

Understanding Pseudo Columns ............................................................................ 1089 LEVEL.............................................................................................................. 1089 NEXTVAL........................................................................................................ 1090 ORA_ROWSCN ............................................................................................... 1091 ROWID............................................................................................................. 1091 ROWNUM........................................................................................................ 1092

Chapter 35: Oracle Data Pump .................................................................................. 1094

Introduction to Data Pump .................................................................................... 1095 What Data Pump Cannot Do.............................................................................. 1096

The Components of Data Pump............................................................................. 1096 Master Control Table......................................................................................... 1096 Background Processes ....................................................................................... 1097 Data Pump Views.............................................................................................. 1097 The Data Pump API (PL/SQL Supplied Packages) ............................................ 1097 DATA_PUMP_DIR .......................................................................................... 1099

Data Pump Security............................................................................................... 1099 Security on Directory Objects............................................................................ 1100 Security on Data Pump ...................................................................................... 1100 Invoker’s Rights Issues...................................................................................... 1101

Data Pump Setup................................................................................................... 1102 Getting Help.......................................................................................................... 1103 Exporting Data Using Data Pump Export .............................................................. 1104

Preparing for Export .......................................................................................... 1104 Modes of Data Pump Export.............................................................................. 1104 Estimating the Size of Exports........................................................................... 1105 An Example of Using Data Pump Export........................................................... 1106 Controlling the Output....................................................................................... 1108 Working with Distributed Databases ................................................................. 1108 Naming the Data Pump Job ............................................................................... 1109 Checking the Status of an Export....................................................................... 1109

Page 41: ChapterOnRMAN

Table of Contents

Resuming an Export .......................................................................................... 1110 Exporting From Within PL/SQL Procedures...................................................... 1111

Importing Data Using Data Pump Import .............................................................. 1112 What is Data Pump Import ................................................................................ 1113 The Parameters.................................................................................................. 1113

FLASHBACK_TIME and FLASHBACK_SCN ............................................ 1113 NETWORK_LINK........................................................................................ 1114 PARALLEL .................................................................................................. 1114 QUERY......................................................................................................... 1115 REMAP_DATAFILE .................................................................................... 1115 REMAP_SCHEMA....................................................................................... 1115 REMAP_TABLESPACE .............................................................................. 1115 TABLE_EXISTS_ACTION .......................................................................... 1115 TRANSFORM .............................................................................................. 1116

An Example of Using Data Pump Import........................................................... 1116 Chapter 36: Oracle Partitioning ................................................................................. 1119

What is Oracle Partitioning ................................................................................... 1120 Who Should Use Partitioning ................................................................................ 1122 What’s New in Oracle 10g Partitioning ................................................................. 1123 When Can Partitions Be Created ........................................................................... 1123

When Creating Tables ....................................................................................... 1123 Add a Partition to the End of a Partitioned Table ............................................... 1124 Split a Partition Within a Partitioned Table........................................................ 1124 Swap a Non-Partitioned Segment With a Partitioned Segment........................... 1124 Use Package DBMS_REDEFINITION.............................................................. 1125

Types of Table Partitioning ................................................................................... 1125 Hash Partitioning............................................................................................... 1125 List Partitioning................................................................................................. 1126 Range Partitioning............................................................................................. 1127 Composite Range + Hash Partitioning ............................................................... 1128 Composite Range + List Partitioning ................................................................. 1129

Composite Partitioning Using Templates............................................................... 1130 Partitioning Tables with LOBs .............................................................................. 1131 Compressing Table Partitions ................................................................................ 1132 Types of Index Partitioning ................................................................................... 1134

Global Prefixed Indexes .................................................................................... 1134 Global Non-Prefixed Indexes ............................................................................ 1135 Local Prefixed Indexes ...................................................................................... 1136 Local Non-Prefixed Indexes .............................................................................. 1136

Views to Describe Partitions.................................................................................. 1137 How to Install and Configure Oracle Partitioning .................................................. 1139 Add Oracle Partitioning to an Existing Home ........................................................ 1140 How to Remove Oracle Partitioning ...................................................................... 1140 How Much Does Partitioning Cost ........................................................................ 1140 Limitations of Oracle Partitioning ......................................................................... 1141

Page 42: ChapterOnRMAN

Table of Contents

General Limitations ........................................................................................... 1141 Partition Key Limitations .................................................................................. 1142

Chapter 37: Intro to Oracle Recovery Manager (RMAN) .......................................... 1143 What is RMAN ..................................................................................................... 1144

What Are the Components of an RMAN Environment ...................................... 1144 Why Use RMAN................................................................................................... 1145

What Are the Main Features of RMAN ............................................................. 1146 What Are the Main Cons of RMAN .................................................................. 1147 Cross-Version RMAN Compatibility Issues ...................................................... 1148 RMAN Versus Your Own Solution ................................................................... 1149 RMAN and the Flash Recovery Area................................................................. 1150

Using RMAN to Reclaim Space in the FRA .................................................. 1151 RMAN and Media Managers / SBT Destinations............................................... 1152

Introduction to Media Managers, Libraries, and Modules .............................. 1152 Licensing Issues for Oracle RMAN....................................................................... 1153 Implementing RMAN............................................................................................ 1153

Define Your RMAN Infrastructure .................................................................... 1154 Install the RMAN Software ............................................................................... 1155 Create an RMAN Recovery Catalog Database ................................................... 1155

Planning Comes First..................................................................................... 1155 Run the DBCA To Create a New Database .................................................... 1156

Create the RMAN Schema ................................................................................ 1167 Create the RMAN Recovery Catalog................................................................. 1168 Register A Target Database ............................................................................... 1168 Configure Database Control as Your RMAN Interface ...................................... 1169

About Connections................................................................................................ 1170 Basic RMAN Commands ...................................................................................... 1170

Administrative Commands ................................................................................ 1171 Configure the Default Device Type ............................................................... 1172 Configure the Default Destination and File Name Format.............................. 1173 Configure the Retention Period...................................................................... 1173 Configure Auto-Backup of the Control File ................................................... 1174 Deleting Backups .......................................................................................... 1174 Deleting Expired Backups and Archlogs........................................................ 1175 Show the Current Settings ............................................................................. 1175 Resynchronize the Catalog ............................................................................ 1176 Reset the Database Profile ............................................................................. 1176

Backup Commands............................................................................................ 1177 Understanding the Syntax .............................................................................. 1177 Omitting or Skipping Objects During Backups .............................................. 1178 To Backup or Copy, That is the Question ...................................................... 1178 Backing Up and Copying Image Copies......................................................... 1179 Backing Up Archlogs .................................................................................... 1180 Backing Up The Flash Recovery Area ........................................................... 1182 Backing Up When Space Is Limited .............................................................. 1184

Page 43: ChapterOnRMAN

Table of Contents

Using Tags to Name Backups ........................................................................ 1185 Using Backup Commands to Scan for File Corruption................................... 1185

Restore and Recovery Commands ..................................................................... 1186 The Restore Process and Command Overview............................................... 1186 The Recovery Process and Command Overview............................................ 1187 Typical Restore and Recover Commands....................................................... 1187 Restoring Archlogs ........................................................................................ 1189 Using Tags to Restore a Named Backup ........................................................ 1189

Chapter 38: Upgrading to 10g & Migrating Platforms ............................................... 1191 Introduction........................................................................................................... 1192

Upgrading from 9.2 to 10.2 ............................................................................... 1192 Migrating from Windows to Solaris................................................................... 1193 Changing Word Size From 32-bit to 64-bit Oracle............................................. 1194

Additional Memory Requirements ................................................................. 1195 Upgrade Methods.................................................................................................. 1196

Tips and Suggestions......................................................................................... 1196 Migration Methods................................................................................................ 1197

Oracle Export & Import..................................................................................... 1198 Time is Against You...................................................................................... 1198 A Quick Review of the Export & Import Utilities .......................................... 1199

Oracle Advanced Replication ............................................................................ 1200 Oracle Streams Replication ............................................................................... 1201

What is Oracle Streams Replication............................................................... 1201 The Pros and Cons of Using Streams to Migrate and Upgrade a Database...... 1202

Oracle Transportable Tablespaces ..................................................................... 1204 Limitations .................................................................................................... 1204 Phases ........................................................................................................... 1206

Phase 1 - Generate a Transportable Tablespace Set .................................... 1206 Phase 2 - Convert the Endianness of Datafiles ........................................... 1207 Phase 3 - Transfer the Tablespaces............................................................. 1208 Phase 4 - Plug-In the Tablespaces .............................................................. 1208

Oracle RMAN Duplicate Database .................................................................... 1209 Limitations .................................................................................................... 1210

Oracle RMAN’s CONVERT Command ............................................................ 1210 Limitations .................................................................................................... 1211

GoldenGate TDM.............................................................................................. 1211 Quest SharePlex for Oracle................................................................................ 1213

Phases ........................................................................................................... 1213 Phase 1 - Capture....................................................................................... 1213 Phase 2 - Transport .................................................................................... 1213 Phase 3 - Post ............................................................................................ 1213

Oracle Puts SharePlex Customers on Notice .................................................. 1213 Consider These Oracle Issues Before Upgrading ................................................... 1214

Gone is the Rule Based Optimizer ..................................................................... 1214 Statistics are Gathered Automatically ................................................................ 1214

Page 44: ChapterOnRMAN

Table of Contents

The New SYSAUX Tablespace ......................................................................... 1215 The New Flash Recovery Area .......................................................................... 1216 Flashback, Undo Retention, and The Recycle Bin.............................................. 1216 Initialization Parameter File Modifications ........................................................ 1217

New Initialization Parameters to Consider Adding......................................... 1217 Old Initialization Parameters to Consider Removing...................................... 1218 Old Initialization Parameters to Consider Changing....................................... 1219

Plan Your New Sever Configuration Before Migrating.......................................... 1220 Select Hardware Platform.................................................................................. 1220 Select Server Model and Specifications ............................................................. 1221 Select Operating System Including Version and Word Size ............................... 1221 Determine Need for 3rd Party File System Management.................................... 1222 Determine Need for Other 3rd Party Software ................................................... 1222 Define Storage Requirements ............................................................................ 1223 Identify Oracle's Required Kernel Parameters.................................................... 1223 Define Directory Names / Paths......................................................................... 1223 Select Oracle Software Including Edition, Version and Word Size .................... 1225 Select Infrastructure Elements Like RMAN, Grid Control, and ASO/SSL ......... 1226 Define Naming Conventions for Databases and Listeners .................................. 1227 Define Oracle Software Owner - UNIX User and Group Names........................ 1228 Select a UNIX Shell such as C, Bourne, Korn, or Bash...................................... 1229 Identify Oracle's Required User Environment Variables .................................... 1229

Chapter 39: A Quick Look at 10g RAC on Veritas SF/RAC with WebLogic............. 1231 What is Oracle RAC.............................................................................................. 1232 What is Veritas SF/RAC ....................................................................................... 1234

Supported Versions ........................................................................................... 1236 Size Limitations ................................................................................................ 1236 What’s Coming in Version 5 ............................................................................. 1237

Files and Storage................................................................................................... 1237 Redundancy is Key............................................................................................ 1237 Types of Files and Where to Store Them........................................................... 1238

Overview of the 10g RAC Installation Process ...................................................... 1239 Gathering the Facts and Getting the System Ready............................................ 1240 Order of Operations........................................................................................... 1241 Upgrading RAC from 10.1 to 10.2..................................................................... 1243 Patchset 10.2.0.3 for Oracle RAC ...................................................................... 1243

What's Different About Creating RAC Databases.................................................. 1244 Sample Oracle Net Files for RAC.......................................................................... 1246

Sample SQLNET.ORA for RAC ....................................................................... 1246 Sample TNSNAMES.ORA for RAC ................................................................. 1247 Sample LISTENER.ORA for RAC.................................................................... 1249

Tips for Working with RAC Databases ................................................................. 1250 Understanding the Veritas Libraries for RAC ........................................................ 1251

The Veritas Cluster Server Membership Manager (VCS MM) Library .............. 1252 The Veritas Cluster Server Inter-Process Communication (VCS ICP) Library ... 1254

Page 45: ChapterOnRMAN

Table of Contents

The Veritas Cluster Server Oracle Disk Manager (VCS ODM) Library ............. 1257 Tasks to Perform When Patching Oracle and Veritas SF/RAC........................... 1259

Using WebLogic with RAC................................................................................... 1262 Introduction to WebLogic MultiPool ................................................................. 1262 Skip Configuring tnsnames.ora? ........................................................................ 1262 Sample Thin Driver URLs................................................................................. 1263 No Remote Listeners, Please ............................................................................. 1263 Reconfigure the Oracle Listener to Accommodate Connection Pools................. 1264

The Problem.................................................................................................. 1264 The Relevant Listener Parameter ................................................................... 1265 Understanding Your Options for Connection Load Balancing........................ 1265 RAC Considerations ...................................................................................... 1265 Examples....................................................................................................... 1266 Summary....................................................................................................... 1266 Pitfalls ........................................................................................................... 1266

Chapter 40: Unusual and “Catch All” Errors ............................................................ 1267

LRM-00104: 'n;' is not a legal integer for 'parallel'................................................. 1268 LRM-00116: syntax error at 'TABLE:' following '=' .............................................. 1268 ORA-00439: Feature not enabled; Partitioning ...................................................... 1269 ORA-00093: _SHARED_POOL_RESERVED_MIN_ALLOC MUST BE BETWEEN 4000 AND 0.......................................................................................................... 1270 ORA-00600 [kdimodnu0: non-colvec supplement]................................................ 1270 ORA-00600 [Keltnfy-ldmInit] , [46] , [1] .............................................................. 1270 ORA-00600 [kzaSqlBindLob1] , [22923].............................................................. 1270 ORA-600 [LibraryCacheNotEmptyOnClose] ........................................................ 1270 ORA-00824: cannot set sga_target due to existing internal settings ....................... 1271 ORA-07445........................................................................................................... 1271 ORA-10635: Invalid segment or tablespace type ................................................... 1271 ORA-10636: ROW MOVEMENT is not enabled .................................................. 1272 ORA-12500: TNS:listener failed to start a dedicated server process ...................... 1272 ORA-12545: Connect failed because target host or object does not exist ............... 1272 ORA-12640: Authentication Adapter Intialization Failed ...................................... 1272 ORA-16014: log string sequence# string not archived, no available destinations ... 1273 ORA-19809: limit exceeded for recovery files....................................................... 1273 ORA-19905: log_archive_format must contain %%s, %%t and %%r .................... 1273 ORA-23616: Failure in executing block 30 for script 245971217D86310DE0440003BA73140D............................................................ 1273 ORA-24313: user already authenticated ................................................................ 1274 ORA-25191: cannot reference overflow table of an index-organized table............. 1274 ORA-26752: Unsupported LCR received .............................................................. 1274 ORA-27477: <object name> already exists............................................................ 1274 ORA-28368: cannot auto-create wallet .................................................................. 1275 ORA-38700: Limit of %s flashback database logs has been exceeded. .................. 1275 ORA-38760: This database instance failed to turn on flashback database .............. 1275 ORA-39087: directory name <name> is invalid..................................................... 1275

Page 46: ChapterOnRMAN

Table of Contents

ORA-39145: directory object parameter must be specified and non-null................ 1276 OPatch Error 73 .................................................................................................... 1276

Chapter 41: A Very Brief Glossary............................................................................ 1278

PUBLISHER’S INDEX NOT INCLUDED WITH EBOOK DISTRIBUTION

Page 47: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1143

Chapter 37: Intro to Oracle Recovery Manager (RMAN)

This chapter provides an overview of the Oracle Recovery Manager utility, commonly referred to as RMAN. The installation and use of RMAN are covered, and a discussion of the all important planning and preparation activities to be performed prior to implementing an RMAN solution in any environment.

The information in this chapter is organized into the following sections: v What is RMAN

v Why Use RMAN v Licensing Issues for Oracle RMAN

v Implementing RMAN v About Connections

v Basic RMAN Commands

Page 48: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1144

What is RMAN Oracle Recovery Manager, or RMAN, is an enterprise class tool for performing backup and recovery operations on Oracle databases. It supports full and incremental backups, hot and cold backups, and two types of compression (NULL and Binary). Encryption is supported for Enterprise Edition customers who have a current license for the Oracle Advanced Security Option (ASO). RMAN also works with several of the leading media managers, or tape library servers. RMAN runs on all platforms that the Oracle database runs on, and works with target databases version 8.0 and higher.

The following sections further describe RMAN in terms of its various components and capabilities. Later sections discuss the features and limitations of RMAN.

What Are the Components of an RMAN Environment To understand RMAN, it helps to think about the various components of RMAN. Every RMAN installation has three core components: the RMAN utility software, the database you want to backup, and a repository that keeps track of the target databases and related backup and recovery facts. There are additional components, which are optional. The three core components of RMAN, and two more optional components of RMAN, are described below: Ø The RMAN Utility Software – Also known as the RMAN Client, this is the

software that can be used to backup and recover a target database. The main executable is a file named rman.exe on Windows, or simply rman on many UNIX platforms. The executable is stored in directory $ORACLE_HOME/bin. The RMAN client has a command-line user interface (CLUI), as opposed to a graphical user interface (GUI). If you really need a GUI for RMAN, you can use the OEM Database Control, but some RMAN functionality is not supported and can only be accessed through the RMAN CLUI. The RMAN utility also uses a proprietary and unique command set: RMAN does not use standard SQL or SQL*Plus commands.

Ø The Target Databases – These are the databases you want to backup or recover using RMAN. They are referred to as “targets” because they are targets of your backup strategy.

Ø The RMAN Repository – This is where Oracle stores metadata about each of your target databases and all of the backup and recovery operations performed on each of those target databases. The repository can be implemented in two forms: the target database’s control file, or a Recovery Catalog Database. By default the RMAN repository is stored in your target database’s control file, but it is limited on space, cannot be used to store scripts, and only supports one target database. The Recovery Catalog Database is an optional database with a special RMAN recovery catalog schema. Simply known as “The Catalog”, the Repository Catalog Database stores all RMAN repository information from all of your target databases. The Recovery Catalog Database can be stored anywhere on your

Page 49: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1145

network, including other geographic locations, so that if your target databases were lost in a disaster your Recovery Catalog Database would survive and be useful in reconstituting all of your target databases.

Ø Flash Recovery Area (FRA) – An optional component of the RMAN environment that is essentially a large disk area that RMAN can use to store backups. The FRA can be used to store archived redo logs, but RMAN works fine whether you store the archlogs in the FRA or not. The FRA can also be used to store Flashback Database Log files used by the Flashback Database command, and the Change Track Writer index used by RMAN to perform very fast incremental backups. The FRA is also a great place to store multiplexed copies of your target database control files and on-line redo log files.

Ø Media Manager - An optional component of the RMAN environment such as a network attached tape server or optical jukebox. A few Oracle customers backup to locally attached disks, but most large organizations have Media Manager infrastructure in place, and require their database backup and recovery solutions work with that existing infrastructure. The most commonly used type of media manager is a tape system, such as the IBM Tivoli Storage Manager. Oracle generally does not provide interfaces to Media Managers. Oracle makes available an API kit for Media Manager vendors to integrate their products with RMAN. For example, IBM makes the Tivoli Data Protection for Oracle, which is a software module for connecting RMAN to Tivoli Storage Manager.

Why Use RMAN In the sections that follow, I discuss many reasons to consider using Oracle’s Recovery Manager (RMAN) utility for database backup and recovery operations. I discuss the main features of RMAN, as well as the primary negatives of RMAN. I then provide a comparison of using RMAN versus your own (i.e., home grown) backup and recovery scripts.

Keep in mind that Oracle RMAN is free. It might not have every feature that a more expensive 3rd party product has, but you need to determine the value of those extra features. A large organization could spend several million dollars on a 3rd party alternative to RMAN, and spend another million dollars per year on annual maintenance agreements and upgrades over the lifespan of that product. You have to wonder if they really got their money’s worth, considering the features that are available in the free RMAN solution.

Over the years, since RMAN was first introduced with Oracle 8, the RMAN product has come a long way. If you used it with Oracle 8 or 8i, and got completely turned off to RMAN at that time (like I did), then you should take another look at the 10g version of RMAN. I think you will be pleasantly surprised at how mature the product has become.

Page 50: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1146

What Are the Main Features of RMAN RMAN has numerous features making it an enterprise class backup and recovery solution. The new features alone could fill a chapter in this book. In this section I describe some of the main features found in RMAN. Ø Backup Sets– RMAN allows you to backup database files as a backup set. A

backup set is a proprietary RMAN format that stores one or more files, such as datafiles, control files, archlogs, or SPFILE. Database files are typically compressed within backup sets, and use less storage space on disk and tape. Also, because backup sets typically contains multiple database files, writes to tape run with fewer interruptions.

Ø Image Copies – RMAN allows you to copy database files as Image Copies. An Image Copy is a true copy of a file, like an operating system copy command issued as part of a cold backup, but because it was made in RMAN it is recorded in the RMAN Recovery Catalog and can be used in automated recovery operations. RMAN makes image copies while the database is up and running, and does not need to issue any special commands to take the file off-line or put the tablespace in backup mode. Competing products might refer to these as “on-line and off-line backups”, but with RMAN the copies are true bit-for-bit copies.

Ø Full and Incremental Backups –RMAN can be used to take a backup of the whole database, and it can be used to take a backup of things that changed. If a full backup is taken while the database is hot (i.e., a Backup Set) then RMAN skips the unused blocks above each segment’s high water mark, for faster backups and smaller backup set files. If an incremental database is taken while the database is live, then RMAN is able to capture just those blocks that have changed since some point in time. All competing products offer full backups, but their full backups take longer and produce larger backup sets because they don’t skip the empty blocks. Likewise, the incremental backups of some competing products take longer because they have to check every block’s header to see if it has been changed since the last backup, whereas Oracle and RMAN work together and support each other.

Ø Fast Incremental Backups – This is a new feature in RMAN 10g supported by the Block Change Tracking feature, which itself is a new feature in Oracle Database 10g. The database’s new Change Track Writer process continually updates a bitmap index stored on the file system with the ID numbers of blocks that have changed since the last backup. The index is generally very small, and can be read very quickly by RMAN. Using this technique, RMAN can quickly locate the blocks that need to be backed up. And, because the bitmap index contains the block’s precise address, RMAN can access and backup those blocks very fast.

Ø Block Corruption Detection and Repair – RMAN has a BACKUP VALIDATE command that can be used to validate your database files. No backup will be generated. Instead, RMAN will validate the names and locations of the files for logical corruption issues, and will check the files at the block-level for physical corruption. If any corruptions are found, RMAN writes the information to the

Page 51: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1147

database’s data dictionary where it can be reviewed using the view V$DATABASE_BLOCK_CORRUPTION. If physical block corruption is encountered, you can use RMAN to rectify the situation with the BLOCKRECOVERY CORRUPTION LIST command. By default, the BACKUP VALIDATE DATABASE command only checks for physical corruption, but you can always force it to check for logical corruption using the BACKUP VALIDATE CHECK LOGICAL DATABASE command.

Ø Encrypted Backups – RMAN can encrypt backups using a password or the credentials stored in an Oracle Wallet. Password based encryption requires you to enter the password on each backup and restore operation, as RMAN has no way to store or persist the password between operations. Wallet-based encryption runs transparently to the system, and does not prompt the operator to enter any passwords. However, the same Wallet must always be available or you cannot restore the data, which is really bad for post-disaster recovery operations. Encrypted backups requires Oracle 10.2 or higher, requires a separate license for Oracle’s Advanced Security Option (ASO), you cannot encrypt image copies made by RMAN, and you can only encrypt backups to tape if the media manager is Oracle’s own Oracle Secure Backup.

Ø Compression – RMAN supports two types of compressed backups: NULL Compression and Binary. NULL Compression works by skipping blocks that have never contained data; some 3rd party tools also do this, but they still have to scan each block to see if it contains data, whereas RMAN simply skips all blocks beyond a certain address. Binary compression is a new feature in RMAN 10g that utilizes the existing Oracle Server compression process for archlogs; backup sets can often be compressed by factors between 2 and 4, but it depends on your database.

Ø Recovery Catalog Database – By default Oracle only stores backup and recovery metadata in the target database’s control file. If the control file is lost, then all metadata is lost. RMAN allows you to create a centralized repository, where the metadata for all target databases is stored. The repository is an Oracle database, referred to as the Recovery Catalog Database. Because the repository is an Oracle database, it can be secured and backed up. For example, you can export the contents of the repository using Oracle DataPump Export and Import utilities. You can also replicate it to other locations for high availability and disaster survivability. Many competing products offer far less capable solutions to storing the backup and recovery metadata.

Tip: in the 10.2 release of RMAN, Oracle has changed the NULL Compression algorithm to be more efficient. In previous releases RMAN would only skip blocks that were never NULL, but starting in 10.2 it will skip blocks that are currently NULL.

What Are the Main Cons of RMAN There are several limitations of the RMAN product that could lead to incomplete recoveries after a major disaster, unless you plan accordingly. By incomplete, I mean in

Page 52: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1148

some cases data could be missing, but it most cases the environment would be missing certain things. Please take the time to review the below list of shortfalls, and update your disaster recovery plans accordingly: Ø RMAN cannot backup BFILEs or external tables, as both are stored outside of the

database. Ø RMAN cannot backup database password files or network configuration files.

Ø RMAN cannot backup the Oracle Base or Oracle Home locations. Ø RMAN cannot backup non-Oracle databases. If your organization has non-Oracle

databases, you could use a different backup & recovery tool for each of them, or you could try to find one tool that covers them all.

If you are using advanced features like Data Guard, then be sure to review the list of known issues between RMAN and those advanced features.

Compared to 3rd party tools, there are a few additional shortcomings. RMAN does not monitor your archlogs destination for space pressure, and does not automatically initiate backup/removal of archlogs to maintain free space like some 3rd party alternatives. Most enterprise class backup and recovery tools also help you write scripts, but with RMAN you need to use the OEM Database Control to generate those scripts with limitations – or you can write them the hard way (i.e., no wizards) inside the RMAN utility. The 3rd party tools might also allow you to initiate logical backups (i.e., import and export operations) in addition to physical backups and recoveries, whereas RMAN strictly supports physical backups and recoveries. The new encryption features of RMAN might not be available to you depending on whether you have 10g Release 1 or 2, and there are licensing restrictions on the encryption feature as well. Additionally, the “unused block compression” feature, which is also known as NULL Compression, generally continues to backup empty blocks up to the high water mark. None of these issues are showstoppers to preclude the use of RMAN, but still you should take them into consideration when deliberating between RMAN and a 3rd party product.

Cross-Version RMAN Compatibility Issues You can use various versions of RMAN to backup Oracle databases, and many customers run multiple versions of Oracle databases on the same server. However, you cannot mix and match RMAN and database versions without restrictions. The newer versions of RMAN contain commands that are not recognized by older target databases. Your Recovery Catalog database should correspond to the highest version of RMAN you are using. According to Oracle Note 307022.1, you should always use the target database’s RMAN executable to backup the database. In other words, you should ensure that the version of the RMAN executable precisely matches the version of the target database. The same note also states that you should always use the latest release of Oracle Database Server for your Recovery Catalog, if you are using a Recovery Catalog database to store the

Page 53: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1149

RMAN repository. Using the latest version ensures the greatest degree of compatibility with the many versions of your target databases.

It’s not uncommon to have multiple Recovery Catalog databases for use with RMAN. You might have one to use when backing up Oracle 8.1.7 databases, another for managing backups of Oracle 9.2 databases, and another for Oracle 10.2 targets. This is not required, but some DBAs contend it makes their environment “cleaner” because it eliminates the pitfalls of mixing software versions. When a database is upgraded from 9.2 to 10.2, for example, the old backup metadata is left in the 9.2 Recovery Catalog Database and the new database’s metadata is stored in the 10.2 Recovery Catalog Database.

RMAN Versus Your Own Solution In this section I discuss the limitations of custom solutions, and how those limitations are overcome by RMAN. Writing your own backup solution requires no special tools or programming language skills other than rudimentary SQL and PL/SQL. I typically build such solutions in Windows Notepad or VI using SQL*Plus and a few PL/SQL commands. In two day’s you can draft your own backup solution. Let’s say that it takes a whole week, because you take the time to debug your program, enhance it, and run it through a series of tests. If we assumed that the average hourly rate for a mid-to-senior Oracle DBA is $125/hour, then writing your own backup solution costs your customer $5,000. That’s cheap. Many 3rd party products charge large organizations hundreds of thousands of dollars, even millions.

As described above, cost might be a good argument for using a home-grown solution versus a pricey 3rd party product. Cost is generally not a good argument for not using RMAN, because RMAN is free. Let’s think for a minute: what might a home-grown solution have or lack compared to RMAN?

Custom solutions can typically perform hot and cold backups. Custom solutions are also typically dynamic, so that any new tablespaces or files are automatically picked up by the backup routine. Custom backups can be scheduled, just like the more pricey alternatives, by using a UNIX “cron table” or the Windows Scheduler feature.

Custom solutions generally can only do full backups, and cannot do incremental backups. If you are using SQL and PL/SQL commands, and even standard operating system commands, you have no way to know which blocks inside each datafile have changed since the last backup.

Custom backups also have trouble with parallel operations and performance in general. Another place where custom backup solutions tend to be lacking is compression; custom backups typically just put the tablespaces into hot backup mode, and then copy the database files to another location. On some platforms it’s relatively easy to send the stream through a compression utility, but on other platforms it is not so easy.

Page 54: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1150

Perhaps the greatest inability of the custom solution is to send the backup to a media manager such as a tape library system. It’s very easy to backup to disk, and it’s not too difficult to backup to a local tape drive, but it’s a major feat to backup to an enterprise class 3rd party media manager like IBM’s TSM. Probably the best you could do is backup to a disk, and then let those files be archived to tape as part of the operating system’s nightly backup routine.

RMAN and the Flash Recovery Area In this section I discuss how RMAN uses the new Oracle 10g Flash Recovery Area (FRA). RMAN and the FRA interact in two basic ways: Ø RMAN can use the FRA to flashback your database

Ø RMAN can backup the FRA to tape I want to focus on the first of the above two interactions between RMAN and the FRA. The second item, backing up to tape, is generally not covered in this book because each 3rd party vendor has unique steps and procedures.

Earlier in this book I described the Flash Recovery Area (FRA) in terms of its various background processes, memory structures, log files, and initialization parameters. To quickly recap, Oracle captures the before images of blocks and writes them out to Flashback log files in the FRA. If you tell Oracle to flashback the database to a prior point in time or SCN, then Oracle applies those before images from the Flashback log files to the datafiles. If the before images get close but not close enough to the flashback point, then Oracle rolls forward with the archlogs and on-line redo log files. Assuming you have configured the database to use the FRA and related processes and memory areas, you should next tell Oracle which files to store in the FRA. Oracle will automatically store all Flashback log files in the FRA. Typically, you should store in the FRA one copy of your control file, one member from each on-line redo log group, and one copy of each archived redo log file. If you are using RMAN, then you should also set the backup destination to be the FRA: a full image copy of the database as well as any full and incremental backup sets should be stored here.

Tip: to store all of these files in the FRA, you need to allocate approximately three to four times as much disk space to the FRA as you did for your datafiles. A terabyte FRA would not be unusual. Writing backups to the FRA is a simple matter. If you set the initialization parameter DB_RECOVERY_FILE_DEST to a valid value, then RMAN will append to that value your database name, and the word “backupset”, and the current date. In the end, Oracle creates a unique directory name for each backupset based on the DB Name plus date. All files associated with the given backupset are stored in this one location.

For example: if I set DB_RECOVERY_FILE_DEST = ‘/oraflash’ and I set DB_NAME=REMIDATA, then RMAN’s backups might go to a destination like the one shown below. Note, the file name is OMF generated and ends with “.bkp”.

/oraflash/REMIDATA/backupset/2006_07_29/<omf filename>.bkp

Page 55: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1151

You can issue the same FLASHBACK DATABASE command in either SQL*Plus or RMAN. If you will issue it in SQL*Plus, then it is up to you to first ensure all pre-requisites are satisfied. If you run the command in RMAN, then it will check to make sure all datafiles and required log files (flashback, on-line redo, and archlogs) are present. Also, if you use RMAN and it determines rolling forward is required, then it will do that automatically, whereas in SQL*Plus you have to take care of that yourself.

Before you can use Flashback Database, there are a few big showstoppers to consider. These are easily overcome, but you need to be aware of these issues and plan accordingly. Ø You cannot flashback any datafiles that have grown after the time you want to

flashback to. For this reason, I recommend against creating your datafiles with the AUTOEXTEND ON clause if you will be using the Flashback Database feature.

Ø You cannot flashback the database unless all datafiles are present. If a datafile is missing or corrupted, then you must recover that datafile using traditional media recovery techniques prior to flashing back the database.

What’s interesting is that Oracle will not do a recovery operation as part of a flashback. If the best way to get you back to a certain point in time is to restore backup files and roll forward, it will ignore that and stick to its task of pulling the before images out of the flashback log files and injecting them into the datafiles.

Using RMAN to Reclaim Space in the FRA All files put into the FRA consume space against a quota. Simply removing files from the FRA (i.e., using operating system commands) does not update Oracle’s metadata related to the FRA, reclaimable space, and your quota. The only way to do all that is to use RMAN to backup the FRA to tape. This tell Oracle the files are no longer required to remain in the FRA and can be removed to reclaim space. Tip: you should not use the FRA unless you are also using RMAN.

Using RMAN to backup the FRA to tape instructs Oracle to update the data dictionary tables that monitor space within the FRA. For example, you will notice column SPACE_RECLAIMABLE increases in the view V$RECOVERY_FILE_DEST after each backup of the FRA to tape. Backing up the FRA to a disk location is not supported, and does not make Oracle aware of reclaimable space. As noted earlier, Oracle is unable to manage space within the FRA unless you have configured RMAN to backup the FRA to a tertiary storage device, such as a tape library. However, Oracle realizes that many developers (including thousands of their own employees and contractors) do not have access to tape storage systems. Oracle provides the "oracle.disksbt" API, which can be used to define a disk area as a pseudo-tape device, and thus allows you to backup the FRA to disk using a SBT_TAPE channel even though you don't really have a tape system. For example,

RMAN> configure channel device type 'SBT_TAPE' parms 'SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/disk3)';

Page 56: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1152

Please note the "oracle.disksbt" API is for development systems only, and is not a support means of backing up production database systems.

Then, to do the actual backup of the recovery area you can use the RMAN command “BACKUP DB_RECOVERY_FILE_DEST” as shown here:

RMAN> BACKUP DB_RECOVERY_FILE_DEST;

Actually, the keyword DB_RECOVERY_FILE_DEST as shown above is a synonym for the Recovery Area. This means you could also perform the exact same backup of the Flash Recovery Area using this command:

RMAN> BACKUP RECOVERY AREA;

Tip: occassionally RMAN will fail to backup the FRA, claiming that an archived redo log file is missing; you see the section on “Backing Up the Flash Recovery Area” for information about how to resolve this issue. Now that you have used RMAN to backup the FRA to a SBT device, you are free to delete some of the backups and archlogs from the FRA and make room for new files.

RMAN> DELETE OBSOLETE;

RMAN and Media Managers / SBT Destinations In this section I discuss how RMAN can be used with tape devices and storage managers like IBM’s Tivoli Storage Manager, EMC’s Legato NetWorker, Symantec’s Veritas NetBackup, and Computer Associates’ BrightStore ARCserve Backup.

Some 3rd party products use RMAN to do the backups of your Oracle databases, and they provide their own software as a fancy user interface as well as a system interface (or module) between RMAN and their backup infrastructure. Other companies sell whole packages, replacing RMAN altogether. If you really want to use RMAN in conjunction with a 3rd party Media Manager, then you must make this point clear to the vendor.

Introduction to Media Managers, Libraries, and Modules RMAN by itself can only backup to disk; RMAN out of the box cannot backup to tape. The disks used to hold your RMAN backups can be internal or mounted. For example, the disks could be part of a corporate storage array that is mounted to your Windows-based Oracle server as the D drive. If your Oracle server catches on fire, your backups are safe because they are stored some place across the network on the corporate storage array. If you want to use RMAN to backup directly to tape, then you need a Media Manager. A Media Manager runs the media infrastructure (i.e., tape library servers). There are plenty of 3rd party media managers. Oracle even offers a product called Oracle Secure Backup.

Sitting between RMAN and the Media Manager is a Media Manager Library, or module. This module takes commands from RMAN and reworks them to be compatible to the Media Manager. Generally speaking, you cannot use RMAN to backup to tape without a Media Manager Library or “module”.

Page 57: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1153

The trick here is, if your Media Manager vendor does not offer a Media Manager Library for RMAN, then you cannot use RMAN to do the backups. All of the vendors I listed at the start of this section provide Media Manager Libraries for RMAN, and there are many more. Just ask your Media Manager vendor about RMAN support. You could try asking Oracle, but that would be a backwards approach: Media Managers can be million dollar corporate investments, and you should not pick the first one to support RMAN.

Tip: start by looking at the tape library systems your organization already has in place, and then ask the resource vendor about a media manager for Oracle RMAN.

One thing to keep in mind when using RMAN with a 3rd party Media Manager is you will need to disable or ignore some of the Media Manager’s features. Take retention policies for example. You should define a retention policy (i.e., recovery window) in RMAN, and disable or unset the retention policy in your Media Manager.

Oracle Secure Backup is discussed elsewhere in this book, so I won’t go into too much detail here. However, I do want to point out a few things about Oracle Secure Backup: it is only available with Oracle 10.2 and higher, and in my opinion it does share or integrate well with corporate media managers like TSM. That is, Oracle wants you to carve out a set of resources to be dedicated to Oracle Secure Backup. Some organizations are fine with that, while other organizations require database backups utilize existing infrastructure.

Licensing Issues for Oracle RMAN RMAN is free and bundled with the Oracle Server license. The question I often hear is, “do I need another license for Oracle to create a RMAN Recovery Catalog Database?” The answer is no, as long as you have licenses for the Oracle running your target databases you are licensed to create and run a RMAN repository at no additional cost. The Oracle licensing documentation states you can create one repository (i.e., catalog database) at no additional cost. The database may hold your RMAN and Grid Control repositories only, and not for application data. It need not be on the same server as your target databases. There are some advertised features of RMAN that are not freebies, and some features are not available to customers using the Standard or Standard ONE editions of Oracle. For example, RMAN Backup Encryption requires an expensive license for the Oracle Advanced Security Option (ASO), which itself requires the Oracle Enterprise Edition. Tip: there is a bug in Oracle’s documentation that states ASO is required to use RMAN compressed backups; ASO is not required to use either of RMAN’s compression techniques.

Implementing RMAN Implementing RMAN is a process that consists of the following general tasks:

Ø Define Your RMAN Infrastructure

Page 58: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1154

Ø Install The RMAN Software Ø Create an RMAN Recovery Catalog Database

Ø Create The Recovery Catalog In The Repository17 Ø Register Each Target Database With RMAN

Ø Test Backups and Recovery Each of these are tasks is addressed below as separate sections.

Define Your RMAN Infrastructure Before you begin the process of setting up RMAN in your customer’s environment, there are a number of planning issues to be addressed: Ø Will you use a Recovery Catalog Database or the target database’s control file to

store the RMAN repository? Do you understand the differences between using one or the other? The rest of the questions assume you will create a Recovery Catalog Database.

Ø Which server will host the RMAN Recovery Catalog Database? I recommend against storing the RMAN Recovery Catalog Database on the same physical server as any of your target databases, and if possible the RMAN database should be stored in a different room or building.

Ø Which tablespaces and catalogs do you need in the Recovery Catalog database, and how big should the tablespaces be?

Ø What will be the name of your RMAN Recovery Catalog Database?

Ø What will be the name and password of your RMAN user account in the Recovery Catalog database?

Ø How will you provide a highly available RMAN Recovery Catalog Database? Will you use RAC, or Streams Replication, or Data Guard? What about 3rd party solutions like Veritas HA.

Ø Will your backups go to disk or tape? If disk, will it be local disk on each database server, or shared storage? If backing up to tape, will you be using a 3rd party media manager like the Tivoli Data Protection for Oracle module, or will you be using Oracle Secure Backup? Will your RMAN backups go to the Flash Recovery Area on disk, and get backed up from there to tape?

Ø Will you be using the new Fast Incremental Backups feature in RMAN 10g, which requires you to enable the Block Change Tracking feature and its associated background processes and memory areas? Do you understand the performance implementations of this, and have you compared these implications to the expected efficiencies of your daily incremental backups?

17 When the Repository is put into a database, the database is then known as a Recovery Catalog Database.

Page 59: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1155

Ø What are the implications of using RMAN with Oracle options like Database Vault? If RMAN requires that you connect to the target database as a SYSDBA user, and the SYSDBA privilege cannot backup data in a database protected by Oracle Database Vault, then how will RMAN be used?

Ø What are Oracle’s requirements for password files on your target databases? If you will be launching the RMAN utility on the same server as the target database, and using the same operating system user account that owns the Oracle Home containing the RMAN utility, then no password is required. In all other cases a password file is required.

Tip: to connect to a target database on UNIX the password file must exist in ORACLE_HOME/dbs. However, on Windows you can put the password file anywhere as long as you set the Registry key ORA_SID_PWFILE.

As you can see from the above listing, there are numerous decisions that need to be made before you install any software or get started with RMAN. Carpenters have a saying, “Measure twice and cut once”. In a nutshell it means to remind us that resolving problems takes a lot more time than good planning.

Install the RMAN Software Installing the Oracle 10g Database Server automatically installs the RMAN software into your Oracle Home. No separate installation steps are required for RMAN. It is interesting to note, there is no option to block RMAN from being installed to your server. It will always be present. RMAN is only found in Oracle 10g Database Server installations. It is not part of the Oracle Client installation package. If you want to access RMAN from a client workstation, I recommend you either use a terminal emulator program like PuTTY, or you use Oracle’s Database Control web-based administration utility. Tip: if you try to run RMAN on a computer that only has the Oracle Client software installed, then you will get an error that RMAN could not find the file $ORACLE_HOME/rdbms/admin/recovery.bsq.

Create an RMAN Recovery Catalog Database The sections below detail the processes of planning and creating your Oracle RMAN Recovery Catalog database. Note: if you will not be using a Recovery Catalog database and will be using the target database’s control files instead, then skip this information. Tip: the Recovery Catalog Database is often called “The Repository”, because it’s the repository for the recovery catalog. It is also referred to as “The Catalog”. Technically that is a misnomer as the database is not the catalog, but rather the holder of the catalog.

Planning Comes First One of the first things to decide is what to name your new database. Maybe you will call it RMANCATD in the development environment, and RMANCATT and RMANCATP

Page 60: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1156

in your test and production environments. The name is up to you. If the database will be used to support both RMAN and Grid Control, then maybe you want a generic name like INFRA for infrastructure. Another piece of easy house keeping is the name and password for the user ID that will own the RMAN catalog. Most people set the name to RMAN, and the password should be something easy to remember yet hard for others to guess. In many of my examples I use RMAN/RMANPWD, but that’s just an example and you should pick a real password. After you create the RMAN user you must grant him the database role RECOVERY_CATALOG_OWNER. This role includes system privileges that are equivalent to the CONNECT and RESOURCE roles, so there is no need to grant these additional roles to the RMAN user. The Recovery Catalog Database does not need a lot of features. If you are familiar with the Oracle catalog scripts, you just need catalog.sql and catproc.sql. You do not need to install the JVM, XML DB, or the Oracle Text catalogs because RMAN won’t use them.

The size of your new database might be anywhere from 2 GB to 8 GB, depending on how many target databases you have and how long you want to keep backup and recovery information. RMAN needs approximately 70 MB per target database per year. A medium sized organization with 50 target databases would need a minimum of 3.5 GB. You should also allocate 500 MB each for the tablespaces SYSTEM, SYSAUX, TEMP, and UNDO. Now you’re up to 5.5 GB. By the time you factor in your control files, redo logs, archlogs, and administrative files, you might get up to the 8 –10 GB range. And that assumes the database will only be used for RMAN. If the database will also be used as a Grid Control repository, then you need to add more space. The memory requirements are low for an RMAN database, but as you know Oracle 10g requires a lot of memory compared to previous releases. Your SGA will be somewhere between 640 MB and 1024 MB, and your PGA Aggregate Target will be around 48 MB.

In a high availability environment, you should consider implementing Oracle RAC or Streams Replication to your RMAN Recovery Catalog database. If you do nothing else to protect the database, then plan to shut it down periodically to make cold backups that can be taken off the server and put in a safe place. If you were to lose the Recovery Catalog database and you did not have a backup, then you would lose all of the metadata for all of your target databases, making all of their backups obsolete.

Run the DBCA To Create a New Database The first step in the process of implementing RMAN is to create an RMAN Recovery Catalog Database. This section provides step-by-step instructions for creating that database. The first step is to launch the Oracle Database Configuration Assistant (DBCA.) Windows users will find the DBCA under Start > Programs > Oracle–HomeX > Configuration and Migration Tools > Database Configuration Assistant.

Page 61: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1157

When you launch the DBCA, the first screen to appear is a “Welcome” screen. Just click Next to continue to the next screen.

When the following screen appears, make sure the option to Create a Database is selected and then click Next.

Page 62: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1158

When the following screen appears, select Custom Database and click Next.

On the following screen, enter the name of your new database including any Oracle Net domain information. My sqlnet.ora specifies a default domain of WORLD, so I set the Global Database Name field to the concatenated values of my ORACLE_SID plus .WORLD. As a result, the initialization parameter DB_NAME will be set to RMANREP and SERVICE_NAMES will be set to RMANREP.WORLD.

Page 63: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1159

On the below screen, you should accept the option for monitoring the database with Oracle Enterprise Manager (that’s good practice for all of your databases) but you do not want to configure daily backups of this database using RMAN, because RMAN cannot backup itself. When ready to continue, click Next.

On the following screen, set your schema passwords and then click Next. To hurry the process you can set all of them to the same password at this time, and worry about assigning unique passwords to each schema later.

Page 64: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1160

On the following screen, select the type of storage system you will be using and then click Next. Typically, you should select File System. In Oracle 10g, however, ASM is also a possibility, and provides the benefits of a logical volume manager to take care of striping and mirroring your database files. However, do not pick ASM unless you know ASM has already been configured and tested on your system. Raw Devices should not be picked unless you are using Oracle RAC, but even then if you are using a clustered file system like Veritas you would pick File System and not RAW.

On the next screen, you are asked to specify the location where you want Oracle to create all of the database files, and then click Next. Here I have selected OMF, but it’s up to you. If you are unsure, stop for a moment to research the various options as they are described in this book.

Where I have selected OMF, Oracle automatically sets the database area to “{ORACLE_BASE}\oradata”. In my case, that is D:\Oracle\Oradata. When the

Page 65: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1161

database files are created, Oracle will automatically append the SID to the path, so my OMF directory name is really D:\Oracle\Oradata\RMANREP.

Tip: if you have multiple mount points or disk partitions, so that the Oracle binaries are on one and the Oracle database files are to be created on another, then the DBCA might not work for you. The workaround is to put everything into a single locating using the most simple OFA case, and then later you can move files to alternate locations.

One last thought before we continue: it is generally wise to multiplex control files and redo log files. However, the “Multiplex” button on this particular screen only works if you selected Oracle Managed Files (OMF). Don’t worry if you did not select OMF, because Oracle still gives you an opportunity to define multiplexed file locations a few screens from now.

On the following screen we are asked two things: do we want to use a Flash Recovery Area, and do we want to run the database in Archivelog Mode. In this example, I accepted the default values. Actually, for an RMAN Recovery Catalog database you might use neither. (A lot of Oracle DBAs run their catalog databases in NOARCHIVELOG mode and take a cold backup of the catalog database once a week.) When ready, click Next to continue with the database creation process.

Page 66: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1162

The following screen asks you which schemas or catalogs to install into your new database. Because this is an RMAN Recovery Catalog database, and not an application data repository, I have deselected every option except the OEM Repository, which is needed later during the configuration of the OEM Database Control. RMAN simply does not need all of those advanced features and add-on products.

On the above screen, notice the button for Standard Database Components. I recommend you click on it, and deselect some “standard” components, because if you are creating a RMAN repository you do not need to install JVM or Oracle Text. Those extra components make patches and upgrades more difficult, and they add to your memory and disk space requirements.

This next screen (step 10 of 12) has four tab pages. I will discuss each separately.

Page 67: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1163

The first tab page “Memory” is used to size the SGA and PGA. As you can see, I have selected Custom and Automatic, so Oracle will use the numbers I provide to set initialization parameters SGA_TARGET and PGA_AGGREGATE_TARGET. The numbers I show here are typical for RMAN in small to medium offices, and should be increased in offices that backup a great many databases with RMAN. Do not click Next just yet, and click on the tab-page for Sizing.

On the Sizing tab-page, shown below, I have kept the default values.

Page 68: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1164

On the Character Set tab-page, shown below, I kept the default values. Please note the default values maybe different for each platform: in my case it is a 32-bit Microsoft Windows platform.

On the Connection Mode tab-page (shown below) I have accepted the default value of Dedicated Server Mode, because RMAN requires dedicated connections.

When done reviewing the various tab pages described earlier, click Next to continue to screen 11 of 12.

Page 69: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1165

Using the screen shown below, verify the list of tablespaces, datafiles, and redo log files. All of the tablespaces will be set, by default, as locally managed with automatically sized extents (i.e., not uniform size) and Automatic Segment Storage Management (ASSM). Each datafile will be set to AUTOEXTEND by default. There will also be three redo log groups with one member each, and all redo log files will be 10 MB. Perhaps the only adjustment you need to make to any of this information is that you might want to add a second file to each redo log group. (Recall earlier the discussion of Multiplexed Files). When ready to continue, click Next.

Page 70: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1166

The last major screen is shown below. By default, the option to Create Database is selected, but if you are not ready to create the database right now you can uncheck that option and check the boxes for Save as Database Template and/or Generate Database Creation Scripts. Regardless of whether I am creating the database or a template, I always check the box for Generate Database Creation Scripts: reviewing the scripts at a later time will help you understand how Oracle works.

A confirmation screen will appear. Click OK to continue. The following progress monitor screen will appear. No action is required on your part.

Page 71: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1167

Please note you cannot use the DBCA on this computer to perform any other tasks until the database has been created and this progress window has been closed.

When the database has been created, a summary screen will appear that starts with the line “Database creation complete.” Simply click Exit to end the process.

Create the RMAN Schema In the preceding section we created a new Oracle 10g database to store an RMAN Repository. But, as you know, storing schema objects requires a user account and a tablespace, which were not created in the earlier section. In this section we will create that user and tablespace to hold the RMAN Repository schema objects. We will also grant the necessary privileges and roles to that schema, as required by the RMAN software. The RMAN schema should only be created in the RMAN Recovery Catalog database. Do not create the RMAN user in each of your target databases. That is, in the databases to be backed up by RMAN you should not create the RMAN user. When you use the RMAN software to backup a database, RMAN must connect to the target as SYSDBA. Here is a complete set of commands that can be run to create the RMAN user in your database. The user’s name need not be RMAN: it can be anything you like. Also, please recall that we cannot create a user unless there are tablespaces in the database, so my example begins with a command to create a tablespace named RMAN.

-- THESE EXAMPLES ASSUMES ORACLE MANAGED FILES (OMF). -- ORACLE WILL GENERATE FILE NAMES AND USE DEFAULT SIZES. -- ORACLE WILL ALSO USE LOCALLY MANAGED EXTENTS AND ASSM. ALTER SYSTEM SET DB_CREATE_FILE_DEST='C:\oracle\oradata\REMIDATA'; CREATE TABLESPACE RMAN; CREATE TEMPORARY TABLESPACE TEMP; CREATE USER RMAN IDENTIFIED BY RMANPWD DEFAULT TABLESPACE RMAN TEMPORARY TABLESPACE TEMP QUOTA UNLIMITED ON RMAN; GRANT RECOVERY_CATALOG_OWNER TO RMAN;

Notice in the above example that I did not grant CONNECT or CREATE SESSION to the user. Nor did I grant RESOURCE or other roles to the RMAN user. This is because the role RECOVERY_CATALOG_OWNER contains the system privileges CREATE SESSION and pretty much everything that the RESOURCE role contains.

Page 72: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1168

Create the RMAN Recovery Catalog When you first create a RMAN Recovery Catalog database, it is a blank slate. It has no recovery catalog, and does not really know what RMAN is. All you need to do is launch the RMAN utility, connect to your new catalog database, and issue the command CREATE CATALOG as shown here:

% rman RMAN> CONNECT CATALOG RMAN/RMANPWD@RMANREP RMAN> CREATE CATALOG; RMAN> EXIT;

Notice in the above example we used the CONNECT CATALOG clause followed by a connection string. It is always required to tell Oracle the type of database you are connecting to, be it a catalog or target.

Register A Target Database Before you can backup any databases using the new Recovery Catalog database, you must register the target database in the catalog. In other words, you must catalog the databases that you want to backup. This is simply done by connecting RMAN to both the catalog and target databases, and then issuing the REGISTER DATABASE command as shown below. You will repeat this process for each and every Oracle database you want to backup. In other words, repeat these steps for each target database.

% rman RMAN> CONNECT TARGET SYS/PWD@REMIDATA RMAN> CONNECT CATALOG RMAN/RMANPWD@RMANREP RMAN> REGISTER DATABASE; RMAN> EXIT;

A comment about the above example. If you are running these RMAN commands on the same server as the target database, then the target’s connect string simply becomes a “/”. In a later section are numerous examples of connecting to the RMAN Catalog and Target Databases. I want to introduce a few related commands here. They are the RESYNC CATALOG and RESET DATABASE commands. If you ever feel that your RMAN Recovery Catalog is out of sync with the actual files of your target database, then launch RMAN and run the RESYNC CATALOG command as follows:

% rman RMAN> CONNECT TARGET SYS/PWD@REMIDATA RMAN> CONNECT CATALOG RMAN/RMANPWD@RMANREP RMAN> RESYNC CATALOG; RMAN> EXIT;

If you open the target database with the RESETLOGS option, then you must launch RMAN and reset the database’s profile in your catalog by running the RESET DATABASE command as follows:

Page 73: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1169

% rman RMAN> CONNECT TARGET SYS/PWD@REMIDATA RMAN> CONNECT CATALOG RMAN/RMANPWD@RMANREP RMAN> RESET DATABASE; RMAN> EXIT;

As noted elsewhere in this chapter, the CONNECT TARGET command rarely needs a username, password, or SID. You should be running RMAN from the target database’s host computer, in which case you can connect using local operating system authentication. I.e., “CONNECT TARGET /” is all you need for the TARGET connect string. Also, there is no need to connect to the target and catalog databases on separate lines as shown in many of my examples. You can do it all on one line like this:

% rman RMAN> CONNECT TARGET / CATALOG RMAN/RMANPWD@RMANREP RMAN> RESYNC CATALOG; RMAN> EXIT;

Configure Database Control as Your RMAN Interface If you used the RMAN utility to establish a recovery catalog and register target databases, then none of this information will be available in OEM Database Control by default. To finish the setup so that Database Control can be used as a GUI for RMAN you should complete the following steps: Ø Launch OEM Database Control and connect to your application database (i.e., a

target database). The connection should be as a SYSDBA user, such as SYS. Ø Navigate to the Maintenance page, and then click on the link for Recovery

Catalog Settings. Ø Click on the radio button for Use Recovery Catalog, and then click on the button

for Add Recovery Catalog. Note, you can leave the host credentials fields blanks, because you have already created and populated the catalog database using the RMAN utlility.

Ø When prompted, enter the details about the name and location of the recovery catalog database, and then click Next.

Ø On the Confirmation screen click Finish. Ø When returned to the Recovery Catalog Settings screen, make sure the radio

button named Use Recovery Catalog is selected. Ø You should test the setup by clicking on the Resynchronize Catalog link. On the

Resynchronize Catalog page ensure the right catalog database is selected, and then enter the name and password of the userID that owns the oracle software on your catalog database server. (The userID is “oracle” on most UNIX servers, or Administrator on most Windows severs.) When ready, click OK to continue. If all goes well you will be returned to the same screen, and near the top will be the message “The recovery catalog has been resynchronized with the target database.”

Page 74: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1170

Ø Click the Cancel button to return to the Maintenance page. This completes the process of configuring OEM Database Control for use with your Oracle RMAN recovery catalog. At this point you have the option of using the RMAN command line utility or the Database Control GUI to perform backup and recovery operations.

About Connections RMAN requires one or more dedicated server connections when connecting to a target database. You cannot connect RMAN to a target database using Oracle Shared Server connections. If your target (i.e., application) database uses Oracle Shared Servers, then you need to edit the Oracle Net files to force a dedicated server connection to be used by administrative applications like RMAN.

Connections to a target database must be as a SYSDBA user. RMAN always appends “AS SYSDBA” to all connection strings involving a target database; it does not do this for connections to the catalog database. If you specifically include “AS SYSDBA” in your connection string, then it will be there twice: once because you put it there and again because RMAN always puts it there. This will cause the connection to fail. Beware of password visibility. If you launch RMAN and connect to the catalog and/or target all at once, then your password might be visible to all other users on the server. That is, any user who does a “ps –ef” command will see your entire command string including any passwords in clear text. Therefore, you should first launch RMAN and then connect to your catalog and target databases from within RMAN. This way your passwords are hidden from other users on the server. Tip: you can put connection commands in scripts that are invoked from within RMAN; this mitigates the risk of anyone looking over your shoulder as you type a password. Suppose you are already in the RMAN utility connected to a certain target database, and you want to open another connection to the same target. You cannot do it. RMAN’s CONNECT command can only be issued if you are not already connected to the specified database. If you need to connect or reconnect to the same database you were already connected to, then you must open a new RMAN session.

Basic RMAN Commands In this section I describe and illustrate a large number of RMAN commands that are typically used by the DBA. Frankly, there are so many RMAN commands that there would be no way for me to describe and illustrate all of them here in this book. I therefore stick to the basic and most frequently requested RMAN commands. This section is divided into three sub-sections:

Ø Administrative Commands Ø Backup Commands

Page 75: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1171

Ø Restore Commands

Administrative Commands Administrative commands are essentially those RMAN commands that are not used to backup or restore databases. Administrative commands are used to connect RMAN to the target and catalog databases, and to set RMAN default behaviors. Connection Examples Let’s start with a classic example of connecting to a target database and the RMAN Recovery Catalog Database (i.e., the Repository) at the same time. In this first example, assume my target database is my corporate applications database and it is named “REMIDATA”, and assume that my RMAN Recovery Catalog database is named “RMANREP”. Also assume the recovery catalog within my RMAN Recovery Catalog database is named “RMAN” and has password “RMANPWD”.

% setenv ORACLE_SID remidata % rman target / catalog rman/rmanpwd@rmanrep

Notice in the above example I issued the operating system command “rman” followed by two clauses to be interpreted by the rman utility. The first one begins with keyword TARGET, and tells RMAN to connect to a target database; I did not specify a user name or password because I am using operating system authentication, and I did not specify a database name because it gets picked up from the environment variable ORACLE_SID. The second clause begins with keyword CATALOG and connects to a catalog database named RMANREP as user RMAN. The earlier example of connecting to both a target and catalog at the same time only works at the operating system command prompt. Once in RMAN, you need to connect to each database separately.

Here are some additional examples of connecting to the RMAN Recovery Catalog Database (i.e., the recovery catalog). In these examples we are not connecting to any target databases. Notice, you can either connect at the same time you invoke RMAN, or after you get in the RMAN utility.

-- Example 1: Launch RMAN and connect to catalog at same time. % rman catalog rman/rmanpwd@rmanrep -- Example 2: Launch RMAN then connect to catalog. % rman RMAN> connect catalog rman/rmanpwd@rmanrep

These next examples are typical of when you want to do a backup. In order to do a backup, you need to launch RMAN and connect to both the Recovery Catalog Database and a Target Database. You should generally launch the RMAN utility on the host where your target database is running, and not on the server where the RMAN Recovery Catalog Database is running, to ensure the correct Oracle Home binaries are used.

-- Example 1: Launch RMAN and connect to both Catalog and Target. -- First, tell Oracle which target database to connect to.

Page 76: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1172

% setenv ORACLE_SID REMIDATA -- Second, invoke RMAN and make connections. The “/” is used -- to connect to the Target DB as SYS AS SYSDBA. However, do not -- include “AS SYSDBA” or connection will fail; RMAN always -- passes that in the background, so if you include it then -- it goes twice and causes an error. % rman TARGET / CATALOG rman/rmanpwd@rmanrep -- Example 2: Invoke RMAN from the Repository DB server. -- As before, we also connect to both the Target DB and -- the Catalog DB all in one big command. % rman TARGET sys/manager@REMIDATA CATALOG rman/rmanpwd@rmanrep -- -- Example 3: Invoke RMAN utility on target db server, and then -- after you get into RMAN connect to Target and Repository DBs. % rman RMAN> connect TARGET sys/manager@REMIDATA RMAN> connect CATALOG rman/rmanpwd@rmanrep

Tip: you must connect to target databases as a SYSDBA user, and you should connect to catalog databases as the RMAN repository owner, typically named RMAN. The “RMAN” user is not a SYSDBA. Notice in all of the above examples I did not specify the AS SYSDBA clause on any connections to the target database, even though all such connections require SYSDBA privileges. This is because RMAN knows all connections to a target database must be as SYSDBA, so RMAN appends that information to the connection string in the background. If you put AS SYSDBA in the connection string, and then RMAN appended the same information in the background, then it would be in the connection string twice and cause an error.

Configure the Default Device Type All new RMAN installations are by default configured to send backups to disk. You can tell Oracle whether to send backups to a disk device or a tape device using the RMAN command CONFIGURE with the DEFAULT DEVICE TYPE TO clause. This only applies to automatic channels, meaning if someone puts the backup commands in a RUN {} block then the default you set here will be ignored. The two device types are DISK and SBT, and the default is DISK.

RMAN> CONFIGURE DEFAULT DEVICE TYPE TO SBT; RMAN> CONFIGURE DEVICE TYPE SBT PARALLELISM 5;

The above example does two things. First, it overrides the default device type from DISK to SBT. Second, it configures the new SBT device type to have a five degree of parallelism, so that during backups Oracle will open five server processes to the device. To check the current settings, use the command SHOW DEFAULT DEVICE TYPE. An example of the command and typical results are shown here:

RMAN> show default device type; RMAN configuration parameters are: CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

Page 77: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1173

To reset the default device type to DISK, you can either set it explicitly to DISK or set it to CLEAR. When RMAN sees CLEAR, it clears the current value and resets it to the default value which is DISK.

RMAN> CONFIGURE DEFAULT DEVICE TYPE TO CLEAR;

Configure the Default Destination and File Name Format Tip: I recommend that you use the FRA, and do not use the FORMAT clause as shown below. By default, all RMAN backups go to the Flash Recovery Area (FRA). If the FRA is not defined, then RMAN uses a port-specific default location, which is generally the directory $ORACLE_HOME/dbs.

To change the destination use the command CONFIGURE CHANNEL DEVICE TYPE. I discussed this same command earlier in the chapter. This time I include the FORMAT clause, which allows you to use a plethora of RMAN format mask elements. For example,

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u03/orabackups/%U';

The above example sets the destination to directory /u03/orabackups, and the %U parameter tells RMAN to generate system-unique file names. There are way too many format mask elements in RMAN to describe all of them here. For more information, see the Oracle Database Backup and Recovery Reference, available on Oracle’s TechNet web site. To clear the custom settings and revert back to RMAN’s default settings, use the CLEAR option as shown below. When the custom settings have been cleared, RMAN will revert to using the FRA as the default destination for backups.

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK CLEAR;

Configure the Retention Period The retention policy tells RMAN how long to keep the backup in good standing. This can be done using two units of measure: number of days old, or number of backups taken. These are known as RECOVERY WINDOW and REDUNDANCY respectively. You can only set one type of retention policy; if you set it both ways, then RMAN replaces the first one you define with the second one, so the last retention policy you define becomes the only one enforced by RMAN. Here’s how retention policies work, in a nutshell. After the retention number has been exceeded, RMAN marks the oldest backup as Obsolete so that it can be removed from the system through another process. Nothing is actually deleted at this point.

The default retention policy is REDUNDANCY 1, which means the system will keep one backup of each database file, and when a second backup of a file is completed the first may be marked Obsolete. I’ve never liked that policy. When a customer gives you backup requirements, it’s typically in the form of “we need to be able to go back N days”. Here’s an example of setting the retention policy to 30 days.

Page 78: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1174

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS;

The retention policy does not tell RMAN when to delete old backups. Rather, it causes backups to be marked Obsolete so you (and RMAN) can quickly identify and manually delete them using the DELETE OBSOLETE command.

Configure Auto-Backup of the Control File Anytime you backup an Oracle database, it’s a good idea to also backup the control file. You can configure RMAN to do this automatically, so that you never forget. This is configured using the CONFIGURE CONTROLFILE command as shown below.

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

Obviously, to turn off this feature you re-run the command replacing ON with OFF.

Deleting Backups There are basically three cases where you want to delete a backup from the server, and the backup’s metadata from the RMAN repository:

Ø You simply want to delete the backups from RMAN. For example, to cleanup a test environment.

Ø You want to delete backups that are marked “Expired” because the backups are no longer around but the metadata is still in RMAN.

Ø You want to delete backups that are marked “Obsolete” because the backups are outside your retention policy and no longer needed to satisfy recovery requirements.

To simply delete all backup sets of a target database use the DELETE BACKUP command. This command will remove all backup sets and all associated metadata from the storage area as well as from the RMAN catalog.

RMAN> DELETE BACKUP;

There are optional clauses that can be appended to the end of the above command, such as the OF clause to specify individual tablespaces or datafiles. To delete image copy backups created by RMAN, use the command DELETE COPY rather than DELETE BACKUP as shown earlier. To delete obsolete backups, run the command DELETE OBSOLETE. RMAN will remove backups that are no longer needed to satisfy recovery requirements, based largely on the retention policy you defined with the administrative commands discussed in the earlier section “Configure the Retention Period”.

RMAN> DELETE OBSOLETE;

To delete expired backups, you first need to prove to RMAN that the backups are expired. Run the CROSSCHECK BACKUP command, which tells RMAN to verify each backup listed in the recovery catalog still exists. Any backups listed in the repository that are not found by the crosscheck are marked “Expired”. You can then run

Page 79: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1175

the DELETE EXPIRED BACKUP command, which will remove the metadata for all expired backups from the recovery catalog.

RMAN> CROSSCHECK BACKUP; RMAN> DELETE EXPIRED BACKUP;

Tip: RMAN will prompt for input when you issue a DELETE command; to prevent this prompting use the NOPROMPT option. For example:

RMAN> DELETE NOPROMPT OBSOLETE;

Occassionally, RMAN will be unable to delete an obsolete backup due to an I/O problem. To get around this situation use the FORCE option as shown here:

RMAN> DELETE FORCE NOPROMPT OBSOLETE;

Deleting Expired Backups and Archlogs Catalog entries are considered “expired” when they no longer exist physically. For example, a backup should be marked expired in the RMAN recovery catalog if the backup was deleted from storage.

After a while your RMAN recovery catalog might get out of sync with reality, and you will need to do some housekeeping. RMAN provides a CROSSCHECK commands that you can use to find any backups or archlogs that are still listed in the recovery catalog but not present in the FRA or other backup destination. The commands look like this:

RMAN> CROSSCHECK ARCHIVELOG ALL; RMAN> CROSSCHECK BACKUP;

Any archlogs and backups not found will be marked “EXPIRED” in the RMAN catalog. The next step is to delete the expired items from disk using the RMAN command DELETE EXPIRED followed by the type of file, as shown here:

RMAN> DELETE EXPIRED ARCHIVELOG ALL; RMAN> DELETE EXPIRED BACKUP;

Show the Current Settings To see the current settings use the SHOW command. Typically, you will use the ALL option as shown here:

RMAN> SHOW ALL;

The SHOW command has a dozen options. Here are a few, which are rather self-explanatory:

RMAN> SHOW BACKUP OPTIMIZATION; RMAN> SHOW CONTROLFILE AUTOBACKUP; RMAN> SHOW DEFAULT DEVICE TYPE; RMAN> SHOW ENCRYPTION ALGORITHM;

Page 80: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1176

RMAN> SHOW EXCLUDE;

Resynchronize the Catalog If you ever feel that your RMAN Recovery Catalog is out of sync with the actual files of your target database, then you should launch RMAN and run the RESYNC CATALOG command as follows:

% rman RMAN> CONNECT TARGET SYS/PWD@REMIDATA RMAN> CONNECT CATALOG RMAN/RMANPWD@RMANREP RMAN> RESYNC CATALOG; RMAN> EXIT;

As with most RMAN commands related to target databases, you should run the RESYNC CATALOG command on the same server as the target database. This ensures you are using the right version of RMAN for that database.

% rman RMAN> CONNECT TARGET / RMAN> CONNECT CATALOG RMAN/RMANPWD@RMANREP RMAN> RESYNC CATALOG; RMAN> EXIT;

Reset the Database Profile If you open the target database with the RESETLOGS option, then you must launch RMAN and reset the database’s profile in your catalog by running the RESET DATABASE command as follows:

% rman RMAN> CONNECT TARGET SYS/PWD@REMIDATA RMAN> CONNECT CATALOG RMAN/RMANPWD@RMANREP RMAN> RESET DATABASE; RMAN> EXIT;

As noted elsewhere in this chapter, the CONNECT TARGET command rarely needs a username, password, or SID. You should be running RMAN from the target database’s host computer, in which case you can connect using local operating system authentication. All you need is, “CONNECT TARGET /”. Also, there is no need to connect to the target and catalog databases on separate lines as shown in many of my examples. In fact, you can do it all on one line, as long as you do it at the operating system command prompt In this next example I show how to connect to the target as a SYSDBA and to the catalog database as RMAN, all at the same time. The trick is this command must be executed at the operating system command prompt; once inside RMAN you cannot connect to both databases in one command.

% rman CONNECT TARGET / CATALOG RMAN/RMANPWD@RMANREP RMAN> RESET DATABASE; RMAN> EXIT;

Page 81: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1177

Backup Commands The basic RMAN commands for backing up an Oracle 10g databases are provided in the below sections.

Understanding the Syntax The syntax of the basic BACKUP command in RMAN is as follows:

RMAN> BACKUP [AS BACKUPSET | AS COPY] <THING>;

The <THING> clause at the end of the command is used to tell RMAN what to backup. It can be keywords like DATABASE, TABLESPACE <name>, DATAFILE <number>, or CURRENT CONTROLFILE. For example, the following are valid RMAN commands:

RMAN> BACKUP DATABASE; RMAN> BACKUP TABLESPACE USERS; RMAN> BACKUP DATAFILE 6; RMAN> BACKUP CURRENT CONTROLFILE;

The above sample commands will backup the database, tablespace, datafile, or the current control file to the active backup device type (either tape or disk.) Notice, however, that my examples did not include the optional clause [AS BACKUPSET | AS COPY]. I was able to omit both, because by default RMAN includes the clause AS BACKUPSET, which is what you want for full and incremental backups.

Backing Up In NOARCHIVELOG Mode Below are sample commands you can use to backup an Oracle 10g database that is running in NOARCHIVELOG mode. Afterwards I explain why all of these commands are necessary.

% rman target / catalog rman/himom@rmandb RMAN> SHUTDOWN IMMEDIATE; RMAN> STARTUP MOUNT; RMAN> BACKUP DATABASE INCLUDE CURRENT CONTROLFILE; RMAN> ALTER DATABASE OPEN;

If the database to be backed up is running in NOARCHIVELOG mode, then the database must be shutdown cleanly prior to starting the backup. RMAN will not shutdown or restart the database for you as part of the backup process, as do many of RMAN's competing products, but you can manually issue the commands from within the RMAN utility as shown above.

RMAN requires that the instance be started and the control files be mounted prior to starting the backup. Therefore, before you backup a database in NOARCHIVELOG mode you must do a STARTUP MOUNT command. This can be done within RMAN, so you do not need to open a SQL*Plus session to do it.

The backup must include the current control file, or the backup will not be useful in a restore operation. You have two options: prior to the backup you can configure automatic backup of the controlfile using the command "CONFIGURE CONTROLFILE

Page 82: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1178

AUTOBACKUP ON", or you can manually grab the control file as part of a backup as shown in the above example.

After the backup has completed you can open the database. Remember the instance is already started, so you should not issue a STARTUP command. Rather, issue an ALTER DATABASE OPEN command to switch from mount mode to fully open. There are a few more points I would like to make about backing up an Oracle 10g database running in NOARCHIVELOG mode: Ø The shutdown must be clean. This means you can use the SHUTDOWN

command, or SHUTDOWN with the following clauses: NORMAL, IMMEDIATE, TRANSACTIONAL. The command SHUTDOWN ABORT is not appropriate, and will prevent RMAN from getting a viable backup.

Ø RMAN can only create full backups of a database that is in NOARCHIVELOG mode. It cannot create incremental backups of a NOARCHIVELOG mode database.

Ø Do not attempt to start or open the database while the backup is running. This will invalidate the backup, and you will have to create a completely new backup.

Omitting or Skipping Objects During Backups RMAN allows you to easily skip tablespaces that are offline or read only. For example,

RMAN> BACKUP DATABASE SKIP READONLY SKIP OFFLINE;

You can also tell RMAN to skip the whole database, if it’s inaccessible when RMAN runs, by inserting the clause SKIP INACCESSIBLE between the usual words BACKUP and DATABASE. For example:

RMAN> BACKUP SKIP INACCESSIBLE DATABASE;

The above command is not how you would normally tell Oracle to skip a tablespace or datafile. That command is just to be used to tell RMAN to skip something that isn’t there to be backed up. If you want to tell RMAN to skip something that is on-line and ready for backups, use CONFIGURE EXCLUDE FOR TABLESPACE <NAME>. For example:

RMAN> CONFIGURE EXCLUDE FOR TABLESPACE USER_SANDBOX; RMAN> CONFIGURE EXCLUDE FOR TABLESPACE USER_PLAYPEN; RMAN> BACKUP DATABASE; RMAN> CONFIGURE EXCLUDE CLEAR;

In the above example, I tell RMAN to always exclude a certain tablespace from backups. Then I run a backup, and tell RMAN to no longer exclude any tablespaces.

To Backup or Copy, That is the Question If you do not specify AS BACKUPSET or AS COPY, then RMAN defaults to AS BACKUPSET. In other words, Oracle always backs up files to backup sets, unless you specifically request it to use image copies with the AS COPY option. You can use the CONFIGURE command to change the default behavior to AS COPY.

Page 83: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1179

RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET; or RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY;

If your BACKUP command specifies the AS COPY clause, as shown below, then RMAN will create an “image copy” of the object.

RMAN> BACKUP AS COPY DATABASE;

Oracle RMAN image copies are exact copies of the datafiles. They contain all of the blocks, whether the blocks have been used or not. RMAN creates image copies while the database is open and users are active, and the database need not be put into any special mode. It is interesting to note that Oracle cannot write image copies directly to tape due to “fuzzy” reads: after RMAN creates the image file it must update the image with any blocks that have changed during the copy, as well as the final SCN, but if the image was written to tape it would not be available for this final updating of blocks and SCN information.

Note: you cannot set the max sizes of sets and pieces when backing up AS COPY, because image copies do not break files into sets or pieces.

If you specify the AS BACKUPSET option, which you generally do not need to do since it’s the default, then RMAN will backup the object using an RMAN backupset that can be written on disk or tape. The AS BACKUPSET option is the default, so the following commands are equivalent:

RMAN> BACKUP AS BACKUPSET DATABASE; RMAN> BACKUP DATABASE;

A backupset is the basic unit of storage. It holds 1 to 4 datafiles, or 1 to 16 archlogs, and otherwise the size is unlimited by default. A backupset has 1 or more “pieces”. The number of pieces Oracle uses depends on the max size of a piece. If you are backing up to a backupset, then you can use the CONFIGURE command to set the max size of the set and pieces:

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK MAXSETSIZE 1G MAXPIECESIZE 20M;

Backing Up and Copying Image Copies If you have already used RMAN to create image copies of files, then you can backup those image copies to a new backupset or image copy using the following RMAN command syntax:

RMAN> BACKUP [AS BACKUPSET | AS COPY] COPY OF <THING>;

As noted earlier, the <THING> clause tells RMAN what to backup, and it can be keywords like DATABASE, TABLESPACE <name>, or DATAFILE <number>. Earlier I also gave examples of how to use those various keywords for the AS BACKUPSET clause. Let’s look at the same keywords now with the COPY OF clause. For example, the following are valid RMAN commands that can be used to backup an existing image copy of the specified thing:

RMAN> BACKUP COPY OF DATABASE;

Page 84: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1180

RMAN> BACKUP AS COPY COPY OF TABLESPACE USERS; RMAN> BACKUP AS BACKUPSET COPY OF DATAFILE 6;

Tip: in the above examples notice one of them has COPY COPY. This is correct. The first COPY tells RMAN to create an image copy vice backupset. The second COPY tells RMAN to backup the existing copy, not the live tablespace. You cannot use the BACKUP COPY OF command syntax to backup the copy of a control file. Instead, you must use the BACKUP CONTROLFILECOPY [ALL] command.

RMAN> BACKUP CONTROLFILECOPY ALL; RMAN> BACKUP CONTROLFILECOPY LIKE '%control_01%'; RMAN> BACKUP CONTROLFILECOPY

'c:\oracle\flash_recovery_area\ORCL_control.cpy';

Keep in mind that the BACKUP CONTROLFILECOPY command is used to backup a copy of a control file, and not an active or current control file in use by the database. Therefore, if you want to use this command then you must specify the name of the RMAN backup file that the control file was copied to. For example, use these two commands together:

RMAN> BACKUP AS COPY CURRENT CONTROLFILE TO 'c:\oracle\flash_area\ORCL_control.cpy';

RMAN> BACKUP CONTROLFILECOPY 'c:\oracle\flash_area\ORCL_control.cpy';

Backing Up Archlogs There are a number of ways to backup the archived redo log files. Generally, you want to backup the archlogs at the same time you backup the database. The trick is to backup the current redo information, too. To get that information you need to force a log switch, so that it gets archived prior to the backup running. RMAN is smart enough to do all of that for you, with the PLUS ARCHIVELOG clause as shown here:

BACKUP DATABASE PLUS ARCHIVELOG;

The above command tells RMAN to do the following:

Ø Issue an ALTER SYSTEM ARCHIVE LOG CURRENT command, to ensure the active redo is archived and ready for backup.

Ø Runs the BACKUP ARCHIVELOG ALL command. Ø Backs up the database files.

Ø Issue a second ALTER SYSTEM ARCHIVE LOG CURRENT command, to ensure the active redo is archived and ready for backup.

Ø Backs up all archlogs that have not yet been backed up. You can tell Oracle to delete the archlogs after a successful backup by using the clause DELETE [ALL] INPUT. As you know the ALL keyword in that clause tells Oracle to delete all copies of archlogs from all Archiver destinations. However, one strange thing

Page 85: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1181

is, RMAN will not let you specify ALL in terms of Archiver destinations to be backed up. For example, consider these commands and notice which are OK and which are not:

-- THIS COMMAND WORKS. RMAN> BACKUP DATABASE PLUS ARCHIVELOG DELETE ALL INPUT; -- THIS COMMAND FAILS. RMAN> BACKUP DATABASE PLUS ARCHIVELOG ALL DELETE ALL INPUT; -- THIS COMMAND WORKS. RMAN> BACKUP ARCHIVELOG ALL DELETE ALL INPUT;

There is actually a very good reason why you cannot specify ARCHIVELOG ALL within the BACKUP DATABASE command. Whenever RMAN sees the PLUS ARCHIVELOG clause it is hard-coded to backup one good copy of each archlog using all available destinations, so it’s already backing up all archlogs. However, if you are not backing up the whole database and just using the BACKUP ARCHIVELOG command then the ALL keyword is allowed as discussed later. The clause PLUS ARCHIVELOG DELETE ALL INPUT tells Oracle to backup one of each archlog and delete all copies of each archlog. This puts you at risk, because you would be down to just one copy of each archlog needed for recovery. I recommend you omit the word ALL, which gives you the clause PLUS ARCHIVELOG DELETE INPUT: this tells Oracle to backup the first copy of each archlog and then delete only the copy that was backed up. If you are multiplexing archlogs to two locations, then the second copy of each archlog will only get picked up by “the next” backup and then it will be deleted. If you multiplex to three destinations, then it takes three backups to delete all copies of each archlog. For example: backup N archives and then deletes the first copy of each file generated after backup N-1 and the second copy of each file generated between backups N-2 and N-1, and it also gets the third copy of each file generated between backups N-2 and N-3. Sometimes you need to backup just the archived redo logs, without the rest of the database. This might be due to your archlog destination filling up in the middle of the day, or maybe you have scheduled a cron job to run every few hours to prevent the destination from filling up. In any case, the command to backup just the archlogs looks like this:

RMAN> BACKUP ARCHIVELOG ALL DELETE INPUT;

The above command backs up the first good copy of each archlog, not every copy of it. The optional DELETE ALL INPUT clause tells RMAN to remove all copies of each archlog after backing up just one copy of it. That is, a given archlog is deleted from all Archiver destinations after a minimum of one good copy has been backed up. If you used DELETE INPUT without ALL, then RMAN only deletes the one copy of the archlog that it backed up, leaving the other copies on the system for processing by the next backup command. This process was detailed earlier.

Tip: the word "ALL" in BACKUP ARCHIVELOG ALL does not mean to backup all archlogs on the server right now. In this context ALL tells RMAN to backup one copy of each archlog now, and pickup the other copies later. If your database writes archlogs to two destinations, for example, then RMAN backs up all archlogs in the first destination

Page 86: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1182

and only uses the second destination when a file in the first destination cannot be used. Then, during your next backup, RMAN will pickup the files in the second destination because RMAN knows those files have never been backed up. Alternatively, you can replace the keyword ALL with LIKE and specify a pattern or range of archlogs.

Suppose your archiver is set to write all archlogs to multiple destinations, and after each file is backed up you want to delete all copies of the file. The solution is to use the DELETE ALL INPUT clause. For example.

RMAN> BACKUP ARCHIVELOG ALL DELETE ALL INPUT;

What the above command does is backup one copy of every archived redo log file, regardless of how many multiplexed destinations you are using, and then delete all copies from all destinations. The command only deletes files that were backed up.

Many DBAs strongly believe in keeping two copies of each archlog file, so consider what would happen to archlogs if you ran the above BACKUP command daily. The command says to backup one copy and delete both copies. When the backup completes you would have one copy of each archlog in your FRA (or other backup destination) but you would no longer have redundancy. You would have a possible single point of failure. You might therefore wish to backup archlogs every day and only delete the input files every other day, or something like that. The BACKUP ARCHIVELOG command has various parameters that you might find useful in constructing a bullet proof solution.

When you issue a command to backup archlogs, Oracle knows what archlogs have been generated and need to be backed up. But, what happens if one or more of those archlogs were deleted from the system. By default RMAN will error-out. In this case you must tell RMAN to skip all archlogs that are missing with the SKIP INACCESSIBLE clause. For example:

RMAN> BACKUP ARCHIVELOG ALL DELETE ALL INPUT SKIP INACCESSIBLE;

If you need to use the SKIP INACCESSIBLE clause, then odds are you also need to run the CROSSCHECK command. After the crosscheck completes Oracle will know which archlogs are no longer available for backups, and you can go back to using BACKUP without the SKIP INACCESSIBLE clause. For example,

RMAN> BACKUP ARCHIVELOG ALL DELETE ALL INPUT SKIP INACCESSIBLE; -- You get a lot of warnings about archlogs that don’t exist. RMAN> CROSSCHECK ARCHIVELOG ALL; RMAN> BACKUP ARCHIVELOG;

Backing Up The Flash Recovery Area As noted earlier the Flash Recovery Area (FRA) is a disk-based cache of recovery files. Included in those recovery files are backups. To be safe-and-sound, those backups and all other recovery files need to be backed up to someplace off the server, such as tape. Also, Oracle is unable to maintain free space in the FRA unless you use RMAN to backup the FRA to a SBT device. It is therefore very important to know how to backup the FRA.

Page 87: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1183

Before you can backup the FRA you must configure a SBT device. RMAN will only backup the FRA to a SBT device. I don’t cover SBT in detail here because it goes outside the scope of this book, and most of you working in development labs or home computers won’t have access to a true SBT device anyways. So, how to finish setting up RMAN to think it has a SBT device? Oracle provides a driver named oracle.disksbt. Configuring RMAN to use it is truly simple, as shown here:

RMAN> configure channel device type 'SBT_TAPE' parms 'SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/disk3)';

Tip: the oracle.disksbt driver is not for use on production systems, and you are responsible for configuring a true SBT device such as Oracle Secure Backup or Tivoli Data Protection for Oracle. The second part of backing of the FRA is knowing the correct RMAN command. There are two RMAN commands for backing up the FRA and you can use either one. Actually, one is a synonym for the other. Both commands are shown here, and you can use either one to backup the FRA.

RMAN> BACKUP DB_RECOVERY_FILE_DEST; or RMAN> BACKUP RECOVERY AREA;

If the FRA backup fails with ORA-19625 because of an allegedly missing archlog, then run the CROSSCHECK and DELETE EXPIRED commands to get RMAN to recognize the missing archlog is supposed to be missing and stop complaining about it. Tip: sometimes when connected to a recovery catalog the CROSSCHECK command will not find archlogs that are expired; run RMAN connected to the target database but NOT connected to the recovery catalog and then run the command “CROSSCHECK ARCHIVELOG FROM SCN NNN UNTIL SCN MMM” where NNN is the SCN of the archlog that RMAN says is missing in action, and MMM is any higher number. Afterwards, reconnect to the recovery catalog and run your backups as usual. Now that you have used RMAN to backup the FRA to a SBT device, you are free to delete some of the backups and archlogs from the FRA and make room for future backups and archlogs. To remove obsolete backups from the FRA issue the following command within the RMAN utility:

RMAN> DELETE FORCE NOPROMPT OBSOLETE;

If the Flash Recovery Area (FRA) is full even after you have deleted obsolete and expired backups and archlog files, then you either need more disk space or you can work some tricks. This trick is not really recommended for production systems, but for a test you can simply reset your retention policy to a small value like “1 DAYS” and then re-run your command to delete obsolete backups. This process will force RMAN to update the catalog with a new value for the amount of free space in the FRA. For example, you might run through the following series of commands:

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1 DAYS; RMAN> DELETE OBSOLETE; RMAN> CROSSCHECK ARCHIVELOG ALL;

Page 88: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1184

RMAN> DELETE EXPIRED ARCHIVELOG ALL; RMAN> CROSSCHECK BACKUP; RMAN> DELETE EXPIRED BACKUP;

Space issues might remain after all of the above commands have been run. RMAN is responsible for monitoring and managing the space pressure issues in the FRA, but it won’t do these things at the end of each backup, and waits for obsolete and expired objects to be removed via the RMAN interface. The next time you run a backup and RMAN thinks there is insufficient space RMAN will defer the backup and then run a job to look at the FRA and deal with space issues. RMAN will then update itself to reflect the new reality of space issues, and should complete the original backup request. If not, just re-run the backup command so RMAN cycles through this two-step process again.

Tip: when trying to resolve space issues do not manually delete flashback log files (.flb) as this might cause the RVWR process to abort, and your instance to crash. The .flb files are auto-deleted by the RVWR process when space pressure occurs, but because these files are tied to archlogs RVWR will not delete any .flb files that correspond to archlogs needed for recovery. To force RVWR to delete the .flb files you must take a database-wide outage to turn off Oracle Flashback Database and then turn it on again. Alternatively, you can try adjusting initialization parameter DB_FLASHBACK_RETENTION_TARGET to a lower number.

For more information, please see the section on “Backing Up The Flash Recovery Area” in this chapter.

Backing Up When Space Is Limited If a backup fails because there is insufficient space in the recovery area (i.e., the FRA) then try backing up the recovery area using the command BACKUP RECOVERY AREA and then deleting obsolete files by running the command DELETE OBSOLETE. There might also be expired backups in the recovery catalog, thus making RMAN think space is unavailable. You can run the commands CROSSCHECK BACKUP followed by DELETE EXPIRED BACKUP. All of these commands are described in this chapter.

The DELETE OBSOLETE command only deletes backups that are outside your default retention policy, unless you specify an alternate retention policy as part of the delete command. For example:

DELETE OBSOLETE RECOVERY WINDOW OF 5 DAYS;

If a full backup of archlog files fails because there is insufficient space in the recovery area (i.e., the FRA) then try a series of partial backups. When the first attempt is run it will list all of the archlogs to be backed up, and one of the displayed column shows “sequence=nnn”. This data corresponds to the log sequence number. You can tell RMAN to only backup archlogs up to and including a certain log sequence number. For example:

BACKUP ARCHIVELOG UNTIL LOGSEQ 265 DELETE INPUT;

After the backup has completed, you can backup the recovery area to make room for more archlogs. Repeat this procedure as needed.

Page 89: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1185

Using Tags to Name Backups Backups can be labeled using the TAG clause. This makes it easy to restore from a particular backup. For example, suppose you are about to add new functionality to your database like Oracle Streams Replication, and you want to make a backup before and after Streams has been implemented:

RMAN> BACKUP DATABASE TAG BKP_PRE_STREAMS_DFILES 2> PLUS ARCHIVELOG TAG BKP_PRE_STREAMS_ARCS; <DO YOUR STREAMS SETUP> <OOPS, YOU MESSED UP STREAMS … START OVER> RMAN> SHUTDOWN IMMEDIATE; RMAN> STARTUP MOUNT; RMAN> RESTORE DATABASE FROM TAG = 'BKP_PRE_STREAMS'; RMAN> RECOVER DATABASE <PUT “UNTIL” CLAUSE HERE>; <DO YOUR STREAMS SETUP> RMAN> ALTER DATABASE OPEN; RMAN> BACKUP DATABASE TAG BKP_POST_STREAMS_DFILES 2> PLUS ARCHIVELOG TAG BKP_POST_STREAMS_ARCS;

When you backup the data files and archlogs in the same command, RMAN applies separate tags to the two types of files. In the earlier example, notice that immediately after telling RMAN to backup the database I specified a tag to be applied to the data files. Then, immediately after telling RMAN to also backup the archlogs I specified a second tag. If I were to omit either tag, then Oracle would substitute a system generated tag in its place. Therefore, if you plan to use tags you must remember to use then in all appropriate places. To see what Oracle created you might want to run the following command. This will list all of the backup sets, with your most recent backup listed last. The tag will be displayed in the right-hand of the output.

RMAN> LIST BACKUPSET SUMMARY;

In addition to backup files having the tags you specified during backup, you might notice additional backup files with a system generated tags: these file contains the control file and SPFILE backups.

Using Backup Commands to Scan for File Corruption RMAN has a BACKUP VALIDATE command that can be used to validate your database files. No backup will be generated. Instead, RMAN will validate the names and locations of the files for logical corruption issues, and will check the files at the block-level for physical corruption. In the first example shown below, just the database files are checked, while in the second example the database files and archived redo logs in all Archiver destinations are also validated.

RMAN> BACKUP VALIDATE DATABASE; RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL;

If any corruptions are found, RMAN writes the information to the target database’s data dictionary where it can be reviewed using the view

Page 90: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1186

V$DATABASE_BLOCK_CORRUPTION. If physical block corruption is encountered, you can use RMAN to rectify the situation with the RMAN command named BLOCKRECOVERY CORRUPTION LIST. By default, the BACKUP VALIDATE DATABASE command only checks for physical corruption, but you can always force it to check for logical corruption using the BACKUP VALIDATE CHECK LOGICAL DATABASE command. In the first example shown below, just the database files are checked, while in the second example the database files and archived redo logs in all Archiver destinations are also validated.

RMAN> BACKUP VALIDATE CHECK LOGICAL DATABASE; RMAN> BACKUP VALIDATE CHECK LOGICAL DATABASE ARCHIVELOG ALL;

Restore and Recovery Commands This section describes the general process of using RMAN to restore and recover a database, whole and in part. Several of the more commonly used commands are illustrated and explained.

The process has two parts: restore needed files from a backup, and then recover the database to the desired point. RMAN supports this two-step process with two commands: RESTORE and RECOVER. With each of these two commands you can work on individual files, lists of files, one or more tablespaces, or the whole database. Mind RMAN has been in existence for some time now, and has become rather robust.

The Restore Process and Command Overview The RESTORE command can be used to restore backup sets consisting of full backups and level 0 incremental backups, and it can be used to restore image copies of datafiles, control files, and archlogs. The RESTORE command also has options to simulate a restore. If you use the VALIDATE clause, then RMAN will tell you which backups are needed to do the restore. If you use the VALIDATE clause, then RMAN will validate that the necessary backups are still available. Without any such clauses, RMAN will actually restore the files.

When restoring files, you need to know how and when Oracle overwrites existing files. On restore RMAN scans the header block of the current file: if the header is corrupt then RMAN restores overtop of the corrupted file; if the header is not corrupt then RMAN will not restore over the file unless you specify the FORCE option. Please note, RMAN only scans the header for corruption, and not the payload or data blocks. Alternatively, if you want to restore the files to a new name or location you can use the SET NEWNAME command. RMAN allows you to manually restore archlogs. However, this is generally not something you will do. When you issue a RECOVER command, RMAN will figure out which archlogs need to be restored and do the restore for you automatically. That said, you still need to understand where RMAN restores archlogs to, and how it handles overwrites and space issues. If any of your LOG_ARCHIVE_DEST_N parameters are set explicitly or implicitly to the value DB_RECOVERY_FILE_DEST, then RMAN will

Page 91: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1187

by default restore all archlogs to the DB_RECOVERY_FILE_DEST. Otherwise, RMAN will by default restore all archlogs to your LOG_ARCHIVE_DEST_1 location. If you don’t want these default behaviors, then you need to issue the command SET ARCHIVELOG DESTINATION prior to running the RECOVER command.

The Recovery Process and Command Overview The RECOVER command performs either complete or point-in-time media recovery using available datafiles and archlogs. By “available” we typically mean “files you have restored” such as by using the RESTORE command. By default RMAN will perform complete recoveries. That is, if you issue the command RECOVER DATABASE then it will try to perform a complete recovery of the database. If you need to perform an incomplete recovery then you need to specify the UNTIL clause, such as RECOVER DATABASE UNTIL SEQUENCE 578. If you are performing complete recovery, then Oracle may use either a full backup or an incremental backup. In both cases it can roll forward using archlogs. If a full backup is restored, then RMAN will roll forward using available archlogs. If an incremental backup is restored, then RMAN will apply the incremental backup first and then apply the archlogs; RMAN won’t skip the incremental backup and simply roll the database forward using nothing but archlogs, because that would be slower and because archlogs don’t contain objects created with the NOLOGGING option.

During recovery operations RMAN looks for the required archlogs on disk, and if they are not present RMAN automatically restores them from backups. Restoring archlogs may present a space issue. Fortunately, RMAN is very smart about this. By default, RMAN automatically deletes any archlogs restored to the Flash Recovery Area (or DB_RECOVERY_FILE_DEST) as soon as they are applied to the database; RMAN will not delete archlogs that were already on disk and not restored. Alternatively, you can specify the DELETE ARCHIVELOG MAXSIZE clause in the RECOVER command, to tell RMAN the maximum amount of disk space to use for holding the restored archlogs. For example:

RMAN> RECOVER DATABASE DELETE ARCHIVELOG MAXSIZE 5G;

The above RECOVER DATABASE command will restore archlogs from backups as necessary, and will purge the restored archlogs automatically to maintain a maximum storage requirement of 5 GB. The auto-deletion of archlogs is the default when using the Flash Recovery Area (FRA), but not when using a non-FRA location.

Typical Restore and Recover Commands To restore the whole database, make sure the database is shutdown and then use the RESTORE DATABASE command. RMAN will not restore the control file or SPFILE, you have to do that using separate commands like RESTORE CONTROLFILE and RESTORE SPFILE. RMAN will not restore offline or read-only datafiles; if you specify the CHECK READONLY clause then RMAN will restore read-only datafiles that have header block corruption only, and will not restore read-only files with other corruption or any offline datafiles. To restore offline files you must restore them at the tablespace or datafile level, but not using the RESTORE DATABASE command.

Page 92: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1188

Here’s an example of restoring the target database: RMAN> RESTORE DATABASE CHECK READONLY;

If you have lost all copies of your control file, then you need to use the RESTORE CONTROLFILE command because using the RESTORE DATABASE command does not restore control files. The command is quite simple as shown here:

RMAN> RESTORE CONTROLFILE;

If you have lost your SPFILE and do not have a backup PFILE, then you need to use the RESTORE SPFILE command. As noted earlier, the RESTORE DATABASE command will never restore a SPFILE. Here’s an example of using the RESTORE SPFILE command:

RMAN> RESTORE SPFILE;

After restoring the database and optionally any other required files, you will want to recover the database using the RECOVER DATABASE command. For example,

RMAN> RECOVER DATABASE;

To restore and recover just a tablespace, and not the whole database, make sure the tablespace is offline and then use the RESTORE TABLESPACE command followed by the RECOVER TABLESPACE command as shown here:

RMAN> SQL "ALTER TABLESPACE FOO OFFLINE IMMEDIATE"; RMAN> RESTORE TABLESPACE FOO; RMAN> RECOVER TABLESPACE FOO; RMAN> SQL "ALTER TABLESPACE FOO ONLINE";

With the RECOVER there are basically three major things you can recover: the database, a comma-delimited list of tablespaces, and a comma-delimited list of datafiles. Below are examples of these commands, but remember that the RECOVER command should be used as part of a larger process that includes RESTORE and SQL commands as we saw in previous examples.

RMAN> RECOVER DATABASE; RMAN> RECOVER TABLEPACE TOOLS, USERS, APPS7; RMAN> RECOVER DATAFILE '/u02/oradata/REMIDATA/tools.dbf';

To skip a tablespace during complete recovery operations, use the SKIP clause. RMAN will take the tablespace offline and leave it offline, even after the recovery is complete and the database has been opened.

RMAN> RECOVER DATABASE SKIP TABLESPACE FOO;

With incomplete recovery the SKIP clause cannot be used. Instead, you can use the SKIP FOREVER clause. Please note this clause deletes files from your database. RMAN will take the tablespace offline with the DROP option, and the associated datafiles will be dropped later.

Page 93: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1189

Restoring Archlogs When restoring archlogs you have four basic options: restore all of them; restore just the ones created after a particular point; restore the ones created before a particular point, or restore the ones created between two points. The “points” can be specified as a SCN, log sequence number, or system time. Below are several examples to illustrate this concept.

To restore all archlogs: RESTORE ARCHIVELOG ALL;

To restore all archlogs from a particular SCN until present: RESTORE ARCHIVELOG FROM SCN=24010527;

To restore all archlogs before a particular SCN until present: RESTORE ARCHIVELOG UNTIL SCN=24010527;

To restore all archlogs between two SCN: RESTORE ARCHIVELOG BETWEEN SCN 24010527 AND 24010529;

As noted earlier, you don’t need to specify SCN. You can specify SEQUENCE or TIME. For example: to restore all archlogs between two dates:

RESTORE ARCHIVELOG BETWEEN TIME 'date string1' AND 'date string2';

The date string can be anything that evaluates to a valid Oracle date/time. For example, you could use the SYSDATE function as shown below to restore all archlogs created in the past 2 days:

RESTORE ARCHIVELOG SINCE TIME 'SYSDATE-2';

Using Tags to Restore a Named Backup Backups can be labeled using the TAG clause. This makes it easy to restore from a particular backup.

Tip: if you forget the name of your backup, you can list backups using the RMAN command LIST BACKUP SUMMARY as shown below; the output of the LIST BACKUP SUMMARY command includes the TAG as the right-most column, and the output is orded by date with backups listed from oldest to newest.

RMAN> LIST BACKUP SUMMARY;

For example, suppose you are about to add new functionality to your database like Oracle Streams Replication, and you want to make a backup before and after Streams has been implemented:

RMAN> BACKUP DATABASE TAG BKP_PRE_STREAMS_DFILES 2> PLUS ARCHIVELOG TAG BKP_PRE_STREAMS_ARCS; <DO YOUR STREAMS SETUP> <OOPS, YOU MESSED UP STREAMS … START OVER> RMAN> SHUTDOWN IMMEDIATE; RMAN> STARTUP MOUNT; RMAN> RESTORE DATABASE FROM TAG = 'BKP_PRE_STREAMS';

Page 94: ChapterOnRMAN

Oracle Database 10g: From Nuts to Soup Chapter 37

1190

RMAN> RECOVER DATABASE <PUT “UNTIL” CLAUSE HERE>; <DO YOUR STREAMS SETUP> RMAN> ALTER DATABASE OPEN; RMAN> BACKUP DATABASE TAG BKP_POST_STREAMS_DFILES 2> PLUS ARCHIVELOG TAG BKP_POST_STREAMS_ARCS;

The above example includes two “tag” clauses per backup statement. As noted in the discussion of backups, RMAN always applies a different tag to datafiles and archlogs, so if you are going to use custom tags then you need to supply two custom values.

After you restore the tagged backup, recover the database until a point-in-time, SCN, or log sequence. Follow the normal rules for recovering to a prior point-in-time. One important note is, if you created any datafiles after the tagged backup was made, then you will not be able to restore from the tagged backup as easily as shown in the above example. You will need to perform recovery as outlined in Oracle Note 130724.1.