Sei sulla pagina 1di 280

Oracle Database 10g:

Backup and Recovery

Volume II • Student Guide

n l y
e O
U s
A I
O
l &
D22057GC10
na
Production 1.0
June 2006
D46525
te r
I n
c l e
r a ®

O
Authors Copyright © 2006, Oracle. All rights reserved.

Donna Keesling Disclaimer


Maria Billings This document contains proprietary information and is protected by copyright and
other intellectual property laws. You may copy and print this document solely for your
Technical Contributors own use in an Oracle training course. The document may not be modified or altered in
any way. Except where your use constitutes "fair use" under copyright law, you may
and Reviewers not use, share, download, upload, copy, print, display, perform, reproduce, publish,
Christopher Andrews license, post, transmit, or distribute this document in whole or in part without the
express authorization of Oracle.
Tammy Bednar
Tom Best The information contained in this document is subject to change without notice. If you
Harald van Breederode find any problems in the document, please report them in writing to: Oracle University,
Mary Jane Bryksa 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
warranted to be error-free.
Marielle Canning
Tim Chien Restricted Rights Notice
Donna Cooksey
Judy Ferstenberg If this documentation is delivered to the United States Government or anyone using
the documentation on behalf of the United States Government, the following notice is
Gerlinde Frenzen applicable:
Joel Goodman
Pete Jones U.S. GOVERNMENT RIGHTS
Isabelle Marchand The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or
disclose these training materials are restricted by the terms of the applicable Oracle
Sabiha Miri license agreement and/or the applicable U.S. Government contract.
Manish Pawar
Jim Spiller Trademark Notice
George Stabler
Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle
Anthony Woodell Corporation and/or its affiliates. Other names may be trademarks of their respective
owners.
Editor
Daniel Milne

n l y
Graphic Designer
Satish Bettegowda
e O
Publisher
U s
Jobi Varghese

A I
O
l &
n a
te r
I n
c l e
r a
O
Contents

1 Introduction
Objectives 1-2
Course Objectives 1-3
What Is Backup and Recovery? 1-4
Performing Backup and Recovery Operations for an Oracle Database 1-5
Using Oracle Recovery Manager 1-6
Recovery Manager Components 1-7
Using Oracle Secure Backup 1-9
Overview of Oracle Backup Methods 1-10
When Do You Need to Use a Backup for Recovery? 1-12
Responding to User Error 1-13
Overview of Data Recovery 1-14
Oracle Database Architecture: Crash Recovery 1-15
Oracle Database Architecture: Recovery After Media Failure 1-16
Developing a Backup and Recovery Strategy for Your Oracle Database 1-17
Oracle Solutions for High Availability 1-18
n l y
Summary 1-21
e O
Oracle High Availability Solutions for Unplanned Downtime 1-19

2 Configuring for Recoverability


U s
Objectives 2-2

A I
Configuring Your Database for Backup and Recovery Operations 2-3
Configuring ARCHIVELOG Mode 2-4
O
l &
Specifying a Backup Destination 2-5
Specifying a Retention Policy 2-6

n a
Using a Flash Recovery Area 2-8

te r
Defining a Flash Recovery Area 2-9
Defining Flash Recovery Area Using Enterprise Manager 2-10

I n
Flash Recovery Area Space Management 2-11

c l e
Flash Recovery Area Space Usage 2-13
Monitoring the Flash Recovery Area 2-14

r aBenefits of Using a Flash Recovery Area 2-15


Summary 2-16
O Practice Overview 2-17

iii
3 Using RMAN to Create Backups
Objectives 3-2
Using RMAN to Create Backups 3-3
Backup Destinations 3-4
Configuring Persistent Settings for RMAN 3-5
Using Enterprise Manager to Configure RMAN Settings 3-6
Managing Persistent Settings 3-7
Configuring and Allocating Channels for Use in Backups 3-8
Configuring Backup Optimization 3-9
Creating Backup Sets 3-11
Creating Image Copies 3-12
BACKUP Command Options 3-14
Creating a Whole Database Backup 3-16
RMAN Backup Types 3-17
Fast Incremental Backup 3-19
Enabling Fast Incremental Backup 3-20
Monitoring Block Change Tracking 3-21
Creating an Oracle-Suggested Backup 3-22
Creating Duplexed Backup Sets 3-23
Creating Duplexed Backup Sets Using CONFIGURE BACKUP COPIES 3-24
Creating Duplexed Backup Sets Using BACKUP COPIES 3-25
n l y
Creating Backups of Backup Sets 3-26
Configuring Control File Autobackups 3-27
e O
Using a Media Manager 3-29
Creating Proxy Copies 3-31
U s
Managing Backups: Reporting 3-32

A
Using Enterprise Manager to View Backup Reports 3-34
I
O
Managing Backups: Crosschecking and Deleting 3-35

Summary 3-37
l &
Using Enterprise Manager to Manage Backups 3-36

Practice Overview 3-38


n a
4
te r
Using RMAN to Perform Recovery
Objectives 4-2
I n
c l e
Using RMAN RESTORE and RECOVER Commands 4-3
Performing Recovery Using Enterprise Manager 4-4

r a
Comparing Complete and Incomplete Recovery 4-5
Complete Recovery Following the Loss of Datafiles 4-6
O
Performing Complete Recovery: Loss of a Non-Critical datafile in ARCHIVELOG
Mode 4-7

iv
Performing Complete Recovery: Loss of a System-Critical Datafile in ARCHIVELOG
Mode 4-8
Recovery Using Incrementally Updated Backups 4-9
Using the Flash Recovery Area for Fast Recovery 4-10
Performing Restore and Recovery of a Database in NOARCHIVELOG Mode 4-11
Using Incremental Backups to Recover a Database in NOARCHIVELOG Mode 4-12
Restoring and Recovering the Database on a New Host 4-13
Preparing to Restore the Database to a New Host 4-14
Restoring the Database to a New Host 4-15
Performing Recovery with a Backup Control File 4-19
Restoring the Server Parameter File from the Control File Autobackup 4-20
Restoring the Control File from Autobackup 4-21
Performing Disaster Recovery 4-23
Summary 4-25
Practice Overview 4-26

5 Using Oracle Flashback Technologies


Objectives 5-2
Using Oracle Flashback Technology 5-3
Flashback Drop and the Recycle Bin 5-4
Understanding the Recycle Bin 5-5
Restoring Tables from the Recycle Bin 5-6
n l y
Automatic Space Reclamation in the Recycle Bin 5-7
Manual Space Reclamation in the Recycle Bin 5-8
e O
Bypassing the Recycle Bin 5-9
U s
Querying the Recycle Bin 5-10
Querying Data in Dropped Tables 5-11
A I
O
Using Flashback Technology to Query Data 5-12
Configuring Undo for Flashback 5-13

l
Flashback Query: Overview 5-14 &
a
Flashback Query: Example 5-15

n
te r
Flashback Versions Query: Overview 5-16
Using Enterprise Manager to Perform Flashback Versions Query 5-17

I n
Flashback Versions Query: Considerations 5-18
Flashback Transaction Query: Overview 5-19

l e
Using Enterprise Manager to Perform Flashback Transaction Query 5-20

c
Flashback Transaction Query: Considerations 5-21

r aFlashback Table: Overview 5-22

O Flashback Table 5-23


Enabling Row Movement on a Table 5-24
Performing Flashback Table 5-25

v
Flashback Table: Considerations 5-26
Flashback Database: Overview 5-27
Flashback Database Architecture 5-28
Configuring Flashback Database 5-29
Using Enterprise Manager to Configure Flashback Database 5-30
Flashback Database: Examples 5-31
Using Enterprise Manager to Perform Flashback Database 5-32
Flashback Database Considerations 5-35
Monitoring Flashback Database 5-36
Tuning Considerations for Flashback Database 5-39
Using Guaranteed Restore Points 5-41
Summary 5-42
Practice Overview 5-43

6 Using RMAN to Create a Duplicate Database


Objectives 6-2
Using RMAN to Create a Duplicate Database 6-3
Using a Duplicate Database 6-4
Creating a Duplicate Database 6-5
Creating an Initialization Parameter File for the Auxiliary Instance 6-6
Specifying Parameters to Control File Naming 6-7
Starting the Instance in NOMOUNT Mode 6-9
n l y
Ensuring That Backups and Archived Redo Log Files Are Available 6-10
Allocating Auxiliary Channels 6-11
e O
Using the RMAN DUPLICATE Command 6-12
U s
Understanding the RMAN Duplication Operation 6-13
Specifying Options for the DUPLICATE Command 6-14
A I
O
Using Enterprise Manager to Create a Duplicate Database 6-15
Using Enterprise Manager: Source Working Directory 6-16

l &
Using Enterprise Manager: Select Destination 6-17

a
Using Enterprise Manager: Destination Options 6-18

n
Summary 6-20
te r
Using Enterprise Manager: Review Page 6-19

n
Practice Overview 6-21
I
7
l e
Performing Tablespace Point-in-Time Recovery

c
Objectives 7-2

r a
Tablespace Point-in-Time Recovery (TSPITR) Concepts 7-3

O
Tablespace Point-in-Time Recovery (TSPITR): Terminology 7-4
Tablespace Point-in-Time Recovery: Architecture 7-5
Understanding When to Use TSPITR 7-7

vi
Preparing for TSPITR 7-8
Determining the Correct Target Time 7-9
Determining the Tablespaces for the Recovery Set 7-10
Identifying Objects That Will Be Lost 7-11
Performing Basic RMAN TSPITR 7-12
Performing Fully Automated TSPITR 7-13
Using Enterprise Manager to Perform TSPITR 7-14
Understanding TSPITR Processing 7-15
Performing Customized RMAN TSPITR with an RMAN-Managed Auxiliary Instance 7-17
Performing RMAN TSPITR Using Your Own Auxiliary Instance 7-18
Troubleshooting RMAN TSPITR 7-19
Summary 7-21
Practice Overview 7-22

8 Using the RMAN Recovery Catalog


Objectives 8-2
RMAN Repository Data Storage: Comparison of Options 8-3
Storing Information in the Recovery Catalog 8-4
Reasons to Use a Recovery Catalog 8-5
Creating the Recovery Catalog: Three Steps 8-6
Configuring the Recovery Catalog Database 8-7
Creating the Recovery Catalog Owner 8-8
n l y
Creating the Recovery Catalog 8-9

e
Managing Target Database Records in the Recovery Catalog 8-10
O
Registering a Database in the Recovery Catalog 8-11
Using Enterprise Manager to Register a Database 8-12
U s
Cataloging Additional Backup Files 8-15 A I
Unregistering a Target Database from the Recovery Catalog 8-14

O
Manually Resynchronizing the Recovery Catalog 8-16
Using RMAN Stored Scripts 8-17
l &
n a
Creating RMAN Stored Scripts 8-18
Executing RMAN Stored Scripts 8-19

te r
Displaying RMAN Stored Script Information 8-20

I n
Updating and Deleting RMAN Stored Scripts 8-21
Backing Up and Recovering the Recovery Catalog 8-22

l e
Re-creating an Unrecoverable Recovery Catalog 8-23

c
Exporting and Importing the Recovery Catalog 8-24

r aUpgrading the Recovery Catalog 8-25

O Dropping the Recovery Catalog 8-26


Summary 8-27
Practice Overview 8-28

vii
9 Monitoring and Tuning RMAN
Objectives 9-2
Monitoring RMAN Sessions 9-3
Monitoring RMAN Job Progress 9-5
Monitoring RMAN Job Performance 9-7
Interpreting RMAN Message Output 9-8
Using the DEBUG Option 9-9
Understanding RMAN Code Layer Error Numbers 9-10
Interpreting RMAN Error Stacks 9-11
Tuning RMAN 9-12
RMAN Multiplexing 9-13
Allocating Disk Buffer: Example 9-14
Allocating Tape Buffers 9-15
Comparing Synchronous and Asynchronous I/O 9-16
Monitoring RMAN Job Performance 9-18
Asynchronous I/O Bottlenecks 9-19
Synchronous I/O Bottlenecks 9-20
Tape Backup Speed 9-21
Tape Subsystem Performance Rules 9-22
Controlling Tape Buffer Size with BLKSIZE 9-23
Channel Tuning 9-24
n l y
Tuning the BACKUP Command 9-25
Tuning RMAN Backup Performance 9-26
e O
Setting LARGE_POOL_SIZE 9-27
Tuning RMAN Tape Streaming Performance Bottlenecks 9-28
U s
Summary 9-30
Practice Overview 9-31
A I
O
10 Oracle Secure Backup Overview
Objectives 10-2
l &
n a
Oracle Secure Backup Tape Backup Management 10-3

te r
What Is Oracle Secure Backup? 10-4
Oracle Secure Backup: Tape Management and Integration with Oracle Products 10-5

I n
Client/Server Architecture Host Roles 10-6

c l e
Oracle Secure Backup for Centralized Tape Backup Management 10-7
Typical SAN Environment 10-8

r a
Oracle Secure Backup Interface Options 10-9
Media Concepts: Overview 10-10
O
Backup Pieces and Backup Images 10-11
Media Management Expiration Policies 10-12
Oracle Secure Backup Media Family 10-14

viii
Tape Drives and Libraries 10-15
Virtual Tape Libraries (VTL) 10-17
Managing Data to Be Protected 10-18
Oracle Secure Backup Jobs 10-19
Securing Data and Access to the Backup Domain 10-20
Oracle Secure Backup: The Integration Advantage 10-22
Why Use Oracle Secure Backup? 10-23
Summary 10-24

11 Installing Oracle Secure Backup


Objectives 11-2
Performing Preinstallation Tasks 11-3
Installation and Configuration of the Administrative Domain 11-4
Performing Installation Tasks 11-5
Administrative Server Installation: Example 11-6
Wizard-Based Installation on Windows 11-13
Oracle Secure Backup Interfaces 11-14
Integration with Enterprise Manager 11-15
Oracle Secure Backup Administrative Server Page 11-16
Configuring the Administrative Server in EM 11-17
Oracle Secure Backup Web Tool Home Page 11-18
Common obtool Commands 11-19 n l y
Configuring Oracle Secure Backup Users 11-20
e O
Adding Oracle Secure Backup Users 11-21
Preauthorizing Access 11-23
U s
Summary 11-24
Practice Overview 11-25
A I
12 Using RMAN and Oracle Secure Backup O
Objectives 12-2
l &
a
RMAN and Oracle Secure Backup Basic Process Flow 12-3
n
te r
RMAN Database Backup to Tape 12-4
Database Backup Storage Selector 12-5

I n
Defining Database Storage Selectors 12-7
Media Families and RMAN 12-8

l e
Oracle Database Disk and Tape Backup Solution 12-9
c
r a
Backing Up the Flash Recovery Area to Tape 12-10
Defining Retention for RMAN Backups 12-11

O Backup Settings 12-12


Scheduling Backups with EM 12-13
Oracle-Suggested Backup to Tape 12-14

ix
RMAN and Oracle Secure Backup Job Execution 12-15
Managing Database Tape Backups 12-16
Performing Database Recovery 12-18
RMAN Automatic Failover to Previous Backup 12-19
Summary 12-20
Practice Overview 12-21

13 Backing Up File-System Files with Oracle Secure Backup


Objectives 13-2
Backing Up File-System Files with Oracle Secure Backup 13-3
File-System Backups 13-4
Managing Media Families 13-5
Dataset Script: Examples 13-6
Creating Datasets 13-9
Creating Backup Windows 13-11
Creating Backup Schedules 13-13
Creating Backup Triggers 13-14
Previewing a Backup Trigger 13-16
Creating On-Demand Backup Requests 13-17
Submitting Backup Requests 13-19
Reviewing Jobs 13-20
Summary 13-21 n l y
Practice Overview 13-22
e O
14 Restoring File-System Backups with Oracle Secure Backup
U s
Objectives 14-2

