- •About the Authors
- •Contents at a Glance
- •Contents
- •Table of Exercises
- •Introduction
- •Assessment Test
- •Answers to Assessment Test
- •What Is ASM?
- •Working with the ASM Instance
- •Overview of ASM Data Dictionary Views
- •Using ASM Storage
- •Using RMAN with ASM
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Understanding the Oracle Database as It Relates to Backup and Recovery
- •Performing Oracle Offline Backups
- •Performing Oracle Online Backups
- •Backing Up the Control File
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Performing Incomplete Recoveries
- •Performing Other Types of Recoveries
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Why Use RMAN?
- •Exploring the RMAN Architecture
- •Connecting to RMAN
- •Configuring RMAN for Use
- •Backing Up Your Database with RMAN
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Introducing the Recovery Catalog
- •Creating the Recovery Catalog User and Schema Objects
- •Using a Recovery Catalog
- •Maintaining the Recovery Catalog
- •Using the RMAN Virtual Private Catalog
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •RMAN Database-Recovery Basics
- •Using Image Copies to Recover Your Database
- •Other Basic Recovery Topics
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Switching Between RMAN Incarnations
- •Overview of RMAN Database Duplication
- •Performing an RMAN Tablespace Point-in-Time Recovery
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Overview of Flashback Technology
- •Using Automatic Undo Management
- •Using Flashback Technologies
- •Using Additional Flashback Operations
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Diagnosing the Database
- •Managing Database Performance
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Managing Memory
- •Managing Space
- •Managing Resources
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Automating Tasks with the Scheduler
- •Exploring the Scheduler Architecture
- •Exploring Common Administration Tools
- •Using Scheduler Jobs
- •Using Scheduler Programs
- •Using Schedules
- •Creating Lightweight Jobs
- •Using Job Chains
- •Using Scheduler Windows
- •Creating and Using Job Classes
- •Using Advanced Scheduler Concepts to Prioritize Jobs
- •Using Scheduler Views
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •An Overview of Globalization Support
- •Using NLS Parameters
- •Using Datetime Datatypes
- •Using Linguistic Sorts and Searches
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Lab 1.1: Creating an ASM Instance
- •Lab 1.2: Creating ASM Disk Groups
- •Lab 1.3: Using ASM Disk Groups from a Database
- •Lab 2.2: Putting the Database in ARCHIVELOG Mode
- •Lab 2.3: Executing a Manual Online (Hot) Backup
- •Lab 3.1: Executing a Time-Based Point-in-Time Recovery
- •Lab 3.2: Recovering from Control-File Loss with a Backup Control File
- •Lab 3.3: Recovering from Loss of the Current Online Redo Log
- •Lab 4.1: Creating an RMAN Offline Backup
- •Lab 4.2: Creating an RMAN Incremental Backup
- •Lab 4.3: Creating an Image-Copy Backup
- •Lab 5.1: Implementing RVPC
- •Lab 6.1: Restoring a Datafile Online
- •Lab 6.2: Performing a Change-Based Recovery with RMAN
- •Lab 6.3: Restoring a Control File from an Autobackup
- •Lab 7.1: Monitoring RMAN Backups
- •Lab 7.2: One of My Backups Is Missing!
- •Lab 8.1: Duplicating a Database Using Active Database Duplication
- •Lab 8.2: Duplicating a Database Using Backup-Based Duplication to a Different Point in Time
- •Lab 9.1: Using the Recycle Bin
- •Lab 9.3: Using Flashback Data Archive
- •Lab 10.1: Using Support Workbench to Report a Problem to Oracle Support
- •Lab 11.1: Exporting a Transportable Tablespace
- •Lab 11.2: Testing Resumable Space Allocation
- •Lab 11.3: Manually Configuring the SGA
- •Lab 12.1: Creating a Local External Job
- •Lab 12.2: Creating a Job Window
- •Lab 13.1: Using the Locale Builder to Create a New Linguistic Sort
- •Lab 13.2: Setting NLS Parameters
- •Lab 13.3: Performing Linguistic Sorts
- •What You’ll Find on the CD
- •System Requirements
- •Using the CD
- •Troubleshooting
- •Glossary
- •Index
Lab 3.1: Executing a Time-Based Point-in-Time Recovery |
697 |
13.This is an optional step. Now that we know our archived redo logs were copied successfully, we can remove them from the archive-log directory if we want.
SQL> Host del c:\oracle\arch\orcl\ARC00003_0662757171.001 SQL> Host del c:\oracle\arch\orcl\ARC00004_0662757171.001 SQL> Host del c:\oracle\arch\orcl\ARC00005_0662757171.001 SQL> Host del c:\oracle\arch\orcl\ARC00006_0662757171.001 SQL> Host del c:\oracle\arch\orcl\ARC00007_0662757171.001
This completes your online backup. You will use this backup to recover your database in a Chapter 3 lab.
In the Chapter 3 labs, we will be doing full database recoveries. This will require all of the archived redo logs generated by the database, including those created after this backup. Make sure you do not delete any archived redo logs that are not backed up. If you want to back up later archived redo logs, simply repeat step 8 of Lab 2.3 as often as needed.
Lab 3.1: Executing a Time-Based
Point-in-Time Recovery
In this exercise, you will do a point-in-time recovery by restoring the database to a given point in time.
1.Back up the database. Details on how to do a full online database backup are found in Chapter 2. In summary, follow these steps:
a.Put the database in hot backup mode.
b.Copy all database datafiles to a backup location.
c.Take the database out of hot backup mode.
d.Force a log switch. Back up the archived redo logs.
Here is an example of a backup:
[oracle@localhost orcl]$ sqlplus “/ as sysdba”
SQL*Plus: Release 11.1.0.6.0 - Production on Sun Aug 17 15:35:48 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production With the Partitioning, OLAP, Data Mining
698 Appendix A n Lab Exercises
and Real Application Testing options SQL> alter database begin backup; Database altered.
SQL> host cp /oracle01/oradata/orcl/*.dbf /oracle01/backup/orcl SQL> alter database end backup;
Database altered.
SQL> alter system switch logfile; System altered.
SQL> host cp /oracle01/backup/arch/* /oracle01/backup/orcl/* SQL> alter database backup controlfile to trace;
Database altered.
SQL> alter database backup controlfile to ‘/oracle01/oradata/orcl/control1.bak’; Database altered.
2.Next, log into the database as scott/tiger and create a new table. Insert two records into the new table and commit the insert.
SQL> connect scott/tiger Connected.
SQL> create table time_table (col_one date); Table created.
SQL> insert into time_table values (sysdate); 1 row created.
SQL> insert into time_table values (sysdate); 1 row created.
SQL> commit; Commit complete.
SQL> alter session set nls_date_format=’mm/dd/yyyy hh24:mi:ss’; Session altered.
SQL> select * from time_table; COL_ONE
-------------------
08/17/2008 22:03:59 08/17/2008 22:03:59
3.Wait a minute or so (however long you like) and add two more records. Commit the inserts.
SQL> insert into time_table values (sysdate); 1 row created.
SQL> insert into time_table values (sysdate);
Lab 3.1: Executing a Time-Based Point-in-Time Recovery |
699 |
1 row created. SQL> commit; Commit complete.
SQL> select * from time_table; COL_ONE
-------------------
08/17/2008 22:03:59 08/17/2008 22:03:59 08/17/2008 22:04:45 08/17/2008 22:04:45
4.Shut down the database.
SQL> connect sys as sysdba Enter password: Connected.
SQL> shutdown immediate Database closed. Database dismounted.
ORACLE instance shut down.
5.Once you are sure the database is down, restore the database datafiles from their backup location to the location where the database files belong.
[oracle@localhost orcl]$ pwd /oracle01/backup/orcl
[oracle@localhost orcl]$ cp *.dbf /oracle01/oradata/orcl/*
6.Mount the database.
[oracle@localhost orcl]$ sqlplus “/ as sysdba”
SQL*Plus: Release 11.1.0.6.0 - Production on Sun Aug 17 17:53:14 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance. SQL> startup mount
ORACLE instance started. |
|
|
Total System Global Area |
167395328 |
bytes |
Fixed Size |
1298612 |
bytes |
Variable Size |
142610252 |
bytes |
Database Buffers |
20971520 |
bytes |
Redo Buffers |
2514944 |
bytes |
Database mounted. |
|
|
700 Appendix A n Lab Exercises
7.Recover the database using the recover database until time command. Use a time that is after the time listed in the second insert in the TIME_TABLE (22:03:59 in our example). In this case, we will recover to 22:04:00. Enter AUTO if prompted for an archived redo log to apply.
SQL> recover database until time ‘2008-08-17:22:04:00’; Media recovery complete.
8.Open the database with the alter database open resetlogs command. Note that once you have done this, you will not be able to recover any data that was entered after the point of the recovery.
SQL> alter database open resetlogs; Database altered.
9.Log into the scott schema. Do a select * from test_table. You should have only two records in the table.
SQL> Connect scott/tiger Connected.
SQL> select * from time_table; COL_ONE
-------------------
08/17/2008 22:03:59 08/17/2008 22:03:59
Lab 3.2: Recovering from Control-File Loss with a Backup Control File
In this lab we will be recovering a database that has experienced the complete loss of its control files. We will be using a backup control file to perform the recovery.
1.Back up the database. Details on how to do a full online database backup are found in Chapter 2. In summary, follow these steps:
a.Put the database in hot backup mode.
b.Copy all database datafiles to a backup location.
c.Take the database out of hot backup mode.
d.Force a log switch. Back up the archived redo logs.
Lab 3.2: Recovering from Control-File Loss with a Backup Control File |
701 |
Here is an example of a backup:
[oracle@localhost orcl]$ sqlplus “/ as sysdba”
SQL*Plus: Release 11.1.0.6.0 - Production on Sun Aug 17 15:35:48 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production With the Partitioning, OLAP, Data Mining
and Real Application Testing options SQL> alter database begin backup; Database altered.
SQL> host cp /oracle01/oradata/orcl/*.dbf /oracle01/backup/orcl SQL> alter database end backup;
Database altered.
SQL> alter system switch logfile; System altered.
SQL> host cp /oracle01/backup/arch/* /oracle01/backup/orcl/* SQL> alter database backup controlfile to trace;
Database altered.
SQL> alter database backup controlfile to ‘/oracle01/oradata/orcl/control1.bak’; Database altered.
2.Find the location of the control files.
SQL> select name from v$controlfile; NAME
--------------------------------------------------------------------------
/oracle01/oradata/orcl/control01.ctl
/oracle01/oradata/orcl/control02.ctl
/oracle01/oradata/orcl/control03.ctl
3.Shut down the database.
SQL> connect sys as sysdba Enter password: Connected.
SQL> shutdown immediate Database closed. Database dismounted.
ORACLE instance shut down.
702 Appendix A n Lab Exercises
4.Remove all control files.
SQL> host rm /oracle01/oradata/orcl/control01.ctl SQL> host rm /oracle01/oradata/orcl/control02.ctl SQL> host rm /oracle01/oradata/orcl/control03.ctl
5.Start up the database. Notice the error resulting from loss of all control files.
SQL> startup
ORACLE instance started. |
|
|
Total System Global Area |
159027200 |
bytes |
Fixed Size |
1298556 |
bytes |
Variable Size |
134221700 |
bytes |
Database Buffers |
20971520 |
bytes |
Redo Buffers |
2535424 |
bytes |
ORA-00205: error in identifying control file, check alert log for more info
6.Copy the backup control file into place.
SQL>Host cp /oracle01/backup/orcl/control.bak /oracle01/oradata/orcl/control01.ctl SQL>Host cp /oracle01/backup/orcl/control.bak /oracle01/oradata/orcl/control02.ctl SQL>Host cp /oracle01/backup/orcl/control.bak /oracle01/oradata/orcl/control03.ctl
7.Mount the database with the alter database mount command.
SQL> alter database mount; Database altered.
8.Recover the database by issuing the recover database using backup controlfile command. Since you have all the online redo logs, you can do a complete recovery. If prompted to recover using archived redo logs, enter AUTO.
SQL> recover database using backup controlfile; ORA-00279: change 5026597 generated at 08/19/2008 16:23:33 needed for thread 1
ORA-00289: suggestion : /oracle01/flash_recovery_area/ORCL/archivelog/2008_08_19/o1_mf_1_10_%u_.arc ORA-00280: change 5026597 for thread 1 is in sequence #10
Specify log: {<RET>=suggested | filename | AUTO | CANCEL} auto
ORA-00308: cannot open archived log
Lab 3.2: Recovering from Control-File Loss with a Backup Control File |
703 |
‘/oracle01/flash_recovery_area/ORCL/archivelog/2008_08_19 /o1_mf_1_10_%u_.arc’
ORA-27037: unable to obtain file status Linux Error: 2: No such file or directory Additional information: 3
ORA-00308: cannot open archived log ‘/oracle01/flash_recovery_area/ORCL/archivelog/2008_08_19 /o1_mf_1_10_%u_.arc’
ORA-27037: unable to obtain file status Linux Error: 2: No such file or directory Additional information: 3
9.(This step is not required if step 8 completed with a message that said media recovery successful.) If you get the error message we got above (you may not), determine which online redo log contains the sequence number needing to be restored by querying V$LOG and V$LOGFILE as shown here.
SQL> select a.group#, a.member, b.sequence# |
|
|
2 from v$logfile a, v$log b |
|
|
3* where a.group#=b.group#; |
|
|
GROUP# MEMBER |
SEQUENCE# |
|
---------- ---------------------------------------- ---------- |
||
1 |
/oracle01/oradata/orcl/redo01.log |
10 |
1 |
/oracle01/oradata/orcl/redo01a.log |
10 |
2 |
/oracle01/oradata/orcl/redo02a.log |
8 |
2 |
/oracle01/oradata/orcl/redo02.log |
8 |
3 |
/oracle01/oradata/orcl/redo03a.log |
9 |
3 |
/oracle01/oradata/orcl/redo03.log |
9 |
In this case, the online redo-log file /oracle01/oradata/orcl/redo01.log contains sequence 10, which we need to restore. Start recovery again, and apply the online redolog file as shown here.
SQL> recover database using backup controlfile; ORA-00279: change 5026597 generated at 08/19/2008 16:23:33 needed for thread 1
ORA-00289: suggestion : /oracle01/flash_recovery_area/ORCL/archivelog/2008_08_19/o1_mf_1_10_%u_.arc ORA-00280: change 5026597 for thread 1 is in sequence #10
Specify log: {<RET>=suggested | filename | AUTO | CANCEL} /oracle01/oradata/orcl/redo01.log
Log applied.
Media recovery complete.