- •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 8.2: Duplicating a Database Using Backup-Based Duplication |
731 |
|
SQL*Plus: Release 11.1.0.6.0 - Production on Sun Oct 5 00:04:02 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> select name, open_mode from v$database; |
|
|
NAME |
OPEN_MODE |
|
--------- |
---------- |
|
AUXDB |
READ WRITE |
|
Lab 8.2: Duplicating a Database Using Backup-Based Duplication to a Different Point in Time
In this exercise, you will use backup-based duplication to create a database on the same system that the target database resides on. For this exercise, your database should be running in ARCHIVELOG mode and all networking to the target database should already be configured.
1.Back up your database as shown in Exercise 4.2.
2.Start RMAN and confirm that you have a valid backup with the list backup of database summary command and the restore database validate command. Note that your output will likely look very different from ours.
C:\Documents and Settings\Robert>rman target=/ Recovery Manager: Release 11.1.0.6.0 - Production on Sat Oct 4 22:56:10 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: ORCL (DBID=1194923408)
RMAN> list backup of database summary;
using target database control file instead of recovery catalog
List of Backups |
|
|
|
|
|
||
=============== |
|
|
|
|
|
||
Key |
TY LV |
S |
Device Type Completion Time #Pieces |
#Copies |
Compressed Tag |
||
------- |
-- -- |
- |
----------- |
--------------- |
------- |
------- |
---------- --- |
2 |
B F |
A |
DISK |
03-OCT-08 |
1 |
1 |
YES |
TAG20081003T135426 |
|
|
|
|
|||
RMAN> restore |
database validate; |
|
|
|
732 Appendix A n Lab Exercises
Starting restore at 04-OCT-08 allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=127 device type=DISK
channel ORA_DISK_1: starting validation of datafile backup set channel ORA_DISK_1: reading from backup piece C:\ORACLE\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2008_10_03 \O1_MF_NNNDF_TAG20081003T135426_4GDY3S9H_.BKP
channel ORA_DISK_1: piece handle=C:\ORACLE\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2008_10_03 \O1_MF_NNNDF_TAG20081003T135426_4GDY3S9H_.BKP tag=TAG20081003T135426 channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:01:36 Finished restore at 04-OCT-08
C:\Documents and Settings\Robert>set oracle_sid=orcl
3.If you are running in Windows, create the service for the new database with oradim. In this example, we are creating a new database instance called neworcl.
C:\>oradim -new -sid neworcl Instance created.
If there are any other OS-specific operations required to create a database instance, complete those now.
4.Create the password file for the neworcl instance.
C:\>orapwd file=c:\oracle\product\11.1.0\db_1\database\pwdneworcl.ora Enter password for SYS:
5.Create a temporary pfile for the neworcl auxiliary instance using your editor of choice. The pfile should be contained in the ORACLE_HOME\database directory of the auxiliary instance and should be named initneworcl.ora. The pfile should have these parameters in it:
db_name=neworcl memory_target=300m
control_files=’c:\oracle\oradata\neworcl\control01.ctl’, ‘c:\oracle\oradata\neworcl\control02.ctl’
We will do the actual file-location conversions during the duplication.
6.Create the directory c:\oracle\oradata\neworcl. mkdir c:\oracle\oradata\neworcl
Lab 8.2: Duplicating a Database Using Backup-Based Duplication |
733 |
7.Start up the auxiliary instance.
C:\oracle\product\11.1.0\db_1\database>set oracle_sid=neworcl C:\oracle\product\11.1.0\db_1\database>sqlplus “/ as sysdba” SQL*Plus: Release 11.1.0.6.0 - Production on Sat Oct 4 23:09:52 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup |
nomount |
|
|
ORACLE instance started. |
|
|
|
Total System |
Global Area |
313860096 |
bytes |
Fixed Size |
|
1332892 |
bytes |
Variable Size |
|
192940388 |
bytes |
Database Buffers |
113246208 |
bytes |
|
Redo Buffers |
|
6340608 |
bytes |
8.Configure service name resolution for your new auxiliary database. The method of this configuration will vary based on your site. In our case, we created an entry in the tnsnames.ora file on our server that looked like this:
NEWORCL = (DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.2)(PORT = 1521)) (CONNECT_DATA =
(SERVER = DEDICATED) (SERVICE_NAME = neworcl)
) )
9.Now you will need to hard-code the instance name into the listener.ora file until the duplication of the database has been completed. You will get network errors if you do not hard-code the auxiliary instance in the listener.ora file. Here’s an example of the entry in our listener.ora:
SID_LIST_LISTENER = (SID_LIST = (SID_DESC =
(ORACLE_HOME=C:\oracle\product\11.1.0\db_1\NETWORK\ADMIN) (SID_NAME=neworcl)
) )
LISTENER = (DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.2)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
) )
734 Appendix A n Lab Exercises
10.Test the network connectivity to the auxiliary instance.
C:\oracle\product\11.1.0\db_1\database>sqlplus sys/robert@neworcl as sysdba SQL*Plus: Release 11.1.0.6.0 - Production on Sat Oct 4 23:17:50 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> select instance_name from v$instance; INSTANCE_NAME
----------------
neworcl
If the connection fails, review the network configuration and ensure that the new auxiliary instance is running.
11.Connect to the ORCL database using the scott account.
C:\Documents and Settings\Robert>sqlplus scott/tiger
SQL*Plus: Release 11.1.0.6.0 - Production on Sat Oct 11 14:43:14 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>
If you are using a new database, you may need to unlock the scott account.
SQL> alter user scott account unlock; User altered.
SQL> alter user scott identified by tiger; User altered.
12.In the scott schema, create a table called DUPE_TABLE.
SQL> create table dupe_table(id number, the_date date); Table created.
13.Insert a record in the DUPE_TABLE table and commit.
SQL> Insert into dupe_table values (1, sysdate); 1 row created.
SQL> commit; Commit complete.
Lab 8.2: Duplicating a Database Using Backup-Based Duplication |
735 |
14.Wait for a minute or so. Insert a second record in the DUPE_TABLE table and commit.
SQL> Insert into dupe_table values (1, sysdate); 1 row created.
SQL> commit; Commit complete.
15.Select from the DUPE_TABLE table.
SQL> select * from dupe_table; ID THE_DATE
---------- -------------------
1 10/11/2008 14:46:14
1 10/11/2008 14:48:25
16.Connect as sys and force a log switch. This is because database duplications from backup will use only archived redo logs to recover a database. Online redo logs are not used. This is not true with active database duplications.
SQL> connect sys/robert as sysdba Connected.
SQL> alter system switch logfile; System altered.
17.Start RMAN and connect to the target and the auxiliary databases.
C:\oracle\product\11.1.0\db_1\database>Set oracle_sid=orcl C:\oracle\product\11.1.0\db_1\database>Rman target=/ auxiliary=sys/Robert@neworcl
Recovery Manager: Release 11.1.0.6.0 - Production on Sat Oct 4 23:19:55 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: ORCL (DBID=1194923408) connected to auxiliary database: NEWORCL (not mounted)
18.We are now ready to start the database duplication. Issue the duplicate database command, recovering the database to a time in between the two insert records. We recommend you recover to about 5 seconds before the second record, as shown here:
duplicate target database to neworcl
until time “to_date(‘10/11/2008 14:48:20’,’mm/dd/yyyy hh24:mi:ss’)“ nofilenamecheck
spfile set control_files= ‘c:\oracle\oradata\neworcl\control01.ctl’,
736 Appendix A n Lab Exercises
‘c:\oracle\oradata\neworcl\control02.ctl’ set db_file_name_convert
’c:\oracle\oradata\orcl’,’c:\oracle\oradata\neworcl’ set log_file_name_convert ’c:\oracle\oradata\orcl’,’c:\oracle\oradata\neworcl’;
This command does the following:
NN |
It starts the duplication process. |
NNIt starts the duplication process restoring the database to the specific point in time using backups of the database and archived redo logs. The restore will be to the point in time listed in the until time clause.
NNThe SPFILE parameter will result in the target database spfile being copied over to the duplicate database. The duplicate database will use this spfile.
NNThe set commands (set control_files, set db_file_name_convert, and set log_file_name_convert) modify or add parameters to the spfile being copied to the duplicate database.
This duplicate command will result in a great deal of output, which we have decided not to include here as it seems a great waste of a perfectly good tree. Here is the output that you hopefully will see at the end of the database duplication:
database opened
Finished Duplicate Db at 04-OCT-08
19.Connect to the duplicated database to verify that it is open.
C:\oracle\product\11.1.0\db_1\database>set oracle_sid=neworcl C:\oracle\product\11.1.0\db_1\database>sqlplus sys/Robert as sysdba SQL*Plus: Release 11.1.0.6.0 - Production on Sun Oct 5 00:04:02 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> select name, open_mode from v$database;
NAME |
OPEN_MODE |
--------- |
---------- |
AUXDB |
READ WRITE |
20.Connect to the scott schema. Query the DUPE_TABLE and ensure that only one record now exists.
SQL> connect scott/tiger Connected.