A I
Browsing the Catalog for File-System Backup Data 14-3
Restoring File-System Data 14-4
O
Restoring File-System Files with Oracle Secure Backup 14-5
The Restore Page 14-6
l &
a
Listing All File-System Backups of a Client 14-7
n
te r
Creating a Catalog-Based Restore Request 14-8
Submitting Restore Requests 14-12
Summary 14-13
I n
Practice Overview 14-14

c l e
r a
O
x
15 Managing Oracle Secure Backup Security
Objectives 15-2
Guarding Access and Data 15-3
Managing User Access Control 15-4
Predefined Classes and User Rights 15-5
Defining an Oracle Secure Backup User 15-8
Oracle Secure Backup User: OS Permissions 15-9
Preauthorization 15-11
Assigning Windows Account Information 15-12
Authentication 15-13
Leveraging Oracle Security Technology 15-14
Administrative Server Certificate Authority (CA) 15-16
Oracle Wallets 15-18
Encrypted Backups to Tape 15-20
Creating RMAN Encrypted Backups 15-21
Using Transparent Mode Encryption 15-22
Using Password Mode Encryption 15-24
Using Dual Mode Encryption 15-25
Restoring Encrypted Backups 15-26
Performing Encrypted Recovery 15-27
Summary 15-28
Practice Overview 15-29 n l y
16 Managing the Administrative Domain
e O
Objectives 16-2
U s
Oracle Secure Backup Processes: Daemons 16-3
Managing Common Daemon Operations 16-5
A I
Managing Policies and Defaults 16-6
O
Configuring Oracle Secure Backup Policies 16-7

l &
Oracle Secure Backup: Backup Metadata Catalogs 16-8

a
Oracle Secure Backup: Directory Structure 16-10
n
te
Adding Clients 16-12 r
Backing Up the Catalog 16-11

I n
Adding Media Servers 16-13
NAS Devices 16-15

l e
Adding NDMP Media Servers 16-16
c
r a
Adding Devices 16-17
Discovering Devices on NDMP Hosts 16-19

O Managing Devices 16-20


Tape Library Properties 16-21
Tape Drive Properties 16-22

xi
Managing Volumes 16-23
Oracle Secure Backup Jobs 16-25
Managing Jobs 16-27
Viewing Job Properties and Transcripts 16-29
Suspending and Resuming Job Dispatching 16-31
Job Summaries 16-33
Displaying Log Files and Transcripts 16-34
Summary 16-35
Practice Overview 16-36

Appendix A: Practices

Appendix B: Practice Solutions

Appendix C: Oracle Secure Backup Additional Installation Topics


Topics C-2
Windows Installation: Overview C-3
Stopping Tape Device Drivers C-4
Oracle Secure Backup Setup C-6
Service Startup Dialogs C-8
Service Login Dialog Box C-9
Oracle Secure Backup Installed Files C-10 n l y
Installed Files for Host Role: Administrative Server C-14
e O
Installed Files for Host Role: Media Server C-16
Installed Files for Host Role: Client C-17
U s
Specifying Installation Parameters C-18
Client Installation: Example C-20
A I
Media Server Installation: Example C-21
Verifying Your Installation C-22 O
l
Uninstalling Oracle Secure Backup C-23&
Summary C-25
n a
Appendix D: Glossary
te r
I n
c l e
r a
O
xii
Appendix A
Practices

n l y
e O
U s
A I
O
l &
na
te r
I n
c le
ra
O
Table of Contents
Practice 2-1: Configure Your Database .......................................................................... 5
Practice 3-1: Use RMAN to Create and Manage Backups ............................................. 7
Practice 4-1: Use RMAN to Recover a Datafile............................................................. 9
Practice 4-2: Use the Flash Recovery Area to Quickly Recover a Datafile ................. 10
Practice 4-3: Recover Control Files.............................................................................. 11
Practice 4-4: Delete Obsolete Backups......................................................................... 12
Practice 5-1: Enable Flashback Database ..................................................................... 14
Practice 5-2: Set Restore Points and Perform Flashback Table.................................... 15
Practice 5-3: Use Flashback Query and Flashback Versions Query............................. 16
Practice 5-4: Use Flashback Database .......................................................................... 17
Practice 6-1: Create a Duplicate Database.................................................................... 19
Practice 7-1: Use Tablespace Point-in-time Recovery ................................................. 21
Practice 8-1: Create the Recovery Catalog and Register the Database ........................ 23
Practice 9-1: Use SQL to Monitor the Progress of RMAN Backups ........................... 25
Practice 9-2: Use Enterprise Manager to Monitor RMAN Jobs ................................... 26
Practice 11-1: Install Oracle Secure Backup ................................................................ 29
Practice 11-2: Configure Devices for Oracle Secure Backup....................................... 30
Practice 11-3: Register the Administrative Server........................................................ 31
Practice 11-4: Configure Oracle Secure Backup User.................................................. 32
Practice 12-1: Create a Database Backup Storage Selector.......................................... 34
Practice 12-2: Perform Oracle-Suggested Backup ....................................................... 35
Practice 13-1: Back Up Your File System with Oracle Secure Backup ....................... 37
Practice 14-1: Restore File-System Data with Oracle Secure Backup ......................... 39 n l y
e O
Practice 15-1: Create an Encrypted Backup ................................................................. 41
Practice 15-2: Recover a Tablespace from an Encrypted Backup................................ 42

U s
Practice 16-1: View Oracle Secure Backup Information.............................................. 44
Practice 16-2: Back Up the Oracle Secure Backup Catalog ......................................... 45

A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-2
Practice for Lesson 1

There are no practices for Lesson 1.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-3
Practice for Lesson 2

In this practice, you configure your database for recoverability.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-4
Practice 2-1: Configure Your Database
1) Use Enterprise Manager to configure your database in ARCHIVELOG mode.
2) Use Enterprise Manager to verify that the Flash Recovery Area has been configured
for your database and increase the Flash Recovery Area size to 3 GB.
3) Set Preferred Credentials in Enterprise Manager.
4) Use Recovery Manager (RMAN) to connect to your target database. Make note of the
database identifier (DBID) of your database.

Database Identifier: ____________________________


Make note of the database identifier (DBID) of your database.
5) Use the RMAN SHOW ALL command to view the configuration settings in your
database and then exit from your RMAN session.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-5
Practice for Lesson 3

In this practice, you configure automatic backup of the control file. You also configure a
backup of your database using the Oracle-Suggested Backup Strategy feature in
Enterprise Manager Database Control.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-6
Practice 3-1: Use RMAN to Create and Manage Backups
1) Use Enterprise Manager Database Control to configure autobackup of the control file
and the server parameter file.
2) Use Enterprise Manager Database Control to configure backup optimization and
enable block change tracking. Specify
/u01/app/oracle/oradata/orcl/chg_track.f for the name of the block
change tracking file.
3) Use Enterprise Manager Database Control to create a whole database backup using
the Oracle-suggested backup strategy.
4) Use Enterprise Manager to view information about your backups.
5) Use RMAN to create a duplexed backup set of the EXAMPLE tablespace.
6) Use Enterprise Manager Database Control to perform a crosscheck of your backups.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-7
Practice for Lesson 4

In this practice, you use RMAN to perform recovery.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-8
Practice 4-1: Use RMAN to Recover a Datafile
In this practice, you use RMAN to recover a lost datafile. Notice how you are prompted
by Enterprise Manager to recover the lost datafile.
1) Use SQL*Plus to query the HR.REGIONS table. Make note of the number of rows in
the HR.REGIONS table.
2) At the operating system prompt, execute the lab_04_01_02_01.sh script to
simulate a failure in your database. This script deletes the EXAMPLE tablespace
datafile.
3) Use SQL*Plus to query the HR.JOBS table.
4) Use Enterprise Manager to perform database recovery of the EXAMPLE tablespace
datafile.
5) Return to your SQL*Plus session and again attempt to query the HR.JOBS table.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-9
Practice 4-2: Use the Flash Recovery Area to Quickly Recover a
Datafile
In this practice, you recover a lost datafile by using the Flash Recovery Area for fast
recovery.
1) Use SQL*Plus to query the HR.REGIONS table. Make note of the number of rows in
the HR.REGIONS table.
2) At the operating system prompt, execute the lab_04_02_02_01.sh script to
simulate a failure in your database. This script deletes the EXAMPLE tablespace
datafile.
3) Use SQL*Plus to query the HR.DEPARTMENTS table.
4) Use the RMAN SWITCH TO COPY command to recover the datafile.
5) Query the HR.JOBS table.
6) Using Enterprise Manager Database Control, verify that the datafile being used for
the EXAMPLE tablespace is in the Flash Recovery Area.
7) Make a copy of the datafile in the original location and switch back to it.
8) Use Enterprise Manager Database Control to verify the file.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-10
Practice 4-3: Recover Control Files
In this practice, you recover your control file using an autobackup.
1) Use SQL*Plus to view files information for the control files in your database. Query
V$CONTROLFILE.
2) Simulate a failure in your environment by executing the lab_04_03_02_01.sh
script to delete all your control files.
3) You need some more information about your control files. Query
V$CONTROLFILE_RECORD_SECTION to learn more about the contents of your
control file.
4) You have lost all your control files and will need to recover them from the control file
autobackup. Use Recovery Manager to recover the control files.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-11
Practice 4-4: Delete Obsolete Backups
1) Use Recovery Manager to view obsolete backups.
2) Use Enterprise Manager Database Control to delete obsolete backups.
3) You can also use RMAN to verify that your obsolete backups were deleted.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-12
Practice for Lesson 5

In this practice, you use Oracle Flashback features to recover from errors in your
database.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-13
Practice 5-1: Enable Flashback Database
1) Use Enterprise Manager to enable Flashback Database.
2) Use the ALTER DATABASE command to enable supplemental logging.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-14
Practice 5-2: Set Restore Points and Perform Flashback Table
Restore points are a way to “bookmark” database points in time. Set a restore point to
remember a significant change so that you can quickly recover to that point in time
without having to record an SCN or time.
1) You must enable row movement to use restore points. Use Enterprise Manager to
enable row movement for the HR.LOCATIONS table.
2) Create a normal restore point.
3) Use SQL*Plus to query the POSTAL_CODE column in the HR.LOCATIONS table.
4) Execute the lab_05_02_04_01.sql script to update the POSTAL_CODE column
in the HR.LOCATIONS table so that all postal codes are set to 11111.
5) Execute the lab_05_02_05_01.sql script to query the POSTAL_CODE column
in the HR.LOCATIONS table again.
6) Restore the POSTAL_CODE column values using the restore point.
7) Return to your SQL*Plus session. Execute the lab_05_02_07_01.sql script to
query the POSTAL_CODE column in HR.LOCATIONS again to be sure the correct
values have been restored.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-15
Practice 5-3: Use Flashback Query and Flashback Versions
Query
1) Execute the lab_05_03_01_01.sql script to query the HR.LOCATIONS table
for location ID 1400.
2) Execute the lab_05_03_02_01.sql script to update the POSTAL_CODE column
in the HR.LOCATIONS table, simulating user error.
3) Execute the lab_05_03_03_01.sql script to query the POSTAL_CODE column
in HR.LOCATIONS and view the change.
4) Execute the lab_05_03_04_01.sql script to update the POSTAL_CODE column
in the HR.LOCATIONS table, simulating user error.
5) Use Enterprise Manager to perform Flashback Versions Query to correct the user
errors.
6) Return to your SQL*Plus session. Query the HR.LOCATIONS table to confirm the
Flashback operation.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-16
Practice 5-4: Use Flashback Database
1) Use Enterprise Manager to verify that Flashback Database is enabled.
2) Use Enterprise Manager to create a Guaranteed Restore Point.
3) Execute the lab_05_04_03_01.sql script to determine the number of rows in
the HR.JOB_HISTORY table. Record the number of rows: ___________
4) Execute the lab_05_04_04_01.sql script to truncate the HR.JOB_HISTORY
table.
5) Execute the lab_05_04_05_01.sql script to determine the number of rows in
the HR.JOB_HISTORY table.
6) Use Flashback Database to restore the HR.JOB_HISTORY table rows.
7) Return to your SQL*Plus session. Execute the lab_05_04_07_02.sql script to
query the HR.JOB_HISTORY table again to be sure the data has been restored.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-17
Practice for Lesson 6

In this practice, you create a duplicate database.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-18
Practice 6-1: Create a Duplicate Database
In this practice, you use RMAN to create a duplicate database on the same host as your
database.
1) Create an Oracle password file for your auxiliary instance.
2) Use Oracle Net Manager to create an entry called AUXDB in the tnsnames.ora
file.
3) Create an initialization parameter file for the auxiliary instance.
4) Start the auxiliary instance in NOMOUNT mode using the initAUX.ora file.
5) Create a server parameter file (SPFILE).
6) Verify that your target database (orcl database) is mounted or open.
7) Start RMAN with a connection to the target database (orcl) and the auxiliary
instance.
8) Create the duplicate database by executing the DUPLICATE command.
9) Use SQL*Plus to log in to your AUX database and execute a query against the
HR.REGIONS table.
10) Now that you have completed the test recovery by creating a duplicate database, shut
down the aux instance.
11) Change your ORACLE_SID to orcl in preparation for later practices.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-19
Practice for Lesson 7

In this practice, you use tablespace point-in-time recovery to recover from unwanted
changes to your database.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-20
Practice 7-1: Use Tablespace Point-in-time Recovery
1) Execute the lab_07_01_01_01.sh script to export the HR schema.
2) Execute the lab_07_01_02_02.sql script to create a new tablespace and a new
user in your database.
3) Execute the lab_07_01_03_01.sh script to populate the new tablespace with a
copy of the data from the HR schema.
Note: The import should complete successfully. You will receive error messages
because the import excludes the COUNTRIES, REGIONS, and LOCATIONS tables.
These messages can be ignored.
4) Create a backup of your database using RMAN.
5) Record the current SCN: ____________
6) Record the current time.
7) Execute the lab_07_01_07_01.sql script to query the HRTEST.EMPLOYEES
table and view information about employees in department 60.
Make note of the highest salary that is displayed: ________
8) Execute the lab_07_01_08_01.sql script to update the salaries for the
employees in department 60 and note the highest salary displayed.
Highest salary: _____________
9) You now want to perform TSPITR for the HRTEST tablespace to return it to the state
prior to the updates. Execute the lab_07_01_09_01.sql script to determine
whether there are any dependencies that will prevent the TSPITR operation. n l y
perform tablespace point-in-time recovery. e O
10) You can use Enterprise Manager Database Control or RMAN command line to

11) Verify that the HRTEST tablespace is online.


U s
department 60 contain the correct values. A I
12) Verify that the SALARY columns in HRTEST.EMPLOYEES for the employees in

O
13) Execute the lab_07_01_13_02.sql script to add a constraint to the
HRTEST.DEPARTMENTS table.
l &
a
14) Assume you need to perform TSPITR on the HRTEST tablespace again. Execute the
n
te r
lab_07_01_14_02.sql query to determine whether there are any dependencies
outside the recovery set.

I n
15) If you wanted to complete the tablespace point-in-time recovery for the HRTEST
tablespace now, what would you need to do?

c l e
Note: You will not perform another tablespace point-in-recovery in this practice.

r a
You would need to disable the DEPT_LOC_ID_FK constraint that was added to your

O HRTEST.DEPARTMENTS table or you would need to add the tablespace that


contains the HR.LOCATIONS table to your recovery set.

Oracle Database 10g: Backup and Recovery A-21


Practice for Lesson 8

