- •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
704 Appendix A n Lab Exercises
10.Open the database with the alter database open resetlogs command. Since you are using a backup control file, you must use the resetlogs command.
SQL> alter database open resetlogs; Database altered.
Lab 3.3: Recovering from Loss of the Current Online Redo Log
In this lab we will be recovering from the loss of the current online redo log. This is perhaps one of the worst-case situations that you would face as an Oracle DBA!
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
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.
Lab 3.3: Recovering from Loss of the Current Online Redo Log |
705 |
2.Determine the location of the online redo logs by querying the MEMBER column of the
V$LOGFILE view.
SQL> select member from v$logfile; MEMBER
--------------------------------------------------------------------------
/oracle01/oradata/orcl/redo03.log
/oracle01/oradata/orcl/redo02.log
/oracle01/oradata/orcl/redo01.log
/oracle01/oradata/orcl/redo01a.log
/oracle01/oradata/orcl/redo02a.log
/oracle01/oradata/orcl/redo03a.log
3.While the database is still running, remove all of the online redo logs.
SQL> host rm /oracle01/oradata/orcl/redo03.log SQL> host rm /oracle01/oradata/orcl/redo02.log SQL> host rm /oracle01/oradata/orcl/redo01.log SQL> host rm /oracle01/oradata/orcl/redo01a.log SQL> host rm /oracle01/oradata/orcl/redo02a.log SQL> host rm /oracle01/oradata/orcl/redo03a.log
Note that this lab is set up to demonstrate recovering a database from an actual crash as a result of the loss of the online redo logs. If the database has not actually crashed, you would issue an alter database checkpoint command and then try an alter database clear logfile command to try to save the database from crashing.
4.If the database is still running, simulate a crash using the shutdown abort command.
SQL> shutdown abort ORACLE instance shut down.
5.Start up the database to see the error you will receive.
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 |
Database mounted. |
|
|
ORA-00313: open failed for members of log group 1 of thread 1
706 Appendix A n Lab Exercises
ORA-00312: online log 1 thread 1: ‘/oracle01/oradata/orcl/redo01a.log’ ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory Additional information: 3
ORA-00312: online log 1 thread 1: ‘/oracle01/oradata/orcl/redo01.log’ ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory Additional information: 3
6.Restore the database from the backup taken in step 1.
[oracle@localhost orcl]$ cp /oracle01/backup/orcl/*.gz . &
7.Mount the database using the startup mount command.
[oracle@localhost orcl]$ sqlplus / as sysdba
SQL*Plus: Release 11.1.0.6.0 - Production on Sun Aug 17 16:26:56 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. |
|
|
8.Using the V$ARCHIVED_LOG, determine the last log sequence number archived.
SQL> select max(sequence#) from v$archived_log 2 where resetlogs_change#=
3 (select max(resetlogs_change#) from v$archived_log); MAX(SEQUENCE#)
--------------
9
9.Recover the database using the recover database until cancel command. Use the last archived redo log sequence number found in step 8 as the sequence to recover to. Once you reach that sequence number, cancel the recovery.
SQL> recover database using backup controlfile until cancel; SQL> recover database until cancel using backup controlfile; ORA-00279: change 5026562 generated at 08/19/2008 16:23:14
Lab 4.1: Creating an RMAN Offline Backup |
707 |
needed for thread 1 ORA-00289: suggestion :
/oracle01/flash_recovery_area/ORCL/archivelog/2008_08_19/ o1_mf_1_9_4bpm2cgp_.arcORA-00280: change 5026562
for thread 1 is in sequence #9
Specify log: {<RET>=suggested | filename | AUTO | CANCEL} 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_4bpm2bt3_.arc
ORA-00280: change 5026597 for thread 1 is in sequence #10 ORA-00278: log file ‘/oracle01/flash_recovery_area/ORCL/archivelog/2008_08_19/ o1_mf_1_9_4bpm2cgp_.arc’ no longer needed for this recovery Specify log: {<RET>=suggested | filename | AUTO | CANCEL} cancel
Media recovery cancelled.
10.Open the database with the alter database open resetlogs command. Your recovery is complete.
SQL> alter database open resetlogs; Database altered.
Lab 4.1: Creating an RMAN
Offline Backup
In this lab, you will be creating an RMAN offline backup. You can back up databases in NOARCHIVELOG or ARCHIVELOG mode with offline backups.
1.Start RMAN.
C:\>rman target=/
Recovery Manager: Release 11.1.0.6.0 - Production on Thu Sep 11 18:58:55 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: ORCL (DBID=1190537904)
708 Appendix A n Lab Exercises
2.Shut down the database from RMAN using the RMAN shutdown immediate command. Then start the database in MOUNT mode with the RMAN startup mount command.
RMAN> shutdown immediate
using target database control file instead of recovery catalog database closed
database dismounted Oracle instance shut down
RMAN> startup mount |
|
|
connected to target database |
(not started) |
|
Oracle instance started |
|
|
database mounted |
|
|
Total System Global Area |
397557760 |
bytes |
Fixed Size |
1333452 |
bytes |
Variable Size |
281020212 |
bytes |
Database Buffers |
109051904 |
bytes |
Redo Buffers |
6152192 |
bytes |
3.Back up the database using the backup command. In this case, we are not going to back up the database archived redo logs if the database is in ARCHIVELOG mode. Since it was shut down in a consistent manner, we don’t need to back up any archived redo logs to restore this backup.
RMAN> Backup database; Starting backup at 11-SEP-08 allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=155 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=C:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF input datafile file number=00001 name=C:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF input datafile file number=00005 name=C:\ORACLE\ORADATA\ORCL\UNDOTBS02.DBF input datafile file number=00004 name=C:\ORACLE\ORADATA\ORCL\USERS01.DBF channel ORA_DISK_1: starting piece 1 at 11-SEP-08
channel ORA_DISK_1: finished piece 1 at 11-SEP-08 piece handle=C:\ORACLE\FLASH_RECOVERY_AREA\ORCL
\BACKUPSET\2008_09_11\O1_MF_NNNDF_TAG20080911T204331_4DMOTSN1_.BKP tag=TAG20080911T204331 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:05:26 Finished backup at 11-SEP-08
Starting Control File and SPFILE Autobackup at 11-SEP-08