- •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 2.2: Putting the Database in ARCHIVELOG Mode |
691 |
Lab 2.2: Putting the Database
in ARCHIVELOG Mode
In this exercise, you will configure the database for ARCHIVELOG mode. You will then actually put the database in ARCHIVELOG mode.
1.Create a directory called c:\oracle\arch\arch.
C:\>mkdir oracle C:\>cd oracle C:\oracle>mkdir arch C:\oracle>cd arch
C:\oracle\arch>mkdir orcl C:\oracle\arch>cd orcl C:\oracle\arch\orcl>
2.Log into your database using SQL*Plus. Check the log mode the database is in by querying the LOG_MODE column in V$DATABASE.
C:\oracle\orabackup\orcl>sqlplus sys as sysdba
SQL*Plus: Release 11.1.0.6.0 - Production on Thu Aug 14 19:37:19 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.
Enter password: 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> select log_mode from v$database; LOG_MODE
------------
NOARCHIVELOG
3.Using the alter system command, set the LOG_ARCHIVE_DEST_1 parameter to point to the new directory you created in step 1.
SQL> Alter system set log_archive_dest_1=’location=c:\oracle\arch\orcl’; System altered.
4.Shut down the database using the shutdown immediate command.
SQL> shutdown immediate Database closed.
692 Appendix A n Lab Exercises
Database dismounted.
ORACLE instance shut down.
5.Put the database in MOUNT mode with the startup mount command. Confirm that the database is in MOUNT mode by querying the OPEN_MODE column in V$DATABASE.
SQL> startup mount
ORACLE instance started. |
|
|
Total System Global Area |
397557760 |
bytes |
Fixed Size |
1333452 |
bytes |
Variable Size |
272631604 |
bytes |
Database Buffers |
117440512 |
bytes |
Redo Buffers |
6152192 |
bytes |
Database mounted. |
|
|
SQL> select open_mode from v$database; OPEN_MODE
----------
MOUNTED
6.Now put the database in ARCHIVELOG mode using the alter database archivelog command.
SQL> alter database archivelog; Database altered.
7.Open the database with the alter database open command. Check the LOG_MODE parameter of the V$DATABASE view to ensure that the database is in ARCHIVELOG mode.
SQL> alter database open; Database altered.
SQL> select log_mode from v$database; LOG_MODE
------------
ARCHIVELOG
8.To ensure that the database is configured correctly, force a log switch.
SQL> Alter system switch logfile; System altered.
9.Now check the directory c:\oracle\arch\orcl to ensure that the archived redo logs are being created correctly.
SQL> Host dir c:\oracle\arch\orcl Volume in drive C has no label.
|
|
Lab 2.3: Executing a Manual Online (Hot) Backup |
693 |
|||
Volume Serial Number is 08DE-E1AB |
|
|
|
|||
Directory of c:\oracle\arch\orcl |
|
|
|
|||
08/14/2008 |
07:48 PM |
<DIR> |
|
. |
|
|
08/14/2008 |
07:48 PM |
<DIR> |
|
.. |
|
|
08/14/2008 |
07:48 PM |
1,024 ARC00003_0662757171.001 |
|
|||
|
1 |
File(s) |
|
1,024 |
bytes |
|
|
2 |
Dir(s) |
12,981,006,336 |
bytes free |
|
Lab 2.3: Executing a Manual
Online (Hot) Backup
In this lab, you will perform an online/hot backup of your database, with the database still running.
1.Create a directory for the backups. In this lab, we use c:\oracle\orabackup\orcl\hot. We assume that the directory structure c:\oracle\orabackup\orcl is already created from the work you did in Lab 2.1.
C:\>cd oracle\orabackup\orcl C:\oracle\orabackup\orcl> mkdir hot
2.Log into your database using SQL*Plus. Check the log mode the database is in by querying the LOG_MODE column in V$DATABASE. It should be in ARCHIVELOG mode.
C:\oracle\orabackup\orcl>sqlplus sys as sysdba
SQL*Plus: Release 11.1.0.6.0 - Production on Thu Aug 14 19:37:19 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.
Enter password: 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> select log_mode from v$database; LOG_MODE
------------
ARCHIVELOG
3.Using the DBA_DATA_FILES view, determine the datafiles that you will need to back up.
SQL> select tablespace_name, file_name from dba_data_files;
694 Appendix A n Lab Exercises
TABLESPACE_NAME FILE_NAME
--------------- ----------------------------------------
USERS C:\ORACLE\ORADATA\ORCL\USERS01.DBF UNDOTBS1 C:\ORACLE\ORADATA\ORCL\UNDOTBS01.DBF SYSAUX C:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF SYSTEM C:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF
4.Using the V$LOG view, determine which sequence is the current online redo log sequence. You must ensure that you have this log sequence and all logs generated during the backup in order to be able to restore the backup.
SQL> select group#, sequence#, status from v$log; GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
14 CURRENT
2 |
2 INACTIVE |
33 INACTIVE
5.Put the database in hot backup mode with the alter database begin backup command.
SQL> alter database begin backup; Database altered.
6.Copy all database datafiles (in our case, they all have an extension of .dbf) to the backup directory created in step 1.
SQL>host C:\oracle\orabackup\orcl>>Copy c:\oracle\oradata\orcl\*.dbf c:\oracle\orabackup\orcl\hot\*.*
c:\oracle\oradata\orcl\SYSAUX01.DBF
c:\oracle\oradata\orcl\SYSTEM01.DBF
c:\oracle\oradata\orcl\TEMP01.DBF
c:\oracle\oradata\orcl\UNDOTBS01.DBF
c:\oracle\oradata\orcl\USERS01.DBF 5 file(s) copied.
7.Using the V$LOG view, determine which sequence is the current online redo log sequence. You must ensure that you have this log sequence and all logs generated during the backup in order to be able to restore the backup. In our case, we need log sequences starting with 4 (the sequence when we started our backup) and continuing through log sequence 7.
SQL> select group#, sequence#, status from v$log;
GROUP# SEQUENCE# STATUS
Lab 2.3: Executing a Manual Online (Hot) Backup |
695 |
---------- ---------- ----------------
17 CURRENT
25 INACTIVE
36 INACTIVE
8.Take the database out of hot backup mode with the alter database end backup command.
SQL> alter database end backup; Database altered.
9.Use the alter system switch logfile command to force a switch from log sequence 7.
SQL> alter system switch logfile;
There may be times when you will need to use the alter system archive log all; command to get the latest archived redo-log files archived in a timely manner.
10.Check the archive-log directory to make sure log-file sequences 4 through 7 have been created. Note that we also checked the LOG_ARCHIVE_FORMAT parameter value. This is so we can know in the filename of the archived redo logs where the sequence number is.
SQL> show parameter log_archive_format |
|
|
||
NAME |
|
TYPE |
VALUE |
|
------------------------------------ ----------- ----------- |
||||
log_archive_format |
string |
ARC%S_%R.%T |
||
SQL> show parameter log_archive_dest_1 |
|
|
||
NAME |
|
TYPE |
VALUE |
|
------------------------------------ -------- |
------------------------- |
|||
log_archive_dest_1 |
string |
location=c:\oracle\arch\orcl |
||
log_archive_dest_10 |
string |
|
||
SQL> host dir c:\oracle\arch\orcl |
|
|
||
Volume in drive C has no label. |
|
|
||
Volume Serial Number is 08DE-E1AB |
|
|
||
Directory of c:\oracle\arch\orcl |
|
|
||
08/16/2008 |
05:25 PM |
<DIR> |
. |
|
08/16/2008 |
05:25 PM |
<DIR> |
.. |
|
08/14/2008 |
07:48 PM |
1,024 |
ARC00003_0662757171.001 |
|
08/15/2008 |
05:01 AM |
49,038,848 |
ARC00004_0662757171.001 |
|
08/15/2008 |
10:12 PM |
48,250,880 |
ARC00005_0662757171.001 |
|
08/16/2008 |
09:00 AM |
48,244,736 |
ARC00006_0662757171.001 |
|
08/16/2008 |
05:25 PM |
34,351,104 |
ARC00007_0662757171.001 |
696 Appendix A n Lab Exercises
5 |
File(s) |
179,886,592 |
bytes |
|
2 |
Dir(s) |
9,701,888,000 |
bytes |
free |
Note in this output that the filename convention has the sequence number of the archived redo log right after the ARC value. Thus we have ARC00003 for log sequence 3, ARC00004 for log sequence 4, and so on. In the preceding output, we appear to have all log sequences that are required to recover this backup.
11.Copy the archived redo logs to the backup location.
SQL> Host copy c:\oracle\arch\orcl\arc*.* c:\oracle\orabackup\orcl\hot\*.* c:\oracle\arch\orcl\ARC00003_0662757171.001 c:\oracle\arch\orcl\ARC00004_0662757171.001 c:\oracle\arch\orcl\ARC00005_0662757171.001 c:\oracle\arch\orcl\ARC00006_0662757171.001 c:\oracle\arch\orcl\ARC00007_0662757171.001
5 file(s) copied.
12.Check the backup directory to ensure that all the files needed are in place.
SQL> Host dir c:\oracle\orabackup\orcl\hot\*.*
Volume in drive C has no label.
Volume Serial Number is 08DE-E1AB
Directory of c:\oracle\orabackup\orcl\hot
08/16/2008 |
05:36 PM |
<DIR> |
. |
08/16/2008 |
05:36 PM |
<DIR> |
.. |
08/14/2008 |
07:48 PM |
1,024 |
ARC00003_0662757171.001 |
08/15/2008 |
05:01 AM |
49,038,848 |
ARC00004_0662757171.001 |
08/15/2008 |
10:12 PM |
48,250,880 |
ARC00005_0662757171.001 |
08/16/2008 |
09:00 AM |
48,244,736 |
ARC00006_0662757171.001 |
08/16/2008 |
05:25 PM |
34,351,104 |
ARC00007_0662757171.001 |
08/15/2008 |
05:40 PM |
594,485,248 |
SYSAUX01.DBF |
08/15/2008 |
05:40 PM |
723,525,632 |
SYSTEM01.DBF |
08/14/2008 |
10:03 PM |
20,979,712 |
TEMP01.DBF |
08/15/2008 |
05:40 PM |
26,222,592 |
UNDOTBS01.DBF |
08/15/2008 |
05:40 PM |
5,251,072 |
USERS01.DBF |
|
10 File(s) |
1,550,350,848 bytes |
|
|
2 Dir(s) |
9,521,692,672 bytes free |
Here is a checklist:
NN |
Datafiles: Check |
NN |
Redo log sequences 4 through 7: Check |