In this practice, you create a recovery catalog in your instructor’s database and register
your database in the recovery catalog.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-22
Practice 8-1: Create the Recovery Catalog and Register the
Database
The tablespace for the recovery catalog and the recovery catalog owner have been created
in the instructor database. The tablespaces are named RCTS01 – RCTS12. The users are
named RCUSER01 – RCUSER12.
1) Connect to the recovery catalog database (instructor’s database) with the appropriate
recovery catalog owner name (if you are using PC01, connect as RCUSER01) using
RMAN. Create the recovery catalog in your assigned tablespace. (If you are using
PC01, your assigned tablespace is RCTS01.) The service name is RCDB.
2) Using RMAN, connect to your target database and the recovery catalog database.
3) Using RMAN, execute the command to resynchronize the control file and recovery
catalog. What happens? Why?
4) Register the target database in the recovery catalog. You can use RMAN command-
line or Enterprise Manager for this step.
5) Create an RMAN script named whole_backup to make a whole database backup.
Do not execute the whole_backup script at this time.
6) Use the PRINT command to query the recovery catalog and verify the creation of
your whole_backup script.
7) In preparation for later practices, use RMAN to unregister your database from the
recovery catalog.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-23
Practice for Lesson 9

In this practice, you monitor the progress of your RMAN backup jobs.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-24
Practice 9-1: Use SQL to Monitor the Progress of RMAN
Backups
1) Invoke RMAN and delete all obsolete backups.
2) Open a second terminal window. Change to the labs directory. Invoke SQL*Plus
and connect as SYSDBA. You will use this second session to monitor a database
backup.
3) Return to your first terminal window. In your RMAN session, begin a whole database
backup.
4) Use your SQL*Plus session to monitor the progress of the whole database backup by
querying the V$SESSION_LONGOPS view. By using this view you can determine
whether the backup is progressing normally or hanging. If the backup is progressing
normally, the TIME_REMAINING column should be decreasing. Execute the
lab_09_01_04_01.sql script to query V$SESSION_LONGOPS.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-25
Practice 9-2: Use Enterprise Manager to Monitor RMAN Jobs
You can easily monitor RMAN jobs in Enterprise Manager.
1) Start Enterprise Manager and log in as SYS/ORACLE as SYSDBA.
2) Delete obsolete backups.
3) Start a whole database backup.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-26
Practice for Lesson 10

There are no practices for Lesson 10.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-27
Practice for Lesson 11

In this practice, you perform the following tasks:


• Create your Oracle Secure Backup home directory.
• Install the Oracle Secure Backup software.
• Configure virtual test devices.
• View information about the configured devices.
• Connect to the EM Database Console application using your browser.
• Register your administrative server with EM.
• Insert four volumes into the tape library.
• Test connectivity to the tape drive.
• Define a new Oracle Secure Backup user.
• Configure preauthorization for this user.

THE VIRTUAL TEST DEVICES USED IN THIS LAB ARE FOR TRAINING
PURPOSES ONLY. THEY ARE NOT SUPPORTED FOR PRODUCTION USE.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-28
Practice 11-1: Install Oracle Secure Backup
In this practice, you perform the following tasks:
• Create your Oracle Secure Backup home directory.
• Install the Oracle Secure Backup software.
Unless specified otherwise during this practice, you should log in as the oracle user to
your terminal emulator session.

Use the following information to install the software:


• The Oracle Secure Backup software is staged on your server in the
/stage/osb/osb_10_1cdrom directory.
• Your Oracle Secure Backup home directory is
/usr/local/oracle/backup.
• During installation, you configure only the local machine as an administrative
server with no attached devices.

1) Log in as the root user and create /usr/local/oracle/backup as your


Oracle Secure Backup home directory. Change to that directory.
2) Continue as the root user. Start the installation of Oracle Secure Backup from the
staging directory. Begin with the setup program.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-29
Practice 11-2: Configure Devices for Oracle Secure Backup
In this practice, you perform the following tasks:
• Configure a virtual test library and a virtual test drive.
• View information about the configured devices and the default media family via
the obtool interface.
1) In a terminal window, navigate to the /home/oracle/labs directory and execute
the ./lab_11_02_01.sh script, to configure the vlib tape library directly attached
to your administrative server.
2) In the /home/oracle/labs directory, execute the ./lab_11_02_02.sh script, to
configure the vt tape drive for the library:
3) Start the obtool as the admin user with the oracle password, and view the
currently configured devices.
(Hint: Use the lsdev command.)
4) View the RMAN-DEFAULT media family.
(Hint: Use the lsmf --long command, , and use the quit command to exit.)

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-30
Practice 11-3: Register the Administrative Server
In this practice, you perform the following tasks:
• Connect to the EM Database Console application using your browser.
• Register your administrative server with EM.
• Insert four volumes into the virtual test library.
• Test connectivity to the virtual test drive.
Unless specified otherwise, you should log in as the oracle user to your terminal
emulator session, and as SYSDBA to your Database Control console and SQL*Plus
sessions.
1) With your browser, connect to Enterprise Manager Database Control using the IP
address or machine name for your host.
2) In Enterprise Manager, register your administrative server.
3) Use Enterprise Manager to insert four volumes into the vlib test library. (An
unlabeled tape is synonymous with a blank tape within Oracle Secure Backup.)
4) Before taking any backups, you want to make sure you can access your tape drives.
On the Devices page, test the virtual tape drive access.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-31
Practice 11-4: Configure Oracle Secure Backup User
In this practice, you perform the following tasks:
• Define a new Oracle Secure Backup user.
• Configure preauthorization for this user.
Unless specified otherwise, you should log on as the oracle user to your terminal
emulator session and as SYSDBA to your EM Database Control Console session.
If you are already in Enterprise Manager, you can use shortcuts, such as clicking the
Administrative Server link in the upper-left part of the Devices page. Then if you right-
click the “File System Backup and Restore” link (at the bottom of the page) and select the
“Open Link in New Window” or “Open Link in New Tab” option, you can have two
windows open, one for Enterprise Manager and the other for the Oracle Secure Backup
Web tool.
1) Use the Oracle Secure Backup Web tool to create the oracle Oracle Secure Backup
user with the following values: User oracle, Password: oracle, User class:
oracle, UNIX name: oracle, UNIX group: dba and NDMP server user: no.
Note: If you have an NDMP server, set the value to “yes”; but inside the regular
classrooms, an NDMP server is not available, so set the value to “no.”
2) Configure the oracle Oracle Secure Backup user as a preauthorized RMAN and
command line user with following values: Hosts: all hosts, OS username: *,
Windows domain name: *, and Attributes: cmdline and rman.
Best Practice Tip: Limit pre-authorized access to selected hosts.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-32
Practice for Lesson 12

In this practice, you perform the following tasks:


• Create a database backup storage selector for your database.
• Perform a backup of your Oracle database with the Oracle-Suggested Backup
strategy.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-33
Practice 12-1: Create a Database Backup Storage Selector
In this practice, you perform the following tasks:
• In SQL*Plus, verify that the database is in ARCHIVELOG mode.
• In Enterprise Manager, create a database backup storage selector for your Oracle
database.
• In Enterprise Manager, perform a test backup to verify that the Oracle Secure
Backup configuration is correct.
Unless specified otherwise, you should log on as the oracle user to your terminal
emulator session, and as SYSDBA to your Database Control Console and SQL*Plus
sessions.
1) First, verify that the database is in ARCHIVELOG mode. If your database is in
ARCHIVELOG mode, continue with the next step. If not, shut down the database,
enable archiving, and then restart the database.
2) In Enterprise Manager, create a backup selector for your database with the following
specifications:
• Tape Drives: 1
• Host Credentials Username: oracle, Password: oracle, and “Save as
Preferred Credential”
• Database Backup Types: Archive log, Auto Backup, Full, and Incremental
3) Test your tape backup.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-34
Practice 12-2: Perform Oracle-Suggested Backup
In Enterprise Manager, perform Oracle-Suggested Backup.
Unless specified otherwise, you should log on as the oracle user to your terminal emulator
session, and as SYSDBA to your Database Control Console and SQL*Plus sessions.
1) In Enterprise Manager, schedule Oracle-Suggested Backup with the following
specifications:
• Backup destination: both disk and tape
• Daily backup of archivelogs and incremental backup
• Tape Drives: 1
• Schedule daily backup within 5 minutes of your current date and time
2) Review your backup job. If this is your first scheduled backup, you should see a full
backup (otherwise an incremental one) first to the Flash Recovery Area, then to tape.
Review the RMAN command, as well as the job execution.
3) Optionally, to reinforce this practice topic, you can view the
Oracle_Suggested_Strategy_viewlet_swf.html viewlet in the
/home/oracle/solutions/viewlets directory.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-35
Practice for Lesson 13

In this practice, you perform the following tasks:


• Create a dataset for a file-system backup.
• Schedule a backup of the dataset.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-36
Practice 13-1: Back Up Your File System with Oracle Secure
Backup
Use the Oracle Secure Backup Web tool, which can be accessed from Enterprise
Manager for the tasks in this practice session.
Unless specified otherwise, access Enterprise Manager as SYDBA and the Oracle Secure
Backup Web tool as admin user. Both use oracle as password.
1) Create a new dataset called mylabs that you will use to back up your $HOME/labs
directory. The dataset should be of the form:
include host <hostname> {
include path /home/oracle/labs
}
Make sure that you replace <hostname> with the machine name of your student
computer.
Note: Do not back up the local root directory.
2) Create a backup with your mylabs dataset. The backup should run immediately.
3) View Oracle Secure Backup job information. Query the Manage: Jobs page for the
previously created and executed job.
4) Optionally, to reinforce this practice topic, you can view the
Scheduling_filesystem_backups_viewlet_swf.html viewlet in the
/home/oracle/solutions/viewlets directory.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-37
Practice for Lesson 14

In this practice, you perform the following tasks:


• Delete the contents of your labs directory.
• Restore the missing lab files.
• Verify that the files are recovered.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-38
Practice 14-1: Restore File-System Data with Oracle Secure
Backup
In this practice, you first delete your lab files and then restore them from the backup
created in the previous practice.
Unless specified otherwise, you should log on as the oracle user to your terminal
emulator session, and as SYSDBA to your Database Control Console session.
For tasks 2 to 5, log in as admin user (with the oracle password) into the Oracle
Secure Backup Web tool, which can be accessed from Enterprise Manager.
1) From your terminal emulator session, remove all the files located in your
$HOME/labs directory.
2) Restore your $HOME/labs directory contents by selecting the appropriate backup
from the Oracle Secure Backup catalog. Use the Browse Host button to locate the
desired backup.
3) Monitor the progress of the restore request.
4) In a terminal window, verify that your lab files are present.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-39
Practice for Lesson 15

In this practice, you perform the following tasks:


• Create an encrypted backup.
• Recover a tablespace from an encrypted backup.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-40
Practice 15-1: Create an Encrypted Backup
In this practice, you perform the following tasks:
• Schedule a customized tape backup of the whole database.
• Edit the RMAN script to encrypt the backup using a password.
• After the backup operation completes, verify that the backup was encrypted.
Unless specified otherwise, you should log in as SYS user (with the oracle password)
and connect as SYSDBA to Enterprise Manager Database Control.
1) In Enterprise Manager, schedule a customized tape backup of the whole database
with the following specifications: full online backup with archive logs to tape. Start
the backup immediately.
2) Edit the RMAN script and include the command to encrypt the backup, specifying
demo as the password. The command syntax is:

SET ENCRYPTION ON IDENTIFIED BY demo ONLY;


Note: Specifying “ONLY” in the command means decryption will require the demo
password, and no other encryption keys will exist for this backup.
3) Check the backup job status. Verify that the RMAN SET ENCRYPTION command is
successfully executed.
4) Verify the successful completion of your backup.
5) Optionally, to reinforce this practice topic, you can view the
Backup_Encryption_viewlet_swf.html viewlet the
/home/oracle/solutions/viewlets directory. n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-41
Practice 15-2: Recover a Tablespace from an Encrypted Backup
In this practice, you perform the following tasks:
• Perform a tablespace recovery using the encrypted backup.
• Troubleshoot the recovery process.
• Edit the RMAN script to decrypt the backup.
Unless specified otherwise, you should log in as SYS user (with the oracle password)
and connect as SYSDBA to Enterprise Manager Database Control.
1) In Enterprise Manager, perform an object level recovery of the EXAMPLE tablespace
to the current time or a previous point in time. Restore the files to the default location.
2) The recovery operation fails. Why?
3) Troubleshoot the recovery process. What do you notice on the Perform Recovery
page?
4) Perform an object level recovery of the EXAMPLE tablespace to the current time or a
previous point in time. Restore the files to the default location.
5) Edit the RMAN script on the “Perform Object Level Recovery: Review” page.
Include the command to decrypt the backup, specifying demo as the password. The
command syntax is:

SET ENCRYPTION ON IDENTIFIED BY demo ONLY;


6) View the Perform Recovery: Result page. Notice the successful execution of your
SET DECRYPTION command.
n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-42
Practice for Lesson 16

In this practice, you perform the following tasks:


• View Oracle Secure Backup information.
• Back up the Oracle Secure Backup catalog.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-43
Practice 16-1: View Oracle Secure Backup Information
In this practice, you view Oracle Secure Backup information: the catalog, volumes and
their content, jobs and job transcripts, and defaults and policies.
Unless specified otherwise, you should log in as the SYS user (with the oracle
password) and connect as SYSDBA to Enterprise Manager Database Control. To access
the Oracle Secure Backup Web tool, use admin as username and oracle as password.
1) The administrative server maintains a catalog in which it stores metadata relating to
backup and restore operations for the administrative domain. Use the Oracle Secure
Backup Web tool to browse the Oracle Secure Backup catalog to view what you have
backed up so far.
2) View the volumes and their content.
3) View a category of jobs—for example, completed ones. Include a review of a job
transcript.
4) View the configuration of your security policies. What is the value of the “Login
token duration” policy?

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-44
Practice 16-2: Back Up the Oracle Secure Backup Catalog
In this practice, you perform the following tasks using obtool:
• Create a dataset for the <OSB_HOME>/admin directory.
• Create a backup request.
• Submit the backup request to the scheduler.
• Verify that the backup completed successfully.
• Identify the volume that contains the backup data.
Previously, you used the Oracle Secure Backup Web tool for a file-system backup. Now
use the obtool utility with admin as username and oracle as password.
1) Create a media family to be used when backing up the Oracle Secure Backup catalog
files. Use the following command:
mkmf --vidunique --writewindow 7days --retain 28days
--noappend OSB_catalogs
2) Create a backup set for the catalog data, using the commands listed here:
mkds --dir catalog_backup
mkds --input catback.ds

When prompted for input, supply the following dataset directives, where
<hostname> is the host name of your assigned computer:
include host <hostname> {
include path /etc/obconfig
include
include
path
path
/usr/etc/ob/xcr
/usr/local/oracle/backup/admin }
3) Create a backup request for this dataset, and then submit the backup request. n l y
To create the backup request using the following obtool command:
e O
backup –l full –p 1 –r vt –g --dataset catback.ds
What does this command do? U s
A I
4) Use the information from the message returned in the previous step to verify that the

O
backup completed successfully. (State should show “completed successfully”).

&
5) Identify the volume that contains the backup.

l
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery A-45
n l y
e O
U s
A I
O
l &
na
te r
I n
c le
ra
O
Appendix B
Practice Solutions

