Oracle Database 10g RMAN Backup & Recovery by Matthew Hart and Robert G.. 63 RMAN Workshop: Create the Target Database RMAN Backup Account.... 78 RMAN Workshop: Register Your Database i
Trang 1Oracle Database 10g RMAN Backup & Recovery
by Matthew Hart and Robert G Free man Orac le Press © 2007 (696 pages) Citation ISBN:9780072263176
1 Deploy a rock-solid data backup and disaster recovery strategy with the in-depth guidance of this authoritative text Learn how to set up RMAN-ready databases, create reliable backup tapes and discs, and perform accurate Oracle system restores
TOC
Introduction 13
Answering the Question…and Asking a New O ne 13
A Book for the DBA and the Sys Admin 13
RMAN : An Evolution into Excellence 14
What This Book Covers 14
Using This Book Effectively 14
RMAN Workshops 15
Part I: Getting Started with RMAN in Oracle Database 10g 15
Chapter List 16
Chapter 1: Oracle Database 10g Backup and Recovery Architecture Tour 16
Overview 16
Backup and Recovery Essentials 17
High Availability 17
Backup and Recovery 17
A Few Oracle Terms to K now 18
Controlling the Database Software 20
Oracle Architecture 21
The Oracle Processes 21
Oracle Memory and RMAN 22
The Oracle Database 23
ARCHIVELOG Mode vs NOARCHIVELOG Mode 25
Oracle Logical Structures 25
The Combined Picture 25
Startup and Shutdown of the Database 25
Using the Database and Internals 27
Oracle Backup and Recovery Primer 29
Logical Backup and Recovery 29
Oracle Physical Backup and Recovery 30
Trang 2Backing Up Other Oracle Components 33
Summary 34
Chapter 2: Introduction to the RMAN Architecture 34
Server-Managed Recovery 34
The RMAN Utility 35
RMAN and Database Privileges 35
The Network Topology of RMAN Backups 36
Running RMAN Remotely 36
Running RMAN Locally from the Target Database’s ORACLE_HOME 37
The Database Control File 38
Record Reuse in the Control File 39
The Snapshot Control File 40
The RMAN Server Processes 41
RMAN Channel Processes 41
The SYS Packages Used by RMAN 42
SYS.DBMS_RCVMAN 42
SYS.DBMS_BACKUP_RESTORE 42
Backing Up the Data Block 43
The Data Block Backup O verview 43
The Benefits of Block-Level Backups 43
RMAN in Memory 44
Input Memory Buffers 45
Memory Buffers on Restore 46
RMAN Memory Utilization: PGA vs SGA 46
The Recovery Catalog 47
The Auxiliary Database 48
Compatibility Issues 49
The Target and the RMAN Executable 49
The Catalog Database and Catalog Schema 50
The Auxiliary Database 50
The RMAN Process: From Start to Finish 50
The Flash Recovery Area 52
Summary 52
Part II: Setup Principles and Practices 53
Chapter List 53
Chapter 3: RMAN Setup and Configuration 53
Configuring Your Database to Run in ARCHIVELOG Mode 53
ARCHIVELOG Destination Directories 53
The Flash Recovery Area 54
Should You Use the FRA? 59
Switching Between ARCHIVELOG Modes 59
If You Created Your Database with the Oracle Database Configuration Assistant 59
RMAN Workshop: Put the Database in ARCHIVELOG Mode 59
The RMAN Command Line 61
Connecting via the RMAN Command Line 61
Using the RMAN connect Command 63
Exiting the RMAN Client 63
Configuring the Database for RMAN Operations 63
Setting Up the Database User 63
RMAN Workshop: Create the Target Database RMAN Backup Account 64
Setting Up Database Security 64
Setting the CONTRO L_FILE_ RECORD_K EEP_TIME Parameter 65
Configuring RMAN Default Settings 66
Trang 3If You Are Using Shared Servers 75
Summary of RMAN Configuration Tasks 75
The Recovery Catalog 76
What Is the Recovery Catalog? 76
Creating the Recovery Catalog 77
RMAN Workshop: Create the Recovery Catalog User Account 77
RMAN Workshop: Create the Recovery Catalog 78
RMAN Workshop: Register Your Database in the Recovery Catalog 78
Backing Up and Recovering the Recovery Catalog 80
Other Backup and Recovery Setup and Configuration Considerations 80
Summary 80
Chapter 4: Media Management Considerations 80
Overview 80
Tape Backups in a Disk Backup World 81
RMAN and the Media Manager: An Overview 82
The Media Manager Catalog 83
The Media Manager: Other Software Components 83
Media Management Library 83
RMAN Workshop: Test Tape Channels with the Oracle Default SBT Interface 84
Interfacing with the MML 85
The SBT API 85
Back Up to Tape: From Start to Finish 86
Restore from Tape: From Start to Finish 87
Using sbttest and loadsbt.exe 87
Media Management Errors 88
Summary 89
Chapter 5: Oracle Secure Backup 89
Features of Oracle Secure Backup 89
Oracle Secure Backup and Recovery Manager 89
Differences Between OSB and OSB Express 90
Backup Encryption 90
Oracle Secure Backup Interfaces 90
Oracle Secure Backup Components 91
Host Access Modes 92
Administrative Data 93
Oracle Secure Backup Users and Classes 93
Operating System Accounts 94
NDMP Hosts 94
Oracle Secure Backup Rights and Classes 94
Installing Oracle Secure Backup 95
RMAN Workshop: Install Oracle Secure Backup 96
Enterprise Manager and Oracle Secure Backup 99
RMAN Workshop: Configuring and Using Enterprise Manager for OSB Backups 100
Submitting Oracle Secure Backup Jobs from RMAN 105
Configuring Backup Storage Selectors with Enterprise Manager 106
Oracle Secure Backup File System Backup and Restore 108
Summary 108
Chapter 6 : Enhancing RMAN with VERITAS NetBackup™ for Oracle 108
Key Features 109
Necessary Components 109
Storage/Media Device Configuration 109
NetBackup Installation 110
Pre-Installation Tasks for NetBackup for Oracle Agent 111
Trang 4NetBackup for Oracle Agent Installation Steps 111
How to Link Oracle to NetBackup Media Manager 112
Automatic Link Method 112
Manual Link Method 112
Architecture 113
Configuring NetBackup Policies 114
Adding New Policies 114
Defining Schedules 116
Defining a Backup Selection 118
Defining Policy Clients 119
Managing Expired Backup Images 120
Delete Expired Backups Using NetBackup Repository 120
Delete Expired Backups Using RMAN 120
RMAN Sample Scripts 120
Troubleshooting 121
Use NetBackup Logs 121
Determine Which Library Is in Use 122
Security Best Practices 122
Cost Justification 123
Summary 123
References 123
Chapter 7: Configuring EMC NetWorker Module for Oracle 123
Architecture of the Oracle and NetWorker Backup and Recovery System 124
Backup and Restore Operations 125
Installing NMO 125
RMAN Workshop: NMO Installation 126
Configuring NetWorker for Client Operating System Backups 127
RMAN Workshop: Configure NetWorker for OS-Level Backups 127
Running and Scheduling RMAN Backups 129
RMAN Workshop: Configuration of the nsrnmo.SID Script 129
Configuring NMO for Oracle Backups 129
Creating RMAN Backup Scripts 130
Restore Commands 132
NSR Environment Variables 133
Summary 133
Chapter 8: RMAN and Tivoli Storage Manager 133
Overview of Tivoli Storage Manager 134
TSM Server System Objects 135
TSM Client 136
TSM Administration Center and Web Client 136
TSM Installation Tasks 137
Storage Manager for Linux Server 137
IBM Integrated Solutions Console 137
Storage Manager Administration 138
TSM for Databases 138
Configuration Tasks 139
Creating a TSM Administrator Account 139
Registering a TSM Client 139
Adding a Server to ISC 140
Adding a Storage Device 141
Configuring TDPO 143
Performing an RMAN Backup Using TDPO 146
Summary 149
Trang 5Part III: Using RMAN Effectively 149
Chapter List 149
Chapter 9: RMAN Backups 149
Benefits of RMAN Backups vs Scripted Backups 150
RMAN Compatibility Issues 150
Monitoring RMAN Backup Status 151
Offline RMAN Database Backups 152
Offline Backups Using Default Settings 152
RMAN Workshop: Do an O ffline Backup 152
Offline Backups Without Using Configured Defaults 154
Backup Command Options 157
Compression 157
Tags 158
Limiting Backup Impacts 158
Limiting the Size of a Backup Set 158
Modifying the Retention Policy for a Backup Set 159
Overriding the configure exclude Command 159
Checking the Database for Errors with the backup Command 159
Skipping O ffline, Inaccessible, or Read-Only Datafiles 160
Forcing a Backup of Read-Only Datafiles 160
Backing Up Datafiles Based on Their Last Backup Time 160
Checking for Logical Corruption During a Backup 161
Making Copies of Backups on Your RMAN Copier 161
Capturing the Elusive Control File 161
Introducing the Set Command 162
Online RMAN Database Backups 162
Online Database Backups 163
RMAN Workshop: Do an Online Backup 163
Tablespace Backups 164
Datafile Backups 165
Archived Redo Log Backups 165
Control File and Parameter File Backups 166
Backup Set Backups 166
Flash Recovery Area Backups 167
Copies 167
Introducing Image Copies 167
Database, Tablespace, and Datafile Image Copies 167
Control File Copies 168
ARCHIVELOG Image Copies 168
Incremental RMAN Backups 168
The Block Change Tracking File 169
The Base Backup 169
Differential vs Incremental Backups 170
RMAN Workshop: Do an Incremental Backup 172
Getting Started 172
RMAN Workshop: Get Your Database Backed Up! 172
Summary 174
Chapter 10: RMAN Restore and Recovery 174
RMAN Restore and Recovery Basics 175
Before You Can Restore the Database 176
Before RMAN Can Get Going 176
Restoring the SPFILE 177
Restoring the Control File 180
Trang 6In addition, try scaling down the memory utilization of these test boxes to be as low as possible You won’t actually be doing that much processing, so you don’t need a lot of buffer cache available The smaller you keep the System Global Area (SGA), the better off your little test box will be
You also need a recovery catalog database that is separate from the target databases that you are using for testing We always recommend that your recovery catalog database be the most recent version, so put this in a 10.2 home In a pinch, this can also be used as a target database, but try to keep your recovery catalog database out of the mix of databases that you blow away and rebuild It just makes life easier If at all possible, put your recovery catalog database on a different server Put it on a Windows workstation or an old Linux box Keep it out of the crash-and-burn destruction path
Using Oracle ASM
If you plan to test out Oracle’s volume manager, Automatic Storage Management (ASM), you have to make preparations when you first configure your RMAN test box In a production environment, you would simply add full, raw disks to an ASM disk group In a test environment, if you want to test multiple ASM disk groups, you can simply use logical
partitions on a single disk But this means you have to think ahead and create some unused, raw partitions on your disks before you get too far into your OS setup
Oracle Enterprise Manager
If you plan to use OEM, make sure there is enough memory to do so As you learned in Chapter 11, there are two flavors
of OEM you can choose from: Database Control and Grid Control From a testing perspective, it might make sense to go with Database Control to save on resources and administration headaches However, make the choice that matches your production environment: If you deploy Grid Control management in production, use Grid Control to manage RMAN backups in the test environment
That being said, try to avoid using production Grid Control for RMAN test environments The databases will be down, up, down, lost, trashed, crashed, and lost This means lots of alerts will be sent to the Oracle Management Service (OMS) and, consequently, e-mailed out to people Avoid bot spam! If you have not already deployed a test Grid Control environment for your enterprise, get one set up for your RMAN backups and then offer it to others for testing purposes
For Database Control, expect a memory hit of 150 to 200MB per instance Also, Database Control makes heavy use of CPUs and uses up database space Database Control generates about 200MB of archive logs per day just by itse lf, with an idle database
For Grid Control, you need a 2GB system all by itself for the repository database and OMS Factor it in as a separate system On the RMAN test system itself, the agent will use only about 60MB of memory and enough CPU to run its Perl scripts
OEM, either Database or Grid Control, is highly dependent on a stable and predictable networking sublayer, which means you cannot constantly change the hostname or IP address Sorry It’s just easier that way If you have to, create your own subnet and manually assign dummy IP addresses in the hosts files The easiest check you can implement to ensure
everything will operate correctly is the nslookup command on the hostname, and a reverse lookup on the IP address Media Management Conside rations
If possible, you should install a version of the media management client that you will be using in production Then, insta ll the Oracle Plug-In and do the backups to tape the same as you would in production This gives you the best opportunity to antic ipate what to expect when you implement your strategy in your enterprise
If you can’t get access to the media management product that is used for your enterprise, there is little alternative left The best option is to try out Oracle Secure Backup, as outlined in Chapter 5 of this book
If you simply need to test tape channel allocations, or the process of staging the flash recovery area to tape, you still have access to the Oracle SBT API, which enables you to write “tape” backups to a disk location This is described in the
Trang 7RMAN Workshop “Test Tape Channels with the Oracle Default SBT Interface” in Chapter 4
The RMAN Configuration
Now that you have your system set up with Oracle insta lled and databases built, we have a few hints on the testing process itself:
• Have a cold backup that remains untouched Before you do any RMAN testing, shut down your database and take
a cold OS copy backup and place it in a folder that doesn’t get touched This is your last line of defense if you completely mess everything up during your RMAN testing
• Switch your redo logs a lot One of the biggest mistakes that happens with RMAN testing is that the timeframe
between the backup and restore is unrealistically short Confusion sets in because there is no space between the completion time of the backup and the “until time” of the restore operation So, after any backup, make sure you switch the log file three or four times, just to put a little “distance” between operations
• Set the NLS_DATE_FORMAT environment variable This is good advice for RMAN in general, but particularly in
a test situation, where the timeframe between a backup and a restore will be unrealistically short and you will want to know the timeframe of a backup to the second So, before starting RMAN, be sure to run the following: export NLS_DATE_FORMAT='mon-dd-yyyy hh24:mi:ss'
Then, when you start RMAN and issue a list backup command, the time will a lways show details to the minute and
second
• Leave your catalog database alone You will be tempted to use the database that houses your catalog as a target
and perform some tests with it That is fine—that’s why it’s called a test environment But you can seriously undermine your testing if you foul up your catalog Do yourself a favor and leave the catalog database alone And export your catalog schema with a user-level export before any new test session begins
• Keep up with catalog maintenance This may be your test environment, but you will be creating a lot of backups
over time, and you have a limited amount of space on your little test box Take the opportunity to test out using retention polic ies to get rid of old backups
• Remove clones as soon as possible Attack of the clones! If you use the duplicate command, you can end up with
numerous different instances running and taking up precious memory and disk space Hey, it’s a clone, and you’re
in a test environment—get rid of it as soon as you make it
• Leave a clone file system in place You don’t need to go through the steps of building the file system and the
init.ora file for your duplicate database every time you want to test the duplicate or duplicate…for standby
command Leave the file system and supporting files in place, and use the same DB_NAME and SID On
Windows, be sure to leave the Oracleservice<sid> in place in the Services control panel
• Don’t get attached to your test environment Sometimes you need to just blow everything away and start over
from scratch, particularly if you don’t have good ma intenance habits Eventually, your database will get to the point that it has had tablespaces dropped, has had re-created, dropped, and forgotten files placed in the wrong directory, has had archive logs stored all over the place—basically a rambling mess Don’t worry That’s why they call it testing Don’t get too wrapped up in the environment you have; just whack everything and start over from the cold backup you took prior to testing
You’ll sure ly find some of your own va luable lessons after you’ve done a bit of testing After you go through the
conceptual learning, take the scripts you’ve built and the knowledge you’ve gained and schedule some time on a
production-grade system to make sure that everything is going to scale up to your enterprise You’ll be glad you took the time to learn it before you went live