Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
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
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
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
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
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
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
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.
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
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
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
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
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:
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
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
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
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:
RMAN>
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';
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)
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.
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.
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';
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
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
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.
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.
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)
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
[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: ____
3. Execute the SWITCH TO COPY command for the datafile you noted in step 3.
RMAN> switch datafile 5 to copy;
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;
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.
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
O output filename=/u01/app/oracle/oradata/orcl/example01.dbf
tag=TAG20060324T13447
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:07
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.
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
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:
O '/u01/app/oracle/oradata/orcl/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
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
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
l&
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN>
e In
c l
3. Restart the instance in NOMOUNT mode.
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;
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
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';
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
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
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
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;
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.
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)
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.
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)
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
2901
26192
M5V 2L7
01307-002
…
1730
3095
99236
80925
23 rows selected.
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.
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.
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.
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.
LOCATION_ID STREET_ADDRESS
POSTAL_CODE
----------- ---------------------------------------- -----
-------
CITY STATE_PROVINCE
CO
------------------------------ ------------------------- -
-
1400 2014 Jabberwocky Rd 26292
Southlake Texas
US
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:
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.
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
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)
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
Table truncated.
COUNT(*)
n l y
O
----------
0
s e
Answer: I U
6) Use Flashback Database to restore the HR.JOB_HISTORY table rows.
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)
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.”
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.
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
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.
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.
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.__.
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:
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
U s
Copyright (c) 1982, 2005, Oracle.
A I
All rights reserved.
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> {
U s
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
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
;
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
Fixed Size
Variable Size A I
1218992 bytes
92276304 bytes
Database Buffers
O
188743680 bytes
Redo Buffers
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
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
database opened
Finished Duplicate Db at 10-APR-06
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
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.
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
A I
SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
O
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type
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
O SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "HR"."COUNTRIES"
6.085 KB 25 rows
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'
I n
4 EXTENT MANAGEMENT LOCAL
5 SEGMENT SPACE MANAGEMENT AUTO;
c l e
Tablespace created.
O 2 PROFILE DEFAULT
3 IDENTIFIED BY hrtest
4 DEFAULT TABLESPACE hrtest
5 TEMPORARY TABLESPACE temp
User created.
SQL> GRANT connect, resource
2 TO hrtest;
Grant succeeded.
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
O . . imported "HRTEST"."DEPARTMENTS"
6.632 KB 27 rows
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;
O catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=127 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
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
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.
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