n l y
e O
U s
A I
O
l &
na
te r
I n
c le
ra
O
Table of Contents
Solutions for Practice 2-1: Configure Your Database .................................................... 5
Solutions for Practice 3-1: Use RMAN to Create and Manage Backups ..................... 10
Solutions for Practice 4-1: Use RMAN to Recover a Datafile ..................................... 17
Solutions for Practice 4-2: Use the Flash Recovery Area to Quickly Recover a Datafile
....................................................................................................................................... 21
Solutions for Practice 4-3: Recover Control Files ........................................................ 26
Solutions for Practice 4-4: Delete Obsolete Backups ................................................... 33
Solutions for Practice 5-1: Enable Flashback Database ............................................... 36
Solutions for Practice 5-2: Set Restore Points and Perform Flashback Table.............. 38
Solutions for Practice 5-3: Use Flashback Query and Flashback Versions Query....... 46
Solutions for Practice 5-4: Use Flashback Database .................................................... 52
Solutions for Practice 6-1: Create a Duplicate Database .............................................. 60
Solutions for Practice 7-1: Use Tablespace Point-in-time Recovery............................ 74
Solutions for Practice 8-1: Create the Recovery Catalog and Register the Database... 89
Solutions for Practice 9-1: Use SQL to Monitor the Progress of RMAN Backups...... 96
Solutions for Practice 9-2: Use Enterprise Manager to Monitor RMAN Jobs ............. 99
Solutions for Practice 11-1: Install Oracle Secure Backup......................................... 106
Solutions for Practice 11-2: Configure Devices for Oracle Secure Backup............... 110
Solutions for Practice 11-3: Register the Administrative Server................................ 112
Solutions for Practice 11-4: Configure Oracle Secure Backup User.......................... 118
Solutions for Practice 12-1: Create a Database Backup Storage Selector .................. 123
Solutions for Practice 12-2: Perform Oracle-Suggested Backup................................ 129
Solutions for Practice 13-1: Back Up Your File System with Oracle Secure Backup 138 n l y
Solutions for Practice 14-1: Restore File-System Data with Oracle Secure Backup . 145
Solutions for Practice 15-1: Create an Encrypted Backup.......................................... 151
e O
Solutions for Practice 15-2: Recover a Tablespace from an Encrypted Backup ........ 158
Solutions for Practice 16-1: View Oracle Secure Backup Information...................... 168
U s
I
Solutions for Practice 16-2: Back Up the Oracle Secure Backup Catalog ................. 174
A
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-2
Practice Solutions for Lesson 1

There are no practices for Lesson 1.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-3
Practice Solutions for Lesson 2

In this practice, you configure your database for recoverability.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-4
Solutions for Practice 2-1: Configure Your Database
1) Use Enterprise Manager to configure your database in ARCHIVELOG mode.
Answer:
1. Start the Web browser and enter http://your host name:1158/em.
2. Enter SYS in the User Name field and oracle in the Password field. Select
SYSDBA in the Connect As menu. Click Login.
3. Click “I agree” on the Oracle Database 10g Licensing Information page.
4. Select the Maintenance page.
5. Select Recovery Settings in the Backup/Recovery Settings section.
6. In the Media Recovery section, select “ARCHIVELOG Mode” and click Apply.

7. The Confirmation page is displayed. Click Yes to restart the database instance.
8. On the Restart Database: Specify Host and Target Database Credentials page. In

n l y
the Host Credentials section, enter oracle in the Username and Password fields.
In the Database Credentials section, enter SYS in the Username field and
O
oracle in the Password field. Select “Save as Preferred Credential.” Click OK.
e
restart of the database instance.
U s
9. The Restart Database: Confirmation page is displayed. Click Yes to confirm the

and then click Refresh. A I


10. The Restart Database: Activity Information page is displayed. Wait a few minutes

O
2) Use Enterprise Manager to verify that the Flash Recovery Area has been configured
&
for your database and increase the Flash Recovery Area size to 3 GB.
l
Answer:

n a
te r
1. Select the Maintenance page.
2. Select Recovery Settings in the Backup/Recovery Settings section.

I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-5
Solutions for Practice 2-1: Configure Your Database (continued)
3. Scroll to the Flash Recovery Area and verify that the Flash Recovery Area is
enabled.

4. Enter 3 in the Flash Recovery Area Size field and click Apply.
5. The Update Message is displayed. Click the Database instance link to return to the
Maintenance page.
3) Set Preferred Credentials in Enterprise Manager.
Answer:
1. Select Preferences at the top of the Maintenance page.
2. Select Preferred Credentials on the left side of the page.
3. Click the Set Credentials icon for the database instance.
n l y
4. Supply the following values:
Normal Username: system
e O
Normal Password: oracle
SYSDBA Username: sys
U s
SYSDBA Password: oracle
Host Username: oracle
A I
Host Password: oracle
O
l &
5. Click Test. The “Credentials successfully verified for orcl.oracle.com” message is
displayed. If you have any errors, correct them and click Test again.

n a
6. Click Apply to save the settings.

te r
7. Click Database to return to the Database home page.

I n
4) Use Recovery Manager (RMAN) to connect to your target database. Make note of the
database identifier (DBID) of your database.

c l e
Database Identifier: ____________________________

r a
Answer:

O 1. Open a terminal window and log in as oracle/oracle.

Oracle Database 10g: Backup and Recovery B-6


Solutions for Practice 2-1: Configure Your Database (continued)
2. Start RMAN and connect to the target database by entering the following
command at the operating system prompt: rman target /
[oracle@edrsr10p1 oracle]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue


Mar 7 12:51:53 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1090770270)

RMAN>

Make note of the database identifier (DBID) of your database.


5) Use the RMAN SHOW ALL command to view the configuration settings in your
database and then exit from your RMAN session.
Answer:
RMAN> show all;

using target database control file instead of recovery


catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
n l y
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE
e O
DISK TO '%F'; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE
SBT_TAPE TO '%F'; # deft
U s
BACKUPSET; # default
A I
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO

O
CONFIGURE DEVICE TYPE SBT_TAPE PARALLELISM 1 BACKUP TYPE
TO BACKUPSET; # default

1; # default
l &
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO

a
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE
n
TO 1; # default

te r
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO
1; # default

I n
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE
SBT_TAPE TO 1; # default

c l e
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' FORMAT
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
'%U';

r a CONFIGURE ENCRYPTION FOR DATABASE OFF; # default


CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

O CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default


CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/u01/app/oracle/product/10.2.0/db_1/dbst

Oracle Database 10g: Backup and Recovery B-7


Solutions for Practice 2-1: Configure Your Database (continued)
RMAN> exit
Recovery Manager complete.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-8
Practice Solutions for Lesson 3

In this practice, you configure automatic backup of the control file. You also configure a
backup of your database using the Oracle-Suggested Backup Strategy feature in
Enterprise Manager Database Control.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-9
Solutions for Practice 3-1: Use RMAN to Create and Manage
Backups
1) Use Enterprise Manager Database Control to configure autobackup of the control file
and the server parameter file.
Answer:
1. Select Maintenance > High Availability > Backup/Recovery Settings > Backup
Settings.
2. On the Backup Settings page, select the Policy tab.
3. In the Backup Policy section, select “Automatically backup the control file and
server parameter file (SPFILE) with every backup and database structural
change.” Click OK.

n l y
4. You are returned to the Maintenance page.

e O
2) Use Enterprise Manager Database Control to configure backup optimization and
enable block change tracking. Specify

U s
/u01/app/oracle/oradata/orcl/chg_track.f for the name of the block
change tracking file.
Answer: A I
O
1. Select Maintenance > High Availability > Backup/Recovery Settings > Backup
Settings.
l &
a
2. On the Backup Settings page, select the Policy tab.
n
te r
3. In the Backup Policy section, select “Optimize the whole database backup by
skipping unchanged files such as read-only and offline datafiles that have been
backed up.”
I n
4. Select “Enable block change tracking for faster incremental backups” and enter
l e
/u01/app/oracle/oradata/orcl/chg_track.f in the Block Change
c
Tracking File field. Click OK.
r a
O
Oracle Database 10g: Backup and Recovery B-10
Solutions for Practice 3-1: Use RMAN to Create and Manage Backups
(continued)

5. You are returned to the Maintenance page.


3) Use Enterprise Manager Database Control to create a whole database backup using
the Oracle-suggested backup strategy.
Answer:
1. Select Maintenance > High Availability > Backup/Recovery > Schedule Backup.
2. In the Oracle-Suggested Backup section of the Schedule Backup page, click
Schedule Oracle-Suggested Backup.
n l y
e O
U s
A I
O
l &
n a
te r
I n
3. On the Schedule Oracle-Suggested Backup: Destination page, select Disk. Click
Next.

c l e
4. Review the information on the Schedule Oracle-Suggested Backup: Setup page.

r a
Note that a full database copy will be performed during the first backup. After
that, an incremental backup to disk will be performed every day. Click Next.
O 5. On the Schedule Oracle-Suggested Backup: Schedule page, you can specify the
time for your backups. Set the Time Zone field to correspond to your time zone.

Oracle Database 10g: Backup and Recovery B-11


Solutions for Practice 3-1: Use RMAN to Create and Manage Backups
(continued)
Select a backup time that is five minutes from the current time. Click Next.

6. Review the information on the Schedule Oracle-Suggested Backup: Review page.


Click Submit Job.
7. The Status page is displayed indicating that the job has been submitted. Click
View Job to monitor the status of the backup job.
8. Click the Refresh button on your browser to refresh the Execution page. Click the
Backup link to view the output log.

n l y
e O
U s
A I
O
9. In the output log, you can see that RMAN has made a datafile copy backup of
each datafile in your database.

l &
n a
te r
I n
c l e
r a
10. Click the Database tab to return to the Database Home page.

O
4) Use Enterprise Manager to view information about your backups.
Answer:
1. Select Maintenance > High Availability > Backup/Recovery > Backup Reports.

Oracle Database 10g: Backup and Recovery B-12


Solutions for Practice 3-1: Use RMAN to Create and Manage Backups
(continued)
2. Click the link for the backup you took in Question 3 to view detailed information
about the backup.

3. Click the Database Instance link to return to the Maintenance page.


5) Use RMAN to create a duplexed backup set of the EXAMPLE tablespace.
Answer:
1. Start RMAN and connect to the target database.
n l y
[oracle@edrsr10p1 backup1]$ rman target /

e O
Recovery Manager: Release 10.2.0.1.0 - Production on Wed
Mar 22 10:38:18 2006
U s
Copyright (c) 1982, 2005, Oracle.
A I
All rights reserved.

O
connected to target database: ORCL (DBID=1090770270)

l &
2. Create two backup set copies. One copy should be in the
/home/oracle/backup1 directory and one copy should be in the
a
/home/oracle/backup2 directory.
n
te r
RMAN> @sol_03_01_05_02.rmn
RMAN> backup device type disk

I
2> copies 2
n
3> tablespace example

l e
4> format '/home/oracle/backup1/%U',

c
'/home/oracle/backup2/%U';

r aStarting backup at 22-MAR-06


using channel ORA_DISK_1

O channel ORA_DISK_1: starting full datafile backupset


channel ORA_DISK_1: specifying datafile(s) in backupset

Oracle Database 10g: Backup and Recovery B-13


Solutions for Practice 3-1: Use RMAN to Create and Manage Backups
(continued)
input datafile fno=00005
name=/u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: starting piece 1 at 22-MAR-06
channel ORA_DISK_1: finished piece 1 at 22-MAR-06 with 2
copies and tag TAG20063
piece handle=/home/oracle/backup1/0ehejks7_1_1
comment=NONE
piece handle=/home/oracle/backup2/0ehejks7_1_2
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:15
Finished backup at 22-MAR-06

Starting Control File and SPFILE Autobackup at 22-MAR-06


piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup
/2006_03_22/o1_E
Finished Control File and SPFILE Autobackup at 22-MAR-06
RMAN> **end-of-file**
RMAN>

3. Use the RMAN LIST BACKUP SUMMARY command to view a listing of the
backup sets and pieces. The #Copies column shows the duplexed backup set
copies you made. Exit from RMAN.
RMAN> @sol_03_01_05_03.rmn
RMAN> list backup summary; n l y
using target database control file instead of recovery
e O
catalog

U s
List of Backups
===============
Key TY LV S Device Type
A I
Completion Time #Pieces
#Copies Compressed Tag
O
&
------- -- -- - ----------- --------------- ------- ------
- ---------- ---
5 B F A DISK
a l 21-MAR-06 1 1
NO
7
TAG200600
B F A DISK
r n 22-MAR-06 1 1
NO
8
NO
I n te
TAG200607
B F A DISK
TAG200603
22-MAR-06 1 2

c
NO
l e B F A DISK
TAG200608
22-MAR-06 1 1

a
RMAN> **end-of-file**

O r RMAN> exit

Recovery Manager complete.

Oracle Database 10g: Backup and Recovery B-14


Solutions for Practice 3-1: Use RMAN to Create and Manage Backups
(continued)
6) Use Enterprise Manager Database Control to perform a cross-check of your backups.
Answer:
1. Select Maintenance > High Availability > Backup/Recovery > Manage Current
Backups.
2. Click Crosscheck All.

3. Review the information on the Crosscheck All: Specify Job Parameters page and
accept the default values. Click Submit Job.
4. You receive the “Job submission succeeded” message. You can click View Job to
monitor the cross-check job. After it completes successfully, return to the
Database Home page.
5. Log out of Enterprise Manager.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-15
Practice Solutions for Lesson 4

In this practice, you use RMAN to perform recovery.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-16
Solutions for Practice 4-1: Use RMAN to Recover a Datafile
In this practice, you use RMAN to recover a lost datafile. Notice how you are prompted
by Enterprise Manager to recover the lost datafile.
1) Use SQL*Plus to query the HR.REGIONS table. Make note of the number of rows in
the HR.REGIONS table.
Answer:
1. Open a terminal window and log in to SQL*Plus and connect as the HR user with
HR as the password.
2. Query the HR.REGIONS table and record the number of rows.

Number of rows: ___________

[oracle@edrsr10p1 oracle]$ sqlplus hr/hr

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 23


12:51:00 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
- Production
With the Partitioning, OLAP and Data Mining options
n l y
SQL> select * from regions;
e O
REGION_ID REGION_NAME
U s
I
---------- -------------------------
1 Europe
2
3
4
Americas
Asia
Middle East and Africa O A
3. Exit from your SQL*Plus session.
l &
n a
2) At the operating system prompt, execute the lab_04_01_02_01.sh script to

datafile.
te r
simulate a failure in your database. This script deletes the EXAMPLE tablespace

Answer:
I n
l e
1. At the operating system prompt, change to the labs directory and execute the
c
lab_04_01_02_01.sh script.

r a[oracle@edrsr10p1 labs]$ ./lab_04_01_02_01.sh

O EXAMPLE tablespace file deleted

Oracle Database 10g: Backup and Recovery B-17


Solutions for Practice 4-1: Use RMAN to Recover a Datafile (continued)
3) Use SQL*Plus to query the HR.JOBS table.
Answer:
1. Log in to SQL*Plus and connect as the HR user with HR as the password.
2. Query the HR.JOBS table.
SQL> select * from jobs;
select * from jobs
*
ERROR at line 1:
ORA-00376: file 5 cannot be read at this time
ORA-01110: data file 5:
'/u01/app/oracle/oradata/orcl/example01.dbf'

4) Use Enterprise Manager to perform database recovery of the EXAMPLE tablespace


datafile.
Answer:
1. Start Enterprise Manager and log in as SYS/ORACLE as SYSDBA.
2. Navigate to the Maintenance page.
3. Select Perform Recovery on the Maintenance page.
4. Click the “Datafiles Need Media Recovery” link.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-18
Solutions for Practice 4-1: Use RMAN to Recover a Datafile (continued)
5. Select the file and click Next.

6. Select “No. Restore the files to the default location.” Click Next.

n l y
e O
U s
A I
7. On the “Perform Object Level Recovery: Review” page, click Edit RMAN Script
to view the script that will be executed. Click Submit.
O
8. The Processing page is displayed. After the recovery operation completes, the

l &
Result page is displayed indicating that the recovery operation succeeded.

n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-19
Solutions for Practice 4-1: Use RMAN to Recover a Datafile (continued)

9. Click OK to return to the Maintenance page.

5) Return to your SQL*Plus session and again attempt to query the HR.JOBS table.
Answer:
1. Query the HR.JOBS table.
SQL> select * from jobs;

n l y
JOB_ID
MAX_SALARY
----------
JOB_TITLE

e
----------------------------------- ----------
OMIN_SALARY

----------
AD_PRES President
U s 20000
40000
AD_VP Administration Vice President
A I 15000

O
30000
AD_ASST Administration Assistant 3000

l&
6000
FI_MGR Finance Manager 8200
16000

n a
MK_REP
9000
t e r
Marketing Representative 4000

In
HR_REP Human Resources Representative 4000
9000

c l
PR_REP
10500 e Public Relations Representative 4500

r a 19 rows selected.

O
Oracle Database 10g: Backup and Recovery B-20
Solutions for Practice 4-2: Use the Flash Recovery Area to
Quickly Recover a Datafile
In this practice, you recover a lost datafile by using the Flash Recovery Area for fast
recovery.
1) Use SQL*Plus to query the HR.REGIONS table. Make note of the number of rows in
the HR.REGIONS table.
Answer:
1. Log in to SQL*Plus and connect as the HR user with HR as the password.
2. Query the HR.REGIONS table.
3. Exit from SQL*Plus.
2) At the operating system prompt, execute the lab_04_02_02_01.sh script to
simulate a failure in your database. This script deletes the EXAMPLE tablespace
datafile.
Answer:
1. At the operating system prompt, change to the labs directory and execute the
lab_04_02_02_01.sh script.
[oracle@edrsr10p1 labs]$ ./lab_04_02_02_01.sh

EXAMPLE tablespace file deleted

[oracle@edrsr10p1 labs]$
n l y
e O
3) Use SQL*Plus to query the HR.DEPARTMENTS table.
Answer:
U s
I
1. Log in to SQL*Plus and connect as the HR user with HR as the password.
A
2. Query the HR.DEPARTMENTS table.
O
SQL> select * from departments;
select * from departments
l &
*

n a
ERROR at line 1:

te r
ORA-01116: error in opening database file 5
ORA-01110: data file 5:

I n
'/u01/app/oracle/oradata/orcl/example01.dbf'
ORA-27041: unable to open file

l e
Linux Error: 2: No such file or directory

c
Additional information: 3

r a
3. Make note of the number of the datafile that is unavailable. Datafile number: ____

O 4. Exit from your SQL*Plus session.


4) Use the RMAN SWITCH TO COPY command to recover the datafile.

Oracle Database 10g: Backup and Recovery B-21


Solutions for Practice 4-2: Use the Flash Recovery Area to Quickly Recover
a Datafile (continued)
Answer:
1. Log in to your target database using RMAN.
2. Take the datafile offline.
RMAN> SQL 'alter database datafile 5 offline';

sql statement: alter database datafile 5 offline

3. Execute the SWITCH TO COPY command for the datafile you noted in step 3.
RMAN> switch datafile 5 to copy;

datafile 5 switched to datafile copy


"/u01/app/oracle/flash_recovery_area/ORCL/"

4. Recover the datafile.


RMAN> recover datafile 5;

Starting recover at 24-MAR-06


allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=132 devtype=DISK
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=130 devtype=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Secure Backup

starting media recovery


n l y
media recovery complete, elapsed time: 00:00:03

e O
Finished recover at 24-MAR-06
5. Bring the datafile online.
U s
A
RMAN> sql 'alter database datafile 5 online';I
O
sql statement: alter database datafile 5 online

RMAN>
l &
6. Exit from your RMAN session.
n a
5) Query the HR.JOBS table.
te r
Answer:
I n
1. Log in to SQL*Plus as HR/HR and query the HR.JOBS table. (Output has been
l e
formatted to fit the code box.)
c
r a SQL> select * from jobs;

O JOB_ID JOB_TITLE MIN_S MAX_SALARY


---------- ------------------------------ ----- ----------
AD_PRES President 20000 40000

Oracle Database 10g: Backup and Recovery B-22


Solutions for Practice 4-2: Use the Flash Recovery Area to Quickly Recover
a Datafile (continued)
AD_VP Administration Vice President 15000 30000

HR_REP Human Resources Representative 4000 9000
PR_REP Public Relations Representative 4500 10500

19 rows selected.

6) Using Enterprise Manager Database Control, verify that the datafile being used for
the EXAMPLE tablespace is in the Flash Recovery Area.
Answer:
1. Select Tablespaces on the Administration page.
2. Select the Example tablespace and click View.

n l y
3. Click Return to return to the Tablespaces page.
e O
Answer:
U s
7) Make a copy of the datafile in the original location and switch back to it.

1. Log in to RMAN and connect to your target database.


A I
O
2. Create an image copy of the datafile in the original location.
RMAN> @sol_04_02_07_02.rmn
RMAN> backup as copy datafile 5
l &
a
2> format '/u01/app/oracle/oradata/orcl/example01.dbf';

n
te r
Starting backup at 24-MAR-06
using target database control file instead of recovery
catalog
I n
allocated channel: ORA_DISK_1

l e
channel ORA_DISK_1: sid=129 devtype=DISK

c
channel ORA_DISK_1: starting datafile copy

r a input datafile fno=00005


name=/u01/app/oracle/flash_recovery_area/ORCL/datafilef

O output filename=/u01/app/oracle/oradata/orcl/example01.dbf
tag=TAG20060324T13447
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:07

Oracle Database 10g: Backup and Recovery B-23


Solutions for Practice 4-2: Use the Flash Recovery Area to Quickly Recover
a Datafile (continued)
Finished backup at 24-MAR-06

Starting Control File and SPFILE Autobackup at 24-MAR-06


piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup
/2006_03_24/o1_E
Finished Control File and SPFILE Autobackup at 24-MAR-06
RMAN> **end-of-file**
3. Take the datafile offline.
RMAN> sql 'alter database datafile 5 offline';

sql statement: alter database datafile 5 offline

4. Switch to the new copy you made.


RMAN> switch datafile 5 to copy;

datafile 5 switched to datafile copy


"/u01/app/oracle/oradata/orcl/example01.dbf"
5. Recover the datafile.
RMAN> recover datafile 5;

Starting recover at 24-MAR-06


using channel ORA_DISK_1
n l y
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=154 devtype=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Secure Backup
e O
starting media recovery
U s
media recovery complete, elapsed time: 00:00:02

A I
Finished recover at 24-MAR-06
O
6. Bring the datafile back online. Exit from RMAN.

l &
a
RMAN> sql 'alter database datafile 5 online';

r n
sql statement: alter database datafile 5 online

I n te
8) Use Enterprise Manager Database Control to verify the file.
Answer:
c l e
r a
1. Select Tablespace on the Administration page.

O
Oracle Database 10g: Backup and Recovery B-24
Solutions for Practice 4-2: Use the Flash Recovery Area to Quickly Recover
a Datafile (continued)
2. Select the EXAMPLE tablespace and click View.

3. Note that the datafile is the one you switched to.


4. Click the Database tab to return to your database home page.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-25
Solutions for Practice 4-3: Recover Control Files
In this practice, you recover your control file by using an autobackup.
1) Use SQL*Plus to view files information for the control files in your database. Query
V$CONTROLFILE.
Answer:
1. Log in to SQL*Plus as SYSDBA.
2. Query the NAME column in V$CONTROLFILE. Exit from SQL*Plus.
SQL> SELECT name FROM v$controlfile;

NAME
---------------------------------------------
/u01/app/oracle/oradata/orcl/control01.ctl
/u01/app/oracle/oradata/orcl/control02.ctl
/u01/app/oracle/oradata/orcl/control03.ctl

2) Simulate a failure in your environment by executing the lab_04_03_02_01.sh


script to delete all your control files.
Answer:
1. In your terminal window session, change to the labs directory and execute the
lab_04_03_02_01.sh script.
[oracle@edrsr10p1 oracle]$ cd labs
[oracle@edrsr10p1 labs]$ ./lab_04_03_02_01.sh
n l y
Control files deleted

e O
[oracle@edrsr10p1 labs]$

U s
A I
3) You need some more information about your control files. Query
V$CONTROLFILE_RECORD_SECTION to learn more about the contents of your
control file. O
Answer:
l &
1. Log in to SQL*Plus as SYSDBA.
n a
r
2. Query the V$CONTROLFILE_RECORD_SECTION view.
te
I n
SQL> SELECT * FROM v$controlfile_record_section;
SELECT * FROM v$controlfile_record_section

c l e *
ERROR at line 1:

r a ORA-00210: cannot open the specified control file


ORA-00202: control file:

O '/u01/app/oracle/oradata/orcl/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory

Oracle Database 10g: Backup and Recovery B-26


Solutions for Practice 4-3: Recover Control Files (continued)
Additional information: 3

4) You have lost all your control files and will need to recover them from the control file
autobackup. Use Recovery Manager to recover the control files.
Answer:
1. Use SQL*Plus to shut down your instance. Exit from your SQL*Plus session.
[oracle@edrsr10p1 oracle]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 28


10:20:26 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
- Production
With the Partitioning, OLAP and Data Mining options
SQL> shutdown abort
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition
Release 10.2.0.1.0 - Pn
n l y
With the Partitioning, OLAP and Data Mining options
[oracle@edrsr10p1 oracle]$

e O
2. Use RMAN to connect to your target database.

U s
I
[oracle@edrsr10p1 oracle]$ rman

Mar 28 10:23:17 2006


O A
Recovery Manager: Release 10.2.0.1.0 - Production on Tue

l&
Copyright (c) 1982, 2005, Oracle. All rights reserved.

RMAN> connect target /


n a
t e r
connected to target database (not started)

RMAN>
e In
c l
3. Restart the instance in NOMOUNT mode.

r a RMAN> startup nomount

O Oracle instance started

Total System Global Area 285212672 bytes

Oracle Database 10g: Backup and Recovery B-27


Solutions for Practice 4-3: Recover Control Files (continued)

Fixed Size 1218992 bytes


Variable Size 109053520 bytes
Database Buffers 171966464 bytes
Redo Buffers 2973696 bytes

4. Set the database identifier.


Note: Your database identifier will be a different value from that shown in the
solution. You recorded the database identifier in Practice 2-1.
RMAN> set dbid 1090770270;

executing command: SET DBID


5. Restore the control file from the autobackup.
RMAN> restore controlfile from autobackup;

Starting restore at 28-MAR-06


using target database control file instead of recovery
catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

recovery area destination:


/u01/app/oracle/flash_recovery_area
database name (or database unique name) used for search:
ORCL
channel ORA_DISK_1: autobackup found in the recovery area n l y
channel ORA_DISK_1: autobackup found:
/u01/app/oracle/flash_recovery_area/ORCL/p
e O
channel ORA_DISK_1: control file restore from autobackup
complete
U s
A I
output filename=/u01/app/oracle/oradata/orcl/control01.ctl
output filename=/u01/app/oracle/oradata/orcl/control02.ctl
output filename=/u01/app/oracle/oradata/orcl/control03.ctl
Finished restore at 28-MAR-06
O
6. Mount the database.
l &
RMAN> alter database mount;

n a
database mounted

te r
released channel: ORA_DISK_1

I n
7. Recover the database by issuing the RECOVER DATABASE command.

c l e
RMAN> recover database;

r a Starting recover at 28-MAR-06

O Starting implicit crosscheck backup at 28-MAR-06


allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 11 objects

Oracle Database 10g: Backup and Recovery B-28


Solutions for Practice 4-3: Recover Control Files (continued)
Finished implicit crosscheck backup at 28-MAR-06

Starting implicit crosscheck copy at 28-MAR-06


using channel ORA_DISK_1
Crosschecked 5 objects
Finished implicit crosscheck copy at 28-MAR-06

searching for all files in the recovery area


cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name:
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2006_0
3_28/o1_mfc
File Name:
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2006_0
3_28/o1_mfc
File Name:
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2006_0
3_28/o1_mfc
File Name:
/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2006_0
3_27/o1_mfp

using channel ORA_DISK_1


allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=155 devtype=SBT_TAPE n l y
channel ORA_SBT_TAPE_1: Oracle Secure Backup

e O
starting media recovery

U s
archive log thread 1 sequence 116 is already on disk as
file /u01/app/oracle/flc

A I
archive log thread 1 sequence 117 is already on disk as
file /u01/app/oracle/flc
O
archive log thread 1 sequence 118 is already on disk as
file /u01/app/oracle/flc

l &
archive log thread 1 sequence 119 is already on disk as
file /u01/app/oracle/org
archive log
n a
og/2006_06
te r
filename=/u01/app/oracle/flash_recovery_area/ORCL/archivel

I n
archive log
filename=/u01/app/oracle/flash_recovery_area/ORCL/archivel

l e
og/2006_07

c
archive log

r afilename=/u01/app/oracle/flash_recovery_area/ORCL/archivel
og/2006_08

O archive log
filename=/u01/app/oracle/oradata/orcl/redo01.log thread=1
sequence=9
media recovery complete, elapsed time: 00:00:02

Oracle Database 10g: Backup and Recovery B-29


Solutions for Practice 4-3: Recover Control Files (continued)
Finished recover at 28-MAR-06

8. Open the database with the RESETLOGS option.


RMAN> alter database open resetlogs;

database opened
9. Back up the current online redo log file and back up all the archived redo log
files.
RMAN> SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';

using target database control file instead of recovery


catalog
sql statement: ALTER SYSTEM ARCHIVE LOG CURRENT
RMAN> backup archivelog all;

Starting backup at 10-APR-06


current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup
set
input archive log thread=1 sequence=15 recid=53
stamp=587378250
input archive log thread=1 sequence=16 recid=54
stamp=587379659 n l y
input archive log thread=1 sequence=17 recid=55
stamp=587379860
e O
input archive log thread=1 sequence=18 recid=56
stamp=587379970
U s
input archive log thread=1 sequence=19 recid=57
stamp=587380091
A
input archive log thread=1 sequence=20 recid=58
I
stamp=587380115
O
stamp=587380409
l &
input archive log thread=1 sequence=21 recid=59

stamp=587386310
n a
input archive log thread=1 sequence=22 recid=65

stamp=587386310
te r
input archive log thread=1 sequence=23 recid=66

I n
input archive log thread=1 sequence=24 recid=67
stamp=587386311

l e
channel ORA_DISK_1: starting piece 1 at 10-APR-06

c
channel ORA_DISK_1: finished piece 1 at 10-APR-06

r a piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/

O 2006_04_10/o1_mE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:26
channel ORA_DISK_1: starting archive log backupset

Oracle Database 10g: Backup and Recovery B-30


Solutions for Practice 4-3: Recover Control Files (continued)
channel ORA_DISK_1: specifying archive log(s) in backup
set
input archive log thread=1 sequence=1 recid=68
stamp=587391539
input archive log thread=1 sequence=2 recid=69
stamp=587391580
channel ORA_DISK_1: starting piece 1 at 10-APR-06
channel ORA_DISK_1: finished piece 1 at 10-APR-06
piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/
2006_04_10/o1_mE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:02
Finished backup at 10-APR-06

Starting Control File and SPFILE Autobackup at 10-APR-06


piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup
/2006_04_10/o1_E
Finished Control File and SPFILE Autobackup at 10-APR-06
10. Create a whole database backup.
RMAN> backup database;
Starting backup at 10-APR-06

y
released channel: ORA_SBT_TAPE_1
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
n l
input datafile fno=00001
e O
channel ORA_DISK_1: specifying datafile(s) in backupset

s
name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003

input datafile fno=00005


I U
name=/u01/app/oracle/oradata/orcl/sysaux01.dbf

input datafile fno=00002


O A
name=/u01/app/oracle/oradata/orcl/example01.dbf

name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004

l &
name=/u01/app/oracle/oradata/orcl/users01.dbf
input datafile fno=00006

n a
te r
name=/u01/app/oracle/oradata/orcl/example02.dbf
channel ORA_DISK_1: starting piece 1 at 10-APR-06
channel ORA_DISK_1: finished piece 1 at 10-APR-06
piece
I n
handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/

l e
2006_04_10/o1_mE

c
channel ORA_DISK_1: backup set complete, elapsed time:

r a 00:01:25
Finished backup at 10-APR-06

O Starting Control File and SPFILE Autobackup at 10-APR-06


piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup
/2006_04_10/o1_E

Oracle Database 10g: Backup and Recovery B-31


Solutions for Practice 4-3: Recover Control Files (continued)
Finished Control File and SPFILE Autobackup at 10-APR-06

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-32
Solutions for Practice 4-4: Delete Obsolete Backups
1) Use Recovery Manager to view obsolete backups.
Answer:
1. In your RMAN session, issue the REPORT OBSOLETE command to determine
whether you have any obsolete backups.
Note: Your results may vary from the following output.
RMAN> report obsolete;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type Key Completion Time
Filename/Handle
-------------------- ------ ------------------ -----------
---------
Archive Log 19 15-MAR-06
/u01/app/oracle/flash_recovery_ac
Archive Log 20 16-MAR-06
/u01/app/oracle/flash_recovery_ac
Archive Log 21 20-MAR-06
/u01/app/oracle/flash_recovery_ac
Archive Log 22 20-MAR-06
/u01/app/oracle/flash_recovery_ac
Archive Log 23 20-MAR-06
/u01/app/oracle/flash_recovery_ac
Archive Log 24 21-MAR-06 n l y
/u01/app/oracle/flash_recovery_ac
Datafile Copy 4 21-MAR-06
e O
/u01/app/oracle/flash_recovery_af
Backup Set 5 21-MAR-06
U s
Backup Piece 5 21-MAR-06
/u01/app/oracle/flash_recovery_ap
Backup Set 7 22-MAR-06 A I
Backup Piece 7 22-MAR-06
O
Backup Set 9
&
/u01/app/oracle/flash_recovery_ap

l
22-MAR-06
Backup Piece 10

n a22-MAR-06
/u01/app/oracle/flash_recovery_ap

te r
2) Use Enterprise Manager Database Control to delete obsolete backups.
Answer:
I n
1. Invoke Enterprise Manager and log in as sys/oracle as SYSDBA.

c l e
2. Select Maintenance > High Availability > Backup/Recovery > Manage Current

r a
Backups.

O
Oracle Database 10g: Backup and Recovery B-33
Solutions for Practice 4-4: Delete Obsolete Backups (continued)
3. Click Delete All Obsolete to remove obsolete backups.

4. Review the information on the Delete All Obsolete: Specify Job Parameters page
and click Submit Job.
5. You receive the “Job submission succeeded” message. You can click View Job to
monitor the job. After it completes successfully, return to the Database Home
page.
6. Access the Manage Current Backups page again to view the backup sets and
image copies that were retained.
3) You can also use RMAN to verify that your obsolete backups were deleted.
Answer:
1. In your RMAN session, execute the REPORT OBSOLETE command.

RMAN> report obsolete;


n l y
RMAN retention policy will be applied to the command
e O
RMAN retention policy is set to redundancy 1
no obsolete backups found
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-34
Practice Solutions for Lesson 5

In this practice, you use Oracle Flashback features to recover from errors in your
database.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-35
Solutions for Practice 5-1: Enable Flashback Database
1) Use Enterprise Manager to enable Flashback Database.
Answer:
1. Start Enterprise Manager and connect as SYS/ORACLE as SYSDBA.
2. Click the Maintenance tab.
3. Select Recovery Settings in the Backup/Recovery Settings section.
4. Scroll to the Flash Recovery section.
5. Select “Enable Flashback Database - flashback logging can be used for fast
database point-in-time recovery” and click Apply.

n l y
e O
U s
A I
O
l &
n a
6. The Confirmation message is displayed. You must restart the database instance to

te r
enable Flashback Database. Click Yes to restart the database instance.
7. Supply the Host and Operating System credentials if they are not filled in by
I n
default. Click OK.

c l e
r a
O
Oracle Database 10g: Backup and Recovery B-36
Solutions for Practice 5-1: Enable Flashback Database (continued)

8. The “Restart Database: Confirmation” page is displayed. Click Yes.


9. The “Restart Database:Activity Information” page is displayed. Wait a few
minutes and click Refresh.
10. Log in to Enterprise Manager as SYS/ORACLE as SYSDBA.
2) Use the ALTER DATABASE command to enable supplemental logging.
n l y
Answer:
e O
1. In a terminal window, log in to SQL*Plus as SYSDBA.

U s
[oracle@edrsr10p1 oracle]$ sqlplus / as sysdba

A I
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Apr 18
09:10:07 2006
O
l&
Copyright (c) 1982, 2005, Oracle. All rights reserved.

n a
Connected to:

t e r
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0

In
- Production
With the Partitioning, OLAP and Data Mining options

l e
2. Execute the ALTER DATABASE command to enable supplemental logging.
c
r a SQL> ALTER DATABASE add supplemental log data;

O Database altered.

Oracle Database 10g: Backup and Recovery B-37


Solutions for Practice 5-2: Set Restore Points and Perform
Flashback Table
Restore points are a way to “bookmark” database points in time. Set a restore point to
remember a significant change so that you can quickly recover to that point in time
without having to record an SCN or time.
1) You must enable row movement to use restore points. Use Enterprise Manager to
enable row movement for the HR.LOCATIONS table.
Answer:
1. Navigate to the Administration page. Select Tables in the Database Objects
section.
2. Enter HR in the Schema field and LOCATIONS in the Object Name field. Click
Go.
3. Select the HR.LOCATIONS table and click Edit.

n l y
e O
U s
A I
O
l &
n a
te r
4. Select the Options subtab.

I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-38
Solutions for Practice 5-2: Set Restore Points and Perform Flashback Table
(continued)
5. Select Yes in the Enable Row Movement menu. Click Apply.

6. The Update Message is displayed indicating that the change has been made to the
HR.LOCATIONS table.
7. Click the Database tab to return to the home page.
2) Create a normal restore point.
Answer:
1. Select the Maintenance tab.
2. Select Manage Restore Points in the Backup/Recovery section.
n l y
3. Click Create on the Manage Restore Points page.

e O
U s
A I
O
l &
n a
te r
4. Enter Before_LOC_Update in the Restore Point Name field. Ensure that

n
“Normal Restore Point” is selected. Click OK.
I
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-39
Solutions for Practice 5-2: Set Restore Points and Perform Flashback Table
(continued)

5. Your restore point has been created.

n l y
e O
U s
A I
O
&
3) Use SQL*Plus to query the POSTAL_CODE column in the HR.LOCATIONS table.
l
Answer:

n a
te r
1. Log in to SQL*Plus as SYSDBA.
2. Execute the lab_05_02_03_02.sql script to query the POSTAL_CODE

I n
column of the HR.LOCATIONS table.

c l
SQL>
SQL> e
@lab_05_02_03_02
SELECT unique (postal_code)

r a 2
3
FROM hr.locations
/

O POSTAL_CODE
------------
10934

Oracle Database 10g: Backup and Recovery B-40


Solutions for Practice 5-2: Set Restore Points and Perform Flashback Table
(continued)
YSW 9T2

2901
26192
M5V 2L7
01307-002

1730
3095
99236
80925

23 rows selected.

4) Execute the lab_05_02_04_01.sql script to update the POSTAL_CODE column


in the HR.LOCATIONS table so that all postal codes are set to 11111.
Answer:
1. Execute the lab_05_02_04_01.sql script.
SQL> @lab_05_02_04_01
SQL> UPDATE hr.locations
2
3
SET postal_code = 11111
/
n l y
23 rows updated.

e O
s
5) Execute the lab_05_02_05_01.sql script to query the POSTAL_CODE column
U
in the HR.LOCATIONS table again.
Answer:
A I
1. Execute the lab_05_02_05_01.sql script. O
SQL> @lab_05_02_05_01
l &
SQL>
2
n
FROM hr.locations a
SELECT unique (postal_code)

3 /

te r
I
POSTAL_CODE
n
------------

l
11111

c e
r a
6) Restore the POSTAL_CODE column values using the restore point.
O Answer:
1. Return to your Enterprise Manager session.

Oracle Database 10g: Backup and Recovery B-41


Solutions for Practice 5-2: Set Restore Points and Perform Flashback Table
(continued)
2. Copy the SCN value in the Creation SCN field to the buffer.

3. Click the database instance link to return to the Maintenance page.


4. Click Perform Recovery.
5. In the “Object Level Recovery” section, select Tables in the Object Type menu.
Click “Perform Object Level Recovery.”

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
6. Select “Flashback to a known SCN” and paste the SCN that you copied in step 2.
O Click Next.

Oracle Database 10g: Backup and Recovery B-42


Solutions for Practice 5-2: Set Restore Points and Perform Flashback Table
(continued)

7. Click Add Tables to add the HR.LOCATIONS table.

n l y
e O
U s
A I
O
l &
n a
te r
8. Enter HR in the Schema Name field and LOCATIONS in the Table field. Click
Search.
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-43
Solutions for Practice 5-2: Set Restore Points and Perform Flashback Table
(continued)
9. Select the HR.LOCATIONS table and click OK.

10. The HR.LOCATIONS table is added to the “Tables to Flashback” field. Click
Next.

n l y
e O
U s
A I
O
l &
n a
te r
I n
11. Accept the default of “Cascade: Flashback the selected tables and all dependent
tables” on the Dependency Options page. Click Next.

c l e
12. On the “Perform Object Level Recovery: Review” page, confirm the information.

r aClick Submit.

O
Oracle Database 10g: Backup and Recovery B-44
Solutions for Practice 5-2: Set Restore Points and Perform Flashback Table
(continued)

13. The Confirmation page is displayed. Click OK to return to the Maintenance page.

n l y
e O
U s
7) Return to your SQL*Plus session. Execute the lab_05_02_07_01.sql script to
query the POSTAL_CODE column in HR.LOCATIONS again to be sure the correct
values have been restored.
Answer: A I
1. Execute the lab_05_02_07_01.sql script. O
l &
SQL>
SQL>
@lab_05_02_07_01

n a
SELECT unique (postal_code)
2
3 /
te r
FROM hr.locations

I
POSTAL_CODE
n
l
10934
c e
------------

a
YSW 9T2

O r …
99236
80925

23 rows selected.

Oracle Database 10g: Backup and Recovery B-45


Solutions for Practice 5-3: Use Flashback Query and Flashback
Versions Query

1) Execute the lab_05_03_01_01.sql script to query the HR.LOCATIONS table


for location ID 1400.
Answer:
1. In SQL*Plus, execute the lab_05_03_01_01.sql script.
SQL> @lab_05_03_01_01
SQL> SELECT *
2 FROM hr.locations
3 WHERE location_id = 1400
4 /

LOCATION_ID STREET_ADDRESS
POSTAL_CODE
----------- ---------------------------------------- -----
-------
CITY STATE_PROVINCE
CO
------------------------------ ------------------------- -
-
1400 2014 Jabberwocky Rd 26192
Southlake
US
Texas

n l y
e O
2) Execute the lab_05_03_02_01.sql script to update the POSTAL_CODE column
in the HR.LOCATIONS table, simulating user error.
Answer: U s
A I
1. Invoke SQL*Plus and execute the lab_05_03_02_01.sql script.
SQL> @lab_05_03_02_01
O
SQL>
2
UPDATE hr.locations

l &
SET postal_code = postal_code + 100
3
4 /
n a
WHERE location_id = 1400

1 row updated.
te r
I
SQL> commitn
c l
2 /
e
r a Commit complete.

O
3) Execute the lab_05_03_03_01.sql script to query the POSTAL_CODE column
in HR.LOCATIONS and view the change.

Oracle Database 10g: Backup and Recovery B-46


Solutions for Practice 5-3: Use Flashback Query and Flashback Versions
Query (continued)
Answer:
1. Execute the lab_05_03_03_01.sql script.
SQL> @lab_05_03_03_01
SQL> SELECT *
2 FROM hr.locations
3 WHERE location_id = 1400
4 /

LOCATION_ID STREET_ADDRESS
POSTAL_CODE
----------- ---------------------------------------- -----
-------
CITY STATE_PROVINCE
CO
------------------------------ ------------------------- -
-
1400 2014 Jabberwocky Rd 26292
Southlake Texas
US

4) Execute the lab_05_03_04_01.sql script to update the POSTAL_CODE column


in the HR.LOCATIONS table, simulating user error.
Answer:
n l y
1. Execute the lab_05_03_04_01.sql script.
e O
SQL>
SQL>
@lab_05_03_04_01
UPDATE hr.locations
U s
2
3
4
SET postal_code = postal_code + 100
WHERE location_id = 1400
/
A I
O
&
1 row updated.

SQL> commit
a l
2 /

r n
Commit complete.

I n te
c
errors.l e
5) Use Enterprise Manager to perform Flashback Versions Query to correct the user

r a
Answer:

O 1. Navigate to the Administration page.


2. Select Tables in the Database Objects section.

Oracle Database 10g: Backup and Recovery B-47


Solutions for Practice 5-3: Use Flashback Query and Flashback Versions
Query (continued)
3. Enter HR in the Schema Name field and LOCATIONS in the Table field. Click
Go.
4. Select the HR.LOCATIONS table. Select Flashback Versions Query in the
Actions menu. Click Go.

5. Choose all the columns by selecting each in the Available Columns list and
clicking Move to move it to the Selected Columns list.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O 6. Enter “where location_id = 1400” in the “Bind the Row Value” field.
Click Next.

Oracle Database 10g: Backup and Recovery B-48


Solutions for Practice 5-3: Use Flashback Query and Flashback Versions
Query (continued)

7. Select the oldest change to the table and click Next.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-49
Solutions for Practice 5-3: Use Flashback Query and Flashback Versions
Query (continued)
8. Confirm the flashback information. Click Next.

9. Accept the default of “Cascade: Flashback the selected tables and all dependent
tables.” Click Next.
10. Review the information. Click Submit.

n l y
e O
U s
A I
O
l &
a
11. The Confirmation page is displayed. Click OK.
n
Flashback operation.
te r
6) Return to your SQL*Plus session. Query the HR.LOCATIONS table to confirm the

Answer: I n
l e
1. Execute the lab_05_03_06_01.sql script to query the HR.LOCATIONS
c
table.
r a SQL> @lab_05_03_06_01
O SQL>
2
3
SELECT *
FROM hr.locations
WHERE location_id = 1400

Oracle Database 10g: Backup and Recovery B-50


Solutions for Practice 5-3: Use Flashback Query and Flashback Versions
Query (continued)
4 /

LOCATION_ID STREET_ADDRESS
POSTAL_CODE
----------- ---------------------------------------- -----
-------
CITY STATE_PROVINCE
CO
------------------------------ ------------------------- -
-
1400 2014 Jabberwocky Rd 26192
Southlake Texas
US

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-51
Solutions for Practice 5-4: Use Flashback Database
1) Use Enterprise Manager to verify that Flashback Database is enabled.
Answer:
1. Navigate to the Maintenance page.
2. Select Recovery Settings in the Backup/Recovery Settings section. Scroll to the
Flash Recovery section. Verify that Flashback Database is enabled.

n l y
e O
U s
A I
3. Click the Database Instance link to return to the Maintenance page.
O
2) Use Enterprise Manager to create a Guaranteed Restore Point.
Answer:
l &
a
1. Select Manage Restore Points in the Backup/Recovery section.
n
te r
2. Click Create to create a new restore point.
3. Enter “Before_Truncate” in the Restore Point Name field. Select
I n
“Guaranteed Restore Point.” Click OK.

c l e
r a
O
Oracle Database 10g: Backup and Recovery B-52
Solutions for Practice 5-4: Use Flashback Database (continued)

4. The Restore Point is created.

n l y
e O
U s
A I
O
3) Execute the lab_05_04_03_01.sql script to determine the number of rows in

l &
the HR.JOB_HISTORY table. Record the number of rows: ___________
Answer:
n a
te r
1. Execute the lab_05_04_03_01.sql script to determine the number of rows
in the HR.JOB_HISTORY table.
SQL> I n
@lab_05_04_03_01

c l
SQL>
2 e
SELECT count(*)
FROM hr.job_history

r a 3 /

O COUNT(*)
----------
10

Oracle Database 10g: Backup and Recovery B-53


Solutions for Practice 5-4: Use Flashback Database (continued)

4) Execute the lab_05_04_04_01.sql script to truncate the HR.JOB_HISTORY


table.
Answer:
1. Execute the lab_05_04_04_01.sql script.
SQL> @lab_05_04_04_01
SQL> truncate table hr.job_history
2 /

Table truncated.

5) Execute the lab_05_04_05_01.sql script to determine the number of rows in


the HR.JOB_HISTORY table.
Answer:
1. Execute the lab_05_04_05_01.sql script.
SQL> @lab_05_04_05_01
SQL> SELECT count(*)
2 FROM hr.job_history
3 /

COUNT(*)
n l y
O
----------
0

s e
Answer: I U
6) Use Flashback Database to restore the HR.JOB_HISTORY table rows.

1. Return to your Enterprise Manager window.


O A
l &
2. Navigate to the Maintenance page.
3. Select Manage Restore Points in the Backup/Recovery section.

n a
4. Select the BEFORE_TRUNCATE restore point. Click “Recover Whole Database
To.”
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-54
Solutions for Practice 5-4: Use Flashback Database (continued)

5. Enter the host credential information. Click Yes.

n l y
e O
U s
6. The database is shut down. Click Refresh.
7. Click Perform Recovery.
A I
8. Enter Host Credentials. Click Continue. O
9. Enter Database login. Click Login.
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-55
Solutions for Practice 5-4: Use Flashback Database (continued)
10. Click “Perform Whole Database Recovery.”

11. Select “Recover to a prior point in time.”


n l y
12. Select Restore Point and click the Flashlight icon.
13. Select the BEFORE_TRUNCATE restore point. Click Select.
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-56
Solutions for Practice 5-4: Use Flashback Database (continued)
14. The Restore Point field is populated. Click Next.

n l y
15. Select Yes. Click Next.

e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-57
Solutions for Practice 5-4: Use Flashback Database (continued)
16. Review the information. Click Submit.

17. The “Processing: Perform Whole Database Recovery” page is displayed.


18. The operation is complete. You can scroll through the output to view the details
of the operation. Click “Open Database” to open the database.

n l y
e O
U s
A I
19. The “The database has been opened successfully” message is displayed. Click
OK.
O
l &
7) Return to your SQL*Plus session. Execute the lab_05_04_07_02.sql script to
query the HR.JOB_HISTORY table again to be sure the data has been restored.
Answer:
n a
te r
1. Invoke SQL*Plus and log in as SYS/ORACLE as SYSDBA.

I n
2. Execute the lab_05_04_07_02.sql script.

l e
SQL> @query_job_hist

c
SQL> SELECT count(*)

r a 2 FROM hr.job_history
3 /

O COUNT(*)
----------
10

Oracle Database 10g: Backup and Recovery B-58


Practice Solutions for Lesson 6

In this practice, you create a duplicate database.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-59
Solutions for Practice 6-1: Create a Duplicate Database
In this practice, you use RMAN to create a duplicate database on the same host as your
database.
1) Create an Oracle password file for your auxiliary instance.
Answer:
1. Change to the $ORACLE_HOME/dbs directory and use the orapwd utility to
create a password file named orapwaux. Specify a password of oracle and
10 for the number of entries.
[oracle@edrsr10p1 oracle]$ cd $ORACLE_HOME/dbs
[oracle@edrsr10p1 dbs]$ orapwd file=orapwaux
password=oracle entries=10
[oracle@edrsr10p1 dbs]$ ls
hc_orcl.dat init.ora orapwaux snapcf_orcl.f
initdw.ora lkORCL orapworcl spfileorcl.ora

2) Use Oracle Net Manager to create an entry called AUXDB in the tnsnames.ora
file.
Answer:
1. Open a terminal window and enter netmgr at the operating system prompt.
[oracle@edrsr10p1 oracle]$ netmgr
2. The Oracle Net Manager window appears.
n l y
3. Expand Local and Service Naming.
e O
name.
U s
4. Select Service Naming and click the green plus sign to create a new Net service

A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-60
Solutions for Practice 6-1: Create a Duplicate Database (continued)
5. Enter auxdb in the Net Service Name field and click Next.

6. Select TCP/IP (default) as the protocol. Click Next.


7. Enter the host name of your PC in the Host Name field. Accept the default of
1521 for the port number. Click Next.
n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-61
Solutions for Practice 6-1: Create a Duplicate Database (continued)
8. Enter aux.oracle.com in the Service Name field. Click Next.

9. Click Finish.
10. Select File and Save Network Configuration to save the changes you made.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
11. Click File and Exit to exit from Oracle Net Manager.
O 12. You can view your updated tnsnames.ora file in the
/u01/app/oracle/product/10.2.0/db_1/network/admin
directory.

Oracle Database 10g: Backup and Recovery B-62


Solutions for Practice 6-1: Create a Duplicate Database (continued)
AUXDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edrsr10p1.us.oracle.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = aux.oracle.com)
)

3) Create an initialization parameter file for the auxiliary instance.


Answer:
1. Create a text initialization parameter file named initAUX.ora from your server
parameter file in the $HOME/auxinstance directory.
[oracle@edrsr10p1 oracle]$ cd $HOME/auxinstance
[oracle@edrsr10p1 auxinstance]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 29


10:51:53 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
- Production
With the Partitioning, OLAP and Data Mining options
n l y
SQL> create pfile='$HOME/auxinstance/initAUX.ora' from
e O
spfile;

U s
File created.

A I
2. Edit the initAUX.ora initialization parameter file to make the following
changes for the auxiliary instance:
O
&
audit_file_dest='/u01/app/oracle/admin/aux/adump'

a l
background_dump_dest='/u01/app/oracle/admin/aux/bdump
control_files='/u01/app/oracle/oradata/aux/control01.c

n
tl','/u01/app/oracle/oradata/aux/control02.ctl','/u01/
r
te
app/oracle/oradata/aux/control03.ctl'
db_name='aux'

I n
user_dump_dest='/u01/app/oracle/admin/aux/udump'

l e
Add the following parameters:
c
DB_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/orcl’,

r a
‘/u01/app/oracle/oradata/aux’

O LOG_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/orcl’,
‘/u01/app/oracle/oradata/aux’

Remove the lines at the beginning of the file that begin with orcl.__.

Oracle Database 10g: Backup and Recovery B-63


Solutions for Practice 6-1: Create a Duplicate Database (continued)

Add the comment character, #, to this line:


*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
4) Start the auxiliary instance in NOMOUNT mode using the initAUX.ora file.
Answer:
1. Set the ORACLE_SID environment variable to aux.
[oracle@edrsr10p1 oracle]$ ORACLE_SID=aux
[oracle@edrsr10p1 oracle]$ echo $ORACLE_SID
aux

2. Invoke SQL*Plus and connect as SYSDBA.


[oracle@edrsr10p1 oracle]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 29


11:38:53 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

3. Start the instance in NOMOUNT mode using the initialization parameter file you
created in step 2.
SQL> startup nomount pfile='$HOME/auxinstance/initAUX.ora'
ORACLE instance started.
n l y
Total System Global Area 285212672 bytes
e O
Fixed Size
Variable Size
1218992
92276304
bytes

U
bytess
Database Buffers
Redo Buffers
188743680

A
2973696I bytes
bytes
5) Create a server parameter file (SPFILE).
O
Answer:

l &
1. Create a server parameter file with the default name of spfileaux.ora from
a
the text initialization parameter file.
n
te r
SQL> create spfile from
pfile='$HOME/auxinstance/initAUX.ora';

I n
e
File created.

c l
r a
2. Exit from SQL*Plus.

O
6) Verify that your target database (orcl database) is mounted or open.
Answer:

Oracle Database 10g: Backup and Recovery B-64


Solutions for Practice 6-1: Create a Duplicate Database (continued)
1. Set your ORACLE_SID to orcl.
[oracle@edrsr10p1 oracle]$ ORACLE_SID=orcl
[oracle@edrsr10p1 oracle]$ echo $ORACLE_SID
orcl
[oracle@edrsr10p1 oracle]$

2. Log in to SQL*Plus as SYSDBA.


3. Query V$DATABASE to determine whether your database is open.
SQL> select open_mode from v$database;

OPEN_MODE
----------
READ WRITE
4. Exit from SQL*Plus.
7) Start RMAN with a connection to the target database (orcl) and the auxiliary
instance.
Answer:
1. Set your ORACLE_SID to aux. Invoke RMAN and connect as SYSDBA.
Connect to the target database.

y
[oracle@edrsr10p1 oracle]$ ORACLE_SID=aux
[oracle@edrsr10p1 oracle]$ echo $ORACLE_SID
aux
n l
[oracle@edrsr10p1 oracle]$ rman

Recovery Manager: Release 10.2.0.1.0 - Production on Thu


e O
Mar 30 07:34:06 2006

U s
Copyright (c) 1982, 2005, Oracle.

A I
All rights reserved.

RMAN> connect auxiliary sys/oracle


O
&
connected to auxiliary database: AUX (not mounted)

l
a
RMAN> connect target sys/oracle@orcl

n
te r
connected to target database: ORCL (DBID=1090770270)

I n
8) Create the duplicate database by executing the DUPLICATE command.

c
Answer:l e
r a
1. Create a RUN block to allocate the auxiliary channel and execute the DUPLICATE

O command.
RMAN> run
2> {

Oracle Database 10g: Backup and Recovery B-65


Solutions for Practice 6-1: Create a Duplicate Database (continued)
3> allocate auxiliary channel aux1 device type disk;
4> duplicate target database to aux;
5> }
allocated channel: aux1
channel aux1: sid=156 devtype=DISK

Starting Duplicate Db at 30-MAR-06


allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=154 devtype=DISK
using channel ORA_AUX_SBT_TAPE_1

contents of Memory Script:


{
set until scn 4236965;
set newname for datafile 1 to
"/u01/app/oracle/oradata/aux/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/aux/undotbs01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/aux/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/aux/users01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/aux/example01.dbf";
restore
check readonly
clone database
; n l y
}
executing Memory Script
e O
executing command: SET until clause

U s
executing command: SET NEWNAME

executing command: SET NEWNAME A I


O
&
executing command: SET NEWNAME

l
a
executing command: SET NEWNAME

n
r
executing command: SET NEWNAME

te
I n
Starting restore at 30-MAR-06
using channel ORA_AUX_DISK_1

l e
using channel ORA_AUX_SBT_TAPE_1

c
channel aux1: restoring datafile 00001

r ainput datafile copy recid=23 stamp=586270526


filename=/u01/app/oracle/flash_recf

O destination for restore of datafile 00001:


/u01/app/oracle/oradata/aux/system01f
channel ORA_AUX_DISK_1: restoring datafile 00002

Oracle Database 10g: Backup and Recovery B-66


Solutions for Practice 6-1: Create a Duplicate Database (continued)
input datafile copy recid=20 stamp=586270521
filename=/u01/app/oracle/flash_recf
destination for restore of datafile 00002:
/u01/app/oracle/oradata/aux/undotbs0f
channel ORA_AUX_DISK_1: copied datafile copy of datafile
00002
output filename=/u01/app/oracle/oradata/aux/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003
input datafile copy recid=22 stamp=586270526
filename=/u01/app/oracle/flash_recf
destination for restore of datafile 00003:
/u01/app/oracle/oradata/aux/sysaux01f
channel aux1: copied datafile copy of datafile 00001
output filename=/u01/app/oracle/oradata/aux/system01.dbf
channel aux1: restoring datafile 00004
input datafile copy recid=19 stamp=586270517
filename=/u01/app/oracle/flash_recf
destination for restore of datafile 00004:
/u01/app/oracle/oradata/aux/users01.f
channel ORA_AUX_DISK_1: copied datafile copy of datafile
00003
output filename=/u01/app/oracle/oradata/aux/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005
input datafile copy recid=21 stamp=586270521
filename=/u01/app/oracle/flash_recf
destination for restore of datafile 00005:
/u01/app/oracle/oradata/aux/example0f
channel aux1: copied datafile copy of datafile 00004 n l y
output filename=/u01/app/oracle/oradata/aux/users01.dbf

e O
channel ORA_AUX_DISK_1: copied datafile copy of datafile
00005

U s
output filename=/u01/app/oracle/oradata/aux/example01.dbf
Finished restore at 30-MAR-06

A I
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUX"
RESETLOGS ARCHIVELOG
MAXLOGFILES 16
O
MAXLOGMEMBERS
MAXDATAFILES
3
100
l &
MAXINSTANCES
MAXLOGHISTORY
8

n a
292
LOGFILE

te r
GROUP 1 ( '/u01/app/oracle/oradata/aux/redo01.log' )

I n
SIZE 50 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/aux/redo02.log' )

l e
SIZE 50 M REUSE,

cGROUP 3 ( '/u01/app/oracle/oradata/aux/redo03.log' )

r aSIZE 50 M REUSE
DATAFILE

O '/u01/app/oracle/oradata/aux/system01.dbf'
CHARACTER SET AL32UTF8

Oracle Database 10g: Backup and Recovery B-67


Solutions for Practice 6-1: Create a Duplicate Database (continued)
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script

released channel: ORA_AUX_DISK_1


released channel: ORA_AUX_SBT_TAPE_1
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=586438014
filename=/u01/app/oracle/oradata/auf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=586438014
filename=/u01/app/oracle/oradata/auf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=586438014
filename=/u01/app/oracle/oradata/auf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=586438014
filename=/u01/app/oracle/oradata/auf

contents of Memory Script:


{
set until scn 4236965;
recover
clone database

;
delete archivelog
n l y
}
executing Memory Script
e O
executing command: SET until clause
U s
Starting recover at 30-MAR-06
A I
channel aux1: starting incremental datafile backupset
restore
O
backup set
l &
channel aux1: specifying datafile(s) to restore from

n a
destination for restore of datafile 00001:
/u01/app/oracle/oradata/aux/system01f

te r
destination for restore of datafile 00002:
/u01/app/oracle/oradata/aux/undotbs0f

I n
destination for restore of datafile 00003:
/u01/app/oracle/oradata/aux/sysaux01f

l e
destination for restore of datafile 00004:

c
/u01/app/oracle/oradata/aux/users01.f

r adestination for restore of datafile 00005:


/u01/app/oracle/oradata/aux/example0f

O channel aux1: reading from backup piece


/u01/app/oracle/flash_recovery_area/ORCp
channel aux1: restored backup piece 1

Oracle Database 10g: Backup and Recovery B-68


Solutions for Practice 6-1: Create a Duplicate Database (continued)
piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/
2006_03_28/o1_m4
channel aux1: restore complete, elapsed time: 00:00:16

starting media recovery


archive log thread 1 sequence 1 is already on disk as file
/u01/app/oracle/flasc
archive log thread 1 sequence 2 is already on disk as file
/u01/app/oracle/flasc
archive log
filename=/u01/app/oracle/flash_recovery_area/ORCL/archivel
og/2006_01
archive log
filename=/u01/app/oracle/flash_recovery_area/ORCL/archivel
og/2006_02
media recovery complete, elapsed time: 00:00:05
Finished recover at 10-APR-06

contents of Memory Script:


{
shutdown clone;
startup clone nomount ;
}
executing Memory Script
database dismounted
Oracle instance shut down
n l y
connected to auxiliary database (not started)
Oracle instance started
e O
Total System Global Area
U s
285212672 bytes

Fixed Size
Variable Size A I
1218992 bytes
92276304 bytes
Database Buffers
O
188743680 bytes
Redo Buffers

l & 2973696 bytes


sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUX"
RESETLOGS ARCHIVELOG
MAXLOGFILES 16
n a
MAXLOGMEMBERS
MAXDATAFILES
te r 3
100

I n
MAXINSTANCES
MAXLOGHISTORY
8
292

l e
LOGFILE

cGROUP 1 ( '/u01/app/oracle/oradata/aux/redo01.log' )

r aSIZE 50 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/aux/redo02.log' )

O SIZE 50 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/aux/redo03.log' )
SIZE 50 M REUSE
DATAFILE

Oracle Database 10g: Backup and Recovery B-69


Solutions for Practice 6-1: Create a Duplicate Database (continued)
'/u01/app/oracle/oradata/aux/system01.dbf'
CHARACTER SET AL32UTF8

contents of Memory Script:


{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/aux/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy
"/u01/app/oracle/oradata/aux/undotbs01.dbf";
catalog clone datafilecopy
"/u01/app/oracle/oradata/aux/sysaux01.dbf";
catalog clone datafilecopy
"/u01/app/oracle/oradata/aux/users01.dbf";
catalog clone datafilecopy
"/u01/app/oracle/oradata/aux/example01.dbf";
catalog clone datafilecopy
"/u01/app/oracle/oradata/aux/example02.dbf";
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed temporary file 1 to


/u01/app/oracle/oradata/aux/temp01.dbf in control fe
n l y
cataloged datafile copy
datafile copy
e O
stamp=8
U s
filename=/u01/app/oracle/oradata/aux/undotbs01.dbf recid=1

cataloged datafile copy


datafile copy A I
O
filename=/u01/app/oracle/oradata/aux/sysaux01.dbf recid=2
stamp=59

l &
cataloged datafile copy
datafile copy
n a
stamp=589
te r
filename=/u01/app/oracle/oradata/aux/users01.dbf recid=3

I n
cataloged datafile copy

l e
datafile copy

c
filename=/u01/app/oracle/oradata/aux/example01.dbf recid=4

r astamp=9

O cataloged datafile copy


datafile copy
filename=/u01/app/oracle/oradata/aux/example02.dbf recid=5
stamp=9

Oracle Database 10g: Backup and Recovery B-70


Solutions for Practice 6-1: Create a Duplicate Database (continued)
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=587391888
filename=/u01/app/oracle/oradata/auf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=587391889
filename=/u01/app/oracle/oradata/auf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=587391889
filename=/u01/app/oracle/oradata/auf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=587391889
filename=/u01/app/oracle/oradata/auf
datafile 6 switched to datafile copy
input datafile copy recid=5 stamp=587391889
filename=/u01/app/oracle/oradata/auf

contents of Memory Script:


{
Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 10-APR-06

2. After the DUPLICATE DATABASE operation completes, exit from RMAN.


n l y
HR.REGIONS table.
e O
9) Use SQL*Plus to log in to your AUX database and execute a query against the

Answer:
1. Verify that ORACLE_SID is set to aux. U s
A I
2. Log in to SQL*Plus as SYSDBA and execute a query against the HR.REGIONS
table.
O
SQL> select * from hr.regions;

l &
REGION_ID REGION_NAME

n a
----------
1
2
r
-------------------------

te
Europe
Americas

I
3
4 n Asia
Middle East and Africa

l e
10) Now that you have completed the test recovery by creating a duplicate database, shut
c
r a
down the aux instance.
Answer:
O 1. Connect as SYSDBA and execute the SHUTDOWN IMMEDIATE command.
SQL> shutdown immediate

Oracle Database 10g: Backup and Recovery B-71


Solutions for Practice 6-1: Create a Duplicate Database (continued)
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

2. Exit from SQL*Plus.


11) Change your ORACLE_SID to orcl in preparation for later practices.
Answer:
1. At the operating prompt, enter ORACLE_SID=orcl to change your
ORACLE_SID.
[oracle@edrsr10p1 oracle]$ ORACLE_SID=orcl
[oracle@edrsr10p1 oracle]$ echo $ORACLE_SID
orcl

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-72
Practice Solutions for Lesson 7

In this practice, you use tablespace point-in-time recovery to recover from unwanted
changes to your database.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-73
Solutions for Practice 7-1: Use Tablespace Point-in-time
Recovery
1) Execute the lab_07_01_01_01.sh script to export the HR schema.
Answer:
1. In a terminal window, change to the labs directory and execute the
lab_07_01_01_01.sh script to export the HR schema.

[oracle@edrsr10p1 labs]$ ./lab_07_01_01_01.sh

Export: Release 10.2.0.1.0 - Production on Wednesday, 12


April, 2006 13:03:27

Copyright (c) 2003, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition


Release 10.2.0.1.0 - Produn
With the Partitioning, OLAP and Data Mining options
tarting "SYSTEM"."SYS_EXPORT_SCHEMA_01": system/********
dumpfile=hrexp.dmp sr
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 448 KB

y
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
n l
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type
SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
e O
Processing object type SCHEMA_EXPORT/TABLE/TABLE
U s
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE

Processing object type

A I
SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT

O
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type

Processing object type


l &
SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

a
SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

n
te r
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type

I n
SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/VIEW/VIEW

l e
Processing object type

c
SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT

r a Processing object type SCHEMA_EXPORT/TABLE/TRIGGER


Processing object type

O SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "HR"."COUNTRIES"
6.085 KB 25 rows

Oracle Database 10g: Backup and Recovery B-74


Solutions for Practice 7-1: Use Tablespace Point-in-time Recovery
(continued)
. . exported "HR"."DEPARTMENTS"
6.632 KB 27 rows
. . exported "HR"."EMPLOYEES"
15.76 KB 107 rows
. . exported "HR"."JOBS"
6.609 KB 19 rows
. . exported "HR"."JOB_HISTORY"
6.585 KB 10 rows
. . exported "HR"."LOCATIONS"
7.710 KB 23 rows
. . exported "HR"."REGIONS"
5.289 KB 4 rows
Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully
loaded/unloaded
**********************************************************
********************
Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:
/u01/app/oracle/product/10.2.0/db_1/rdbms/log/hrexp.dmp
Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed
at 13:03:44

2) Execute the lab_07_01_02_02.sql script to create a new tablespace and a new


user in your database.
Answer: n l y
1. In your terminal window, log in to SQL*Plus as SYSDBA.
e O
and the HRTEST user.
U s
2. Execute the lab_07_01_02_02.sql script to create the HRTEST tablespace

SQL> @lab_07_01_02_02
A I
SQL> SET TERMOUT ON
SQL> CONNECT / AS SYSDBA
O
Connected.

l &
SQL> REM ***** Tablespace for the HR import *****

a
SQL> CREATE SMALLFILE TABLESPACE HRTEST

n
SIZE 10M

te r
2 DATAFILE '/u01/app/oracle/oradata/orcl/hrtest01.dbf'

3 AUTOEXTEND ON NEXT 500K MAXSIZE UNLIMITED LOGGING

I n
4 EXTENT MANAGEMENT LOCAL
5 SEGMENT SPACE MANAGEMENT AUTO;

c l e
Tablespace created.

r aSQL> REM ***** User/schema for the HR import *****


SQL> CREATE USER hrtest

O 2 PROFILE DEFAULT
3 IDENTIFIED BY hrtest
4 DEFAULT TABLESPACE hrtest
5 TEMPORARY TABLESPACE temp

Oracle Database 10g: Backup and Recovery B-75


Solutions for Practice 7-1: Use Tablespace Point-in-time Recovery
(continued)
6 QUOTA UNLIMITED ON hrtest
7 ACCOUNT UNLOCK
8 ;

User created.
SQL> GRANT connect, resource
2 TO hrtest;

Grant succeeded.

3) Execute the lab_07_01_03_01.sh script to populate the new tablespace with a


copy of the data from the HR schema.
Note: The import should complete successfully. You will receive error messages
because the import excludes the COUNTRIES, REGIONS, and LOCATIONS tables.
These messages can be ignored.
Answer:
1. In your terminal window at the operating system prompt, execute the
lab_07_01_03_01.sh script.

[oracle@edrsr10p1 labs]$ ./lab_07_01_03_01.sh

Import: Release 10.2.0.1.0 - Production on Friday, 14


n l y
April, 2006 7:08:42

e O
Copyright (c) 2003, 2005, Oracle.
s
All rights reserved.

U
I
Connected to: Oracle Database 10g Enterprise Edition
Release 10.2.0.1.0 - Produn

O A
With the Partitioning, OLAP and Data Mining options
Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully
loaded/unloaded

dumpfile=hrexp.dmp par
l &
Starting "SYSTEM"."SYS_IMPORT_FULL_01": system/********

n a
Processing object type SCHEMA_EXPORT/USER

te r
ORA-31684: Object type USER:"HRTEST" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT

I n
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE

e
Processing object type

c l
SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE

r a Processing object type SCHEMA_EXPORT/TABLE/TABLE


Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA

O . . imported "HRTEST"."DEPARTMENTS"
6.632 KB 27 rows

Oracle Database 10g: Backup and Recovery B-76


Solutions for Practice 7-1: Use Tablespace Point-in-time Recovery
(continued)
. . imported "HRTEST"."EMPLOYEES"
15.76 KB 107 rows
. . imported "HRTEST"."JOBS"
6.609 KB 19 rows
. . imported "HRTEST"."JOB_HISTORY"
6.585 KB 10 rows
Processing object type
SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type
SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type
SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type
SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/VIEW/VIEW
ORA-39082: Object type VIEW:"HRTEST"."EMP_DETAILS_VIEW"
created with compilatios
Processing object type
SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
ORA-39083: Object type REF_CONSTRAINT failed to create
with error:
ORA-00942: table or view does not exist
Failing sql is:
n l y
O
ALTER TABLE "HRTEST"."DEPARTMENTS" ADD CONSTRAINT
"DEPT_LOC_FK" FOREIGN KEY ("LE

Processing object type SCHEMA_EXPORT/TABLE/TRIGGER


se
Processing object type

I
SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS U
error(s) at 07:08:54
O A
Job "SYSTEM"."SYS_IMPORT_FULL_01" completed with 3

l &
4) Create a backup of your database using RMAN.
Answer:
n a
te r
1. Invoke RMAN and connect to your target database.

n
2. Execute the BACKUP DATABASE command.
I
c l e
RMAN> backup database;

r a Starting backup at 14-APR-06


using target database control file instead of recovery

O catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=127 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset

Oracle Database 10g: Backup and Recovery B-77


Solutions for Practice 7-1: Use Tablespace Point-in-time Recovery
(continued)
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001
name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003
name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005
name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002
name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004
name=/u01/app/oracle/oradata/orcl/users01.dbf
input datafile fno=00007
name=/u01/app/oracle/oradata/orcl/hrtest01.dbf
input datafile fno=00006
name=/u01/app/oracle/oradata/orcl/example02.dbf
channel ORA_DISK_1: starting piece 1 at 14-APR-06
channel ORA_DISK_1: finished piece 1 at 14-APR-06
piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/
2006_04_14/o1_mE
channel ORA_DISK_1: backup set complete, elapsed time:
00:01:35
Finished backup at 14-APR-06

Starting Control File and SPFILE Autobackup at 14-APR-06


piece
n l y
O
handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup
/2006_04_14/o1_E
Finished Control File and SPFILE Autobackup at 14-APR-06

s e
5) Record the current SCN: ____________
I U
Answer:
1. Invoke SQL*Plus as SYSDBA. O A
l &
2. Query the CURRENT_SCN column in V$DATABASE and record the current SCN.

n a
SQL> select current_scn from V$database;

CURRENT_SCN
te r
I n
-----------
4725352

l e
6) Record the current time.
c
r a
Answer:
1. Execute the date command at the operating system prompt.
O [oracle@edrsr10p1 labs]$ date
Fri Apr 14 13:07:57 PDT 2006

Oracle Database 10g: Backup and Recovery B-78


Solutions for Practice 7-1: Use Tablespace Point-in-time Recovery
(continued)
7) Execute the lab_07_01_07_01.sql script to query the HRTEST.EMPLOYEES
table and view information about employees in department 60.
Make note of the highest salary that is displayed: ________
Answer:
1. Execute the lab_07_01_07_01.sql script.
SQL> @lab_07_01_07_01
SQL> select employee_id, last_name, salary
2 from employees
3 where department_id = 60
4 /

EMPLOYEE_ID LAST_NAME SALARY


----------- ------------------------- ----------
103 Hunold 9000
104 Ernst 6000
105 Austin 4800
106 Pataballa 4800
107 Lorentz 4200

8) Execute the lab_07_01_08_01.sql script to update the salaries for the


employees in department 60 and note the highest salary displayed.
Highest salary: _____________
Answer:
n l y
1. Execute the lab_07_01_08_01.sql script.
SQL> @lab_07_01_08_01
e O
SQL>
2
update hrtest.employees
set salary = salary * 1.25
U s
3
4
where department_id = 60
/
A I
5 rows updated.
O
2 from hrtest.employees
l &
SQL> select employee_id, last_name, salary

a
3 where department_id = 60

n
r
4 /

EMPLOYEE_ID

I
-----------
103n te
LAST_NAME SALARY
------------------------- ----------
Hunold 11250

c l e104
105
Ernst
Austin
7500
6000

r a 106
107
Pataballa
Lorentz
6000
5250

O
Oracle Database 10g: Backup and Recovery B-79
Solutions for Practice 7-1: Use Tablespace Point-in-time Recovery
(continued)
9) You now want to perform TSPITR for the HRTEST tablespace to return it to the state
prior to the updates. Execute the lab_07_01_09_01.sql script to determine
whether there are any dependencies that will prevent the TSPITR operation.
Answer:
1. Execute the lab_07_01_09_01.sql script.
SQL> @lab_07_01_09_01
SQL> SELECT obj1_owner, obj1_name, obj1_type, ts1_name,
2 obj2_owner, obj2_name, obj2_type, ts2_name,
3 constraint_name, reason
4 FROM SYS.TS_PITR_CHECK
5 WHERE (TS1_NAME IN ('HRTEST')
6 AND TS2_NAME NOT IN ('HRTEST'))
7 OR (TS1_NAME NOT IN ('HRTEST')
8 AND TS2_NAME IN ('HRTEST'))
9 /

no rows selected

“No rows selected” indicates that there are no dependencies to any tablespaces
outside of the recovery set, so you can proceed with the tablespace point-in-time
recovery.
10) You can use Enterprise Manager Database Control or RMAN command line to
perform tablespace point-in-time recovery.
n l y
Answer:
O
The answer presents the solution using Enterprise Manager Database Control.
e
s
If you want to use RMAN command line, refer to the course notes for detailed
information and execute the RECOVER TABLESPACE command as follows:
U
RECOVER TABLESPACE hrtest UNTIL SCN <scn>

A I
AUXILIARY DESTINATION ‘/u01/app/oracle/oradata/tspitr’;

O
1. Invoke Enterprise Manager Database Control and log in as SYS/ORACLE as
SYSDBA.
2. Select the Maintenance page.
l &
n a
3. Select Perform Recovery in the Backup/Recovery section.

te r
4. Select Tablespaces in the Object Level Recovery section. The page refreshes.
Accept the default selection “Recover to current time or a previous point-in-time.”
I n
Click Perform Object Level Recovery.

c l e
r a
O
Oracle Database 10g: Backup and Recovery B-80
Solutions for Practice 7-1: Use Tablespace Point-in-time Recovery
(continued)

5. Select “Recover to a prior point-in-time” and specify the SCN you recorded
earlier. Click Next.
n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-81
Solutions for Practice 7-1: Use Tablespace Point-in-time Recovery
(continued)
6. Specify the auxiliary instance location of
/u01/app/oracle/oradata/tspitr. Click Add to select the tablespace.

7. Select the HRTEST tablespace. Click Select.

n l y
e O
U s
A I
O
l &
n a
te r
I n
c l e
r a
O
Oracle Database 10g: Backup and Recovery B-82

Potrebbero piacerti anche