Professional Documents
Culture Documents
D50079GC12 sg1
D50079GC12 sg1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
t r a ns
Oracle Database 11g: o n -
an
Administrations Workshop II
h a ฺ
m ) u i de
o tG
ilฺIc• Student
g m tuden Guide
a
Volume
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
D50079GC12
Edition 1.2
April 2009
D59862
Computer Pride Limited
Tom Best This document contains proprietary information and is protected by copyright and
Donna Keesling other intellectual property laws. You may copy and print this document solely for your
own use in an Oracle training course. The document may not be modified or altered in
James Spiller any way. Except where your use constitutes "fair use" under copyright law, you may
not use, share, download, upload, copy, print, display, perform, reproduce, publish,
Maria Billings
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
license, post, transmit, or distribute this document in whole or in part without the
Gwen Lazenby express authorization of Oracle.
The information contained in this document is subject to change without notice. If you
Technical Contributors find any problems in the document, please report them in writing to: Oracle University,
and Reviewers 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
warranted to be error-free.
Sharath Bhujani
Restricted Rights Notice
Timothy Chien
Al Flournoy If this documentation is delivered to the United States Government or anyone using
the documentation on behalf of the United States Government, the following notice is
Andy Fortunak applicable:
Gerlinde Frenzen
U.S. GOVERNMENT RIGHTS
ble
Joel Goodman The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or
disclose these training materials are restricted by the terms of the applicable Oracle
fe r a
Magnus Isaksson license agreement and/or the applicable U.S. Government contract.
an s
Pete Jones
n - t r
no
Trademark Notice
Pierre Labrousse
Jerry Lee s a
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other
h a eฺ
names may be trademarks of their respective owners.
)
Hakan Lindfors
m i d
Isabelle Marchand
i l ฺ co nt Gu
Srinivas Putrevu
m a de
Andreas Reinhardt
i @ g S tu
Ira Singer
s y uk this
( M a use
Editors
y u ki se to
Arijit Ghosh as en
M
y Narasimhan
Vijayalakshmi l i c
l e
n Narayan
Sta
Amitha
Atanu Raychaudhuri
Richard Wallis
Graphic Designer
Rajiv Chandrabhanu
Publishers
Pavithran S Adka
Nita Brozowski
Jobi Varghese
Giri Venugopal
Computer Pride Limited
Contents
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
yM li
SYSASM Role 1-26
nle Accessing an ASM Instance 1-27
Sta Using Enterprise Manager to Manage ASM Users 1-28
Shutting Down an ASM Instance 1-29
ASM Storage: Concepts 1-30
ASM Disk Group 1-31
Failure Group 1-33
Disk Group Mirroring 1-34
Disk Group Dynamic Rebalancing 1-35
Managing Disk Groups 1-36
Creating and Dropping Disk Groups 1-37
Adding Disks to Disk Groups 1-38
ASM Disk Group Compatibility 1-39
ASM Disk Group Attributes 1-41
Using Enterprise Manager to Edit Disk Group Attributes 1-42
iii
Computer Pride Limited
iv
Computer Pride Limited
a syu cense
Summary 3-36
yM li
Practice 3 Overview: Using the RMAN Recovery Catalog 3-37
nle
Sta 4 Configuring Backup Specifications
Objectives 4-2
Using RMAN to Create Backups 4-3
Backup Destinations 4-4
Configuring Persistent Settings for RMAN 4-5
Using Enterprise Manager to Configure RMAN Settings 4-6
Control File Autobackups 4-7
Managing Persistent Settings 4-9
Configuring Devices for Backup 4-10
Configuring and Allocating Channels for Use in Backups 4-12
Configuring Backup Optimization 4-13
Summary 4-15
Practice 4 Overview: Configuring Backup Specifications 4-16
v
Computer Pride Limited
syu cense
Using a Media Manager 5-30
a
yM li
Performing Proxy Copies 5-32
n le
Creating an Oracle-Suggested Backup 5-33
Sta Managing Backups: Reporting 5-34
Managing Backups: Dynamic Performance Views 5-36
Using Enterprise Manager to View Backup Reports 5-37
Managing Backups: Cross-Checking and Deleting 5-38
Summary 5-39
Practice 5 Overview: Creating Backups 5-40
vi
Computer Pride Limited
a syu cense
Choosing an Incomplete Recovery Method 6-37
yM li
Performing User-Managed Incomplete Recovery 6-38
nle Performing User-Managed Incomplete Recovery: Steps 6-40
Sta User-Managed Time-Based Recovery: Example 6-41
User-Managed Cancel-Based Recovery: Example 6-43
Recovering a Read-Only Tablespace 6-45
Recovering NOLOGGING Database Objects 6-46
Recovering from the Loss of All Control File Copies: Overview 6-47
Recovering the Control File to the Default Location 6-48
Summary 6-49
Practice 6 Overview: Performing User-Managed Recovery 6-50
vii
Computer Pride Limited
viii
Computer Pride Limited
Summary 8-21
Practice 8 Overview: Using RMAN to Duplicate a Database 8-22
Objectives 9-2
Tablespace Point-in-Time Recovery (TSPITR): Concepts 9-3
Tablespace Point-in-Time Recovery (TSPITR): Terminology 9-4
Tablespace Point-in-Time Recovery: Architecture 9-5
When to Use TSPITR 9-7
Preparing for TSPITR 9-8
Determining the Correct Target Time 9-9
Determining the Tablespaces for the Recovery Set 9-10
Identifying Objects That Will Be Lost 9-11
Performing Basic RMAN TSPITR 9-12 ble
Performing Fully Automated TSPITR 9-13 fe r a
ans
Using Enterprise Manager to Perform TSPITR 9-14
n - t r
RMAN TSPITR Processing 9-15
a no
s
Performing RMAN TSPITR with an RMAN-Managed Auxiliary Instance 9-17
a
) h d eฺ
Performing RMAN TSPITR Using Your Own Auxiliary Instance 9-18
i
m
co nt Gu
Troubleshooting RMAN TSPITR 9-19
i l ฺ
Summary 9-20
g ma tude
u k i@ is S
Practice 9 Overview: Performing TSPITR 9-21
a sy se th
10 Monitoring and
i (M u
Tuning RMAN
t o
k
yu 10-2
Objectives se
a s e n
y M l ic of Backup Sets 10-3
Parallelization
ix
Computer Pride Limited
syu cense
Flashback Query: Example 11-18
a
yM li
Flashback Version Query 11-19
n le
Using Enterprise Manager to Perform Flashback Version Query 11-20
Sta Flashback Version Query: Considerations 11-21
Flashback Transaction Query 11-22
Using Enterprise Manager to Perform Flashback Transaction Query 11-23
Flashback Transaction Query: Considerations 11-24
Flashback Transaction 11-25
Prerequisites 11-26
Flashing Back a Transaction 11-27
Possible Workflow 11-28
Viewing Data 11-29
Flashback Transaction Wizard 11-30
Choosing Other Back-out Options 11-34
Final Steps Without EM 11-36
x
Computer Pride Limited
Summary 11-37
Practice 11 Overview: Performing Flashback Database 11-38
Objectives 12-2
Flashback Table: Overview 12-3
Flashback Table 12-4
Enabling Row Movement on a Table 12-5
Performing Flashback Table 12-6
Flashback Table: Considerations 12-7
Flashback Database 12-8
Flashback Database Architecture 12-9
Configuring Flashback Database 12-10
Configuring Flashback Database Using EM 12-11 ble
Flashback Database: Examples 12-13 fe r a
ans
Performing Flashback Database Using EM 12-14
n - t r
Flashback Database Considerations 12-17
a no
Monitoring Flashback Database 12-18
a s
) h
Monitoring Flashback Database with EM 12-20 i d eฺ
m
co nt Gu
i l ฺ
Guaranteed Restore Points 12-21
ma tude
Flashback Database and Guaranteed Restore Points 12-22
g
u k i@ is S
Flashback Data Archive 12-24
sy se th
Flashback Data Archive Process 12-25
a
k i (M to u
Flashback Data Archive Scenario 12-26
syu cense
Viewing Flashback Data Archives 12-28
a
yM li
Flashback Data Archive DDL Restrictions 12-29
xi
Computer Pride Limited
syu cense
Verifying Block Integrity in Real Time: DB_BLOCK_CHECKING 13-39
a
yM li
Block Media Recovery 13-40
le
Prerequisites for Block Media Recovery 13-41
n
Sta The RECOVER...BLOCK Command 13-42
Data Recovery Advisor 13-43
Data Recovery Advisor: RMAN Command-Line Interface 13-44
Listing of Data Failures 13-45
Advising on Repair 13-47
Executing Repairs 13-48
Classifying (and Closing) Failures 13-49
Data Recovery Advisor Views 13-50
Summary 13-51
Practice 13 Overview: Diagnosing the Database 13-52
14 Managing Memory
Objectives 14-2
Memory Management: Overview 14-3
xii
Computer Pride Limited
syu cense
Enabling Automatic Memory Management with EM 14-33
a
yM li
Monitor Automatic Memory Management 14-34
xiii
Computer Pride Limited
syu cense
System Architecture: Capture 15-39
a li
System Architecture: Processing the Workload 15-40
yM
le
System Architecture: Replay 15-41
n
Sta The Big Picture 15-42
Workloads Supported 15-43
Using Enterprise Manager for Workload Capture 15-44
Using Enterprise Manager for Workload Replay 15-45
Summary 15-46
Practice 15 Overview: Monitor Instance Performance 15-47
16 Space Management
Objectives 16-2
Space Management: Overview 16-3
Free Space Management Within Segments 16-4
Types of Segments 16-5
Allocating Extents 16-6
Block Space Management 16-7
xiv
Computer Pride Limited
syu cense
Database Transportation Procedure: Source System Conversion 16-37
a
yM li
Database Transportation Procedure: Target System Conversion 16-38
17 Managing Resources
Objectives 17-2
Database Resource Manager: Overview 17-3
Database Resource Manager: Concepts 17-4
Why Use Resource Manager 17-5
Accessing Resource Plans 17-7
Default Maintenance Resource Manager Plan 17-8
Example: DEFAULT_PLAN 17-9
Creating a New Resource Plan 17-10
Creating Consumer Groups 17-11
Assigning Users to Consumer Groups 17-12
xv
Computer Pride Limited
syu cense
Creating a Time-Based Job 18-11
a li
Persistent Lightweight Jobs 18-13
yM
le
Choosing the Right Job 18-14
n
Sta Creating a Single Lightweight Job 18-16
Creating an Event-Based Schedule 18-17
Creating Event-Based Schedules with Enterprise Manager 18-18
Creating an Event-Based Job 18-19
Event-Based Scheduling 18-20
Creating Complex Schedules 18-22
Creating Job Chains 18-23
Example of a Chain 18-25
1. Creating a Chain Object 18-26
2. Defining Chain Steps 18-27
3. Defining Chain Rules 18-28
4. Starting the Chain 18-29
Monitoring Job Chains 18-30
xvi
Computer Pride Limited
Summary 18-31
Practice 18 Overview: Automating Tasks with the Scheduler 18-32
Objectives 19-2
Advanced Scheduler Features 19-3
Job Classes 19-4
Creating a Job Class 19-6
Windows 19-7
Creating a Window 19-8
Prioritizing Jobs Within a Window 19-10
Creating an Array of Lightweight Jobs 19-11
Creating Lightweight Jobs 19-12
Viewing Lightweight Jobs in Dictionary 19-14 ble
PL/SQL APIs 19-15 fe r a
ans
Generic Scheduler Data Dictionary Views 19-16
n - t r
Summary 19-18
a no
a s
20 Globalization ) h i d eฺ
m
co nt Gu
Objectives 20-2
i l ฺ
ma tude
Globalization Support Features 20-3
g
What Every DBA Needs to Know
u k i@ 20-4is S
sy 20-5
What Is a Character Set?
a e th
M to20-7
Understanding (Unicode
i us
How Arey k sSets
uCharacter e Used? 20-9
a s
Problems toic e n
Avoid 20-10
y M l
nle Another Sample Problem 20-11
Sta Choosing Your Character Set 20-12
Database Character Sets and National Character Sets 20-13
Obtaining Character Set Information 20-14
Specifying Language-Dependent Behavior 20-15
Specifying Language-Dependent Behavior for the Session 20-16
Language-Dependent and Territory-Dependent Parameters 20-17
Specifying Language-Dependent Behavior 20-19
Linguistic Searching and Sorting 20-20
Using Linguistic Searching and Sorting 20-22
Case-Insensitive and Accent-Insensitive Search and Sort 20-24
Support in SQL and Functions 20-25
Linguistic Index Support 20-26
Customizing Linguistic Searching and Sorting 20-27
Implicit Conversion Between CLOB and NCLOB 20-29
xvii
Computer Pride Limited
Summary 20-35
Practice 20 Overview: Using Globalization Support 20-36
Appendix A
Index
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
xviii
Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
The Oracle Database k i
a s yu ense
A database isM
y lic of data treated as a unit. The purpose of a database is to store and
a collection
e information.
nlrelated
retrieve
t a
S Oracle Database reliably manages a large amount of data in a multiuser environment so
An
that many users can concurrently access the same data. This is accomplished while delivering
high performance. At the same time, the database prevents unauthorized access and provides
efficient solutions for failure recovery.
Library
Database cache
Redo log
buffer
buffer
cache Data dictionary
cache
PGA
Server
process DBWn CKPT LGWR ARCn
ble
fe r a
ans
n - t r
n o
User
a
sArchived
Control Online )
redoh a eฺ
log files
process
logm i d
co nt Gu
Data files files files
Database i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Oracle Database Architecture i
a s yu ense
An Oracle database
y M server lic consists of an Oracle database and one or more database
t a nle instance consists of memory structures and background processes. Every time an
instances.The
S
instance is started, a shared memory area called the System Global Area (SGA) is allocated
and the background processes are started.
The database consists of both physical structures and logical structures. Because the physical
and logical structures are separate, the physical storage of data can be managed without
affecting access to logical storage structures.
an instance
• Session: Specific connection of a user to an instance
through a user process
ble
Session fe r a
USER
SQL> Select … User
ans
n - t r
a no
a s
) h i d eฺ
Connection o m
c nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Connecting to the Databasei
a s yu ense
M sessionlicare closely related to user process but are very different in meaning.
Connection and
y
t a nle is a communication pathway between a user process and an Oracle Database
A connection
S
instance. A communication pathway is established using available interprocess communication
mechanisms (on a computer that runs both the user process and Oracle Database) or network
software (when different computers run the database application and Oracle Database, and
communicate through a network).
A session represents the state of a current user login to the database instance. For example,
when a user starts SQL*Plus, the user must provide a valid username and password, and then a
session is established for that user. A session lasts from the time the user connects until the
time the user disconnects or exits the database application.
Multiple sessions can be created and exist concurrently for a single Oracle Database user who
is using the same username. For example, a user with the username/password of HR/HR can
connect to the same Oracle Database instance several times.
Library
Database cache
User Server Redo log
process process buffer
buffer
cache Data dict.
cache
Database
ble
fe r a
Storage structures an s
n - t r
a no
a s
) h i d eฺ
m
o Control G u Online redo
Data files ilฺc n t
files log files
a e
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Database Structures
y u ki se to
After startingM
s cethen Oracle software associates the instance with a specific database.
anainstance,
li
l ey mounting the database. The database is then ready to be opened, which makes it
This isncalled
Sta to authorized users. Multiple instances can execute concurrently on the same
accessible
computer, each accessing its own physical database.
You can look at the Oracle Database architecture as various interrelated structural
components.
An Oracle instance uses memory structures and processes to manage and access the database.
All memory structures exist in the main memory of the computers that constitute the database
server. Processes are jobs that work in the memory of these computers. A process is defined as
a “thread of control” or a mechanism in an operating system that can run a series of steps.
Library Other
cache
ble
Redo log Shared pool
fe r a
buffer
Free ans
Database buffer I/O Buffer
memory n - t r
cache
Response a no
Request
a s
Java Streams queue
h queue
)Large pool
i d eฺ
pool pool m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Oracle Memory Structures k i
a s yu ense
M createslicand uses memory structures for various purposes. For example,
Oracle Database
y
memory
t a nlestores program code being run, data shared among users, and private data areas for
S connected user.
each
Two basic memory structures are associated with an instance:
• The System Global Area (SGA) is a group of shared memory structures, known as SGA
components, that contain data and control information for one Oracle Database instance.
The SGA is shared by all server and background processes. Examples of data stored in the
SGA include cached data blocks and shared SQL areas.
• The Program Global Areas (PGAs) are memory regions that contain data and control
information for a server or background process. A PGA is nonshared memory created by
Oracle Database when a server or background process is started. Access to the PGA is
exclusive to the server process. Each server process and background process has its own
PGA.
• Shared pool: Caches various constructs that can be shared among users
• Large pool: Is an optional area that provides large memory allocations for certain large
processes, such as Oracle backup and recovery operations, and I/O server processes
• Java pool: Is used for all session-specific Java code and data within the Java Virtual
Machine (JVM)
• Streams pool: Is used by Oracle Streams to store information required by capture and
apply
When you start the instance by using Enterprise Manager or SQL*Plus, the amount of memory
allocated for the SGA is displayed.
a b le
f
A Program Global Area (PGA) is a memory region that contains data and control information
s er
- r an server
for each server process. An Oracle server process services a client’s requests. tEach
process has its own private PGA that is created when the server process is
n onstarted. Access to
the PGA is exclusive to that server process, and the PGA is read and
s awritten only by the
Oracle code acting on its behalf. a
) h uideฺ
m
o t buffer
G cache, the shared pool,
a ilฺcdatabase
With the dynamic SGA infrastructure, the size of the
n
the large pool, the Java pool, and the Streams
g m de without shutting down the
pool changes
t u
instance.
u k i@ is S
The Oracle database uses initialization
a e th to create and configure memory structures.
sy parameters
i (
For example, the MEMORY_TARGET us
M to parameter specifies the Oracle systemwide usable
u k e
memory, and the Oracle
a e ns tunes memory to the MEMORY_TARGET value, reducing or
sy cdatabase
yM
enlarging the SGA andliPGA components as needed.
n le
Sta
Process Architecture
• User process
– Is started when a database user or a batch process connects
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
to Oracle Database
• Database processes
– Server process: Connects to the Oracle instance and is
started when a user establishes a session
– Background processes: Are started when an Oracle instance
is started Instance
SGA Shared pool
ble
Library
fe r a
Database
buffer
Redo log cache
t r a ns
cache
buffer
o n
Data
-dictionary
PGA
a n cache
s
haprocesses
User
process
Server
process )
Background i d eฺ
m
o tSMON
CKPT ฺcLGWR G u PMON ARCn Others
DBWn
i l
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Process Architecture k i
a s yu ense
lic Database system can be categorized into two major groups:
The processesMin an Oracle
y
t a nleprocesses that run the application or Oracle tool code.
• User
S• Oracle Database processes that run the Oracle database server code. They include server
processes and background processes.
When a user runs an application program or an Oracle tool such as SQL*Plus, Oracle Database
creates a user process to run the user’s application. Oracle Database also creates a server
process to execute the commands issued by the user process. In addition, the Oracle server
also has a set of background processes for an instance that interact with each other and with
the operating system to manage the memory structures and asynchronously perform I/O to
write data to disk, and perform other required tasks.
The process structure varies for different Oracle Database configurations, depending on the
operating system and the choice of Oracle Database options. The code for connected users can
be configured as a dedicated server or a shared server.
• With dedicated server, for each user, the database application is run by a user process that
is served by a dedicated server process that executes Oracle database server code.
• A shared server eliminates the need for a dedicated server process for each connection. A
dispatcher directs multiple incoming network session requests to a pool of shared server
processes. A shared server process serves any client request.
Oracle Database 11g: Administration Workshop II 1 - 9
Computer Pride Limited
Process Structures
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
a b le
Some background processes are created automatically when an instance is started, while others
r
are started as required.
nsfe
n - tra
o
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
ki this
s y u
( M a u se
y u ki se to
M as licen
le y
n
Sta
ble
fe r a
Parameter file Backup files
ns
Archived redo log
files-tra
n on
s a
a
) h uideฺ
m
Password file Alerta lฺcoandentrace
ilog t G files
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Oracle Database Storage
y u ki Architecture
s e
The files thatM as licaneOracle
constitute
n database are organized into the following:
l ey files: Contain data about the database itself (that is, physical database structure
• Control
n
Stainformation). These files are critical to the database. Without them, you cannot open data
files to access the data within the database.
• Data files: Contain the user or application data of the database, as well as metadata and
the data dictionary
• Online redo log files: Allow for instance recovery of the database. If the database server
crashes and does not lose any data files, then the instance can recover the database with
the information in these files.
The following additional files are important to the successful running of the database:
• Parameter file: Is used to define how the instance is configured when it starts up
• Password file: Allows sysdba/sysoper/sysasm to connect remotely to the instance
and perform administrative tasks
• Backup files: Are used for database recovery. You typically restore a backup file when a
media failure or user error has damaged or deleted the original file.
• Archived redo log files: Contain an ongoing history of the data changes (redo) that are
generated by the instance. Using these files and a backup of the database, you can recover
a lost data file. That is, archive logs enable the recovery of restored data files.
chronological log of messages and errors. It is recommended that you review the alert log
periodically.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Logical Physical
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Database
Segment
ble
fe r a
Extent ans
n - t r
a no
Oracle data h a s ฺ
) i
OS d eblock
block m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Logical and Physical k i
u nse Structures
Database
s y
alogical e
The databaseM
y
has l i cstructures and physical structures.
t a nle
Tablespaces
S
A database is divided into logical storage units called tablespaces, which group related logical
structures together. For example, tablespaces commonly group all of an application’s objects
to simplify some administrative operations. You may have a tablespace for application data
and an additional one for application indexes.
Databases, Tablespaces, and Data Files
The relationship among databases, tablespaces, and data files is illustrated in the slide. Each
database is logically divided into one or more tablespaces. One or more data files are explicitly
created for each tablespace to physically store the data of all logical structures in a tablespace.
If it is a TEMPORARY tablespace, then instead of a data file, the tablespace has a temporary
file.
ble
Data file 1 Data file 2 fe r a
ans
n - t r
a no
a s
USERS tablespace
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Tablespaces and Data k i
Files
a s yu ense
A database isM
y lic logical storage units called tablespaces, which can be used to group
divided into
le structures together. Each database is logically divided into one or more
relatednlogical
a
S t
tablespaces. One or more data files are explicitly created for each tablespace to physically
store the data of all logical structures in a tablespace.
Note: You can also create bigfile tablespaces. These tablespaces can have only a single file,
which is often very large. The file may be any size up to maximum that the row ID
architecture will permit. The maximum size is the block size for the tablespace times 2 to the
36th power, or 128 TB for a 32 KB block size. The traditional smallfile tablespaces (which are
the default) usually contain multiple data files, but the files cannot be as large. For more
information about the bigfile tablespaces, see the Database Administrator’s Guide.
tablespaces.
• They are created at the time of database creation.
• The SYSTEM tablespace is used for core functionality (for
example, data dictionary tables).
• The auxiliary SYSAUX tablespace is used for additional
database components (such as the Enterprise Manager
Repository). e
r a bl
s fe
- t r an
n no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
k i (M e to u
SYSTEM and SYSAUXuTablespaces
asy must e n s
Each Oracle M
y
database lic contain a SYSTEM tablespace and a SYSAUX tablespace. They are
t a nle created when the database is created. The system default is to create a smallfile
automatically
S
tablespace. You can also create bigfile tablespaces, which enable the Oracle database to
manage ultralarge files.
A tablespace can be online (accessible) or offline (not accessible). The SYSTEM tablespace is
always online when the database is open. It stores tables that support the core functionality of
the database, such as the data dictionary tables.
The SYSAUX tablespace is an auxiliary tablespace to the SYSTEM tablespace. The SYSAUX
tablespace stores many database components, and it must be online for the correct functioning
of all database components.
Note: The SYSAUX tablespace may be taken offline to do tablespace recovery, whereas this is
not possible for SYSTEM tablespace. Neither of them may be made read-only.
bl e
fe r a
ans
n - t r
a no
Segment Extents Data
h a s ฺ Disk
blocks ) id e blocks
o m G u
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Segments, Extents,uand
y ki Blockss e
Database objects,
M assuchliascetables
n and indexes, are stored as segments in tablespaces. Each
segment l y
econtains one or more extents. An extent consists of contiguous data blocks, which
t a n
S that each extent can exist only in one data file. Data blocks are the smallest unit of I/O
means
in the database.
When the database requests a set of data blocks from the operating system (OS), the OS maps
this to an actual file system or disk block on the storage device. Because of this, you need not
know the physical address of any of the data in your database. This also means that a data file
can be striped or mirrored on several disks.
The size of the data block is defined by the DB_BLOCK_SIZE parameter. The default size of
8 KB is adequate for most databases. If your database supports a data warehouse application
that has large tables and indexes, then a larger block size may be beneficial.
If your database supports a transactional application where reads and writes are random, then
specifying a smaller block size may be beneficial. The maximum block size depends on your
OS.
You can have tablespaces with a nonstandard block size. For details, see the Database
Administrator’s Guide.
Database Architecture:
Summary of Structural Components
• Memory structures:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
You can increase the speed of a rebalance operation, or lower it to reduce the impact on the
I/O subsystem. ASM provides mirroring protection without the need to purchase a third-party
Logical Volume Manager. One unique advantage of ASM is that the mirroring is applied on a
file basis, rather than on a volume basis. Therefore, the same disk group can contain a
combination of files protected by mirroring, along with those that are not protected at all.
ASM supports data files, log files, control files, archive logs, temp files, archive log files,
SPFILEs, RMAN backup sets, and other Oracle database file types. ASM supports Real
Application Clusters and eliminates the need for a Cluster Logical Volume Manager or a
Cluster File System.
ra ble
fe
a ns
o n -tr
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
ki this
s y u
( M a u se
y u ki se to
M as licen
ley
n
Sta
DB instance
SID=SALES
ASM RBAL
DBW0 ASMB
instance
ARB0
FG
SID=+ASM …
RBAL
ARBA
GMON
bl e
fe r a
ans
n - t r
n o
ASM disks ASM disks ASM disks ASM disks ASM disks
s a ASM disks
a
) h uideฺ
m
o t disk G group 2
ASM disk group 1
a ilฺc eASM n
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
ASM: General Architecture
y u ki se to
To use ASM,M youasmustlistart
c ena special instance, called an ASM instance, before you start your
database l y
einstance. ASM instances do not mount databases, instead they manage the metadata
t a n
S to make ASM files available to ordinary database instances. Both ASM instances and
needed
database instances have access to some common set of disks called disk groups. Database
instances access the contents of ASM files directly, communicating with an ASM instance
only to get information about the layout of these files.
An ASM instance starts several background processes specific to ASM. One process
coordinates rebalance activity for disk groups. It is called RBAL. The second one performs the
actual rebalance AU movements. There can be many of these at a time, and they are called
ARB0, ARB1, and so forth. The GMON process, or Group Monitor, is used for partner and
status table, and node membership. An ASM instance also has some of the same background
processes as a database instance, including SMON, PMON, LGWR, DBWR, and CKPT.
Each database instance using ASM has two extra background processes called ASMB and
RBAL. RBAL performs global opens of the disks in the disk groups. At database instance
startup, ASMB connects as a foreground process to the ASM instance. Communication between
the database and the ASM instance is performed via this bridge. This includes physical file
changes such as data file creation and deletion. Over this connection, periodic messages are
exchanged to update statistics and to verify that both instances are healthy.
Oracle Database 11g: Administration Workshop II 1 - 22
Computer Pride Limited
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Creating an ASM Instance k i
a s yu ense
lic by running the Database Configuration Assistant (DBCA). On
You create anMASM instance
y
t a nle
the first page, select the Configure Automatic Storage Management option, and then follow
S steps. The ASM instance is created and started for you. Then you are guided through the
the
process of defining disk groups for the instance.
As part of the ASM instance creation process, the DBCA automatically creates an entry into
the oratab file. This entry is used for discovery purposes. On the Windows platform where a
services mechanism is used, the DBCA automatically creates an Oracle Service and the
appropriate registry entry to facilitate the discovery of ASM instances. In addition, you are
prompted to run the localconfig script that configures Cluster Synchronization Services
to manage the ASM instance. When an ASM instance is configured, the DBCA creates an
ASM instance parameter file and an ASM instance password file.
If you were to create an ASM-enabled database, the DBCA determines whether an ASM
instance already exists on your host. If ASM instance discovery returns an empty list, the
DBCA creates a new ASM instance.
INSTANCE_TYPE = ASM
DB_UNIQUE_NAME = +ASM
ASM_POWER_LIMIT = 1
ASM_DISKSTRING = '/dev/rdsk/*s2', '/dev/rdsk/c1*'
ASM_DISKGROUPS = dgroupA, dgroupB
SPFILE = '$ORACLE_HOME/dbs/spfile+ASM.ora'
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
ASM Instance Initialization
u nsParameters
e
a s y e
An ASM instance
y lic
M is controlled by a parameter file in the same way as a regular database
$ export ORACLE_SID='+ASM'
$ sqlplus /nolog
SQL> CONNECT / AS sysasm
Connected to an idle instance.
SQL> STARTUP;
Total System Global Area 284565504 bytes
Fixed Size 1299428 bytes
ble
Variable Size 258100252 bytes
fe r a
ASM Cache 25165824 bytes ans
n - t r
ASM diskgroups mounted
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Starting Up an ASMuInstancek i (M e to u
a systartede n s
ASM instances
y M are lic similarly to database instances except that the initialization
parameter
a n le file contains the entry INSTANCE_TYPE=ASM. When this parameter is set to the
t
value
S ASM, it informs the Oracle executable that an ASM instance is starting, not a database
instance. Also, the ORACLE_SID variable must be set to the ASM instance name. When the
ASM instance starts up, the mount stage attempts to mount the disk groups specified by the
ASM_DISKGROUPS initialization parameter rather than mounting a database, as is done with
non-ASM instances.
Other STARTUP clauses have comparable interpretation for ASM instances as they do for
database instances. The list below describes how ASM interprets STARTUP command
parameters.
• FORCE: Issues a SHUTDOWN ABORT to the ASM instance before restarting it.
• MOUNT or OPEN: Mounts the disk groups specified in the ASM_DISKGROUPS
initialization parameter. This is the default if no command parameter is specified.
• NOMOUNT: Starts up the ASM instance without mounting any disk groups.
• RESTRICT: Starts up an instance in restricted mode that enables access only to users
with both the CREATE SESSION and RESTRICTED SESSION system privileges. The
RESTRICT clause can be used in combination with the MOUNT, NOMOUNT, and OPEN
clauses.
SYSASM Role
As SYSASM
ASM
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
or SYSDBA
instance As SYSOPER
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using Enterprise Managerk i
u nstoeManage ASM Users
s y
a allows eyou to manage the users who access the ASM instance through
Enterprise Manager
M l i c
remote n l ey
connection (using password file authentication). These users are reserved exclusively
t a
S the ASM instance.
for
You have this functionality only when you are connected as the SYSASM user. It is hidden if
you connect as SYSDBA or SYSOPER users.
• When you click the Create button, the Create User page is displayed.
• When you click the Edit button the Edit User page is displayed.
• By clicking the Delete button, you can delete the created users.
Note: Oracle Database 11g adds the SYSASM role to the ASM instance login page.
ASM
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Database
disk group
File-system ble
Extent
fe r a
file Allocation unit s
or - t r an
raw device n no
Oracle a
sPhysical
block
) h a eฺ
m i d
i l ฺ co nt Gu block
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
ASM Storage: Concepts k i
a s yu ense
ASM does not
y Meliminatelicany existing database functionality. Existing databases are able to
t a nlase they always have. New files may be created as ASM files, whereas existing ones are
operate
S
administered in the old way or can be migrated to ASM.
The diagram illustrates the relationships between the various storage components inside an
Oracle database. The left and center parts of the diagram show the relationships that exist in
previous releases. The right part of the diagram shows related ASM concepts. However, these
ASM concepts are used only to describe file storage and do not replace any existing concepts
such as segments and tablespaces. With ASM, database files can now be stored as ASM files.
At the top of the new hierarchy, you can find what are called ASM disk groups. Any single
ASM file is contained in only one disk group. However, a disk group may contain files
belonging to several databases, and a single database may use storage from multiple disk
groups. As you can see, one disk group is made up of ASM disks, and each ASM disk belongs
to only one disk group. Also, ASM files are always spread across all the ASM disks in the disk
group. ASM disks are partitioned in allocation units (AUs). An AU is the smallest contiguous
disk space that ASM allocates. ASM does not allow physical blocks to be split across AUs.
When you create a disk group, you can set the ASM AU size to be between 1 MB and 64 MB
in powers of two (such as 1, 2, 4, 8, 16, 32, or 64). Note that the diagram deals only with data
files. However, ASM can be used to store other database file types.
t a nlegroups in units of ASM disks. Every ASM disk has an ASM disk name, which is a
from disk
S common to all nodes in a cluster. The ASM disk name abstraction is required because
name
different hosts can use different names to refer to the same disk.
An ASM file begins with an extent size equal to 1 AU. As the file size increases, the extent
size also increases to 8 AU, and then to 64 AU at a predefined number of extents. Therefore,
the extent map size that defines a file can be smaller by a factor of 8 and 64 depending on the
size of the file. The initial extent size is equal to the AU size, and it increases by the 8 and 64
factors at predefined thresholds. This is automatic for newly created files after the
COMPATIBLE.ASM and COMPATIBLE.RDBMS parameters have been advanced to 11.1.
ASM striping has two primary purposes: to balance loads across all of the disks in a disk group
and to reduce I/O latency. Coarse-grained striping provides load balancing for disk groups
while fine-grained striping reduces latency for certain file types by spreading the load more
widely. To stripe data, ASM separates files into stripes and spreads data evenly across all of
the disks in a disk group. The stripes are equal in size to the effective AU. The coarse-grained
stripe size is always equal to the AU size. The fine-grained stripe size always equals 128 KB;
this provides lower I/O latency for small I/O operations such as redo log writes.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Failure Group
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
a
4
3
fe r
2
ans
1
1
7
7
13
13
1
1
7
7
13
13
1
1
n
7
7
- t r
13
13
o
1 7 13 1 7 13 1 7 13
• Automatic online
rebalance whenever
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
storage configuration
changes
• Moving only the
amount of data
that is proportional to
the storage added
• No need for manual
a b le
I/O tuning s fer
- t r an
• Online migration to on
new storage a n
a s
• Configurable load m ) h uideฺ
co nt G
ailฺ
on system using ASM_POWER_LIMIT
m tude
g
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Disk Group Dynamic k i
Rebalancing
a s yu ense
• With ASM,
y lic process is very easy and happens without any intervention from
M the rebalance
t a nleDBA or system administrator. ASM automatically rebalances a disk group whenever
the
S disks are added or dropped. However, rebalancing will be delayed when disk groups are
dropped because of errors.
• By using index techniques to spread extents on the available disks, ASM does not need to
restripe all the data, but instead needs to move only an amount of data that is proportional
to the amount of storage added or removed to evenly redistribute the files and maintain a
balanced I/O load across the disks in a disk group.
• With the I/O balanced whenever files are allocated and whenever the storage
configuration changes, the DBA never needs to search for hot spots in a disk group and
manually move data to restore a balanced I/O load. However, because the database needs
to resync cached ASM metadata, rebalances will have less impact if done in quiet periods.
• It is more efficient to add or drop multiple disks simultaneously so that they are
rebalanced as a single operation. This avoids unnecessary movement of data. With this
technique, it is easy to achieve online migration of your data. All you need to do is add
the new disks and drop the old ones in one operation.
• You can control how much of a load the rebalance operation has on the system by setting
the ASM_POWER_LIMIT parameter. Its range of values is 1 through 11. The lower the
number, the lighter the load; a higher setting has more of a load and finishes sooner.
Oracle Database 11g: Administration Workshop II 1 - 35
Computer Pride Limited
CREATE DISKGROUP
ble
fe r a
Database
ans
instance n - t r
a no
a s
ALTER DISKGROUP ) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Managing Disk Groups k i
a s yu ense
The main goal
y Mof an ASMlic instance is to manage disk groups and protect their data. ASM
t a nlealso communicate file layout to database instances. In this way, database instances
instances
S directly access files stored in disk groups.
can
There are several disk group administrative commands. They all require the SYSASM or
SYSDBA privilege and must be issued from an ASM instance.
You can add new disk groups. You can also modify existing disk groups to add new disks,
remove existing ones, and perform many other operations. You can remove existing disk
groups.
ble
fe r a
Disk formatting
ans
n - t r
a no
a s
) h i d eฺ
Disk group rebalancing m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Adding Disks to Disk k i
Groups
a s yu ense
This exampleM
y
shows howlic to add disks to a disk group. You execute an ALTER DISKGROUP
ADD DISK
a n le command to add the disks. The first statement adds four new disks to the
S t
DGROUPA disk group.
The second statement demonstrates the interactions of discovery strings. Consider the
following configuration:
/devices/A1 is a member of disk group DGROUPA.
/devices/A2 is a member of disk group DGROUPA.
/devices/A3 is a member of disk group DGROUPA.
/devices/A4 is a candidate disk.
The second command adds A4 to the DGROUPA disk group. It ignores the other disks, even
though they match the discovery string, because they are already part of the DGROUPA disk
group. The diagram shows that, when you add a disk to a disk group, the ASM instance
ensures that the disk is addressable and usable. The disk is then formatted and rebalanced. The
rebalance process is time consuming because it moves extents from all files onto the new disk.
Note: Rebalancing does not block any database operations. The main impact that a rebalance
process has is on the I/O load on the system. The higher the power of the rebalance, the more
I/O load it puts on the system. Thus less I/O bandwidth is available for database I/Os.
t a nledata structures that describe a disk group, and the capabilities of the clients
persistent
S
(consumers of disk groups). These attributes are called ASM compatibility and RDBMS
compatibility, respectively. The compatibility of each disk group is independently controllable.
This is required to enable heterogeneous environments with disk groups from both Oracle
Database 10g and Oracle Database 11g. These two compatibility settings are attributes of each
ASM disk group:
• RDBMS compatibility refers to the minimum compatible version of the RDBMS instance
that would allow the instance to mount the disk group. This compatibility dictates the
format of messages that are exchanged between the ASM and database (RDBMS)
instances. An ASM instance has the capability to support different RDBMS clients
running at different compatibility settings. The database compatible version setting of
each instance must be greater than or equal to the RDBMS compatibility of all disk
groups used by that database. Database instances are typically run from a different Oracle
home than the ASM instance. This implies that the database instance may be running a
different software version than the ASM instance. When a database instance first connects
to an ASM instance, it negotiates the highest version that they both can support.
must always be greater than or equal to the RDBMS compatibility level of the same disk
group. ASM compatibility is concerned only with the format of the ASM metadata. The
format of the file contents is up to the database instance. For example, the ASM
compatibility of a disk group can be set to 11.0 while its RDBMS compatibility could be
10.1. This implies that the disk group can be managed only by ASM software whose
software version is 11.0 or higher, whereas any database client whose software version is
higher than or equal to 10.1 can use that disk group.
The compatibility of a disk group needs to be advanced only when there is a change to either
persistent disk structures or protocol messaging. However, advancing disk group compatibility
a b le
s fer
is an irreversible operation. You can set the disk group compatibility by using either the
CREATE DISKGROUP or ALTER DISKGROUP commands.
-tr an
on (database
Note: In addition to the disk group compatibilities, the compatible parameter
n
a to the database or ASM
compatible version) determines the features that are enabled; it applies
s
a
instance depending on the instance_type parameter. For example:
m i deฺ it to 10.1 would
) h uSetting
a i l ฺco n11gt G
preclude use of any features introduced in Oracle Database (disk online/offline, variable
extents, and so on).
g Stu m de
i @
s y uk this
( M a use
y u ki se to
M as licen
ley
n
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Using Enterprise Manager i
u nstoeEdit Disk Group Attributes
s y
a provides e a simple way to store and retrieve environment settings related to
Enterprise Manager
M l i c
l ey
disk groups.
n
Stacan set the compatible attributes from both the create disk group page and the edit disk
You
group advanced attributes page. The disk_repair_time attribute is added to only edit the
disk group advanced attributes page.
Note: For pre-11g ASM instances, the default ASM compatibility and the client compatibility
are each 10.1. For 11g ASM instances, the default ASM compatibility is 10.1 and the database
compatibility is 10.1.
Secondary
Primary
extent
extent
ble
fe r a
ans
n - t r
a no
a s
4 Disk again accessible: h i d eฺ
)time < uDISK_REPAIR_TIME
3 Failure
o m
ilฺc ent G
Only need to resync modified extents
a
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
ASM Fast Mirror Resync
y u ki Overview
s e
ASM fast mirror
s csignificantly
aresync en reduces the time required to resynchronize a transient
y M l i
lea disk. When a disk goes offline following a transient failure, ASM tracks the extents
failurenof
a
t
S are modified during the outage. When the transient failure is repaired, ASM can quickly
that
resynchronize only the ASM disk extents that have been affected during the outage.
This feature assumes that the content of the affected ASM disks has not been damaged or
modified.
When an ASM disk path fails, the ASM disk is taken offline but not dropped if you have set
the DISK_REPAIR_TIME attribute for the corresponding disk group. The setting for this
attribute determines the duration of a disk outage that ASM tolerates while still being able to
resynchronize after you complete the repair.
Note: The tracking mechanism uses one bit for each modified allocation unit. This ensures that
the tracking mechanism very efficient.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using EM to Perform k i
u nMirror
Fast e Resync
s y
a l(EM), s
e when you offline an ASM disk, you are asked to confirm the
In EnterpriseMManager i c
l
operation.
n eyOn the Confirmation page, you can override the default Disk Repair Time.
Sta you can View by failure group and choose a particular failure group to offline.
Similarly,
When finished, you can online the disk using Enterprise Manager.
ASMCMD Utility
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
$ export ORACLE_SID=+ASM
$ asmcmd
ble
ASMCMD> ls -l DGROUP1/ORCL/DATAFILE
fe r a
Type Redund Striped Time Sys Name
ans
DATAFILE MIRROR COARSE OCT 05 21:00:00 Y
n - t r
HRAPPS.257.570923611
DATAFILE MIRROR COARSE OCT 05 21:00:00 Y no
TBSASM.256.570922917
a
a s
eฺ
ASMCMD>
) h i d
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
ASMCMD Utility k i
a s yu ense
ASMCMD isM
y lic utility that you can use to view and manipulate files and
a command-line
t a nle within ASM disk groups. ASMCMD can list the contents of disk groups, perform
directories
S
searches, create and remove directories and aliases, display space utilization, and more.
ASMCMD works with ASM files, directories, and aliases.
Every file created in ASM gets a system-generated file name, otherwise known as a fully
qualified file name. This is the same as a complete path name in a local file system. As in
other file systems, an ASM directory is a container for files, and an ASM directory can be part
of a tree structure of other directories. The fully qualified file name represents a hierarchy of
directories in which the plus sign (+) represent the root directory.
ASMCMD> ls -l +DGROUP1/ORCL/DATAFILE
Type Redund Striped Time Sys Name
DATAFILE MIRROR COARSE OCT 05 21:00:00 Y HRAPPS.257.570923611
You can create your own directories as subdirectories of the system-generated
directories using the ASMCMD mkdir command:
ASMCMD> mkdir +dgroup1/sample/mydir
ASMCMD Utility
User created directories
Templates
Disk group compatibility md_backup
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
newdg
lsdsk
ble
fe r a
ans
ASMCMD> md_backup –b /tmp/dgbackup070222 –g admdsk1 –g asmdsk2
n - t r
no
ASMCMD> md_restore –t full –g asmdsk1 –i backup_file
ASMCMD> lsdsk -k DATA *_0001
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
ASMCMD Utility (continued)k i
a s yu ense
• ASMCMD
y lic ASM metadata backup and restore functionality. This provides
M can perform
t a nle
the ability to re-create a preexisting ASM disk group with the exact same template and
S alias directory structure.
• The lsdsk command lists ASM disk information. This command can run in two modes:
connected and non-connected. In connected mode, ASMCMD uses the V$ and GV$ views
to retrieve disk information. In non-connected mode, ASMCMD scans disk headers to
retrieve disk information, using an ASM disk string to restrict the discovery set. The
connected mode is always attempted first.
• Bad block repair is a new feature that runs automatically on normal- or high-redundancy
disk groups. When a normal read from an ASM disk group fails with an I/O error, ASM
attempts to repair that block by reading from the mirror copy and write to it and by
relocating it if the copy failed to produce a good read. This whole process happens
automatically only on blocks that are read. It is possible that some blocks and extents on
an ASM disk group are seldom read. One prime example is the secondary extents. The
ASMCMD’s repair command is designed to trigger a read on these extents, so the
resulting failure in I/O can start the automatic block repair process. One can use the
ASMCMD’s repair interface if the storage array returns an error on a physical block, then
the ASMCMD repair can initiate a read on that block to trigger the repair.
t a nle improving memory usage efficiency. An ASM file begins with an extent equal to
size while
S AU. As the file size increases, the extent size also increases to 8 AU and then to 64 AU at
one
a predefined number of extents. The size of the extent map that defines a file can be smaller by
a factor of 8 and 64 depending on the file size. The initial extent size is equal to the allocation
unit size and it increases by a factor of 8 and 64 at predefined thresholds.
Fewer extent pointers are needed to describe the file and less memory is required to manage
the extent maps in the shared pool, which would have been prohibitive in large file
configurations. Extent size can vary both across files and within files.
Variable size extents also enable you to deploy Oracle databases using ASM storage that are
several hundred TB even several PB in size. The management of variable size extents is
completely automated and does not require manual administration.
However, external fragmentation may occur when a large number of non-contiguous small
data extents have been allocated and freed, and no additional contiguous large extents are
available. A defragmentation operation is integrated as part of the rebalance operation. So, as a
DBA, you always have the possibility to defragment your disk group by executing a rebalance
operation.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Summary
Practice 1 Overview:
Database Architecture and ASM
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
• Data protection
– Media failure
– User errors
– Application errors
• Data preservation
• Data transfer
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
(M toFunctionality
Purpose of Backup and k i
Recovery
a s yu ense
You need to beM
y ic when there are problems introduced into your database. When you
able to recover
l
t a nleerrors.
take backups
application
of your database, you protect against problems such as media failure, user errors, and
Media errors cause data problems by failing at the hardware level; a bad controller
S
or disk drive can introduce either subtle or obvious errors. Users can also cause data errors, simply by
issuing commands that should not be issued. Those same types of errors can be caused by an
application with a bug.
Backup also provides for the preservation of data. You may want to create a copy of the database as
of a specifically meaningful point in time and store it for a long term. This could be for possible
future restoration, or it might be simply to meet compliance regulations.
You can also use backup and recovery tools to move data to other databases—even in other
locations. A backup of the database is an efficient way to do this: back up the database and restore it
at another location.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
t a nlefeatures
• Recovery
major
Manager: A command-line tool for performing backup and recovery. Some of the
available when using RMAN are:
S - Incremental backups: A type of backup in which only data blocks that have changed since
the last incremental backup are written to the backup
- Block media recovery: A method of recovering specific blocks of data, as opposed to
entire tables (with Data Pump) or data files (with RMAN)
- Unused block compression: A space-saving method by which blocks that have never been
used are not written to the backup
- Binary compression: A space-saving feature in which backup files are compressed using
well-known algorithms (comparable to utilities such as zip on Linux)
- Backup encryption: A security device for protecting backups you make
• Data Pump: A command-line tool for exporting and importing table data from and to OS files
$ rman target /
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
• Stand-alone command:
– Is executed individually at the RMAN prompt
– Cannot appear as subcommands within RUN
• Job command:
– Must be within the braces of a RUN command
– Is executed as a group
Some commands can be executed as either a stand-alone or a able
job command. s fer
n tra
n -
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Types of RMAN Commands k i
a s yu ense
You can issue M
y ic of RMAN commands: stand-alone and job commands.
two basic ltypes
t a nle commands are executed at the RMAN prompt and are generally self-contained. Some of
Stand-alone
Sstand-alone commands are:
the
• CHANGE
• CONNECT
• CREATE CATALOG, RESYNC CATALOG
• CREATE SCRIPT, DELETE SCRIPT, REPLACE SCRIPT
Job commands are usually grouped and executed sequentially inside a command block. If any
command within the block fails, RMAN ceases processing; no further commands within the block
are executed. The effects of any already executed commands still remain, though; they are not
undone in any way.
An example of a command that can be run only as a job command is ALLOCATE CHANNEL. The
channel is allocated only for the execution of the job, so it cannot be issued as a stand-alone
command. There are some commands that can be issued either at the prompt or within a RUN
command block, such as BACKUP DATABASE. If you issue stand-alone commands, RMAN allocates
any needed channels by using the automatic channel allocation feature.
You can execute stand-alone and job commands in interactive mode or batch mode.
RMAN> RUN
2> {
3> ALLOCATE CHANNEL c1 DEVICE TYPE DISK
4> FORMAT "/disk2/%U";
5> BACKUP AS BACKUPSET DATABASE;
6> SQL 'alter system archive log current';
7> }
ble
fe r a
ans
n - t r
Execution of entire block starts
when this line is entered. a no
h a s ฺ
)Deallocated
i d eafter
c o m G u the
ฺ
ail den t
RUN block completes
m
g Stu
i @ isAll rights reserved.
s y uk© 2009, Oracle.
Copyright
t h
( M a use
Job Commands: Example
y u ki se to
Unlike stand-alone
M ascommands,
l i c enjob commands must appear within the braces of a RUN command.
Commands
n l eyplaced inside a RUN block as shown in the slide are run as a single unit of commands.
Staconfigurations made within the run block apply within the scope of the block and override any
Any
previously made settings. The following are examples of job commands, which must appear inside a
RUN block:
• ALLOCATE CHANNEL
• SWITCH
RMAN executes the job commands inside a RUN command block sequentially. If any command
within the block fails, then RMAN ceases processing; no further commands within the block are
executed. In effect, the RUN command defines a unit of command execution. When the last command
within a RUN block completes, the Oracle database releases any server-side resources such as
input/output (I/O) buffers or I/O slave processes allocated within the block.
Archiver
(ARCn)
Online redo Archived
log files redo log files
ARCHIVELOG Mode
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
bl e
fe r a
ans
Archiver
n - t r
(ARCn)
a no
a s Archived
Online redo
log files ) h i d eฺ log files
m
co nt Gu
redo
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
ARCHIVELOG Mode uki
a s y ense
As modifications
y M icthe database are made, the redo data is written out to the online redo log
to datalin
a le file is specified as being written to at a given time. When it is full, the Archiver process
file. A given
ncopies
S t
(ARCn) the online log file to another location that serves as an archive of that file, which can
be preserved for as long as you need it. This provides more opportunities for recovery, because you
can save, back up, and restore all of the archive redo logs ever generated.
Because the online redo log files are reused in a circular fashion, there is a protocol for controlling
when one is allowed to be reused. In ARCHIVELOG mode, the database only begins writing to an
online redo log file if it has been archived. This ensures that every redo log file has a chance to be
archived.
following steps:
• Using Enterprise Manager
– Select the “ARCHIVELOG Mode” check box.
– Click Apply. The database can be set to ARCHIVELOG mode
only from the MOUNT state.
– Click Yes when asked whether you want to restart the
database.
bl e
• Using SQL commands fe r a
– Mount the database. an s
- t r
non
– Issue the ALTER DATABASE ARCHIVELOG command.
a
a s
– Open the database.
m ) h uideฺ
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Configuring ARCHIVELOG
y u ki Mode s e
M asin ARCHIVELOG
Placing the database
l i c en mode prevents redo logs from being overwritten until they
y
have beenlearchived.
tan Manager, do this by navigating to Availability > Recovery Settings and selecting the
InSEnterprise
ARCHIVELOG Mode check box. The database must be restarted after making this change.
To issue the SQL command to put the database in ARCHIVELOG mode, the database must be in
MOUNT mode. In order to get to the MOUNT state, the database must be in the SHUTDOWN state; if the
database is currently open, you must shut it down, and then mount it. The following shows the
commands to shut down an open database, put it in ARCHIVELOG mode, and then open it:
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP MOUNT
SQL> ALTER DATABASE ARCHIVELOG;
SQL> ALTER DATABASE OPEN;
With the database in NOARCHIVELOG mode (the default), recovery is possible only until the time of
the last backup. All transactions made after that backup are lost.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Online redo
LOG_ARCHIVE_DEST_n Archived
log files
redo log files
Archived
redo log files
• Local-only destinations:
ble
fe r a
ans
n - t r
Online redo
LOG_ARCHIVE_DEST n o
log files s a
LOG_ARCHIVE_DUPLEX_DEST
) ha ideฺ
Archived
c o m Gu
redo log files
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Configuring Archive Log u e to
ki Destinations
y
as youliccan s
enchoose from, for specifying where archive log files are to be written:
There are two M
models
• Locall y remote destinations: Specify local and remote destinations by setting the set of
eand
a n
StLOG_ARCHIVE_DEST_n initialization parameters. There are ten of these, so n can be 1
through 10. In order to specify a local storage location, supply a local directory name for the
value of one of these variables, supplying the "LOCATION=" string. For example, to specify the
/disk3/arch directory, set one of these variables as follows:
LOG_ARCHIVE_DEST_1 = 'LOCATION=/disk3/arch'
If you want to specify a remote location for a standby database, use the SERVICE
keyword in the value, as in the following example, where standyby1 is the network service
name for the standby database instance:
LOG_ARCHIVE_DEST_2 = 'SERVICE=standby1'
• Local-only destinations: Another option for specifying destinations supports only local disk
locations. Set the LOG_ARCHIVE_DEST and the LOG_ARCHIVE_DUPLEX_DEST parameters
to local disk directories. Thus, you can have up to two archive log file locations. For example:
LOG_ARCHIVE_DEST = '/disk1/arch'
LOG_ARCHIVE_DUPLEX_DEST = '/disk2/arch‘
Oracle recommends that you use the LOG_ARCHIVE_DEST_n method, because this allows the
most flexibility in type of destinations, and also number of destinations.
1 3
Online redo
log files Standby1
2
ble
fe r a
ans
n - t r
LOG_ARCHIVE_MIN_SUCCEED_DEST = 2
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Guaranteeing ArchiveuLog k i (M t
Success o
a s y ense
If you have specified
y M more
l icthan one destination for archive log files, you should specify a minimum
number of
this t a nlethe
using
them that are required to succeed in order for the archive to be considered successful. Do
LOG_ARCHIVE_MIN_SUCCEED_DEST initialization parameter. Set it to the number
S
of destinations that must succeed in receiving the archived log file. The online log file is not reused
until this number is met.
In the example in the slide, there are three destinations specified: two are local, and one is remote.
LOG_ARCHIVE_MIN_SUCCEED_DEST is set to 2, which means as long as at least two of the
destinations succeed, the online redo log file can be overwritten. The example shows that destination
1 has failed. That does not stop the database, because two of them succeeded.
You can use this parameter with either of the models described in the previous slide. If you use it
with the LOG_ARCHIVE_DEST_n model, then this parameter can have values ranging from 1
through 10. If you use it with the LOG_ARCHIVE_DEST model, then the values can be 1 or 2,
because you can specify only two destinations in that case.
A mandatory destination is given special consideration. If any mandatory destination fails, then
Oracle Database considers the archiving of the log to have not succeeded, and the online redo log file
is not allowed to be overwritten. In this case, it ignores the LOG_ARCHIVE_MIN_SUCCEED_DEST
parameter.
Any destination specified by LOG_ARCHIVE_DEST is mandatory. Any destination declared by
LOG_ARCHIVE_DUPLEX_DEST is optional if LOG_ARCHIVE_MIN_SUCCEED_DEST = 1 and
mandatory if LOG_ARCHIVE_MIN_SUCCEED_DEST = 2.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
• Disk directory
• Tape, using Oracle Secure Backup
• Media Management Library
– Tape
– Disk or tape, using proxy copy
• Flash Recovery Area: Disk area set aside for backup and
recovery and flashback database purposes ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Specifying a Backup u k i (M e to u
Destination
ns disk directory, a Media Management Library (MML), or the
asy tolica edesignated
Backups can beMwritten
l ey Area. Specifying a disk directory or the Flash Recovery Area means that backups go
Flash Recovery
n
toS ta media. Typically, backups are regularly moved offline to tape via the media
hard-disk
management interface in order to maintain disk space availability. Any disk directory can be
specified as the destination of a backup provided that it already exists. A media management library
can be used to copy files to tape devices, or to carry out proxy copies. A proxy copy is where the
MML is requested to make a copy of a file to a disk or tape device. The MML must be able to
provide the proxy copy service for this to work.
If you set up a Flash Recovery Area, many backup and recovery tasks are simplified for you. The
Oracle database automatically names files for you, and deletes obsolete files when there is space
pressure. More information about configuring a Flash Recovery Area is provided later in this lesson.
To specify that backups are to be written to disk, use this command:
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO DISK;
Subsequently, when backups are made, if the FORMAT keyword is used (that specifies a disk
directory location for the backup), then the backup is written there. If there is a Flash Recovery Area
configured, then it goes there; otherwise, backups are written to a platform-specific default location.
To specify that a tape device is to be used, use this command:
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO SBT;
Backup Recovery
window SYSDATE
bl e
– Redundancy: Establishes a fixed number of backups that fe r a
s
must be kept ran n -t
o
s an
Backup 1 Backuph2a eฺ SYSDATE
m ) i d
• Retention policies are mutually exclusive. i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Specifying a Retention k i
Policy
a s yu ense
A retention policy
y lic which
M describes backups will be kept and for how long. You can set the value of
n l e
the retention policy by using the RMAN CONFIGURE command or Enterprise Manager.
Sta Window Retention Policy
Recovery
The best practice is to establish a period of time during which it will be possible to discover logical
errors and fix the affected objects by doing a point-in-time recovery to just before the error occurred.
This period of time is called the recovery window. This policy is specified in number of days. For
each data file, there must always exist at least one backup that satisfies the following condition:
SYSDATE – backup_checkpoint_time >= recovery_window
You can use the following command syntax to configure a recovery window retention policy:
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF <days>
DAYS;
where <days> is the size of the recovery window.
If you are not using a recovery catalog, then you should keep the recovery window time period less
than or equal to the value of the control file parameter CONTROL_FILE_RECORD_KEEP_TIME to
prevent the record of older backups from being overwritten in the control file. If you are using a
recovery catalog, then make sure CONTROL_FILE_RECORD_KEEP_TIME is greater than the time
period between catalog resynchronizations. Resynchronizations happen when you:
• Create a backup. In this case the synchronization is done implicitly.
• Execute the RESYNC CATALOG command
Oracle Database 11g: Administration Workshop II 2 - 18
Computer Pride Limited
before any backup is identified as obsolete. The default retention policy has a redundancy of 1, which
means that only one backup of a file must exist at any given time. A backup is deemed obsolete when
a more recent version of the same file has been backed up.
You can use the following command to reconfigure a redundancy retention policy:
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY <copies>;
where <copies> is the number of copies that are required for policy satisfaction.
Disabling the Retention Policy
You may want to disable the retention policy totally. If you have a separate system, outside of
b
RMAN, that backs up your disk backups to tape, you may want to do this. If you disable the retention
a le
policy, then RMAN never considers a backup obsolete. Because RMAN does not have to decide
s fer
when to remove a backup from disk (because another utility is managing that), RMAN
- t r andoes not need
n maintained for as
to be configured for making that decision. In this case, records of each backupoare
n
long as is specified by the CONTROL_FILE_RECORD_KEEP_TIME initialization
s a parameter.
Disable the retention policy by using this command: )h a eฺ
RMAN> CONFIGURE RETENTION POLICY TO NONE; o m u id
G
lฺc ent policy that you have defined.
Note: You can specify that a backup is an exceptionatoi the retention
This is called an archival backup, which is @ gmin S
covered thetu
d
lesson titled “Using RMAN to Create
Backups.” y u ki this
a s se
( M u
y u ki se to
M as licen
n l ey
Sta
A Recovery Window
Retention Policy: Example
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Log 100 Log 200 Log 300 Log 400 Log 500
Backup A Backup B Backup C
Now
ble
fe r a
Backup Obsolete Recovery window of 7 days s
- t r an
Backup Not Obsolete n no
s a
Backup B and archive logs 201 through 500 ) h a
are eฺ
required to
m u i d
o
satisfy this retention policy.
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
i ( M to
Specifying a Recovery
y u kWindow s eRetention Policy: Example
s n
a in thelicslide
The retention policy e shows that it requires the ability to recover to any time within the
last sevenle
M
y Some of the backups and logs are obsolete, because they are not needed to recover to
days.
aStime
n
tawithin the seven-day window. This retention policy is configured thus:
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
Given the backups and archived log files available, the only data needed to recover to a point inside
the recovery window is Backup B and logs 201 through 500. Note that Backup A is not needed
because there is a later backup (B) that is still before the recovery window. Also, Backup C is not
sufficient as the only backup to retain because it would not satisfy a need to recover to points in time
at the beginning of the recovery window. The last backup that was taken before the beginning of the
recovery window, including all logs since that backup, is what is necessary.
• Permanent items:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Archiver background process creates archived redo log files in the Flash Recovery Area and in
other configured LOG_ARCHIVE_DEST_n locations. If no LOG_ARCHIVE_DEST_n
locations are defined, the default location for archived redo log files is in the Flash Recovery
Area.
• Flashback logs: Flashback logs are generated when Flashback Database is enabled.
• Control file autobackups: The default location for control file autobackups created by RMAN
and autobackups generated by the Oracle database server is the Flash Recovery Area.
• Data file copies: The BACKUP AS COPY command creates image data file copies in the Flash
Recovery Area.
• RMAN files: The Flash Recovery Area is the default location that is used by RMAN for ble
backups and restoration of the archive log content from tape for a recovery operation.fera
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
(M a u
Defining a Flash Recovery k i Area t o
a s yu ense
Use the following
y lic parameters to define
M mandatory the Flash Recovery Area:
n l e
• DB_RECOVERY_FILE_DEST_SIZE: You must define a disk limit, which is the amount of
a that the Flash Recovery Area is permitted to use. Setting a limit allows the remaining disk
Stspace
space not dedicated to the Flash Recovery Area to be used for other purposes. A basic
recommendation for the size of the disk limit is the sum of the database size, the size of
incremental backups, and the size of all archive log files that have not been copied to tape. The
minimum size of the Flash Recovery Area should be at least large enough to contain archived
redo log files that have not been copied to tape. The sizing of the Flash Recovery Area is
dependent on the backup strategy and other options that are implemented. Flashback database
set points, and multilevel incremental backups all have an effect on the size of the Flash
Recovery Area.
• DB_RECOVERY_FILE_DEST: A Flash Recovery Area specification contains a location, which
is a valid destination to create files.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
(M a u
Defining a Flash Recovery k
u nsei Area t o
Using Enterprise Manager
s y
a Manager e Grid Control and Database Control to easily define the Flash
You can use Enterprise
M l i c
y On the Database Control home page, navigate to Availability > Recovery Settings in
RecoveryleArea.
the ta n
Backup/Recovery Settings region. You can define the Flash Recovery Area location and its size
S
on the Recovery Settings page.
You must set the size of the Flash Recovery Area when specifying its location.
Space limit is
reached and a
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Flash Recovery Area u k
Spacei (MUsaget o
a s y ense
To avoid running
y M l ic in the Flash Recovery Area, perform the following steps as needed or
out of space
e
anlRMAN to delete unnecessary files from the Flash Recovery Area.
appropriate:
•StUse
• Use RMAN to take frequent backups of the Flash Recovery Area.
• Change the RMAN retention policy to retain backups for a smaller period of time.
• Change the RMAN archived log deletion policy.
• Add disk space and increase the value of the DB_RECOVERY_FILE_DEST_SIZE database
initialization parameter if you frequently run out of space.
Enterprise Manager does not report the amount of space used by the Flash Recovery Area on the disk
or the amount of space used in the Flash Recovery Area directory tree, but it does report the sizes of
the file that RMAN believes are in the directory. So do not put any files in this area that are not
managed by RMAN.
If you remove any file from this area with a tool other than RMAN, use RMAN to remove the file
entries from the catalog. For example, to back up the archived log files in the Flash Recovery Area
and then delete the files after they have been successfully backed up, you would use the RMAN
command as follows:
BACKUP ARCHIVELOG ALL DELETE ALL INPUT;
you can perform a cross-check operation and also delete expired and obsolete backups.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Monitoring the Flash u k
Recovery to u
i (M eArea
Real-time Flash a sy cArea
Recovery e nsmetrics can be viewed through Enterprise Manager Database
li scroll down to the Related Links section and select All Metrics. Scan the
ytheMHome page,
l
Control. One
list tanclick Recovery Area.
Sand
The displayed page shows the Recovery Area Free Space (%) metric, which indicates the percentage
of the recovery that is free space. Click the percentage number to see the graph of recovery area
usage.
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to Area u
Benefits of Using a Flashk i Recovery
a s yu ense
Using a Flash Recovery
y M l ic for all recovery-related files simplifies the ongoing administration of
Area
t a nle
your database.
S Corporation recommends the use of the Flash Recovery Area for all recovery-related files.
Oracle
Summary
Practice 2 Overview:
Configuring for Recoverability
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
Metadata e
Backup set list r a bl
s fe
Image copy list
- t r an
. n
no
. s a
) h a eฺ
. m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M tComparisonu
RMAN Repository Data k
u nse i
Storage: o of Options
s y
a data eis always stored in the control file of the target database. But it can also,
The RMAN repository
M l i c
l eybe stored in a separate database called a recovery catalog.
additionally,
n
AS ta catalog preserves backup information in a separate database, which is useful in the event
recovery
of a lost control file. This allows you to store a longer history of backups than what is possible with a
control file–based repository. A single recovery catalog is able to store information for multiple
target databases. The recovery catalog can also hold RMAN stored scripts, which are sequences of
RMAN commands.
If you have very simple backup management requirements, Oracle recommends that you use the
control file option rather than a recovery catalog. Having a recovery catalog means you need to
manage and back up another database. Therefore, use a recovery catalog only if you can take
advantage of the benefits it offers, such as longer backup retention.
Recovery
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Manager
(RMAN)
Database structure
Archived redo logs e
Backup sets Recovery catalog r a bl
Target database
database n s fe
control file Data file copies
n - tra
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
Storing Information inuthe k i (Recovery
e Catalog
s y
ainformation n s
e about the database structure, archived redo logs, backup sets, and
RMAN propagatesM l i c
l ey into the recovery catalog from the target database’s control file after any operation
data file copies
n
a the repository, and also before certain operations.
Stupdates
that
ble
Configure the Create the fe r a
recovery catalog recovery catalog
Create the
t r
recovery catalog. a ns
database. owner. - on
a n
a s
m ) h uideฺ
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
i ( M to Steps
Creating the Recovery
y u kCatalog:s e Three
ascatalog,
To create a recovery
M l i c n
eperform the following three steps:
y
2. t a nle the the
1. Configure
Create
database in which you want to store the recovery catalog.
recovery catalog owner.
S3. Create the recovery catalog.
owner:
$ rman
RMAN> CONNECT CATALOG username/password@net_service_name
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
(M a u
Managing Target Database k i t o
u nse in the Recovery Catalog
Records
s y
a lice
Although mostM information is automatically propagated from the control file to the recovery catalog,
y
there are laefew operations you may need to perform to maintain target database records in the
n
Sta catalog.
recovery
Run EM on the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
target database.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
(to
Using Enterprise Managerk i
u nsRegister
e a Database (continued)
s y
ahomelipage,
e navigate to Availability > Recovery Catalog Settings. Click Add
From the Database
M c
y to specify the host, port, and SID of a database with an existing recovery catalog.
Recoveryle
Catalog
n
StaIf no recovery catalogs have been added yet, you see a message to that affect in the Recovery
Note:
Catalog drop-down list. It is possible that you see several to choose from, if they have already been
added.
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
(to
Using Enterprise Manager k i
u nsRegister e a Database (continued)
s y
a the e
After you haveM
y
defined
l i crecovery catalog database, select “Use Recovery Catalog” on the
Recoveryle
t
click a n Catalog
OK, the
Setting page to register the database in the recovery catalog database. When you
database is registered with the catalog.
S
recovery catalog.
• Use this when you no longer want the target database to be
defined in the recovery catalog.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Backup sets
Data file copies
t a nleofthattheistarget
control file
information
database or a backup control file and updates the recovery catalog with
missing or changed.
S
There are two types of resynchronization: partial and full. For partial resynchronization, RMAN
compares the control file to the recovery catalog and updates the recovery catalog with any metadata
concerning backups, archived redo logs, data file copies, and so on. For a full synchronization,
RMAN first creates a control file snapshot, which is simply a temporary copy of the control file. It
uses the snapshot to make the comparison to the recovery catalog. It compares and updates all the
data that a partial resynchronization does, but it also includes any database structure changes. For
example, database schema changes or new tablespaces are included in a full resynchronization.
Note: The database schema includes names and locations of data files, redo log files, archive log
files, undo segments, and other information found in the control file.
If the only changes to the control file are those records that are governed by
CONTROL_FILE_RECORD_KEEP_TIME, then a partial resynchronization is done. Otherwise, a
full resynchronization is done. A full resynchronization is also done when you issue the RESYNC
CATALOG command, which is described in the next slide.
situations:
• After the recovery catalog was unavailable for RMAN to
automatically resynchronize it
• When you perform infrequent backups of your target
database
• After making changes to the physical structure of the target
database e
r a bl
s fe
RMAN> RESYNC CATALOG; - t r an
n no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
(M a u
Manually Resynchronizing k
u nse i the t o
Recovery Catalog
s y
aresynchronization
e
Perform a manual
y M l i c of the recovery catalog in the following situations:
• If thelerecovery catalog was unavailable when you issued RMAN commands that cause a partial
an
Stresynchronization
• If you perform infrequent backups of your target database because the recovery catalog is not
updated automatically when a redo log switch occurs or when a redo log is archived
• After making any change to the physical structure of the target database
Note: Refer to the Backup and Recovery User’s Guide for detailed information about records that are
updated during resynchronization.
a specific system.
• Stored scripts are available to any RMAN client that can
connect to the target database and recovery catalog.
• Two types of RMAN stored scripts:
– Local: Associated with the target database to which RMAN is
connected when the script is created
– Global: Can be executed against any database registered in le
a b
the recovery catalog er f
t r a ns
n-
no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using RMAN Stored Scripts k i
a s yu ense
You can use RMAN
y M stored
l icscripts as an alternative to command files for managing frequently used
sequencesleof RMAN commands. Unlike command files that are available only on the system on
n
Stathey are stored, a stored script is always available to any RMAN client that can connect to the
which
target database and recovery catalog.
Stored scripts can be defined as global or local. A local stored script is associated with the target
database to which RMAN is connected when the script is created, and can be executed only when
you are connected to that target database. A global stored script can be executed against any database
registered in the recovery catalog, if the RMAN client is connected to the recovery catalog and a
target database.
• Executing a script:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
• Displaying a script:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
• Updating a script:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Recovery
Manager
(RMAN)
Recovery catalog
ble
fe r a
ans
n - t r
a no
Recovery catalog ) ha
s
i d eฺ
control fileco m G u
i l ฺ t
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
(Catalog
Backing Up the Recovery k i
a s yu ense
The recovery catalog
M is anicOracle database, so it needs to be backed up as any database should.
y l
l e
Oracle recommends
n using RMAN to back it up and, of course, use the control file as the RMAN
Sta instead of a recovery catalog. Never store a recovery catalog containing the RMAN
repository,
repository for a database in the same database as the target database or on the same disks as the target
database. A recovery catalog is effective only if it is separated from the data that it is designed to
protect.
Configure control file autobackup so that the control file is backed up every time a backup is made of
the recovery catalog. Any time you make a backup in the target database, back up the recovery
catalog right afterward. This protects the record of the latest backup.
Below is a summary of how to configure the backup and recovery environment for your recovery
catalog:
• Run the recovery catalog in ARCHIVELOG mode.
• Set the retention policy to a REDUNDANCY value greater than one.
• Back up the recovery catalog to disk and tape.
• To make the backups, use the BACKUP DATABASE PLUS ARCHIVELOG command.
• Use the control file (NOCATALOG), not another recovery catalog, as the RMAN repository.
• Configure control file autobackup to be ON.
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M Recovery u
Re-Creating an Unrecoverablek
u nsei t o Catalog
s y
a database e is lost or damaged, and recovery of the recovery catalog database
If the recoveryM catalog
l i c
l
through the
n eynormal Oracle recovery procedures is not possible, then you must
Sta the catalog.
re-create
You can use the following commands to partially repopulate the contents of the recovery catalog:
• RESYNC CATALOG: Use this command to update the recovery catalog with any RMAN
repository information from the control file of the target database or a control file copy. Note
that any metadata from control file records that aged out of the control file is lost.
• CATALOG START WITH... : Use this command to recatalog any available backups.
Use the Export and Import utilities or the Data Pump utilities to:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(MRecovery u
Exporting and Importing k i
u nse the t o Catalog
s y
a and lImport
e to move the recovery catalog from one database to another.
You can use Export
M i c
You can
n l ey create an export of the recovery catalog to serve as a logical backup.
also
Sta the following steps to export a recovery catalog from one database and import the catalog
Perform
into a second database:
1. Use one of the Oracle Export utilities to export the catalog data from the database.
2. Create a recovery catalog user on the database you are exporting to and grant the user necessary
privileges.
3. Use the corresponding Import utility to import the catalog data into the schema created in step 2.
You should not execute the CREATE CATALOG command before or after importing the catalog into
the database. The import operation creates the catalog in the second database.
Note: The recovery catalog can be backed up and moved to another database as a transportable
tablespace by using Export and Import or Data Pump, as well as using logical methods.
UPGRADE CATALOG;
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Upgrading the Recovery k iCatalog
a s yu ense
If you use a version of theic
you mustleupgrade
l recoverythecatalog
y M it by executing
that is older than that required by the RMAN client, then
UPGRADE CATALOG command.
n
StaTo install the new recovery catalog schema, the recovery catalog user must have the CREATE
Note:
TYPE privilege.
You must be connected to the catalog database, and the catalog database must be open. You do not
have to be connected to the target database.
You must enter the UPGRADE command a second time to confirm the upgrade. You receive an error
if the recovery catalog is already at a version greater than that needed by the RMAN executable.
However, RMAN permits the command to be run if the recovery catalog is current, so that the
packages can be re-created if necessary.
RMAN displays all error messages generated during the upgrade in the message log.
command:
DROP CATALOG;
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Dropping the Recovery k i
Catalog
a s yu ense
If you no longer
y M lic CATALOG
want to maintain a recovery catalog, you can drop the recovery catalog schema from
n l e
the tablespace with the DROP command. Dropping the catalog deletes the recovery
Sta record of backups for all target databases registered in the catalog.
catalog
Note: Execute this command only at the RMAN prompt.
You must be connected to the recovery catalog database through the CATALOG command-line option
or the CONNECT CATALOG command. The catalog database must be open. You do not have to be
connected to the target database.
Enter the command twice to confirm that you want to drop the schema.
Virtual Owner of 1
private
catalog 1
bl e
fe r a
ans
Base
n - t r
recovery n o
catalog Virtual Owner a
s of 2ฺ
private h a
catalog 2 m ) u i de
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
i ( M to
Using a Virtual Private
y u kCatalogs e
A recovery catalog
M asis alsolicreferred
en to as a base recovery catalog. If separation of duties is a security
l
requirement
n eyin your database, then it may also be a requirement regarding the data found in your
Sta catalog. To help meet that requirement, you can create a virtual private catalog. A virtual
recovery
recovery catalog essentially separates the recovery catalog into distinct catalogs, but only virtually.
This is done with a set of views and synonyms on the base recovery catalog.
A base recovery catalog can be sliced up into virtual private catalogs that serve specific groups of
databases and users. The catalog owner creates the base catalog, and grants
RECOVERY_CATALOG_OWNER to the owner of the virtual catalog. The catalog owner can either
grant access to a registered database to the virtual catalog owner or grant REGISTER to the virtual
catalog owner. For the former, the virtual catalog owner can then connect to the catalog for a
particular target. For the latter, he or she can register a target database. After the virtual private
catalog is configured, the virtual private catalog owner uses it just like he or she would a base
recovery catalog.
This feature allows a consolidation of RMAN repositories while maintaining a separation of
responsibilities.
Note: For more information about separation of duties, refer to the Oracle Database Vault
Administrator’s Guide.
privileges to perform RMAN operations on the target database. The user performing the backup
operation must have knowledge of both a username with access privileges on the recovery catalog
and a username that has been granted SYSDBA or SYSOPER on the target database. Most RMAN
operations on the target database require either SYSDBA or SYSOPER privileges.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Summary
Practice 3 Overview:
Using the RMAN Recovery Catalog
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Backup Destinations
• Disk directory
• Media Management Library
– Typically used for disaster recovery, when disk backups are
lost.
– Oracle Secure Backup provides one.
• Flash Recovery Area
– This is the disk area set aside for backup and recovery and
a b le
flashback database purposes.
s fer
– Define the location and the size. - t r an
– Files are automatically named by using Oracle n on
Managed Files.
s a
) ha asdenecessary.
– Files are automatically retained and deleted ฺ
m u i
o G
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Backup Destinations uki e
y s
as tolica edesignated
n
Backups can beMwritten disk directory, a Media Management Library, or the Flash
Recoveryle y
Area. Specifying a disk directory or the Flash Recovery Area means that backups go to
t a n media.
hard-disk Typically, they are regularly moved offline to tape via the media management
S
interface in order to maintain disk space availability. Any disk directory can be specified as the
destination of a backup provided that it already exists.
If you configure a Flash Recovery Area, many backup and recovery tasks are simplified for you. The
Oracle Database server automatically names files for you, and deletes obsolete files when there is
space pressure.
Note: See the Oracle Secure Backup Administrator’s Guide for more information about Oracle
Secure Backup.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
(to
Using Enterprise Manager k i
u nsConfigure
e RMAN Settings
s y
a Enterprise e Manager to specify the backup settings for an instance. From the
You can use Oracle
M l i c
y page, navigate to Availability > Backup Settings.
Databasele
Home
n
a Settings property page consists of three tabs:
StBackup
The
• Device: Used to set the disk and tape configuration settings, including the Media Management
Library (MML) settings
• Backup Set (shown in the slide): Used to specify parameters for backup sets and to enter host
credentials
• Policy: Used to set various backup and retention policies before you initiate a backup, such as
automatically backing up the control file and SPFILE. The Policy page also allows you to
configure block change tracking support, a feature that provides faster incremental backups.
Note: Backup settings provide the default settings for all backups taken. When creating a backup,
some of these settings can be overridden for that specific backup.
ble
fe r a
ans
n - t r
a no
a s enable
Best practice: Oracle recommends that ) h you
i d eฺ
control file autobackup. m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Control File Autobackups k i
a s yu ense
To easily recover
M from theicloss of all control file copies, you should configure RMAN to take
y l
automaticlebackups of the control file. The automatic backup of the control file occurs independently
tanbackup of the current control file explicitly requested as part of your backup command. If you
ofSany
are running RMAN in NOCATALOG mode, it is highly recommended that you activate control file
autobackup. Otherwise, if you lose your control file, your database may be unrecoverable.
To configure control file autobackup, modify the backup policy for your database by using Enterprise
Manager or use the following RMAN command:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
By default, control file autobackups are disabled. If you enable control file autobackups, then RMAN
automatically backs up the control file and the current server parameter file (if used to start up the
database) in one of two circumstances:
• A successful backup is recorded in the RMAN repository.
• A structural change to the database affects the contents of the control file, which, therefore, must
be backed up.
You can change the default format by using the CONFIGURE CONTROLFILE AUTOBACKUP
FORMAT FOR DEVICE TYPE type TO 'string' command. The value of string must contain
the substitution variable %F and cannot contain other substitution variables. For example:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT
FOR DEVICE TYPE DISK TO '/u01/oradata/cf_ORCL_auto_%F';
Control file autobackups are stored in the Flash Recovery Area, unless otherwise specified.
With a control file autobackup, RMAN can recover the database even if the current control file,
recovery catalog, and server parameter file are inaccessible. Because the path used to store the
autobackup follows a well-known format, RMAN can search for and restore the server parameter a b le
file
r
or control file from that autobackup.
nsfe
n - tra
o
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
ki this
s y u
( M a u se
y u ki se to
M as licen
ley
n
Sta
ble
RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY;
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Configuring Devices u k
for iBackup
a s y e n se
You can configure
M a device
ic to be used by RMAN using the CONFIGURE DEVICE TYPE
y l
t a nle
command.
S
Parallelism
Parallelism is the number of streams of data that can be used to read from and write to the device.
This effectively causes that number of channels to be allocated when the device is used by RMAN.
For example, if a media manager has two tape drives available, then parallelism 2 would allow both
tape drives to be used simultaneously for BACKUP commands using that media manager. Parallelism
for the disk device type is also useful, when you want to spread out a backup over multiple disks.
Specify the parallelism to be used on the device using the PARALLELISM clause, like this:
CONFIGURE DEVICE TYPE <device> PARALLELISM <n>
where <n> is the parallelism value.
Backup Type
The output of the backup can be either a backup set or an image copy. Configure the default for a
device type using the BACKUP TYPE TO clause. Specify BACKUPSET for a backup set and COPY
for an image copy.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
command:
RMAN> CONFIGURE DEVICE TYPE sbt PARALLELISM 1;
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO sbt;
RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt ...
RMAN> BACKUP DATABASE;
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
y u ki se to
Configuring Backup Optimization
M as optimization,
If you enable backup
l i c en the BACKUP command skips backing up files when the identical
files havele y been backed up to the specified device type.
already
n
ta determines that a file is identical and it has already been backed up, then it is a candidate
IfSRMAN
to be skipped. However, RMAN performs further checking to determine whether to skip the file,
because both the retention policy and the backup duplexing feature are factors in the algorithm that
RMAN uses to determine whether there are sufficient backups on the specified device type.
Refer to the Oracle Database Backup and Recovery User’s Guide for detailed information about the
criteria that RMAN uses to determine whether a file is identical and the backup optimization
algorithm.
You can enable backup optimization on the Backup Settings page in Enterprise Manager or by
issuing the CONFIGURE BACKUP OPTIMIZATION ON command. By default, backup optimization
is disabled.
Backup optimization is automatically enabled for the BACKUP RECOVERY AREA |
DB_RECOVERY_FILE_DEST and BACKUP RECOVERY FILES commands.
following command:
CONFIGURE BACKUP OPTIMIZATION OFF;
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Summary
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Practice 4 Overview:
Configuring Backup Specifications
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
Datafile Datafile
1 1
ble
Datafile Datafile
fe r a
2 2
ans
Datafile n - t r
Datafile
3 3 a no
a s
Tablespace ) Backup
h i d eฺ
HR_DATA m
co nt Gu set
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Creating Backup Setsuki
a s y ense
RMAN can store
y M l ic in an RMAN-exclusive format called a backup set. A backup set is a
its backups
collectionleof files called backup pieces, each of which may contain a backup of one or more database
n
Sta
files.
Note: The FORMAT parameter specifies a pattern to use in creating a file name for the backup pieces
created by this command. The FORMAT specification can also be provided through the ALLOCATE
CHANNEL and CONFIGURE commands.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
ble
fe r a
ans
Control n - t r
Archived log Data file file
a noSPFILE
a s
file copies copies
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(MBackup u
Creating a Whole Database k i t o
a s yu ense
A whole databaseM backupic can be either backup sets or image copies of the entire set of data files and
y l
e the control file. You can optionally include the server parameter file (SPFILE) and
nlredo
must include
t a
archived
S log files. Using Recovery Manager (RMAN) to make an image copy of all the database
files simply requires mounting or opening the database, starting RMAN, and entering the BACKUP
command shown in the slide. Optionally, you can supply the DELETE INPUT option when backing
up archivelog files. That causes RMAN to remove the archivelog files after backing them up. This is
useful especially if you are not using a Flash Recovery Area, which would perform space
management for you, deleting files when space pressure grows. In that case, the command in the
slide would look like this:
RMAN> BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
You must have issued the following CONFIGURE commands to make the backup as described
previously:
• CONFIGURE DEFAULT DEVICE TYPE TO disk;
• CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY;
• CONFIGURE CONTROLFILE AUTOBACKUP ON;
You can also create a backup (either a backup set or image copies) of previous image copies of all
data files and control files in the database by using the following command:
RMAN> BACKUP COPY OF DATABASE;
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
file blocks.
• A level 0 incremental backup is
equivalent to a full backup that has
been marked as level 0.
• A cumulative level 1 Cumulative
incremental backup
incremental backup contains
only blocks modified since the
last level 0 incremental a b le
backup. s fer
-
Differentialt r an
• A differential level 1 incremental
n onbackup
incremental backup contains s a
a
) h uideฺ
only blocks modified since the m
co nt G
last incremental backup. ailฺ m tude
g
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
RMAN Backup Typesuki
a s y ense
Full Backups M
y lic
l e
A full backup
n is different from a whole database backup. A full data file backup is a backup that
t a
S every used data block in the file. RMAN copies all blocks into the backup set or image
includes
copy, skipping only those data file blocks that have never been used. For a full image copy, the entire
file contents are reproduced exactly. A full backup cannot be part of an incremental backup strategy;
it cannot be the parent for a subsequent incremental backup.
Incremental Backups
An incremental backup is either a level 0 backup, which includes every block in the data files except
blocks that have never been used, or a level 1 backup, which includes only those blocks that have
been changed since a previous backup was taken. A level 0 incremental backup is physically
identical to a full backup. The only difference is that the level 0 backup can be used as the base for a
level 1 backup, but a full backup can never be used as the base for a level 1 backup.
Incremental backups are specified using the INCREMENTAL keyword of the BACKUP command.
You specify INCREMENTAL LEVEL [0 | 1].
ble
List of changed
fe r a
1011001010110 Change s
CTWR
blocks
0001110100101 t
tracking
- r an
Redo 1010101110011 on
nfile
generation s a
SGA a
) h uideRedoฺ log
o m
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Fast Incremental Backup
y u ki se to
The goal of anM as licbackup
incremental en is to back up only those data blocks that have changed since a
ey You can use RMAN to create incremental backups of data files, tablespaces, or the
previous lbackup.
n
Stadatabase. When making an incremental backup, RMAN scans each block of the data files to
whole
see which have changed since the last backup. That makes the backup smaller because only changed
blocks are backed up. It also makes recovery faster because fewer blocks need to be restored.
You can perform fast incremental backup by enabling block change tracking. Block change tracking
writes to a file the physical address of each block that is changed. When it is time to perform the
incremental backup, RMAN can look at the block change tracking file, and back up only those
blocks referenced there; it does not have to scan every block to see if it has changed since the last
backup. This makes the incremental backup faster.
The maintenance of the tracking file is fully automatic and does not require your intervention. The
size of the block change tracking file is proportional to the:
• Database size, in bytes
• Number of enabled threads in a RAC environment
• Number of old backups maintained by the block change tracking file
The minimum size for the block change tracking file is 10 MB, and any new space is allocated in 10
MB increments. The Oracle database does not record block change information by default.
ble
fe r a
ans
ALTER DATABASE n - t r
{ENABLE|DISABLE} BLOCK CHANGE TRACKING a no
[USING FILE '...'] has i )
d eฺ
o m
u
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Enabling Fast Incremental
y u ki Backups e
You enable block
s tracking
achange c en from the Database Control home page. Navigate to Availability >
M l i
l ey > Policy. You do not need to set the block change tracking file destination if the
Backup Settings
n
Sta
DB_CREATE_FILE_DEST initialization parameter is set because the file is created as an Oracle
Managed File (OMF) file in the DB_CREATE_FILE_DEST location. You can, however, specify the
name of the block change tracking file, placing it in any location you choose.
You can also enable or disable this feature by using an ALTER DATABASE command. If the change
tracking file is stored in the database area with your database files, then it is deleted when you
disable change tracking. You can rename the block change tracking file by using the ALTER
DATABASE RENAME command. Your database must be in the MOUNT state to rename the tracking
file. The ALTER DATABASE RENAME FILE command updates the control file to refer to the new
location. You can use the following syntax to change the location of the block change tracking file:
ALTER DATABASE RENAME FILE '...' TO '...';
Note: RMAN does not support backup and recovery of the block change tracking file. For this
reason, you should not place it in the Flashback Recovery Area.
(M a u
Creating Duplexed Backup k
u nsei Sets t o
Using CONFIGURE BACKUP COPIES
Use the CONFIGURE s
a ...y eBACKUP COPIES command to specify the number of identical backup
M l i c
l eywant to create on the specified device type. This setting applies to all backups except
sets that you
n
ta file autobackups (because the autobackup of a control file always produces one copy) and
control
S
backup sets when backed up with the BACKUP BACKUPSET command.
Note: You must have automatic channels configured.
To create a duplexed backup set with CONFIGURE BACKUP COPIES, perform the following steps:
1. Configure the number of copies on the desired device type for data files and archived redo log
files.
2. Execute the BACKUP command.
3. Issue a LIST BACKUP command to verify your backup.
Note: The last BACKUP command is not affected by the COPIES configuration setting. It
creates a single copy to disk.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
(M a u
Creating Duplexed Backup k i
u nse Sets t o
Using BACKUP COPIES
You can use the s y
a liccommand
e with the COPIES option to override other COPIES or DUPLEX
y M BACKUP
Datafile Datafile
1 1
Datafile
Datafile 2
2 Datafile ble
3 fe r a
Datafile ans
3 Archived n - t r
redo logs a no
Archived
a s
redo logs ) h i d eฺ
Backuposets Gu m
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Creating Backups of Backup
y u ki sSets e
as liBACKUPSET
Use the RMANMBACKUP c en command to back up previously created backup sets. Only
l e
backup sets y
that were created on device type DISK can be backed up using RMAN. The backup sets
n
Stbea backed up to any available device type.
can
The BACKUP BACKUPSET command uses the default disk channel to copy backup sets from disk to
disk. To back up from disk to tape, you must either configure or manually allocate a nondisk channel.
Archival backup
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Now
ble
End of Q1 fe r a
Recovery window of 7 days
s
tra n
o n -
Log nnn and Backup s an
Not needed for retention policy
) ha ideฺ
om tfor
BackuplฺcNeeded G u
retention policy
i
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Archival Backups: Concepts k i
a s yu ense
If you need to M preserve anic
online backup for a specified amount of time, RMAN normally assumes
y l
t a
satisfy
nthislewant
you might to perform point-in-time recovery for any time since that backup to the present. To
scenario, RMAN keeps the archived logs for that time period. However, you may have a
S
requirement to simply keep the specific backup (and what is necessary to keep it consistent and
recoverable) for a specified amount of time—for example, for two years. You do not have the
intention of recovering to a point in time since that backup, but you just want to be able to recover to
the exact time of the backup, and no later. You also want to maintain a retention policy that keeps
your backup area free of clutter, so making it reach back two years is not acceptable. This is a
common need, when meeting business or legal requirements for data retention.
An archival backup solves this problem. If you mark a backup as an archival backup, that attribute
overrides any configured retention policy for the purpose of this backup. You can retain archival
backups such that they are either considered obsolete only after a specific time that you specify, or
never considered obsolete. If you want to specify the latter, you need to use a recovery catalog.
The KEEP clause creates an archival backup that is a snapshot of the database at a point in time.
The only redo logs that are kept are those required to restore this backup to a consistent state. The
RESTORE POINT clause issued after the backup is completed determines the number of redo logs
that are kept (enough to restore the backup to the RESTORE POINT time).
That essentially gives a meaningful name to the point of time the backup was made.
After an archival backup is created, it is retained for as long as specified. Even if you have a much
smaller retention window and run the DELETE OBSOLETE command, the archival backup remains.
This backup is a snapshot of the database at a point in time, and can be used to restore the database to
another host for testing purposes, for example.
Note: Archival backups cannot be written to the Flash Recovery Area. So if you have one, you must
provide a FORMAT clause to specify a different location.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
(M a u
Creating Archival Backups k i with t
EM o
a s yu ense
To create an archival
y M l ic using Enterprise Manager, perform the following steps:
backup
2. t a nleAvailability
1. Select
Follow the steps of
> Schedule Backup > Schedule Customized Backup.
the Schedule Customized Backup wizard until you are on the Settings page.
S3. Click Override Current Settings and then the Policy tab. In the Override Retention Policy
section, you can select to keep a backup for a specified number of days. A restore point is
generated based on the backup job name. You probably also want to specify a different
destination for the backup files; to do this, use the Device tab.
clause causes both data file and archive log backup sets to be
included.
KEEP {FOREVER | UNTIL TIME [=] ' date_string '}
[RESTORE POINT rsname]
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
(M a u
Creating Archival Backups k i with t o
RMAN
a s yu ense
Use the following
y M l c{FOREVER|UNTIL
syntax ito create an archival backup using RMAN:
n l e
BACKUP ... KEEP TIME 'SYSDATE + <n>'} RESTORE POINT
Sta
<restore_point_name>
The UNTIL TIME clause enables you to specify when the archival backup is no longer immune to
the retention policy. You can optionally specify FOREVER, meaning that the backup is an archival
backup until you take some other action to change that.
Optionally, use the RESTORE POINT clause to specify the name of a restore point to be associated
with this backup.
ble
2 Changing the status of a database copy: fe r a
ans
n - t r
no
RMAN> CHANGE COPY OF DATABASE CONTROLFILE NOKEEP;
a
a s
m ) h uideฺ
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Managing Archival Database
y u ki sBackups
e
M as lchanges
The CHANGE command i c en the exemption status of a backup or copy in relation to the
configured
l y
eretention policy. For example, you can specify CHANGE ... NOKEEP, to make a
n
Sta that is currently exempt from the retention policy eligible for the OBSOLETE status.
backup
The first example changes a consistent backup into an archival backup, which you plan to store
offsite. Because the database is consistent and, therefore, requires no recovery, you do not need to
save archived redo logs with the backup.
The second example specifies that any long-term image copies of data files and control files should
lose their exempt status and so become eligible to be obsolete according to the existing retention
policy. This statement essentially removes the archival attribute from those backup files. If you do
not specify a tag, as in this case, then the CHANGE execution applies to all backups of the type
specified. You should specify a tag to change only the backup files you intend to change.
Note: The RESTORE POINT option is not valid with the CHANGE command, because there is no
way to create the restore point for a time that has already passed (when the backup was created).
Channel 1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Section 1
Channel 2
Section 2
Channel 3
Section 3
Channel 4
Section 4
ble
fe r a
Channel 5 ans
Section 5
n - t r
Channel 6 a no
Section 6 a s
) h i d eฺ
One large data file m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Multisection Backups: k i
Overview
a s yu ense
Oracle data files
M can be upicto 128 TB in size. Normally, the smallest unit of an RMAN backup is an
y l
l
entire file.
n eThis is not practical with such large files. RMAN can optionally break up large files into
Sta and back up and restore these sections independently. You do this by creating multisection
sections
backups, which break up the files generated for the backup set into separate files. This can be done
only with backup sets, not image copies.
Each file section is a contiguous range of blocks of a file. Each file section can be processed
independently, either serially or in parallel. Backing up a file into separate sections can improve the
performance of the backup operation, and it also allows large file backups to be restarted.
A multisection backup job produces a multipiece backup set. Each piece contains one section of the
file. All sections of a multisection backup, except perhaps for the last section, are of the same size.
There are a maximum of 256 sections per file.
Note: You should not apply large values of parallelism to back up a large file that resides on a small
number of disks, as that would defeat the purpose of the parallel operation; multiple simultaneous
accesses to the same disk device would be competing with each other.
This feature is built into RMAN. No installation is required beyond the normal installation of Oracle
Database 11g. COMPATIBLE must be set to at least 11.0, because earlier releases cannot restore
multisection backups.
Example:
Compressing Backups
is generated.
• It can be performed in addition to unused block
compression.
• By default, RMAN uses the BZIP2 compression algorithm.
• BZIP2 generally differs from ZLIB in the following respects:
– It has a better compression ratio.
– It is slower. ble
fe r a
• No extra steps are required by the DBA to restore a ns
compressed backup. t r a
n- no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Compressing Backups k i
a s yu ense
While unused block
y M l ic decreases the number of blocks that are written to the backup,
compression
t a nle algorithms
binary compression
compression
can be used to algorithmically compact the data that is written. The two available
are ZLIB and BZIP2.
S
ZLIB is optimized for CPU efficiency. BZIP2 is optimized for maximum compression. BZIP2
consumes more CPU resource than ZLIB but usually produces more compact backups. The
COMPATIBLE initialization parameter must be set to 11.0.0 or higher for ZLIB compression, which
requires the Oracle Advanced Compression option.
You do not have to perform any additional steps when restoring a compressed backup. Note,
however, that compression and decompression operations require CPU resources. So both creating
and restoring a compressed backup will, of course, probably take longer and require more system
resources.
When choosing an algorithm, consider your disk space in addition to dynamic system resources such
as CPU and memory.
Encrypting Backups
Password: **********
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Encrypting Backups uki
a s y ense
You can encrypt
y M backupsiin
l c one of three ways:
e
anl encryption: This method of encryption relies on a password. There is no need to
• Transparent encryption: This method uses a wallet, and it is the default mode.
•StPassword
configure a wallet. You must know the password that was used for the backup in order to
restore.
• Dual mode encryption: Both transparent and password encryption are used. In order to restore,
either the transparent mode or the password mode can be used. This type of encryption is useful
if you usually restore your backups to the local site, but sometimes ship the backups to other
sites.
Modify the encryption setting using SET ENCRYPTION. Here is an example of password
encryption:
RMAN> SET ENCRYPTION IDENTIFIED BY mypassword;
RMAN> BACKUP DATAFILE 5;
...
RMAN> SET DECRYPTION IDENTIFIED BY mypassword;
use a wallet. This is the same wallet used with Transparent Data Encryption. The wallet must be
created before it can be used for either encrypted backups or TDE.
Add an entry to the SQLNET.ORA file:
ENCRYPTION_WALLET_LOCATION =
(SOURCE =
(METHOD = FILE)
(METHOD_DATA =
(DIRECTORY =
/oracle/dbsid/admin/pdcs11/wallet)))
Create a simple password-protected wallet with the following command: ble
ALTER SYSTEM SET [ENCRYPTION] KEY IDENTIFIED BY "welcome1";
fe r a
n s
Note: Encryption by Oracle Secure Backup (OSB) can be configured so that all backups
n - t ra are
a
Backup Administrator’s Guide for more information about OSB encryption.
no See the Secure
encrypted by OSB no matter what type of encryption is requested by the client.
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n l e
Sta
ble
fe r a
ans
n - t r
a no
a s
Flash Recovery Area
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Backing Up RecoveryuFiles k i (M e to u
astoyback e n s
There are two M ways ic current and data.
up recovery The BACKUP RECOVERY AREA command backs up
y lthe
n l e
all files that are found in any previous Flash Recovery Areas. The BACKUP
S ta
RECOVERY FILES command backs up all recovery files, even if they are not in the Flash Recovery
Area. You gain added protection from loss by using the latter, which would back up, for example,
any copies of control files or data files that are not in the Flash Recovery Area.
By default, backup optimization is in effect for these two commands, even if you have disabled it
using the CONFIGURE command. This means that the only recovery files that this command backs
up are those that are not already backed up. You can force all files to be backed up by using the
FORCE option. Backup optimization is covered in the lesson titled “Configuring Backup
Specifications.”
You cannot specify DEVICE TYPE DISK for either of these commands.
Note: RMAN backs up only database files: data files, redo log files, control files, SPFILES, archive
log files, and backups of these files. Placing an operating system file in the Flash Recovery Area
causes it to be included with a backup of the recovery area.
Server
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Recovery session
Manager (channel)
Media
Management
Library
Oracle Secure Or
Backup with
built-in MML Media ble
management fe r a
server software ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using a Media Manager k i
a s yu ense
To use tape storage
y M l ic database backups, RMAN requires Oracle Secure Backup or a media
for your
manager.le
AS tan manager is a utility that loads, labels, and unloads sequential media (such as tape drives) for
media
the purpose of backing up, restoring, and recovering data. The Oracle database server calls Media
Management Library (MML) software routines to back up and restore data files to and from media
that is controlled by the media manager.
Note that the Oracle database server does not need to connect to the MML software when it backs up
to disk.
Oracle Backup Solutions Program (BSP) provides a range of media management products that are
compliant with Oracle’s MML specification. Software that is compliant with the MML interface
enables an Oracle database session to back up data to a media manager and request the media
manager to restore backups. Check with your media vendor to determine whether it is a member of
Oracle BSP.
Before you can begin using RMAN with a media manager, you must install the media manager
software and make sure that RMAN can communicate with it. Instructions for this procedure should
be available in the media manager vendor’s software documentation.
3. Obtain and install the third-party media management module for integration with the Oracle
database. This module must contain the library loaded by the Oracle database server when
accessing the media manager.
Backup and Restore Operations Using a Media Manager
The following Recovery Manager script performs a data file backup to a tape drive controlled by a
media manager:
run {
# Allocating a channel of type 'sbt' for serial device
ALLOCATE CHANNEL ch1 DEVICE TYPE sbt;
bl e
BACKUP DATAFILE 3;
fe r a
}
t r a ns
When Recovery Manager executes this command, it sends the backup requestoto n -the Oracle database
session performing the backup. The Oracle database session identifies the n channel as a media
a output
s
haand write
management device and requests the media manager to load a tape
) i d eฺthe output.
The media manager labels and keeps track of the tape and m
cothe namesG ofuthe files on each tape. The
i l ฺ t
media manager also handles restore operations. When
g m a you restore
u d en a file, the following steps occur:
1. The Oracle database server requests the
k i @ restoration
i s Soft a particular file.
2. The media manager identifies the
s y utape containing
th the file and reads the tape.
3. The media manager passes a e
us back to the Oracle database session.
i (Mthe
4. The Oracle databasekserver
information
t
writeso the file to disk.
a syu cense
yM li
n l e
Sta
Server
Recovery session
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Manager (channel)
Media
Management
Library
Media ble
management fe r a
server software ans
n - t r
a no
a s
Storage Area Network m ) h
(SAN) i d eฺ
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Performing Proxy Copies k i
u nse
a s y
Use the PROXYMoption ofitheeRMAN BACKUP command to request a MML to perform the copy of
l c
the files. ley
n
Stamedia management products can completely manage all data movement between Oracle data
Some
files and the backup devices. Some products that use high-speed connections between storage and
media subsystems can reduce much of the backup load from the primary database server. This is
beneficial in that the copying takes place across the SAN instead of the LAN. Also, RMAN is out of
the picture at that point, except for communicating status across the LAN to and from the MML.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M Backup u
k
Creating an Oracle-Suggested i t o
a s yu ense
Enterprise Manager
y M makes
l icit easy for you to set up an Oracle-suggested backup strategy that protects
your datale
far t a
back
nasand
48
provides efficient recoverability to any point in the preceding 24 hours, and possibly as
hours, depending on when the last backup was created. The Oracle-suggested strategy
S
uses the incremental backup and incrementally updated backup features, providing faster
recoverability than is possible when applying database changes from the archived log files.
To establish an Oracle-suggested strategy, navigate to the Maintenance page. In the
Backup/Recovery region, select Schedule Backup. The Backup Strategies section enables you to
select from the Oracle-suggested backup and Customized backup strategies. The Oracle-suggested
strategy takes a full database copy as the first backup. Because it is a whole database backup, you
might want to consider taking this at a period of least activity. After that, an incremental backup to
disk is taken every day. Optionally, a weekly tape backup can be made, which backs up all recovery-
related files.
Because these backups on disk are retained, you can always perform a full database recovery or a
point-in-time recovery to any time within the past 24 hours, at the minimum. The recovery time
could reach back as far as 48 hours. This is because just before a backup is taken on a given day, the
backup from the beginning of day n–1 still exists.
your backups:
• LIST: Displays information about backup sets, proxy copies,
and image copies recorded in the repository
• REPORT: Produces a detailed analysis of the repository
• REPORT NEED BACKUP: Lists all data files that require a
backup
• REPORT OBSOLETE: Identifies files that are no longer b le
r a
needed to satisfy backup retention policies sfe n
n - tra
o
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
y u ki se to
Managing Backups: Reporting
as command
Use the RMANMLIST
l i c en to display information about backup sets, proxy copies, and image
l ey in the repository. Use this command to list:
copies recorded
n
S a
• tBackups and copies that do not have the AVAILABLE status in the RMAN repository
• Backups and copies of data files that are available and can possibly be used in a restore
operation
• Backup sets and copies that contain a backup of a specified list of data files or specified
tablespaces
• Backup sets and copies that contain a backup of any archived logs with a specified name or
range
• Backup sets and copies restricted by tag, completion time, recoverability, or device
• Incarnations of a specified database or of all databases known to the repository
• Stored scripts in the recovery catalog
Use the RMAN REPORT command to analyze information in the RMAN repository in more detail.
The REPORT NEED BACKUP command is used to identify all data files that need a backup. The
report assumes that the most recent backup would be used in the event of a restore.
Refer to the Oracle Database Backup and Recovery Reference for detailed syntax information.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
(to
Using Enterprise Manager k i
u nsView e Backup Reports
s y
a lReport e page to display lists of backup jobs that are known to the database
You can use the M Backup i c
l
through the
n eyinformation recorded about them in the database control file.
Stacan customize the jobs that appear in the Results table by using the Search fields at the top of
You
the page. The Results table lists basic information about each backup job, such as the Start Time, the
Time Taken, and the Status of the backup job. You can also use the Results table to drill down to
individual, detailed backup job reports by using the link in the Backup Name column.
You can drill down to a Summary of Job page of the backup job by clicking the Status of the job in
the Results table, where you can view the contents of the output log.
Click the Backup Name link, and you can use the Backup Report page to display detailed
information about that backup. The information displayed on this page is derived from the
information recorded in the database control file.
The Backup Report page displays result information in the Result section in various categories, such
as Input Summary, containing rollup information about the files that were backed up; Output
Summary, containing rollup information about the Backup Sets and Image Copies; and then Inputs
and Outputs sections that display tables containing detailed job information about the data files,
control files, backup sets, backup pieces, and image copies.
Summary
Practice 5 Overview:
Creating Backups
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
Restore
ble
fe r a
ans
Redo log
n - t r
Recover a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Restoring and Recovering k i
a s yu ense
The “recovery”
y Mportionliofc backup and recovery tasks includes two major types of activities:
restoring
a n leand recovering. Restoring a file is the process of copying a backup into place to be
t
used
S by the database. This is necessary if, for example, a file is damaged because the physical
disk it is on fails. This is usually due to hardware problems, such as disk write errors, or
controller failure. In that case, a backup of the file needs to be copied onto a new (or repaired)
disk.
Recovering the file entails applying redo such that the state of the file is brought forward in time,
to whatever point you want. That point is usually as close to the time of failure as possible.
In the database industry, these two operations are often referred to, collectively, with the single
term “recovery.”
• User error
• Application error
• Media failure
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Causes of File Loss uki
a s y ense
Files can be lost
y lic due to:
M or damaged
• User
a n leerror: An administrator may inadvertently delete or copy over a necessary operating
t
S system file.
• Application error: An application or script can also have a logic error in it, as it processes
database files, resulting in a lost or damaged file.
• Media failure: A disk drive or controller may fail fully or partially, and introduce
corruption into files, or even cause a total loss of files.
function.
Losing a Tempfile
Tablespace altered.
Tablespace altered.
No Active
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Recovering from theuLoss k to u Log Group
i (Mofea Redo
a y ens
sentire
If you have lost
y M an licredo log group, then all copies of the log files for that group are
unusable
t a nleor gone.
S simplest case is where the redo log group is in the INACTIVE state. That means it is not
The
currently being written to, and it is no longer needed for instance recovery. If the problem is
temporary, or you are able to fix the media, then the database continues to run normally, and the
group is reused when enough log switch events occur. Otherwise, if the media cannot be fixed,
you can clear the log file. When you clear a log file, you are indicating that it can be reused.
If the redo log group in question is ACTIVE, then, even though it is not currently being written
to, it is still needed for instance recovery. If you are able to perform a checkpoint, then the log
file group is no longer needed for instance recovery, and you can proceed as if the group were in
the inactive state.
If the log group is in the CURRENT state, then it is, or was, being actively written to at the time
of the loss. You may even see the LGWR process fail in this case. If this happens, the instance
crashes. Your only option at this point is to restore from backup, perform cancel-based
incomplete recovery, and then open the database with the RESETLOGS option.
Start
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Yes
Log file
ALTER DATABASE CLEAR LOGFILE ... archived?
No
Yes
Needed for
data file?
ble
fe r a
No
an s
ALTER DATABASE CLEAR UNARCHIVED LOGFILE ... n - t r
a no
h a s ฺ
) i d eDATAFILE
ALTER DATABASE CLEAR UNARCHIVED LOGFILE ... UNRECOVERABLE m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Clearing a Log File uki
a s y ense
Clear a log file
y M using this
l iccommand:
t a nle ALTER DATABASE CLEAR [UNARCHIVED] LOGFILE GROUP <n>
S [UNRECOVERABLE DATAFILE]
When you clear a log file, you are indicating that it can be reused. If the log file has already been
archived, the simplest form of the command can be used. Use the following query to determine
which log groups have been archived:
SQL> SELECT GROUP#, STATUS, ARCHIVED FROM V$LOG;
For example, the following command clears redo log group 3, which has already been archived:
SQL> ALTER DATABASE CLEAR LOFGILE GROUP 3;
If the redo log group has not been archived, then you must specify the UNARCHIVED keyword.
This forces you to acknowledge that it is possible that there are backups that rely on that redo
log for recovery, and you have decided to forgo that recovery opportunity. This may be
satisfactory for you, especially if you take another backup right after you correct the redo log
group problem; you then no longer need that redo log file.
It is possible that the redo log is required to recover a data file that is currently offline.
Re-Creating Indexes
• PARALLEL
• NOLOGGING
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Re-Creating Indexesuki
a s y ense
When creating
y lic an index, you can use the following keywords to reduce the
Mor re-creating
creation
a n le
time:
t
S• PARALLEL (NOPARALLEL is the default): Multiple processes can work together
simultaneously to create an index. By dividing the work necessary to create an index among
multiple server processes, the Oracle server can create the index more quickly than if a
single server process created the index sequentially. The table is randomly sampled and a
set of index keys is found that equally divides the index into the same number of pieces as
the specified degree of parallelism. A first set of query processes scans the table, extracts
key, row ID pairs, and sends each pair to a process in a second set of query processes based
on the key. Each process in the second set sorts the keys and builds an index in the usual
fashion. After all index pieces are built, the parallel coordinator concatenates the pieces
(which are ordered) to form the final index.
• NOLOGGING: Using this keyword makes index creation faster because it creates a very
minimal amount of redo log entries as a result of the creation process. This greatly
minimized redo generation also applies to direct path inserts and Direct Loader
(SQL*Loader) inserts. This is a permanent attribute and thus appears in the data dictionary.
It can be updated with the ALTER INDEX NOLOGGING/LOGGING command at any time.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Recovering from a Lost k i
u nseTablespace
Index
s y
a objects, e in that they do not provide any original data, and they are only a
Indexes are computed
y M l i c
different
n l erepresentation of data that already exists. So, in most cases, indexes can be re-created
t a
easily.
S If you have a tablespace that contains only indexes, recovering from a loss of a data file
belonging to that tablespace can be simplified.
When a data file like this is lost, you can perform the following steps:
1. Drop the data file.
2. Drop the tablespace.
3. Re-create the index tablespace.
4. Re-create the indexes that were in the tablespace.
Authentication Methods
for Database Administrators
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Re-creating a Password
Authentication File
SQL> grant sysdba to admin2;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
Complete
Time of
fe r a
recovery
crash
ans
n - t r
Incomplete
recovery a no
s
Recovery
a
Restore from Missing transactions ) htask eฺ
started
i d
m u time
co nt atGthis
this backup after incomplete recovery
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Comparing Complete k i
u nIncomplete
and e Recovery
s y
a complete s
e recovery, you bring the database to the state where it is fully up-to-
When you perform
M l i c
l ey all committed data modifications to the present time. Incomplete recovery,
date, including
n
Sta brings the database to some point in the past. This means there are missing
however,
transactions; any data modifications done between the recovery destination time and the present
are lost. In many cases, this is the desirable goal because there may have been some changes
made to the database that need to be undone. Recovering to a point in the past is a way to
remove the unwanted changes.
Archived
log Archived
log Online
Redo log
2 4
bl e
fe r a
1 t r a ns
3 5 n -
n o
Restored Data files containing as a
data files committed and uncommitted
m ) h uideฺRecovered
o
ilฺc ent G
transactions data files
a
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Complete Recovery u
y ki se to
Process
The followingM as describe
steps l i c enwhat takes place during complete recovery:
l ey or missing files are restored from a backup.
1. Damaged
n
S2.taChanges from incremental backups, archived redo log files, and online redo log files are
applied as necessary. The redo log changes are applied to the data files until the current
online log is reached and the most recent transactions have been reentered. Undo blocks are
generated during this entire process. This is referred to as rolling forward or cache recovery.
3. The restored data files may now contain committed and uncommitted changes.
4. The undo blocks are used to roll back any uncommitted changes. This is sometimes referred
to as transaction recovery.
5. The data files are now in a recovered state and are consistent with the other data files in the
database.
Archived
log Archived
X
log Online
X
Redo log
are missing an archived log containing transactions that occurred sometime between the time of
the backup you are restoring from and the target recovery SCN. Without the missing log, you
have no record of the updates to your data files during that period. Your only choice is to recover
the database from the point in time of the restored backup, as far as the unbroken series of
archived logs permits, and then open the database with the RESETLOGS option. All changes in
or after the missing redo log file are lost.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Types of Backup and k i
u nse Practices
Recovery
s y
a lyou ecan use to recover your database. You can use RMAN, and take
There are twoM methods i c
l
advantage
n eyof its automatic recovery capabilities. It can restore the appropriate files and bring the
Sta back to a current state by using very few commands. You can also recover manually.
database
This is called user-managed recovery. User-managed recovery entails moving the files around
using OS commands, and then issuing the recovery commands in SQL*Plus.
Both of these methods use restore and recovery processes.
Performing a User-Managed
Backup of the Database
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
No Yes
ARCHIVELOG
mode?
ble
fe r a
an s
n - t r
Copy files.
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Performing a User-Managed k i
u nseBackup of the Database
s y
You can backM upathe database
l i c e by using OS commands to make copies of the data files. The
l
course of y depends on whether the database is in ARCHIVELOG mode or not. If it is, then
eaction
n
Stacan keep the database open and available by putting each tablespace into backup mode
you
before copying its data files. Otherwise, you have to shut down the database before copying the
data files.
Copy
Database block data file
while
online ble
fe r a
ans
n - t r
t1 t2
a no t3
a s
) h i d eฺ
If the block is copied at time t2, then m
cothe block
G u fractured.
is
i l ฺ t
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
The Need for Backup k i
Mode
a s yu ense
When a blockM
y lic to as part of the execution of a data manipulation language
is being written
a le
(DML)nstatement, there could be several parts of the block affected. Not all of the modifications
t
toSthe block happen at the same time, so there is the possibility of inconsistency in the block at
certain times. Suppose time t2 represents the time between when different parts of the block are
written to. If, at time t2, the block is copied as part of the execution of an OS copy command,
then the block is considered fractured. Also, the OS copy command does not necessarily copy
the file header first, so it must be frozen for the duration of the copy execution.
RMAN has the means to deal with this problem. If a fractured block is read, it keeps rereading it
until it is consistent.
However, if an OS command such as the Linux cp command is copying the data file, the
fractured block is not recognized as such, and the copy of the block is not consistent. In order to
remedy this, put the tablespace, or even the entire database, into what is called backup mode.
The effect of doing this is that additional redo is generated. An image of each block, before it is
modified, is written to the redo log. Then, during recovery of blocks in that data file, the before
image of a fractured block can be used for the basis of recovery and the additional redo data is
applied to it. In order to reduce the overhead associated with maintaining extra redo data, Oracle
recommends putting one tablespace at a time into backup mode, while its data files are being
copied.
NAME
------------------------------------------------------------------------
/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_36mky81f_.dbf
/u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_36mky81p_.dbf
/u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_36mky857_.dbf
/u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_36mky876_.dbf
/u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_36ml2cmh_.dbf
/u01/app/oracle/oradata/ORCL/datafile/survey01.dbf
ble
fe r a
SQL> select name from v$controlfile;
ans
NAME
n - t r
------------------------------------------------------------------------
a no
/u01/app/oracle/oradata/ORCL/controlfile/o1_mf_36ml1f8x_.ctl
a s
) h
/u01/app/oracle/flash_recovery_area/ORCL/controlfile/o1_mf_36ml1fkk_.ctl
i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Identifying Files to Manually
u nseBackup
s y
a lirequire e you to know the data file names and locations on disk, so you
User-managedMbackups c
know n l
whateyfiles need to be copied. Identify the data files to be backed up by querying the
Sta
V$DATAFILE view. Identify the control file location by querying the V$CONTROLFILE view.
Only one of the multiplexed control files needs to be backed up, because they are identical.
Database altered.
Performing User-Managed
Complete Database Recovery: Overview
User-managed complete database recovery:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
open?
Query for files to recover.
No
a no
a s
) h
Open i d eฺ
database.
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Performing Complete k i
u nseDatabase Recovery: Overview
Closed
s y
a lice such as damage to a file belonging to the SYSTEM tablespace, the
Under certainM circumstances,
instancel y down automatically. Even if the instance keeps running, and there are problems
eshuts
n
Staother data files, you may decide there is no value is keeping the database running; too many
with
database objects are affected. In that case, shut down the database to perform the recovery.
If the database is still open, you can query the V$RECOVER_FILE view to see which data files
are in need of recovery, and after you restored them, query V$RECOVERY_LOG to see which
archive logs are required. That will tell you which files need to be restored from backup, if any.
Then shut down the database. Look into the media failure to determine the cause of the problem.
Repair the problem so that you can restore the files from backup. For example, you may need to
replace a disk drive.
Now you can perform the recovery using the RECOVER command. Limit the scope of the
recovery to only what is needed, such as data file or tablespace. If needed, recover the entire
database. Then open the database.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Identifying Recovery-Related k i
u nseFiles
s y
If the databaseMisastill open,
l i c equery the files as described below. Otherwise, attempt to start the
instance
n l eandy mount the database to issue the queries.
ta to determine which data files require recovery, query the V$RECOVER_FILE view.
Sorder
In
The ERROR column indicates why the file requires recovery. If this column has any value other
than OFFLINE NORMAL, then it needs recovery. To see the whole picture of which data files
and tablespaces are affected, join V$DATAFILE and V$TABLESPACE in this query. Here is an
example:
SELECT r.FILE#, d.NAME df_name, t.NAME tbsp_name,
d.STATUS, r.ERROR, r.CHANGE#, r.TIME
FROM V$RECOVER_FILE r, V$DATAFILE d, V$TABLESPACE t
WHERE t.TS# = d.TS#
AND d.FILE# = r.FILE#;
This tells you the extent of the damage, helping you decide what the objects of the RECOVER
command should be.
The V$RECOVERY_LOG view shows which archive log files are needed to perform the
recovery. If the list shows files that have since been moved off the default archive log location,
then you have to restore them to some location before performing recovery.
After recording the results of these queries, shut down the database.
1 Data files
Archive logs
2 /disk1/datafile.dbf /disk2/datafile.dbf bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
3 ONLINE m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Restoring Recovery-Related i
u nseFiles
s y
a whatlidatae files and archive log files are required, restore them to appropriate
After determining
M c
l ey Restore a data file by copying it from the backup location, as in this example:
disk locations.
n
Sta $ cp /disk2/backup/datafile/survey01.dbf \
> $ORACLE_BASE/oradata/ORCL/datafile/survey01.dbf
If any archive logs are needed for recovery, check whether they are still in the default disk
location for archive logs. They may not be, if they have been moved to tape or another disk
drive, for example. If they have been moved, they need to be restored, either to the default
archive log location or to a temporary location. If there is enough space available in the default
location (which is specified by the LOG_ARCHIVE_DEST_1 initialization parameter), then
restore them there. Otherwise, you can put them on some other disk location. When it is time to
restore, you can specify that alternate location to find archive log files.
If you had to move a data file, that fact has to be recorded in the control file. That is done by
executing the ALTER DATABASE RENAME FILE command, as shown in the following
example:
SQL> ALTER DATABASE RENAME FILE
2> '/u01/app/oracle/oradata/ORCL/datafile/survey01.dbf' TO
3> '/newdisk/ORCL/datafile/survey01.dbf';
Note: You must start the instance and mount the database before executing the ALTER
DATABASE RENAME FILE command.
Oracle Database 11g: Administration Workshop II 6 - 31
Computer Pride Limited
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
ble
Could be DATABASE, fe r a
TABLESPACE, or DATAFILE
ans
n - t r
a no
2. Open the database: a s
) h i d eฺ
SQL> ALTER DATABASE OPEN; m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Applying Redo Datauki
a s y ense
Now the dataM
y c restored to some point in the past. The archive log files have also
files havelibeen
a n le either to their default location or to some other location, for the purpose of this
been restored:
S t
recovery only. You are ready to perform the actual recovery step, which means the redo is
applied and the data files are brought up to the latest SCN. Do that using the SQL*Plus
RECOVER command.
If you do not specify the AUTOMATIC option, then you are prompted for each redo log file that
is about to be applied. That gives you more control over the recovery process. Typically,
AUTOMATIC is used for full recovery.
If the archive log files have been restored to some disk location other than the default for the
database, then you must specify the FROM clause. Supply the directory where the files are stored,
and the recovery process will look there for the files.
Finally, open the database. It is now fully recovered.
No
a b le
Restore damaged files and archive logs. r
n s fe
n - tra
Recover data files.
a no
a s
) h i d eฺ
Bring tablespaces online. m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Performing Complete k i
u nsDatabase
Open e Recovery
s y
a lwhile e the database is open, the database continues to function. When an
If media failure
M occurs i c
y to write to one of these data files, the data file is taken offline automatically. A
attempt
n isemade
l
Sta against one of these data files does not cause it to go offline, but it does result in an error
query
being returned to the user that issued the query.
As with the closed database recovery, you first need to query for the files and archive logs that
need to be recovered. Then, take all tablespaces that contain damaged data files offline. Use a
command such as the following to do this:
SQL> ALTER TABLESPACE survey OFFLINE TEMPORARY;
Using the TEMPORARY option causes Oracle to perform a checkpoint on any online data files
belonging to the tablespace. Checkpointed data files do not require recovery when they are
brought back online, because they are up-to-date for the latest SCN of any transactions that
would have affected them. This is the more desirable option, although the data files must be
available at the time this command is run. It is possible that the problem was temporary, and you
are able to bring the tablespaces online with no errors.
Guide.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Performing User-Managed
Incomplete Recovery: Overview
Recover the database to a past point in time in the following
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
situations:
• You want the database to be in the state that existed before
a user error or an administrative error occurred.
• The database contains corrupt blocks after you tried block
media recovery.
• You are unable to perform complete database recovery
because some of the redo log files are missing. le
a b
• You want to create a test database that is in the state at sfer
some time in the past. - t r an
n o n
• One or more unarchived redo log files and a data
a file are
a s
lost. ) h deฺ m u i
o G
a ilฺc ent
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Performing User-Managed
y u ki Incomplete
s e Recovery: Overview
An incomplete
s n
a liciseone that does not bring the database back to the most recent SCN that
recovery
M
l ey For some reason, as listed in the slide, you need to recover that database only up
was transacted.
n
toSata
point in the past, not to the present. The processing that occurs when performing incomplete
recovery differs from the processing for complete recovery, basically, in the amount of redo that
is applied.
Performing User-Managed
Incomplete Recovery
• Recover a database until time:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Performing User-Managed i
u nIncomplete
e Recovery
s y s
a liciseused to perform incomplete recovery:
The followingMcommand
n l eyRECOVER [AUTOMATIC] DATABASE option
Sta are the meanings of the options:
Following
• AUTOMATIC: Automatically applies archived and redo log files
• option: UNTIL TIME 'YYYY-MM-DD:HH24:MI:SS'
UNTIL CANCEL
UNTIL CHANGE <integer>
USING BACKUP CONTROLFILE
Cancel-Based Incomplete Recovery
Cancel-based incomplete recovery is very much like closed database complete recovery. The
difference is how you execute the RECOVER command; specify the UNTIL CANCEL clause.
This clause causes the recovery process to prompt you with the suggested name for each redo
log file to be applied. So, as the recovery proceeds, you are prompted with an archived or online
redo log file name, and, for each one, you can either accept it or change it. When you reach the
point where you want the recovery to stop, enter CANCEL instead of accepting the file name.
This stops the recovery.
After this is done, you have to open the database with the RESETLOGS option. The database is
in another instantiation now, so the redo log sequence numbers need to be reset.
time specified on the command line of the RECOVER command, to know when to stop. Change-
based recovery uses an SCN, specified on the command line.
As with all incomplete recoveries, the database must then be opened using the RESETLOGS
option.
Note: To apply redo log files automatically during recovery, you can use the SQL*Plus SET
AUTORECOVERY ON command, enter AUTO at the recovery prompt, or use the RECOVER
AUTOMATIC command.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Performing User-Managed
Incomplete Recovery: Steps
To perform user-managed incomplete recovery, follow these
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
steps:
1. Shut down the database.
2. Restore data files.
3. Mount the database.
4. Recover the database.
5. Open the database with the RESETLOGS option.
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Performing User-Managed k i
u nIncomplete e Recovery: Steps
s y
a is open, s
eshut it down by using the NORMAL, IMMEDIATE, or
1. If the database
M l i c
l ey
TRANSACTIONAL
n option.
t a
S2. Restore all data files from backup. You must use a backup taken before the time you plan to
recover to. You may also need to restore archived logs. If there is enough space available,
restore to the LOG_ARCHIVE_DEST location or use the ALTER SYSTEM ARCHIVE
LOG START TO <LOCATION> command or the SET LOGSOURCE <LOCATION>
command to change the location. If you perform incomplete recovery to a point when the
database structure is different than the current, you also need to restore the control file.
3. Mount the database.
4. Recover the database by using the RECOVER DATABASE command.
5. To synchronize data files with control files and redo logs, open the database by using the
RESETLOGS option.
bl e
SQL> SHUTDOWN IMMEDIATE
fe r a
$ cp /BACKUP/*.dbf /u01/db01/ORADATA
n s
SQL> STARTUP MOUNT
n - tra
SQL> no
RECOVER DATABASE UNTIL TIME '2005-11-28:11:44:00';
a
SQL> ALTER DATABASE OPEN RESETLOGS; as ) h uideฺ
o m
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to Example
User-Managed Time-Based
y u ki sRecovery:
e
The followingM
s cscenario
isaa typical en employing UNTIL TIME recovery. Assume the following
l i
facts: nley
S• taThe current time is 12:00 PM on November 28, 2005.
• A job was run incorrectly, and many tables in several schemas were affected.
• This happened at approximately 11:45 AM.
• Database activity is minimal because most staff are currently in a meeting. The state of the
database before the job ran must be restored.
Because the approximate time of the error is known and the database structure has not changed
since 11:44 AM, you can use the UNTIL TIME method:
1. If the database is open, shut it down by using the NORMAL, IMMEDIATE, or
TRANSACTIONAL option.
2. Restore all data files from backup (the most recent if possible). You may also need to
restore archived logs. If there is enough space available, restore to the
LOG_ARCHIVE_DEST location or use the ALTER SYSTEM ARCHIVE LOG START
TO <LOCATION> command or the SET LOGSOURCE <LOCATION> command to
change the location.
3. Mount the database.
RESETLOGS option:
SQL> alter database open resetlogs;
SQL> archive log list
...
Oldest online log sequence 0
Next log sequence to archive 1
Current log sequence 1
When recovery is successful, notify users that the database is available for use, and any data
entered after the recovery time (11:44 AM) will need to be reentered.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
a read-only tablespace:
• You do not have to put it in backup mode in order to make a
copy of its data files.
• You do not have to take the tablespace or data file offline
before making a copy of it.
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Recovering a Read-Only k i
u Tablespace
a s y e n se
Because read-only
y lic are not being written to, there are special considerations to take
M tablespaces
a n le which can make the recovery process faster and more efficient. You do not have to
into account,
putt
S a read-only tablespace into backup mode or take it offline before copying it to the backup
location. Simply copy it.
When restoring a read-only tablespace, take the tablespace offline, restore the data files
belonging to the tablespace, and then bring the tablespace back online.
Consider the following scenario, where a read-only tablespace is changed to be read/write:
1. Make a backup of a read-only tablespace.
2. Make the tablespace read-write.
3. Recover the tablespace.
The backup you made in step 1 can still be used to recover this tablespace, even though, since
the backup was made, the tablespace was made read-write, and has even possibly been written
to. In this case, the tablespace requires recovery, after the files are stored from such a backup.
Redo log
ble
fe r a
SQL> CREATE TABLE sales_copy NOLOGGING; ans
SQL> INSERT /*+ APPEND */ INTO sales_copy n - t r
2 SELECT * FROM sales_history; a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to Objectsu
Recovering NOLOGGING k i Database
a s yu ense
Take advantage
y l ic
M of the efficiencies of the NOLOGGING attribute of tables and indexes if you can.
When you
a n le create a table as NOLOGGING, minimal redo data is written to the redo stream to
t
support
S the creation of the object. This is useful for making large inserts go faster.
In the example in the slide, the SALES_COPY table is created as a NOLOGGING table. As a
result, when an insert is done with the APPEND hint, no redo is generated for that particular
insert statement. As a result, you cannot recover this transaction on the SALES_HISTORY table.
If that is a problem, it is important that you make a backup of whatever tables you populate in
this way, right afterward. Then you are able to go to the more recent backup of the table.
If you perform media recovery, and there are NOLOGGING objects involved, they will be
marked logically corrupt during the recovery process. In this case, drop the NOLOGGING objects
and re-create them.
Current Backup
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
bl e
fe r a
Online log status
tra
Data file-status
ns
n on
s a
a
) h uideฺ
o m
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Recovering from theuLoss
y ki ofseAlltoControl File Copies: Overview
Even though you
s copies
ahave c enof the control file stored in different locations, there is still the
M l i
l eythat you will, at some point, have to recover from losing all of those copies. If you
possibility
n
Stalost all copies of the current control file, and have a backup control file, your course of
have
action depends on the status of the online log files and the data files. The chart in the slide shows
what to do in each of the situations shown.
Online Logs Available
If the online logs are available and contain redo necessary for recovery, and the data files are
current, then you can restore a backup control file, perform complete recovery, and open the
database with the RESETLOGS option. You must specify the file names of the online redo logs
during recovery. If the data files are not current, perform the same procedure.
Online Logs Not Available
If the online logs are not available, and the data files are current, then re-create the control file
and open RESETLOGS. However, if the data files are not current, restore a backup control file,
perform incomplete recovery, and open RESETLOGS.
Database
Repair hardware.
open?
SHUTDOWN ABORT
STARTUP MOUNT Open database
using
RESETLOGS.
Start database recovery. ble
fe r a
ans
No
n - t r
no
Archivelog
missing?
s a
) h a eฺ online log.
m i d
l ฺ o t Gu
cYes
Specify
i
g ma tuden
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Recovering the Control k i
u nstoe the Default Location
File
s y
a the e
If you need toM
y
recover l i c control file, and the default location is still a valid one, follow the
a n le in the slide. The database must be shut down first. Then repair any hardware, so that
steps shown
the t
S default location is able to remain as a valid one. Restore the control file to the default
location. Do this using a command such as this, which copies the backup control file to the
default location:
% cp /backup/control01.dbf /disk1/oradata/trgt/control01.dbf
% cp /backup/control02.dbf /disk2/oradata/trgt/control02.dbf
Mount the database, and start the recovery process. You must specify that a backup control file
is being used.
SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;
If, during the recovery process, you are prompted for a missing redo log, it probably means that
the missing redo log is an online redo log file. When prompted, supply the name of the online
redo log file. After the recovery completes, open the database, specifying the RESETLOGS
option.
Summary
Practice 6 Overview:
Performing User-Managed Recovery
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
to:
• Perform complete recovery when a critical or noncritical data
file is lost
• Recover using incrementally updated backups
• Switch to image copies for fast recovery
• Restore a database onto a new host
• Recover using a backup control file ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Performing Recovery k i
u nsEnterprise
Using e Manager
s y
a complete e or incomplete recovery by using the Recovery Wizard available
You can also M perform l i c
throughn l ey
Enterprise Manager. On the Availability page, click Perform Recovery in the
t a
Backup/Recovery
S section.
Note: An automated method of detecting the need for recovery, and carrying out that recovery
makes use of the Data Recovery Advisor, which is covered in the lesson titled “Diagnosing the
Database.”
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M toLoss u
Performing Complete k i
Recovery:
u nse of a Noncritical Data File in ARCHIVELOG
Mode s y
a lice
y M
With the
n l edatabase in ARCHIVELOG mode, the loss of any data file not belonging to the
S t a
SYSTEM or UNDO tablespaces affects only those objects that are in the missing file.
To restore and recover the missing data file using Enterprise Manager, perform the following
steps:
1. Click Perform Recovery on the Availability properties page.
2. Select “Datafiles” as Recovery Scope and “Restore datafiles” as Operation Type.
3. Add all data files that need recovery.
4. Specify from what backup the files are to be restored.
5. Determine whether you want to restore the files to the default location or (if a disk or
controller is missing) to a new location.
6. Submit the RMAN job to restore and recover the missing files.
Because the database is in ARCHIVELOG mode, recovery up to the time of the last commit is
possible and users are not required to reenter any data.
backups:
• Image copies are updated with all changes up to the
incremental backup SCN.
• Incremental backup reduces the time required for media
recovery.
• There is no need to perform an image copy after the
incremental restoration. e
r a bl
RMAN> RECOVER COPY OF
s fe
an
2> DATAFILE {n|'file_name'}
n - t r
Incremental a no
a s
deฺ
backup files h
m )Imageucopy
i
o G file
a ilฺc enoft data
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Recovering Image Copies
y u ki se to
You can use RMAN
M as to lapply
i c enincremental backups to data file image copies. With this recovery
method,
n l eyouy use RMAN to recover a copy of a data file—that is, you roll forward (recover) the
Sta copy to the specified point in time by applying the incremental backups to the image
image
copy. The image copy is updated with all changes up through the SCN at which the incremental
backup was taken. RMAN uses the resulting updated data file in media recovery just as it would
use a full image copy taken at that SCN, without the overhead of performing a full image copy
of the database every day. The following are the benefits of applying incremental backups to
data file image copies:
• You reduce the time required for media recovery (using archive logs) because you need to
apply archive logs only since the last incremental backup.
• You do not need to perform a full image copy after the incremental restoration.
If the recovery process fails during the application of the incremental backup file, you simply
restart the recovery process. RMAN automatically determines the required incremental backup
files to apply, from before the image data file copy until the time at which you want to stop the
recovery process. If there is more than one version of an image copy recorded in the RMAN
catalog, RMAN automatically uses the latest version of the image copy. RMAN reports an error
if it cannot merge an incremental backup file with an image copy.
ble
Day 1 Nothing Create image copies
fe r a
ans
Day 2 Nothing r
Create incremental level 1
n - t
Day 3 and Recover copies based on a no
Create incremental level 1
a s
onward incremental
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Recovery Image Copies: k i
u Example
a s y e n se
If you run theM
y
commands licshown in the slide daily, you get continuously updated image copies of
le data files at any time.
all thendatabase
a
t
S chart shows what happens for each run. Note that this algorithm requires some priming; the
The
strategy does not come to fruition until after day 3.
Day 1
The RECOVER command does nothing. There exist no image copies to recover yet. The
BACKUP command creates the image copies.
Day 2
The RECOVER command, again, does nothing. This is because there is no incremental backup
yet. The BACKUP command creates the incremental backup, now that baseline image copies
have been created on day 1.
Day 3
The RECOVER command applies the changes from the incremental backup, to the image copies.
The BACKUP command takes another incremental backup, which will be used to recover the
image copies on day 4. The cycle continues like this.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
For RUN blocks, you can use the SET NEWNAME command to
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
Performing Restore u k
and i (Recovery
e of a Database in NOARCHIVELOG Mode
s y
a filelicfrom n s
e a database in NOARCHIVELOG mode requires complete
The loss of anyM data
l
restoration
n eyof the database, including control files and all data files. If the lost data file belongs
toSata
read-only tablespace, you need to restore only that file.
With the database in NOARCHIVELOG mode, recovery is possible only up to the time of the last
backup. So users must reenter all changes made since that backup.
For this type of recovery, use the RESTORE and RECOVER commands, or perform the following
tasks in Enterprise Manager:
1. Shut down the instance if it is not already down.
2. Click Perform Recovery on the Maintenance properties page.
3. Select Whole Database as the type of recovery.
• Now:
SQL> CREATE RESTORE POINT before_mods;
bl e
fe r a
ans
Timeline n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Creating Restore Points k i
a s yu ense
You can giveMa name toliacparticular point in time, or an SCN number. This is useful for future
y
t a nlewhen performing point-in-time recovery or flashback operations.
reference,
S first example in the slide creates a restore point that represents the present point in time. If
The
you were about to apply an update of an application or data in the database, and you wanted to
refer back to this state of the database, you could use the BEFORE_MODS restore point.
The second example in the slide creates a restore point representing a past SCN, 100. This
restore point can be used in the same ways as the previous one.
Normally, restore points are maintained in the database for at least as long as specified by the
CONTROL_FILE_RECORD_KEEP_TIME initialization parameter. However, you can use the
PRESERVE option when creating a restore point, which causes the restore point to be saved
until you explicitly delete it.
Restore point usage with point-in-time recovery is covered later in this lesson. Using restore
points with Flashback technology is covered in the lesson titled “Additional Flashback
Operations.”
following:
1. Determine the target point of the restore: SCN, time,
restore point, or log sequence number.
2. Set the NLS environment variables appropriately.
3. Mount the database.
4. Prepare and run a RUN block, using the SET UNTIL,
RESTORE, and RECOVER commands. b le
r a
5. Open the database in READONLY mode, and verify thatnsfe
the recovery point is what you wanted. n - tra
o
6. Open the database using RESETLOGS. s a n
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Performing Incomplete u kiRecovery
e to
y s
s cen incomplete recovery using the following steps. The database
aserver-managed
You can performM li mode.
e
must be lin yARCHIVELOG
n
S1.taDetermine the restore target. This can be in terms of a date and time, an SCN, restore point,
or log sequence number. For example, if you know that some bad transactions were
submitted at 3:00 PM yesterday, then you can choose 2:59 PM yesterday as the target
restore point time.
2. Set the National Language Support (NLS) OS environment variables, so that the time
constants you provide to RMAN are formatted correctly. These are some example settings:
$ export NLS_LANG = american_america.us7ascii
$ export NLS_DATE_FORMAT = "yyyy-mm-dd:hh24:mi:ss"
3. Mount the database. If it is open, you have to shut it down first, as in this example:
RMAN> shutdown immediate
RMAN> startup mount
RUN
{
SET UNTIL TIME '2007-08-14:21:59:00';
RESTORE DATABASE;
RECOVER DATABASE;
}
5. As soon as you open the database for read/write, you have committed to the restore you just
performed. So, first, open the database READ ONLY, and view some data, to check whether
the recovery did what you expected.
RMAN> SQL 'ALTER DATABASE OPEN READ ONLY';
a b le
6. If satisfied with the results of the recovery, open the database with the RESETLOGS
s feroption,
as shown:
- t r an
RMAN> ALTER DATABASE OPEN RESETLOGS;
n on
s a
a
) h uideฺ
o m
a ilฺc ent G
@ gm Stud
y u ki this
a s se
( M u
y u ki se to
M as licen
n l ey
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Performing Recovery k i
u nasBackup
with e Control File
a s y e the current control file, you must restore and mount a backup
If you have lost
M all copies
l i c of
l eybefore performing recovery. Your recovery operation may be to recover lost data
controlnfile
Staor it may be to simply recover the control file. If you are using a recovery catalog, the
files
process is identical to recovery with a current control file because RMAN can use the recovery
catalog to obtain RMAN metadata.
Recovery
Manager
(RMAN) Flash Recovery
Area
ble
fe r a
ans
n - t r
Server a no
a s
parameter ) h i d eฺ
file Database m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
k
Restoring the ServeruParameter i (M e toFileu from the Control File Autobackup
If you have lost a
the
ns file, you can restore it from the autobackup. The procedure
syserverceparameter
M
yrestoring li
is similar
n l eto the control file from autobackup. If the autobackup is not in the flash
t a
recovery
S area, set the DBID for your database. Issue the RESTORE SPFILE FROM
AUTOBACKUP command.
If you are restoring the SPFILE to a nondefault location, specify the command as follows:
RESTORE SPFILE TO <file_name> FROM AUTOBACKUP
If you are restoring the server parameter file from the Flash Recovery Area, specify the
command as follows:
RMAN> run {
2> restore spfile from autobackup
3> recovery area = '<flash recovery area destination>'
4> db_name = '<db_name>';
5> }
Recovery
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Manager
(RMAN) Flash Recovery
Area
Control
file
Database ble
fe r a
tra ns
RMAN> STARTUP NOMOUNT;
n -
RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP;
a no
RMAN> ALTER DATABASE MOUNT;
a s
RMAN> RECOVER DATABASE; ) h i d eฺ
m u
RMAN> lฺco t G
ALTER DATABASE OPEN RESETLOGS;
ai den
m
g Stu
i @ isAll rights reserved.
s y uk© 2009, Oracle.
Copyright
t h
( M a use
Restoring the Control u i from
kFile e o
tAutobackup
y
as a recovery s
en catalog, you should have autobackup of the control file
If you are notM
using l i c
l eyso that you are able to quickly restore the control file if needed. The commands used
configured,
n
for a
Strestoring your control file are the same, whether or not you are using a Flash Recovery Area.
However, if you are using a Flash Recovery Area, RMAN implicitly cross-checks backups and
image copies listed in the control file, and catalogs any files in the Flash Recovery Area not
recorded in the restored control file, improving the usefulness of the restored control file in the
restoration of the rest of your database.
Use the commands shown in the slide to recover from lost control files. First, start the instance
in NOMOUNT mode. It cannot be mounted because there is no control file. Restore the control
file from backup. Now that there is a control file, you can mount the database. You must now
recover the database, because you now have a backup control file that contains information
about an older version of the database. After recovering the database, you can open it. You must
specify RESETLOGS because the new control file represents a different instantiation of the
database.
Note: Tape backups are not automatically cross-checked after the restoration of a control file. If
you are using tape backups, then after restoring the control file and mounting the database, you
must cross-check the backups on tape.
Backups RMAN>
ble
fe r a
ans
n - t r
Server Server o
parameter file an
parameter file
s
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Restoring and Recovering k i
u nthe e Database on a New Host
s y
a described s
e on the following pages to perform test restores. You can also use it
Use the procedure
y M l i c
to moven l ea production database to a new host.
t a
S database identifier (DBID) for the restored test database is the same as the DBID of the
The
original database. If you are using a recovery catalog and connect to the test database and the
recovery catalog database, the recovery catalog is updated with information about the test
database. This can impact RMAN’s ability to restore and recover the source database.
You should create a duplicate database using the RMAN DUPLICATE command if your goal is
to create a new copy of your target database for ongoing use on a new host. The duplicate
database is assigned a new DBID that allows it to be registered in the same recovery catalog as
the original target database. Refer to the lesson titled “Using RMAN to Duplicate a Database”
for detailed information about the DUPLICATE command.
database:
1. Configure the ORACLE_SID environment variable.
2. Start RMAN and connect to the target instance in
NOCATALOG mode.
3. Set the database identifier (DBID).
4. Start the instance in NOMOUNT mode.
5. Restore the server parameter file from the backup sets. a b le
6. Shut down the instance. s fer
- t r an
7. Edit the restored initialization parameter file. non
8. Start the instance in NOMOUNT mode. as a ฺ
m ) h uide
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M toHost
Restoring the Database
y u ki to asNew e
Perform the steps
s on
alisted c n page and the next on the restore host to restore the database.
ethis
M l i
l ey the ORACLE_SID environment variable as shown in the following example:
1. Configure
n
Sta $ setenv ORACLE_SID orcl
2. Start RMAN and connect to the target instance. Do not connect to the recovery catalog as
shown in the following example:
$ rman TARGET /
3. Set the database identifier (DBID). You can find the DBID of your source database by
querying the DBID column in V$DATABASE.
RMAN> SET DBID 1090770270;
4. Start the instance in NOMOUNT mode:
RMAN> STARTUP NOMOUNT
You will receive an error similar to the following because the server parameter file has not
been restored. RMAN uses a “dummy” parameter file to start the instance.
startup failed: ORA-01078: failure in processing system
parameters
SHUTDOWN IMMEDIATE;
7. Edit the restored initialization parameter file to change any location-specific parameters,
such as those ending in _DEST, to reflect the new directory structure.
8. Start the instance in NOMOUNT mode using your edited text initialization parameter file.
RMAN> STARTUP NOMOUNT
> PFILE='?/oradata/test/initorcl.ora';
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Basic procedure:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Summary
the following:
• Perform complete recovery when a critical or noncritical data
file is lost
• Recover using incrementally updated backups
• Switch to image copies for fast recovery
• Restore a database onto a new host
e
• Recover using a backup control file abl fer
a n s
n -tr
o
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
y u ki se to
M as licen
le y
n
Sta
Practice 7 Overview:
Using RMAN to Perform Recovery
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
an s
Archived
n - t r
redo log files
a no
Auxiliary instance
a s
Target database ) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using RMAN to Create k i
u Duplicate
a e Database
s y
a islaiccopyn s
e of the target database (or a subset of the target database) with a
A duplicate database
M
l ey database identifier (DBID). The target database site and duplicate database site can
new, unique
n
be tathe same host or separate hosts. The duplicate database is created using backups and
Son
archived redo log files from the target database.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Using a Duplicate Database
a s yu ense
M islaiccopy of your target database. You can operate it independently of the
A duplicate database
y
target n
a le to:
database
t
S• Test backup and recovery procedures
• Recover objects that were inadvertently dropped from the target database by creating an
export containing the objects in the duplicate database and importing them into the
production database
• DB_NAME
– If the duplicate database is in the same Oracle home as the
target database, names must be different.
– Use the same value in the DUPLICATE command.
• DB_BLOCK_SIZE
– Specify the same value as set for the target database.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Creating an Initialization k i
u Parameter e File for the Auxiliary Instance
s y n s
aa text linitialization
e
You must create
y M i c parameter file for the auxiliary instance. The text
a n le parameter file must reside on the same host as the RMAN client that you use to
initialization
t
execute
S the DUPLICATE command.
Take note of the requirements for each of the following parameters:
• DB_NAME: If the target database and the duplicate database are in the same Oracle home,
you must set DB_NAME to a different name. If they are in different Oracle homes, you must
ensure that the name of the duplicate database differs from the other names in its Oracle
home. Be sure to use the same database name that you set for this parameter when you
execute the DUPLICATE command.
• DB_BLOCK_SIZE: The block size of the auxiliary database must match the block size of
the target database. Specify the same value in the initialization parameter file for the
auxiliary database as set in the initialization parameter file for the target database. If the
parameter is not set in the initialization parameter file for the target database, do not set it in
the auxiliary instance initialization parameter file.
In addition, be sure to verify the settings of all initialization parameters that specify path names.
Verify that all specified paths are accessible on the duplicate database host.
CONTROL_FILES='/u01/app/oracle/oradata/aux/control01.ctl',
ble
'/u01/app/oracle/oradata/aux/control02.ctl',
fe r a
'/u01/app/oracle/oradata/aux/control03.ctl'
ans
DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl',
n - t r
'/u01/app/oracle/oradata/aux'
a no
LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl',
a s
'/u01/app/oracle/oradata/aux' ) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Specifying Parameters k i
u nControl
for e File Naming
s y s
anameslicfore the required database files when you execute the DUPLICATE
RMAN generates
M
l
command.
n eyYou can control the naming of the files by specifying the following initialization
Sta in the auxiliary instance initialization parameter file:
parameters
• CONTROL_FILES: Specify the names of the control files in this parameter. If you do not
set the names via this parameter, the Oracle server creates an Oracle-managed control file in
a default control destination. Refer to the SQL CREATE CONTROLFILE command in the
SQL Reference manual for specific information.
• DB_FILE_NAME_CONVERT: This parameter is used to specify the names of data files for
the auxiliary database. It has the format DB_FILE_NAME_CONVERT = 'string1' ,
'string2', where string1 is the pattern of the target database file name and
string2 is the pattern of the auxiliary database file name. You can also specify the
DB_FILE_NAME_CONVERT parameter as an option to the DUPLICATE DATABASE
command.
• LOG_FILE_NAME_CONVERT: This parameter is used to specify the names of the redo log
files for the auxiliary database. It has the format LOG_FILE_NAME_CONVERT =
'string1' , 'string2', where string1 is the pattern of the target database file
name and string2 is the pattern of the auxiliary database file name. You can also use the
LOGFILE clause of the DUPLICATE DATABASE command to specify redo log file names.
You can use the following techniques to specify new names for data files:
• Include the SET NEWNAME FOR DATAFILE command within a RUN block to specify new
names for the data files.
• Use the CONFIGURE AUXNAME command.
• Specify the DB_FILE_NAME_CONVERT parameter with the DUPLICATE command.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
instance.
• Specify the same database name that you used in the
DB_NAME initialization parameter.
RMAN> RUN
{ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK;
…
DUPLICATE TARGET DATABASE to auxdb;
a b le
} fer s
- t r an
n no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M command u
Using the RMAN DUPLICATEk i t o
a s yu ense
Invoke RMAN
y ic to the target database and auxiliary instance before issuing the
Mand connect
l
DUPLICATE
a n le command. The auxiliary instance must be started with the NOMOUNT option and
the t
S target database must be mounted or open.
command:
Option Purpose
Or
Running instance
ble
Staging Clone
fe r a
area
Or database
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
Existing backup
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
k i (M e to u
Using EM to Clone auDatabase
s
sy cenManager
useaEnterprise
You can also M li (EM) to create a duplicate (clone) database. You can
y
le the following venues for the clone operation:
choosenfrom
t a
S• Running instance: You can specify a running instance to be cloned.
• Staging area: A disk area specified on the source and destination hosts. A backup is created
and stored here, then put in the destination staging area, and read from on that destination
host to create the clone database.
• Existing backup: If you already have a backup that reflects the database in the state you
want it cloned, you can use that.
• Open database in
ARCHIVELOG mode
• Open database in
NOARCHIVELOG mode
• Existing database backup
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Cloning a Running Database i
a s yu ense
To start the clone
y lic in EM, select Data Movement > Clone Database. The Clone
M operation
t a nleWizard steps you through the process of creating a duplicate database.
Database
S the Source Type page, designate the source for the cloning operation. You can select a
On
current database instance or a saved working directory from a previous clone operation. You can
alternatively point to a backup of a database.
If you select a running database, the next page of the clone wizard prompts you to specify the
source database. This must be an open database, and may be either in ARCHIVELOG or
NOARCHIVELOG mode. If it is in NOARCHIVELOG mode, then be aware that the source
database is restarted during the clone operation.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Cloning a Running Database k i
u nse(continued)
s y
aof the wizarde prompts you for information about the destination database.
The second step
M l i c
Providen l eyfollowing:
the
S• taHost name: Name of server to host the new database
• Oracle Home location: Directory for Oracle home of the new database
• OS login credentials: Owner of the Oracle software, usually oracle
• Database name: The global name and the instance name
• Storage method to use: Choices are File System, ASM, and Raw devices.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Cloning a Running Database k i
u nse(continued)
s y
The third stepM ofathe wizard
l i c easks for the details about the file layout for the destination database.
l ey how much space is needed to create the database.
It alsonreports
Sta
From
source
database
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Cloning a Running Database i
u nse(continued)
s y
a thelilocation
e of the network configuration files in the source database. This
In step four, specify
M c
l ey where you find such files as tnsnames.ora and listener.ora.
is the directory
n
Stafifth step is where you can specify EM configuration for the new database, and any
The
postcloning scripts to be run on the new database.
In the last step, the clone wizard simply prompts you to confirm the parameters and run time for
the clone job to run.
Existing
backup
location
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Cloning a Database u k
fromi (aMBackup
t o
a s y ense
If you chose to
y ic based on a backup, choose that option when presented with the
Mcreate alclone
le options. Then indicate the directory where a backup currently exists.
sourcentype
a
S t
Summary
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Practice 8 Overview:
Using RMAN to Duplicate a Database
backup.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Performing Tablespace
Point-in-Time Recovery
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Tablespace Point-in-Time k i
u nRecoverye (TSPITR): Concepts
s y
a tablespace s
e point-in-time recovery (TSPITR) enables you to quickly recover
RMAN automaticM l i c
l ey tablespaces in an Oracle database to an earlier time, without affecting the state of
one ornmore
a tablespaces and objects in the database.
Stother
the
be recovered to
• Recovery set: Data files that compose the tablespaces to be
recovered
• Auxiliary set: Data files required for the TSPITR of the
recovery set that are not part of the recovery set. It typically
includes:
– SYSTEM tablespace e
– Undo segment tablespaces r a bl
s fe
– Temporary tablespace - t r an
o n
an
• Auxiliary destination: Disk location to store files
s
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Tablespace Point-in-Timek i
u nRecoverye (TSPITR): Terminology
s y s
a liceis used when discussing TSPITR:
The followingM terminology
l
• Target
n ey time: The point in time or system change number (SCN) that the tablespace will be
Starecovered to during TSPITR
• Recovery set: Data files composing the tablespaces to be recovered
• Auxiliary set: Data files required for TSPITR of the recovery set that are not themselves
part of the recovery set. The auxiliary set typically includes:
- A copy of the SYSTEM tablespace
- Data files containing undo segments from the target instance
- In some cases, a temporary tablespace, used during the export of database objects from
the auxiliary instance
• Auxiliary destination: A location on disk that can be used to store any of the auxiliary set
data files, control files, and online logs of the auxiliary instance during TSPITR. Files
stored in the auxiliary destination can be deleted after TSPITR is complete.
RMAN
Data file
Restore
ble
backups fe r a
Restore
an s
Recover n - t r
1 Archived no
redo log files a
sRecovered tablespace
) h a e ฺ
Target database
2
o m u id
ilฺc ent G
a
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to Architecture
Tablespace Point-in-Time
y u ki Recovery:
s e
In the diagram,M asfollowing
the l i c enTSPITR entities are shown:
l
• Target
n ey database: Contains the tablespace to be recovered
S• taControl file: Provides backup information to RMAN
• Backup sets: Come from the target database and are the source of the reconstructed
tablespace
• Archived redo logs: Come from the target database and are the source of the reconstructed
tablespace
• Auxiliary instance: Is the Oracle database instance used during the recovery process to
perform the recovery
RMAN performs the following steps during tablespace point-in-time recovery:
1. Restores a backup control file from a point in time before the target time to the auxiliary
instance. It restores the data files for the recovery set to the target database and the data files
for the auxiliary set to the auxiliary instance.
2. Recovers the restored data files to the specified point in time
RMAN
5
Import metadata
bl e
Control file fe r a
t r a ns
Export
o n
Auxiliary- file
an
Recovered instance
tablespace
Target database s
ha ide3ฺ
4 m Gu) Export
Point to recovered tablespace ฺco
ail den t metadata
m
g Stu
i @ isAll rights reserved.
s y uk© 2009, Oracle.
Copyright
t h
( M a use
Tablespace Point-in-Timeu ki Recoverye to Architecture (continued)
y
s cemetadata
adictionary n s
3. Exports the
M l i about objects in the recovered tablespace to the target
le y
database
t a n
S4. Issues SWITCH commands on the target database so that the target database control file
points to the data files in the recovery set that were recovered on the auxiliary instance
5. Imports the dictionary metadata from the auxiliary instance to the target instance, allowing
the recovered objects to be accessed
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Preparing for TSPITR k i
a s yu ense
Before performing
y M TSPITR,lic you need to determine the correct target time for your recovery.
You need
a n leto determine whether you need additional tablespaces in your recovery set. You
t
should
S evaluate what objects will be lost as a result of the TSPITR operation and determine how
you want to preserve those objects.
Each of these steps is discussed in more detail in this lesson.
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Identifying Objects That k i
u Will ebe Lost
s y
a lice n s
Query the TS_PITR_OBJECTS_TO_BE_DROPPED
M view to determine whether there are any
y
le will be lost as a result of performing tablespace point-in-time recovery.
objectsnthat
t a
S an example, you are performing TSPITR for the USERS and EXAMPLE tablespaces to the
As
target time of April 3, 2006 at 8:30:00 AM. Issue the following query to determine whether there
are any objects that will be lost following your TSPITR:
SELECT OWNER, NAME, TABLESPACE_NAME,
TO_CHAR(CREATION_TIME, 'YYYY-MM-DD:HH24:MI:SS')
FROM TS_PITR_OBJECTS_TO_BE_DROPPED
WHERE TABLESPACE_NAME IN ('USERS','EXAMPLE')
AND CREATION_TIME >
TO_DATE('2006-APR-03:08:30:00','YY-MON-DD:HH24:MI:SS')
ORDER BY TABLESPACE_NAME, CREATION_TIME;
instance.
2. Specify the auxiliary destination using the AUXILIARY
DESTINATION option.
RMAN> CONNECT TARGET
RMAN> RECOVER TABLESPACE users, example
> UNTIL TIME '2007-06-29:08:00:00'
> AUXILIARY DESTINATION
> '/u01/app/oracle/oradata/aux'; ble
fe r a
ans
3. Back up the recovered tablespaces and bring them online.
-tr
o n
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Performing Fully Automated
u to
ki seTSPITR
y
s cenrequirements discussed earlier in the lesson, when you perform
theapreparation
In addition toM li
l e y TSPITR,
fully automated you must:
t a n
S• Configure any channels required for TSPITR on the target instance
• Specify a destination for RMAN to use for the auxiliary set of data files and other auxiliary
instance files
After TSPITR has completed, back up the recovered tablespaces and bring them online. You
cannot use backups of any tablespaces that participate in TSPITR taken prior to TSPITR after
you perform TSPITR.
Note: This time format assumes that NLS_DATE_FORMAT is set to 'yyyy-mm-
dd:hh24:mi:ss' and NLS_LANG is set to AMERICAN_AMERICA.WE8MSWIN1252.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using Enterprise Manager k i
u ntosePerform TSPITR
s y
You can also MuseaEnterprise
l i c e Manager to perform TSPITR. Navigate to Availability > Perform
l
Recovery.
n eyIn the User Directed Recovery section, select Tablespaces from the Recovery Scope
Sta menu.
drop-down
There are three operations you can perform, for tablespaces:
• Recover to current time or a previous point in time: Restores the data files for the
tablespace, if needed. This operation then uses redo to recover to the time you specify:
either the current time or a time in the past. This is the combination of the following two
operations.
• Restore tablespaces: Only restore the data files for the tablespace. No recovery is
performed.
• Recover from previously restored tablespaces: Perform recovery (redo application) only,
of the tablespace’s data files.
t a nle
S
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
RMAN TSPITR Processing k i
u n(continued)
a s y e se
After RMANM completeslic
the last step, the TSPITR process is complete. The recovery set data
e y
t a nlreturned
files are to the state they were in at the specified target time.
S
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Troubleshooting RMAN k i TSPITR
a s yu ense
File name conflicts:
y M If yourl ic use of SET NEWNAME, CONFIGURE AUXNAME, and
le
DB_FILE_NAME_CONVERT
a n cause multiple files in the auxiliary or recovery sets to have the
t
same
S name, you receive an error during TSPITR. To correct the problem, specify different
values for these parameters to eliminate the duplicate name.
RMAN cannot identify tablespaces with undo segments: During TSPITR, RMAN needs
information about which tablespaces had undo segments at the TSPITR target time. This
information is usually available in the recovery catalog, if one is used. If there is no recovery
catalog, or if the information is not found in the recovery catalog, RMAN proceeds assuming
that the set of tablespaces with undo segments at the target time is the same as the set of
tablespaces with undo segments at the present time. If this assumption is not correct, the TSPITR
operation fails and an error is reported. To prevent this from happening, provide a list of
tablespaces with undo segments at the target time in the UNDO TABLESPACE clause.
Restarting manual auxiliary instance after TSPITR failure: If you are managing your own
auxiliary instance and there is a failure in TSPITR, then before you can retry TSPITR, you must
shut down the auxiliary instance, correct the problem, and put the auxiliary instance back in
NOMOUNT mode.
Summary
Practice 9 Overview:
Performing TSPITR
This practice covers the following topic:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
• Performing TSPITR
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
specific channels.
MML Backup
piece 1
parallelizes its operation and writes multiple backup sets in parallel. The allocated server
sessions share the work of backing up the specified data files, control files, and archived redo
logs. You cannot stripe a single backup set across multiple channels.
Parallelization of backup sets is achieved by:
• Configuring PARALLELISM to greater than 1 or allocating multiple channels
• Specifying many files to back up
Example
• There are nine files that need to be backed up (data files 1 through 9).
• Assign the data files to a backup set so that each set has approximately the same numberbof
a le
data blocks to back up (for efficiency).
s fer
- Data files 1, 4, and 5 are assigned to backup set 1.
- t r an
- Data files 2, 3, and 9 are assigned to backup set 2.
n on
- Data files 6, 7, and 8 are assigned to backup set 3.
s a
Note: You can also use the FILESPERSET parameter to limit a
) hthe numbereฺ of data files that are
m u i d
included in a backup set.
ail den ฺco t G
m
g Stu
i @
s y uk this
( M a use
y u ki se to
M as licen
le y
n
Sta
{
SET COMMAND ID TO 'sess1';
BACKUP DATABASE;
}
Set the command ID to a string such as sess2 in the job running in session 2:
RUN
{
SET COMMAND ID TO 'sess2';
BACKUP DATABASE;
ble
}
fe r a
2. Start a SQL*Plus session and then query the joined V$SESSION and V$PROCESS
t r a ns views
while the RMAN job is being executed. For example, enter: n-
no
s a
SELECT SID, SPID, CLIENT_INFO
) h a eฺ
FROM V$PROCESS p, V$SESSION s
m i d
WHERE p.ADDR = s.PADDR
i l ฺ co nt Gu
AND CLIENT_INFO LIKE '%id=sess%';
g ma tude
u i@ isin S
kcommand
If you run the SET COMMAND y
a s ID
e th the RMAN job, then the CLIENT_INFO
column is displayed in(the
i M following
t o usformat:
id=command_id,rman
s y uk nsechannel=channel_id
For example,
M a the following
l i c e shows a sample output:
n l eySID SPID
Sta ---- ------------
CLIENT_INFO
------------------------------
11 8358 id=sess1
15 8638 id=sess2
14 8374 id=sess1,rman channel=c1
9 8642 id=sess2,rman channel=c1
querying V$SESSION_LONGOPS.
• TOTALWORK: For image copies, the total number of blocks in the file; for backup input
rows, the total number of blocks to be read from all files that are processed in this job step;
for backup output rows, the value is 0 because RMAN does not know how many blocks it
will write into any backup piece; for restores, the total number of blocks in all files restored
in this job step; and for proxy copies, the total number of files to be copied in this job step
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Interpreting RMAN Messagek i
u nseOutput
s y
a output e contains actions that are relevant to the RMAN job as well as error
The RMAN command
M l i c
y are generated by RMAN, the server, and the media vendor. RMAN error
l
messages
n ethat
Sta have an RMAN-nnnn prefix. The output is displayed to the terminal (standard output)
messages
but can be written to a file by defining the LOG option or by shell redirection.
The RMAN trace file contains the DEBUG output and is used only when the TRACE command
option is used.
The alert log contains a chronological log of errors, nondefault initialization parameter settings,
and administration operations. Because it records values for overwritten control file records, it
can be useful for RMAN maintenance when operating without a recovery catalog.
The Oracle trace file contains detailed output that is generated by Oracle server processes. This
file is created when an ORA-600 or ORA-3113 (following an ORA-7445) error message
occurs, whenever RMAN cannot allocate a channel, and when the Media Management Library
fails to load. It can be found in USER_DUMP_DEST.
The sbtio.log file contains vendor-specific information that is written by the media
management software and can be found in USER_DUMP_DEST. Note that this log does not
contain Oracle server or RMAN errors.
Tuning RMAN
following tasks:
– Read or write data.
– Process data by copying and validating blocks.
• The slowest of these tasks is referred to as a bottleneck, for
any particular process.
• Tuning RMAN requires that the bottlenecks be identified and
addressed. le
a b
• Performance of backup versus recovery operations can be s fer
n
balanced to suit your needs. -tra on
a n
a s
m ) h uideฺ
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Tuning RMAN
y u ki se to
RMAN backup M as restore
and l i c n
eoperations perform the following distinct tasks:
y
le or writing input data
• Reading
t a n
S• Processing data by validating and copying blocks from the input to the output buffers
The slowest of these tasks is called a bottleneck. RMAN tuning involves identifying the
bottleneck (or bottlenecks) and attempting to make it more efficient by using RMAN commands,
initialization parameter settings, or adjustments to the physical media. The key to tuning RMAN
is in understanding the input/output (I/O). The backup and restore jobs of RMAN use two types
of I/O buffers: disk and tertiary storage (usually tape). When performing a backup, RMAN reads
input files by using disk buffers and writes the output backup file by using either the disk or the
tape buffer. When performing restores, RMAN reverses these roles. I/O can be synchronous and
asynchronous. Synchronous devices perform only one I/O task at a time. Therefore, you can
easily determine how much time the backup jobs require. In contrast to synchronous I/O (SIO),
asynchronous I/O (AIO) can perform more than one task at a time. To tune RMAN effectively,
you must thoroughly understand the concepts of synchronous and asynchronous I/O, disk and
tape buffers, and channel architecture. With an understanding of these concepts, you can use
fixed views to monitor bottlenecks.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
RMAN Multiplexing
• For reads:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Level <= 4 1 MB buffers are allocated so that the total buffer size
for all input files is 16 MB.
4 < Level <= 8 512 KB are allocated so that the total buffer size for all
files is less than 16 MB.
Level > 8 RMAN allocates four 128 KB disk buffers per channel
for each file, so that the total size is 512 KB per channel ble
for each file. fe r a
ans
n - t r
no of
• For writes, each channel allocates four output buffers
a
1 MB each. has ฺ ) i de
o m u
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
RMAN Multiplexing uki e
y
s cetypes
adifferent s
n of buffers for I/O: disk and tape. RMAN multiplexing
RMAN uses twoM l i
l
determines
n eyhow RMAN allocates disk buffers. RMAN multiplexing is the number of files in a
Sta read simultaneously and then written to the same backup piece. The degree of
backup
multiplexing depends on the FILESPERSET parameter of the BACKUP command as well as the
MAXOPENFILES parameter of the CONFIGURE CHANNEL command or ALLOCATE
CHANNEL command. Note: RMAN multiplexing is set at the channel level.
For example, assume that you back up two data files with one channel. You set FILESPERSET
to 3 and MAXOPENFILES to 8. In this case, the number of files in each backup set is 2 (the
lesser of FILESPERSET and the files read by each channel) and the level of multiplexing is 2
(the lesser of MAXOPENFILES and the number of files in each backup set). When RMAN backs
up from disk, it uses the algorithm that is described in the table shown in the slide.
For writing, each channel allocates four output buffers of size 1 MB each.
These buffers are allocated from the PGA unless DBWR_IO_SLAVES is set to a nonzero value.
Note: For best recovery performance, do not set FILESPERSET to a value greater than 8.
1 MB 1 MB
1 MB 1 MB
1 MB 1 MB
1 MB 1 MB
Channel
FILESPERSET = 4
bl e
1 MB 1 MB
MAXOPENFILES = 4
fe r a
1 MB 1 MB ans
n - t r
a no
a s
1 MB 1 MB
) h i d eฺ
1 MB 1 MB m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Allocating Disk Buffers: k i
u Example
a s y e n se
In the example
y Mshown inlicthe slide, one channel is backing up four data files. MAXOPENFILES is
e FILESPERSET is set to 4. The level of multiplexing is 4 in this example. The total
set to 4 land
n
sizet a
S of the buffers for each data file is 4 MB. To calculate the total size of the buffers that are
allocated in a backup set, multiply the total bytes for each data file by the number of data files
that are being concurrently accessed by the channel, and then multiply this number by the
number of channels.
Assume that you use one channel to back up four data files, and use the settings that are shown
in the slide. In this case, multiply as follows to obtain the total size of the buffers that are
allocated for the backup:
4 MB per data file 1 channel 4 data files per channel = 16 MB
Set the MAXOPENFILES parameter so that the number of files that are read simultaneously is
just enough to use the output device fully. This consideration is important when the output
device is a tape.
ble
fe r a
t r a ns
• If BACKUP_TAPE_IO_SLAVES is FALSE, tape buffers o n - are
allocated from the PGA. s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Allocating Tape Buffers
y u ki se to
If you make aM as tolica etape
backup
n device, the Oracle server allocates four buffers per channel for
the tape
n l ey (or reads if doing a restore). The Oracle server allocates these buffers only if the
writers
Sta is a System Backup to Tape (SBT) channel. Typically, each tape buffer is 256 KB. To
channel
calculate the total size of buffers that are used during a backup or restore, multiply the buffer
size by four, and then multiply this product by the number of channels.
As illustrated in the example shown in the slide, assume that you use one tape channel and each
buffer is 256 KB. In this case, the total size of buffers that are used during a backup is as
follows:
256 KB per buffer 4 buffers per channel 1 channel = 1,024 KB
RMAN allocates the tape buffers in the System Global Area (SGA) or the Program Global Area
(PGA), depending on whether I/O slaves are used. If the BACKUP_TAPE_IO_SLAVES
initialization parameter is set to TRUE, RMAN allocates tape buffers from the shared pool or the
large pool if the LARGE_POOL_SIZE initialization parameter is set. If you set the parameter to
FALSE, RMAN allocates the buffers from the PGA. If you use I/O slaves, set the
LARGE_POOL_SIZE initialization parameter to set aside SGA memory that is dedicated to
holding these large memory allocations. By doing this, the RMAN I/O buffers do not compete
with the library cache for shared pool memory.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Synchronous I/O
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Server 0100100
process 0100100
Tape ble
Server process buffers fe r a
4 writes data to
ra ns
new buffer. 3 Tape processn-t
no
signals finish.
a
a s
m ) h uideฺ
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Comparing Synchronous
y u ki and s eAsynchronous I/O
When RMANM
s
a or lwrites
reads c n
e data, the I/O is either synchronous or asynchronous. When the I/O
i
l ey a server process can perform only one task at a time. When it is asynchronous, a
is synchronous,
n
Sta process can begin an I/O and then perform other tasks while waiting for the I/O to
server
complete. It can also begin multiple I/O operations before waiting for the first to complete.
You can set initialization parameters that determine the type of I/O. If you set
BACKUP_TAPE_IO_SLAVES to TRUE, the tape I/O is asynchronous. Otherwise, the I/O is
synchronous.
The example in the slide shows synchronous I/O in a backup to tape. The following steps occur
in a synchronous transfer:
1. A server process writes blocks to a tape buffer.
2. The tape process writes data to tape. The server process is idle while the media manager
copies data from the Oracle buffers to the media manager’s internal buffers.
3. The tape process relays to the server process that it has completed writing.
4. The server process can initiate a new task.
Asynchronous I/O
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Server 0100100
process 0100100 0100100
Tape ble
buffers fe r a
ans
n - t r
a no
3 Server process writes to new a s
buffer while step 2 completes. ) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Comparing Synchronous k i
u nand eAsynchronous I/O (continued)
s y s
asystemslicsupport
e native asynchronous I/O and Oracle can take advantage of this
Many operating
M
l ey it is available. It is recommended that you always set
featurenwhenever
Sta
BACKUP_TAPE_IO_SLAVES to TRUE when the platform supports it. On operating systems
that do not support native asynchronous I/O, Oracle can simulate it by using special I/O slave
processes that are dedicated to performing I/O on behalf of another process. You can control
disk I/O slaves by setting the DBWR_IO_SLAVES parameter to a nonzero value. Oracle
allocates four backup disk I/O slaves for any nonzero value of DBWR_IO_SLAVES.
The example in the slide illustrates asynchronous I/O in a backup to tape. The steps that occur in
an asynchronous exchange are detailed below:
1. A server process writes blocks to a tape buffer.
2. The tape process writes data to the tape. While the tape process is writing, other server
processes are free to process more input blocks and fill more output buffers.
3. The spawned server process writes to the tape buffers while the initial tape process writes to
the tape.
restore performance:
– V$BACKUP_SYNC_IO
– V$BACKUP_ASYNC_IO
• The following rows exist for a backup or restore:
– One row for each data file
– One aggregate data file row
– One row for each backup piece e
r a bl
• Whether or not I/O is synchronous depends on how the s
n fe
controlling process views it. -tra on
a n
a s
m ) h uideฺ
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
i ( M to
Monitoring RMAN Job
y u kPerformance
s e
The maximum M as lspeed
backup i c enis limited by the available hardware. It is not possible to back up
l
any faster y the aggregate tape bandwidth. One exception to this is if there are many empty
ethan
n
Sta in the data files that need not be backed up.
blocks
One of the components of the backup system will be a bottleneck—which one depends on the
relative speeds of the disk, tape drive, and any other transport components such as the network.
As an example, if the bottleneck is the tape drive, and the tape is streaming, then the backup
cannot possibly proceed any faster.
Note: If you have synchronous I/O and have set the BACKUP_DISK_IO_SLAVES
initialization parameter to TRUE, I/O is displayed in V$BACKUP_ASYNC_IO.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Synchronous I/O Bottlenecksi
a s yu ense
When using synchronous
y M licI/O, it can easily be determined how much time the backup jobs
le devices perform only one I/O task at a time. Oracle I/O uses a polling
requirenbecause
a
S t
mechanism rather than an interrupt mechanism to determine when each I/O request completes.
Because the backup or restore process is not immediately notified of I/O completion by the
operating system, you cannot determine the duration of each I/O.
Use V$BACKUP_SYNC_IO to determine the source of backup or restore bottlenecks and to
determine the progress of backup jobs. V$BACKUP_SYNC_IO contains rows when the I/O is
synchronous to the process (or thread, on some platforms) that is performing the backup.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Tape Backup Speeduki
a s y ense
The tape native
y c is the write speed without compression. This speed represents the
Mtransferlirate
a n le of the backup rate. The upper limit of your backup performance should be the
upper limit
S t
aggregate transfer rate of all the tape drives. If the backup is performing at that rate, and an
excessive amount of CPU is not being used, then tuning RMAN does not help.
Tape compression greatly affects backup performance. If the tape has good compression, then
the sustained backup rate is faster. For example, if the compression ratio is 2:1 and the native
transfer rate of the tape drive is 6 MB per second, then the resulting backup speed is 12 MB per
second.
Almost all tape drives currently in the market are fixed-speed, streaming tape drives—that is,
these drives can write data only at one speed. As a result, when they run out of data to write to
tape, they must slow down and stop. For example, when the drive’s buffer empties, the tape is
moving so quickly that it actually overshoots and must rewind past the point where it stopped
writing.
The physical tape block size can affect the backup performance. The block size is the amount of
data that is written by the media management software to a tape in one write operation. The
common rule is that a larger tape block size leads to a faster backup. The physical tape block
size is controlled by the media management software.
If the tape device is attached as a network device, then the network speed may affect tape access
speed also
Oracle Database 11g: Administration Workshop II 10 - 23
Computer Pride Limited
• Adjust the size of the tape buffer to keep the tape streaming.
• Use the BLKSIZE option of PARMS to set the desired buffer
size:
RMAN> CONFIGURE CHANNEL DEVICE TYPE SBT_TAPE
2> PARMS="BLKSIZE=1048576 ";
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M with u
Controlling Tape Buffer k i Size t o
a s yu ense BLKSIZE
If the tape is not
y lic but the problem is not due to an incremental backup or by the
M streaming,
backing n e of empty files, then try adjusting the block size of the tape buffer. You can change
lup
the t a
S size of each tape buffer by using the PARMS parameter of the ALLOCATE CHANNEL or
CONFIGURE CHANNEL command. If the BLKSIZE parameter for PARMS is supported on your
platform, then you can set it to the desired size of each buffer. For example, configure an SBT
channel as follows:
RMAN> CONFIGURE CHANNEL DEVICE TYPE SBT
> PARMS="BLKSIZE=1048576";
Channel Tuning
commands to:
• Limit the size of backup pieces
• Prevent RMAN from consuming too much disk bandwidth
• Determine the level of multiplexing for each channel
• Configure multiple disks, thus spreading the I/O activity
across multiple devices.
• Configure multiple channels on the SBT device, allowing you able
to assign different data files to each one. s fer
n tra
n -
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Channel Tuning k i
a s yu ense
You can set various
y M channel l ic limit parameters that apply to operations that are performed by the
allocatedleserver session in the CONFIGURE CHANNEL and ALLOCATE CHANNEL commands.
n
StaMAXPIECESIZE parameter specifies the maximum size of a backup piece. Use this
The
parameter to make RMAN create multiple backup pieces in a backup set. RMAN creates each
backup piece with a size that is no larger than the value that has been specified in the parameter.
The RATE parameter specifies the bytes per second that RMAN reads on the channel. This
parameter is useful in preventing RMAN from consuming excessive disk bandwidth and
degrading online transaction processing (OLTP) performance. For example, if each disk drive
delivers 3 MB per second and you set RATE=1500K, some disk bandwidth will still be
available to the online system.
The MAXOPENFILES parameter determines the maximum number of input files that a backup
or copy can have open at a given time. If not set manually, the value defaults to 8. The level of
RMAN multiplexing is partially determined by MAXOPENFILES. The level of multiplexing in
turn determines how RMAN allocates disk buffers. Multiplexing is the number of input files that
are simultaneously read from and then written into the same backup piece.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
t a nle
the channel.
S FILESPERSET parameter specifies the maximum number of files to place in a backup set.
The
If you allocate only one channel, then you can use this parameter to make RMAN create
multiple backup sets. For example, if you have 50 input data files and two channels, you can set
FILESPERSET=5 to create 10 backup sets. This strategy can prevent you from splitting a
backup set among multiple tapes.
The MAXOPENFILES parameter setting depends on your disk subsystem characteristics. If you
use ASM, then set it to 1 or 2. Otherwise, if your data is not striped, then you may want to set
this higher. To gain performance, increase either the number of files per backup set, or this
parameter. If you are not using ASM or striping of any kind, then try increasing
MAXOPENFILES.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Setting LARGE_POOL_SIZE
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Tuning RMAN Tape u k
Streaming to u
i (M e Performance Bottlenecks
s y n s
a libottlenecks
e
To identify and
y M remedy c that affect RMAN’s performance on tape backups, perform
a n le actions :
the following
t
S• Use BACKUP... VALIDATE to determine whether tape streaming or disk I/O is the
bottleneck in a given backup job. Compare the time required to run backup tasks with the
time required to run BACKUP VALIDATE of the same tasks. BACKUP VALIDATE of a
backup to tape performs the same disk reads as a real backup but performs no tape I/O. If
the time required for the BACKUP VALIDATE to tape is significantly less than the time
required for a real backup to tape, then writing to tape is the likely bottleneck.
• Use multiplexing to improve tape streaming with disk bottlenecks. In some situations when
RMAN is performing a backup to tape, it may not be able to send data blocks to the tape
drive fast enough to support streaming. For example, during an incremental backup, RMAN
backs up only blocks changed since a previous data file backup as part of the same strategy.
If you do not enable change tracking, RMAN must scan entire data files for changed blocks,
and fill output buffers as it finds such blocks. If there are not many changed blocks, RMAN
may not fill output buffers fast enough to keep the tape drive streaming. You can improve
performance by increasing the degree of multiplexing used for backups. This increases the
rate at which RMAN fills tape buffers, which makes it more likely that buffers are sent to
the media manager fast enough to maintain streaming.
running the database being backed up, then incremental backups can be faster.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Summary
Practice 10 Overview:
Monitoring and Tuning RMAN
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
Flashback Technology
Object Scenario Examples Flashback Depends Affects
Level Technology On Data
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
RECYCLEBIN=ON
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Recycle Bin
BIN$zbjrBdpw==$0 EMPLOYEES
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
BIN$zbjra9wy==$0 EMPLOYEES_PK
Recycle
bin
4
DBA_FREE_SPACE
EMPLOYEES BIN$zbjrBdpw==$0
3
l e
EMPLOYEES_PK
Objects are: rab
BIN$zbjra9wy==$0
fe
n s
– Renamed tra n -
o
– Not moved
s an
1
2 ) ha ideฺ
c o m Gu
DROP TABLE employees;
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Recycle Bin
y u ki se to
as binlicenabled,
Without the recycle
M en when you drop a table, the space associated with the table
l ey
and itsndependent objects is immediately reclaimable (that is, it can be used for other objects).
S t a
If the recycle bin is enabled, when you drop a table, then the space associated with the table
and its dependent objects is not immediately reclaimable, even though it does appear in
DBA_FREE_SPACE. Instead, the dropped objects are referenced in the recycle bin and still
belong to their owner. The space used by recycle bin objects is never automatically reclaimed
unless there is space pressure. This enables you to recover recycle bin objects for the
maximum possible duration.
When a dropped table is “moved” to the recycle bin, the table and its associated objects and
constraints are renamed using system-generated names. The renaming convention is as
follows:
BIN$unique_id$version
where unique_id is a 26-character globally unique identifier for this object making the
recycle bin name unique across all databases and version is a version number assigned by
the database.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
ble
fe r a
ans
FLASHBACK TABLE <table_name> TO BEFORE DROP
n - t r
[RENAME TO <new_name>];
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Restoring Tables from k i
u nsRecycle
the e Bin
s y
a TABLE e ... TO BEFORE DROP command to recover a table and all of
Use the FLASHBACK
M l i c
l eydependent objects from the recycle bin. You can specify either the original name
its possible
n
ta table or the system-generated name assigned to the object when it was dropped.
ofSthe
If you specify the original name, and if the recycle bin contains more than one object of that
name, then the object that was moved to the recycle bin most recently is recovered first (LIFO:
last in, first out). If you want to retrieve an older version of the table, you can specify the
system-generated name of the table that you want to retrieve, or issue additional FLASHBACK
TABLE ... TO BEFORE DROP statements until you retrieve the table you want.
If a new table of the same name has been created in the same schema since the original table
was dropped, then an error is returned unless you also specify the RENAME TO clause.
Note: When you flash back a dropped table, the recovered indexes, triggers, and constraints
keep their recycle bin names. Therefore, it is advisable to query the recycle bin and
DBA_CONSTRAINTS before flashing back a dropped table. In this way, you can rename the
recovered indexes, triggers, and constraints to more usable names.
Recycle bin
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
BIN$zbjrBdpw==$0
BIN$zbjra9wy==$0 BIN$zbjrBdpw==$0
BIN$zbjra9wy==$0
ble
fe r a
ans
DBA_FREE_SPACE - RECYCLEBIN 1
n - t r
a no
a s
) h
Autoextendi d e3ฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Recycle Bin: Automatic k i
u Space e Reclamation
s y
a used n s
eby recycle bin objects is not reclaimed, you can recover those
As long as theMspace l i c
l
objectsnbyeyusing Flashback Drop. The following are recycle bin object reclamation policies:
S• taManual cleanup when you explicitly issue a PURGE command
• Automatic cleanup under space pressure: While objects are in the recycle bin, their
corresponding space is also reported in DBA_FREE_SPACE because their space is
automatically reclaimable. The free space in a particular tablespace is then consumed in
the following order:
1. Free space not corresponding to recycle bin objects
2. Free space corresponding to recycle bin objects. In this case, recycle bin objects are
automatically purged from the recycle bin using a first in, first out (FIFO) algorithm.
3. Free space automatically allocated if the tablespace is auto-extensible. Suppose that
you create a new table inside the TBS1 tablespace. If there is free space allocated to
this tablespace that does not correspond to a recycle bin object, this free space is used
as a first step. If this is not enough, free space is used that corresponds to recycle bin
objects that reside inside TBS1. If the free space of some recycle bin objects is used,
these objects are purged automatically from the recycle bin. At this time, you can no
longer recover these objects by using the Flashback Drop feature. As a last resort, the
TBS1 tablespace is extended (if possible) if the space requirement is not yet satisfied.
PURGE [USER_|DBA_]RECYCLEBIN
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Recycle Bin: ManualuSpacek i (M Reclamation
t o
a s y ense
Use the PURGE
y M commandlic to permanently remove objects from the recycle bin. When an
objectnisle
purged from the recycle bin, the object and dependent objects are permanently
S t a
removed from the database. As a consequence, objects purged from the recycle bin are no
longer recoverable by using Flashback Drop. The following are possible uses of PURGE:
• PURGE TABLE purges the specified table.
• PURGE INDEX purges the specified index.
• PURGE TABLESPACE purges all the objects residing in the specified tablespace. In
addition, objects residing in other tablespaces may get purged if they are dependent.
• PURGE RECYCLEBIN purges all the objects that belong to the current user.
RECYCLEBIN and USER_RECYCLEBIN are synonymous.
• PURGE DBA_RECYCLEBIN purges all the objects. You must have enough system
privileges or the SYSDBA system privilege to issue this command.
Tables can also be purged from the recycle bin using Enterprise Manager. On the Schema
folder tab, click Tables, then select the schema the dropped object resided in and click the
Recycle Bin button. Select the table from the results list and click the Purge button.
Note: For PURGE TABLE and PURGE INDEX commands, if you specify an original name and
if the recycle bin contains more than one object of that name, then the object that has been in
the recycle bin the longest is purged first (FIFO).
Oracle Database 11g: Administration Workshop II 11 - 9
Computer Pride Limited
You can also see the content of the recycle bin by using Database Control.
Note: For detailed information about the DBA_RECYCLEBIN view, see the Oracle Database
Reference guide.
Original data
in
buffer cache
Retention guarantee:
15 minutes
Undo data in
undo
ble
tablespace
fe r a
ans
n - t r
o
SELECT statements a nthat generates
A transaction
s
running 15 minutes or less more
) h aundo than
e ฺ what there
are always satisfied. m is space i d
u for will fail.
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
ki se to
Guaranteeing UndouRetention
y
s ceisnto overwrite committed transactions that have not yet expired
abehavior
The default undo
M li
rather n l
thaneyto allow an active transaction to fail because of lack of undo space. In case of
Sta transactions have precedence over queries.
conflict,
This behavior can be changed by guaranteeing retention. With guaranteed retention, undo
retention settings are enforced even if they cause transactions to fail. (So in case of conflict,
queries have precedence over transactions.)
RETENTION GUARANTEE is a tablespace attribute rather than an initialization parameter.
This attribute can be changed using either SQL command-line statements or Enterprise
Manager. The syntax to change an undo tablespace to guarantee retention is:
SQL> ALTER TABLESPACE undotbs1 RETENTION GUARANTEE;
To return a guaranteed undo tablespace to its normal setting, use the following command:
SQL> ALTER TABLESPACE undotbs1 RETENTION NOGUARANTEE;
You can set Undo Retention Guarantee in Enterprise Manager. Navigate to the Automatic
Undo Management page. Click the current setting for Retention Guarantee (General/Undo
Retention Settings) to modify it.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
• Flashback Query
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Flashback Query
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
T1 T2 ble
fe r a
ans
n - t r
SELECT employee_id, salary FROM employees
n o
AS OF TIMESTAMP <T1> s a
h a ฺ
WHERE employee_id = 200 ) ide o m Gu
il ฺ c n t
a e
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Flashback Query uki e
y
as Query s
n you can perform queries as of a certain time. By using the
efeature,
With the Flashback
M l i c
l ey of the SELECT statement, you can specify the time stamp for which to view the
AS OFnclause
StaThis is useful for analyzing a data discrepancy.
data.
Note: TIMESTAMP and SCN are valid options for the AS OF clause.
11:00 11:10
UPDATE employees
a b le
SET salary = s fer
(SELECT salary FROM employees
- t r an
AS OF TIMESTAMP TO_TIMESTAMP n on
s a
('2005-05-04 11:00:00', 'yyyy-mm-dd hh24:mi:ss')
WHERE employee_id = 200)
a
) h uideฺ
m
WHERE employee_id = 200 ฺco G
a il n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Flashback Query: Example
y u ki se to
If a raise has M aserroneously
been l i c en given to a particular employee recently, you can update the
l ey assigning the salary provided by a subquery that returns the flashed-back value.
salarynagain,
Sta
200
t1 t2
SELECT versions_xid, salary FROM employees
ble
VERSIONS BETWEEN TIMESTAMP <t1> and <t2> fe r a
ans
WHERE employee_id = 200;
n - t r
a no
a s
Tx0 Tx1 ) h
Tx2
i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Flashback Version Query k i
a s yu ense
With Flashback
y c can perform queries on the database as of a certain time span or
M Query,liyou
range nofle
user-specified system change numbers (SCNs). The Flashback Version Query feature
t a
enables
S you to use the VERSIONS clause to retrieve all the versions of the rows that exist
between two points in time or two SCNs.
The rows returned by Flashback Version Query represent a history of changes for the rows
across transactions. Flashback Version Query retrieves only committed occurrences of the
rows. Uncommitted row versions within a transaction are not shown. The rows returned also
include deleted and subsequently reinserted versions of the rows.
You can use Flashback Version Query to retrieve row history. It provides you with a way to
audit the rows of a table and retrieve information about the transactions that affected the rows.
You can then use the returned transaction identifier to perform transaction mining by using
LogMiner or to perform a Flashback Transaction Query, as described later in this lesson.
Note: VERSIONS_XID is a pseudocolumn that returns the transaction identifier of the
corresponding version of a row.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Flashback Version Query k i
u nUsing e Enterprise Manager
s y
a Flashback s
e Version Query by using Enterprise Manager (EM).
You can also Mperform l i c
On the n l ey
Availability page, select Perform Recovery.
t a
S the Perform Recovery page, select Tables as Object Type and Flashback Existing Tables as
On
Operation Type. Click Perform Object Level Recovery. On the “Perform Object Level
Recovery: Point-in-Time” page, select “Evaluate row changes and transactions to decide on a
point in time,” and specify the name of the target table.
Select the columns that you want to view in the Available Columns box, and then enter a
search clause in the Bind The Row Value box. Select “Show all row history,” and then click
Next.
– External tables
– Temporary tables
– Fixed tables
– Views
• The VERSIONS clause cannot span DDL commands.
• Segment shrink operations are filtered out.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k
Flashback Version Query:i
u nConsiderations
a s y e se
The VERSIONS
y c be used to query the following types of tables:
M clauselicannot
t a nle tables
• External
S• Temporary tables
• Fixed tables
You cannot use the VERSIONS clause to query a view. However, a view definition can use the
VERSIONS clause.
The VERSIONS clause in a SELECT statement cannot produce versions of rows across the
DDL statements that change the structure of the corresponding tables. This means that the
query stops producing rows after it reaches a time in the past when the table structure was
changed.
Certain maintenance operations, such as a segment shrink, may move table rows across blocks.
In this case, the version query filters out such phantom versions because the row data remains
the same.
FLASHBACK_TRANSACTION_QUERY
DBA
Erroneous
Undo e
DML
SQL r a bl
s fe
- t r an
n no
s a
) h a eฺ
m i d
User
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Flashback Transaction k i Query
a s yu ense
Flashback Transaction
y M ic is a diagnostic tool that you can use to view changes made to the
lQuery
t a nleat the transaction level. This enables you to diagnose problems in your database and
database
S analysis and audits of transactions.
perform
You can use the FLASHBACK_TRANSACTION_QUERY view to determine all the necessary
SQL statements that can be used to undo the changes made either by a specific transaction or
during a specific period of time.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using Enterprise Manager k i
u nstoePerform Flashback Transaction Query
s y
a in conjunction
e
This feature isMused
y l i c with the Flashback Version Query feature with the help of
t a nle Recovery Wizard. On the “Perform Object Level Recovery: Choose SCN” page,
the Perform
S the corresponding Transaction ID link in the Flashback Version Query Result region.
click
In the example in the slide, a Flashback Version Query is performed on the JOBS table to
retrieve the three versions of the JOBS row for JOB_ID = 'AD_PRES'. Then, one of the
transaction IDs is clicked, showing all the changes that were part of that transaction. Notice
that in addition to the JOBS table update, there was also an update to the EMPLOYEES table in
that transaction.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Flashback Transaction k i
u nse Considerations
Query:
s y
a DDL eoperations are nothing but a series of space management operations
Within the database,
M l i c
l ey to the data dictionary. Flashback Transaction Query on a transaction underlying a
and changes
n
Stacommand displays the changes made to the data dictionary.
DDL
When Flashback Transaction Query involves tables that have been dropped from the database,
the table names are not reflected. Instead, object numbers are used.
If the user who executed a transaction is dropped, Flashback Transaction Query of that
transaction displays the corresponding user ID only, and not the username.
Note: When there is not enough undo data for a specific transaction, a row with a value of
UNKNOWN in the OPERATION column of FLASHBACK_TRANSACTION_QUERY is returned.
Flashback Transaction
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Flashback Transaction k i
a s yu ense
With Flashback
y lic you can reverse a transaction and dependant transactions. Oracle
M Transaction,
t a nledetermines the dependencies between transactions and, in effect, creates a
Database
S
compensating transaction that reverses the unwanted changes. The database rewinds to a state
as if the transaction, and any transactions that could be dependent on it, never occurred.
You can use the Flashback Transaction functionality from within Enterprise Manager or with
PL/SQL packages.
Prerequisites
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Prerequisites k i
a s yu ense
In order to use
y lic
Mthis functionality, supplemental logging must be enabled and the correct
a n leestablished. For example, the HR user in the HR schema decides to use Flashback
privileges
S t
Transaction for the REGIONS table. The SYSDBA performs the following setup steps in
SQL*Plus:
alter database add supplemental log data;
alter database add supplemental log data (primary key) columns;
grant execute on dbms_flashback to hr;
grant select any transaction to hr;
Possible Workflow
Viewing Data
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Viewing Data k i
a s yu ense
To view the data
y lic in Enterprise Manager, go to the Schema folder and select Tables
M in a table
under n
a le objects.
Database
t
S viewing the content of the HR.REGIONS table, you discover a logical problem. Region
While
5 is misnamed. You decide to immediately address this issue.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Flashback Transaction k i Wizard
a s yu ense
In Enterprise M
y c HR.REGIONS under Table, select Flashback Transaction from
Manager,liselect
t a nle drop-down list, and then click Go. This invokes the Flashback Transaction Wizard
the Actions
S your selected table. The Flashback Transaction: Perform Query page is displayed.
for
Select the appropriate time range and add query parameters. (The more specific you can be,
the shorter is the search of the Flashback Transaction Wizard.)
Without Enterprise Manager, use the DBMS_FLASHBACK.TRANSACTION_BACKOUT
procedure, which is described in the PL/SQL Packages and Types Reference. Essentially, you
take an array of transaction IDs as the starting point of your dependency search. For example:
CREATE TYPE XID_ARRAY AS VARRAY(100) OF RAW(8);
CREATE OR REPLACE PROCEDURE TRANSACTION_BACKOUT(
numberOfXIDs NUMBER, -- number of transactions passed as input
xids XID_ARRAY, -- the list of transaction ids
options NUMBER default NOCASCADE, -- back out dependent
txn timeHint TIMESTAMP default MINTIME -- time hint on the txn
start
);
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Flashback Transaction k i
u nse (continued)
Wizard
s y
a lice Select Transaction page displays the transactions according to
The FlashbackM Transaction:
l ey entered specifications. First, display the transaction details to confirm that you
your previously
n
are a
Stflashing back the correct transaction. Then select the offending transaction and continue
with the wizard.
1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Flashback Transaction k i
u nse (continued)
Wizard
s y
a liceWizard now generates the undo script and flashes back the
The Flashback MTransaction
l eybut it gives you control to COMMIT this flashback. Before you commit the
transaction,
n
Sta
transaction, you can use the Execute SQL area at the bottom of the Flashback Transaction:
Review page, to view what the result of your COMMIT will be.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Finishing Up k i
a s yu ense
On the Flashback
y lic Review page click the Show Undo SQL Script button to view
M Transaction:
t a nle
the compensating SQL commands. Click Finish to commit your compensating transaction.
S
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Choosing Other Back-out k i
u nOptions
a s y e se
y M lic
The TRANSACTION_BACKOUT procedure checks dependencies, such as:
t a nle
• Write-after-write (WAW)
S• Primary and unique constraints
A transaction can have a WAW dependency, which means a transaction updates or deletes a
row that has been inserted or updated by a dependent transaction. This can occur, for example,
in a master/detail relationship of primary (or unique) and mandatory foreign key constraints.
To understand the difference between the NONCONFLICT_ONLY and the
NOCASCADE_FORCE options, assume that the T1 transaction changes rows R1, R2, and R3
and the T2 transaction changes rows R1, R3, and R4. In this scenario, both transactions update
row R1, so it is a “conflicting” row. The T2 transaction has a WAW dependency on the T1
transaction. With the NONCONFLICT_ONLY option, R2 and R3 are backed out, because there
is no conflict and it is assumed that you know best, what to do with the R1 row. With the
NOCASCADE_FORCE option, all three rows (R1, R2, and R3) are backed out.
Note: This screenshot is not part of the workflow example, but shows additional details of a
more complex situation.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Choosing Other Back-outk i
u nOptions
e (continued)
s y s
a liceWizard works as follows:
The Flashback MTransaction
If the n l ey
DBMS_FLASHBACK.TRANSACTION_BACKOUT procedure with the NOCASCADE
S t a
option fails (because there are dependent transactions), you can change the recovery options.
• With the Nonconflict Only option, nonconflicting rows within a transaction are backed
out, which implies that database consistency is maintained (although the transaction
atomicity is broken for the sake of data repair).
• If you want to forcibly back out the given transactions, without paying attention to the
dependent transactions, use the Nocascade Force option. The server simply executes the
compensating DML commands for the given transactions in reverse order of their commit
times. If no constraints break, you can proceed to commit the changes, or else roll back.
• To initiate the complete removal of the given transactions and all their dependents in a
post-order fashion, use the Cascade option.
Note: This screenshot is not part of the workflow example, but shows additional details of a
more complex situation.
Summary
Practice 11 Overview:
Performing Flashback Database
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
ble
fe r a
ans
n - t r
a no
Erroneous a s
Flashed
DMLs User ) h i d eฺ back
tables
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Flashback Table Overview
y u ki se to
s you
Using FlashbackaTable, c encan recover a set of tables to a specific point in time without having
M l i
to perform
n l eytraditional point-in-time recovery operations.
ta
ASFlashback Table operation is done in-place, while the database is online, by rolling back only
the changes that are made to the given tables and their dependent objects.
A Flashback Table statement is executed as a single transaction. All tables must be flashed back
successfully, or the entire transaction is rolled back.
Note: You can use Flashback Versions Query and Flashback Transaction Query to determine the
appropriate flashback time.
Flashback Table
ble
fe r a
ans
n - t r
no
ALTER TABLE employees ENABLE ROW MOVEMENT;
a
a s
m ) h uideฺ
o
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Enabling Row Movement
y u ki onsea Table
s movement
You must enablearow c en on a table to be able to flash back the table. When you enable
M l i
n l ey the Oracle server can move a row in the table.
row movement,
Sta Enterprise Manager, you can enable row movement on a table by performing the
Using
following steps:
1. Select Tables in the Database Objects region of the Schema property page. Enter the
schema name to search for the table, and click Go.
2. Click the table name of the table for which you want to enable row movement. You are now
on the View Table page.
3. Click Edit, which takes you to the Edit Table page.
4. Click the Options tab, where you can change the Enable Row Movement setting for the
table.
5. Set Enable Row Movement to Yes, and click Apply. The update confirmation message is
displayed.
ble
fe r a
ans
n - t r
n o
FLASHBACK TABLE hr.departments TO TIMESTAMP s a
) h a eฺ
TO_TIMESTAMP('2007-04-05 21:00:00',
m i d
'YYYY-MM-DD HH24:MI:SS');
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Performing Flashback k i
Table
a syu Manager
You can use Enterprise e n seto flash back a table by performing the following steps:
1. Select yPerform lic in the Backup/Recovery region on the Availability property page.
M Recovery
n l e
S2.taIn the Object Level Recovery region, select Tables from the Object Type drop-down list.
3. Select Flashback Existing Tables as Operation Type. Click Recover. The “Perform Object
Level Recovery: Point-in-time” page is displayed.
4. Select “Flashback to a timestamp” or “Flashback to a known SCN” and then specify a time
stamp or SCN to flash back to, and click Next.
5. Click Add Tables to add tables to the list for the flashback operation. Click Next.
6. The Dependency Options page appears if there are dependent tables. Select the desired
option for dealing with dependent tables. Typically, you would select “Cascade” to ensure a
consistent flashback. Click Next.
7. The “Perform Object Level Recovery: Review” page appears. Review the information and
click Submit. The Confirmation page appears.
Note: You can also flash back tables from the Tables link in the Schema region of the
Administration page.
Flashback Database
ble
fe r a
a n s
Errors are The "Press the rewind button" - t r The
generated. database is (FLASHBACK DATABASE). on database is
corrupted. a n "rewound."
s ha ideฺ
m Gu)
ฺ c o t
a il e n
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
Flashback Databaseuki
( M to
y
s ceyou s e
n can quickly bring your database to an earlier point in time by
With Flashback a Database,
undoingle
M l i
allythe changes that have taken place since that time. This operation is fast because you
n
S a need to restore backups. You can use this feature to undo changes that have resulted in
do tnot
logical data corruptions.
When you use Flashback Database, Oracle Database uses past block images to back out changes
to the database. During normal database operation, Oracle Database occasionally logs these
block images in flashback logs. Flashback logs are written sequentially and are not archived.
Oracle Database automatically creates, deletes, and resizes flashback logs in the Flash Recovery
Area. You need to be aware of flashback logs only for monitoring performance and deciding
how much disk space to allocate to the Flash Recovery Area for flashback logs.
The time it takes to rewind a database with Flashback Database is proportional to how far back
in time you need to go and the amount of database activity after the target time. The time it
would take to restore and recover the whole database could be much longer. The before images
in the flashback logs are used only to restore the database to a point in the past, and forward
recovery is used to bring the database to a consistent state at some time in the past. Oracle
Database returns data files to the previous point in time, but not auxiliary files, such as
initialization parameter files. Flashback Database can also be used to compliment Data Guard
and Recovery Advisor, and for synchronizing clone databases.
SGA
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Log block
before
images
periodically.
ble
Flashback RVWR
Redo
fe r a
logs logs
ans
Do forward
n - t r
1
Back out changes media recovery.
2 n
o
to database using
s a
before images.
) h a eฺ
m i d
…
i l ฺ co nt Gu …
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
k i (M e to u
Flashback DatabaseuArchitecture
When you enable a Flashback
s
sy cenDatabase, the RVWR (Flashback Writer) background process is
M l i
n l ey background process sequentially writes Flashback Database data from the flashback
started. This
ta to the Flashback Database logs, which are circularly reused. Subsequently, when a
buffer
S
FLASHBACK DATABASE command is issued, the flashback logs are used to restore to the
blocks’ before images, and then redo data is used to roll forward to the desired flashback time.
The overhead of enabling Flashback Database depends on the read/write mix of the database
workload. Because queries do not need to log any flashback data, the more write-intensive the
workload, the higher the overhead of turning on Flashback Database.
bl e
SQL> SHUTDOWN IMMEDIATE;
fe r a
SQL> STARTUP MOUNT EXCLUSIVE;
n s
SQL> ALTER SYSTEM SET
n - tra
2 no
DB_FLASHBACK_RETENTION_TARGET=2880 SCOPE=BOTH;
a
SQL> ALTER DATABASE FLASHBACK ON;
h a s ฺ
SQL> ALTER DATABASE OPEN; ) ide o m Gu
il ฺ c n t
a e
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Configuring Flashback
y u kiDatabase
s e
You can configure
M asFlashback
l i c enDatabase as follows:
n l ey the Flash Recovery Area.
1. Configure
S2.taSet the retention target with the DB_FLASHBACK_RETENTION_TARGET initialization
parameter. You can specify an upper limit, in minutes, on how far back you want to be able
to flash back the database. The example uses 2,880 minutes, which is equivalent to two
days. This parameter is only a target and does not provide any guarantee. Your flashback
time interval depends on how much flashback data has been kept in the Flash Recovery
Area.
3. Enable Flashback Database with the following command:
ALTER DATABASE FLASHBACK ON;
Before you can issue the command to enable Flashback Database, the database must be
configured for archiving and started in MOUNT EXCLUSIVE mode.
You can determine whether Flashback Database is enabled with the following query:
SELECT flashback_on FROM v$database;
You can disable Flashback Database with the ALTER DATABASE FLASHBACK OFF
command. As a result, all existing Flashback Database logs are deleted automatically.
Note: You can enable Flashback Database only when the database is mounted in exclusive
mode, not open.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M toUsing u
Configuring Flashback k
u nse iDatabase EM
s y
a Manager
Log in to Enterprise e (EM). On the Availability page, select Recovery Settings in the
M l i c
n l ey
Backup/Recovery region. Make sure that your database is in ARCHIVELOG mode. If not, select
Sta
ARCHIVELOG Mode and then click Continue. You will need to shut down and restart the
instance for your changes to take effect.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M toUsing u
Configuring Flashback k
u nseiDatabase EM (continued)
s y
a that
When you are certain ethe database is in ARCHIVELOG mode, return to the Recovery
M l i c
ey and scroll down to the Flash Recovery Area region to observe the new settings.
Settingslpage
n
Sta the Flash Recovery Area and archiving are configured,
When
USE_DB_RECOVERY_FILE_DEST is configured for archive log destination 10. Enable
flashback logging by selecting Enable Flashback Logging. You can also set the flashback
retention time, and you can view important information regarding your flashback database
window.
Review the Flash Recovery Area location. The Flash Recovery Area is a unified storage location
for all recovery-related files and activities in an Oracle database. All files that are needed to
completely recover a database from a media failure are part of the Flash Recovery Area. The
recovery-related files that can be created in the Flash Recovery Area include: archived redo log
files, control files, backups created by Recovery Manager (RMAN), flashback logs, and the
change tracking file. By allocating a storage location and unifying recovery-related files within a
specific area, the Oracle database server relieves the database administrator from having to
manage the disk files created by these components. The default location for the Flash Recovery
Area is $ORACLE_BASE/flash_recovery_area. If you would like it in a different
location, change it now. Scroll down to the bottom of the Recovery Settings page and click
Apply.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M toUsing u
Performing Flashback k
u nsei
Database EM
s
On the Availability
y
a page, e Perform Recovery. From the Recovery Scope drop-down list,
choose
M l i c
n l ey Database. Next, select “Recover to the current time or a previous point-in-time” as
select Whole
Sta Type. Finally, provide the operating system credentials for a database user (that is,
Operation
one who belongs to the dba group). When these steps are completed, click Continue to proceed
to the next step in the Flashback Database operation.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M toUsing u
Performing Flashback k
u nsei
Database EM (continued)
s y
a operation
After the recovery e type has been chosen, the Recovery Wizard is launched. You are
M l i c
y the database will be shut down and restarted in MOUNT mode. This operation takes
informedlethat
n
Sta minutes and you will be informed of the delay. After waiting an appropriate amount of
several
time, you must click Refresh to continue with the operation.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M toUsing u
Performing Flashback k i
Database
u nse EM (continued)
s y
a islicnow
The Recovery Wizard e started. At this stage, the database is shut down and started in
M
ey Click Refresh.
MOUNT lmode.
n
Stadisplays the Perform Recovery: Point-in-time page. On this page, select the “Recover to a
This
prior point-in-time” option, and then specify either a date or an SCN. Then, click Next.
The Perform Recovery: Flashback page appears next, and you can choose to perform either
recovery using flashback or regular recovery. Choose the corresponding option, and then click
Next. Next in the sequence is the Perform Whole Database Recovery: Review page that is
shown in the slide. Click Submit to flash back the database.
the database:
– In read-only mode to verify that the correct target time or SCN
was used
– With a RESETLOGS operation to allow for DML
• The opposite of “flash back” is “recover.”
• You cannot use Flashback Database in the following
situations: e
– The control file has been restored or re-created. r a bl
ns fe
– A tablespace has been dropped. - t r a
o n
– A data file has been reduced in size. an s
• Use the TO BEFORE RESETLOGS clause) tohaflashi d ฺ to
eback
m u
lฺco t G
before the last RESETLOGS operation.
ai den
m
g Stu
i @ isAll rights reserved.
s y uk© 2009, Oracle.
Copyright
t h
( M a use
ki se to
Flashback DatabaseuConsiderations
y
asyoulicannot
In situations where
M c en use the Flashback Database feature, you should use an
incomplete
n l eyrecovery operation to return the database to a specific time. After the Flashback
Sta operation is complete, you can open the database in read-only mode to verify that the
Database
correct target time or SCN was used. If not, you can flash back the database again, or perform a
recovery to roll forward the database. So, to undo a Flashback Database operation, you should
recover the database forward.
You cannot use Flashback Database to recover a data file that was dropped during the span of
time you are flashing back. The dropped data file is added to the control file and marked offline,
but it is not flashed back. Flashback Database cannot flash back a data file to a time after its
creation and before the resize operation. If a file was resized during the span of time to which
you are going to flash back the database, then you should take the file offline before beginning
the Flashback Database operation. This is applicable for files that are shrunk rather than
expanded. You can use Flashback Database with data files that you have configured for
automatic extension. You can flash back to just before the last RESETLOGS operation by
supplying the TO BEFORE RESETLOGS clause in the FLASHBACK DATABASE command.
Note: The flashback retention target is not an absolute guarantee that flashback will be
available. If space is needed for required files in the Flash Recovery Area, flashback logs may be
deleted automatically.
Based on this information, you may need to adjust the retention time or the Flash Recovery Area
size.
FLASHBACK_DATA and REDO_DATA represent the number of bytes of flashback data and redo
data written, respectively, during the time interval, and DB_DATA gives the number of bytes of
data blocks read and written. This view also contains the estimated flashback space needed for
the interval.
You can query V$RECOVERY_FILE_DEST to view information regarding the Flash Recovery
Area. The column descriptions are:
• NAME: Flash Recovery Area name, indicating location string
a b le
• SPACE_LIMIT: Disk limit specified in the DB_RECOVERY_FILE_DEST_SIZE
s fer
parameter
- t r an
• SPACE_USED: Space used by Flash Recovery Area files (in bytes) on
• SPACE_RECLAIMABLE: Amount of space that can be reclaimed
n deleting obsolete,
a by
s
ha ideฺ algorithm
redundant, and other low-priority files through the space) management
• NUMBER_OF_FILES: Number of files
ilฺ ent com Gu
a
m tud
SQL> SELECT name, space_limit AS gquota, S
k @
i AS used,
i s
2 space_used u h
sy sASe treclaimable,
3 a
space_reclaimable
(M to u AS files
4
k i
number_of_files
a syu cense
5 FROM v$recovery_file_dest ;
M li
NAME nley QUOTA USED RECLAIMABLE FILES
S t a
------------------------ ---------- ---------- ----------- -----
/u01/flash_recovery_area 5368709120 2509807104 203386880 226
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M towith u
Monitoring Flashback k i
Database
u nse EM
s y
a Database
Most of the Flashback e statistics mentioned on the preceding pages can be viewed from
M l i c
n l ey Settings page. These metrics include the current space used by all flashback logs,
the Recovery
S a SCN, and the time of the lowest SCN in the flashback data.
thetlowest
bl e
fe r a
SQL> CREATE RESTORE POINT before_upgrade
t r a ns
2 GUARANTEE FLASHBACK DATABASE; on-
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Guaranteed RestoreuPoints
y ki se to
M as points,
Like normal restore
l i c n
eguaranteed restore points can be used as aliases for SCNs in recovery
operations.
n l eyA principal difference is that guaranteed restore points never age out of the control
S a must be explicitly dropped. However, they also provide specific functionality related to
filetand
the use of the Flashback Database feature.
Creating a guaranteed restore point at a particular SCN enforces the requirement that you can
perform a Flashback Database operation to return your database to its state at that SCN, even if
flashback logging is not enabled for your database. If flashback logging is enabled, creating a
guaranteed restore point enforces the retention of flashback logs required for Flashback
Database back to any point in time after the creation of the earliest guaranteed restore point.
A guaranteed restore point can be used to revert a whole database to a known good state days or
weeks ago, as long as there is enough disk space in the Flash Recovery Area to store the needed
logs. As with normal restore points, guaranteed restore points can be used to specify a point in
time for RECOVER DATABASE operations.
Note: Limitations that apply to Flashback Database also apply to guaranteed restore points. For
example, shrinking a data file or dropping a tablespace can prevent flashing back the affected
data files to the guaranteed restore point.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Original
data in
buffer cache
DML operations
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Flashback Data Archive k i Process
a
The first step is to n se Data Archive. Second, you can specify a default Flashback
yu aeFlashback
screate
Data ArchiveyM lic
for the system. A Flashback Data Archive is configured with retention time. Data
n l e
Sta in the Flashback Data Archive is retained for the retention time.
archived
Third, you can enable flashback archiving (and then disable it again) for a table. While flashback
archiving is enabled for a table, some DDL statements are not allowed on that table. By default,
flashback archiving is off for any table.
Last, you can examine the Flashback Data Archives. There are static data dictionary views that
you can query for information about Flashback Data Archives.
ble
-- Enable Flashback Data Archive
fe r a
ALTER TABLE inventory FLASHBACK ARCHIVE;
ans3
ALTER TABLE stock_data FLASHBACK ARCHIVE;
n - t r
a no
SELECT product_number, product_name, count FROM
h a s inventory
ฺ AS
OF TIMESTAMP TO_TIMESTAMP ('2007-01-01) 00:00:00',
m u i de 'YYYY-MM-
o
ilฺc ent G
DD HH24:MI:SS');
a
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Flashback Data Archive
y u ki Scenario
s e
as liData
You create a Flashback
M c enArchive with the CREATE FLASHBACK ARCHIVE statement.
y optionally specify the default Flashback Data Archive for the system.
• Youlecan
n
S• taYou need to provide the name of the Flashback Data Archive.
• You need to provide the name of the first tablespace of the Flashback Data Archive.
• You can identify the maximum amount of space that the Flashback Data Archive can use in
the tablespace. The default is unlimited. Unless your space quota on the first tablespace is
unlimited, you must specify this value, or else an ORA-55621 will ensue.
• You need to provide the retention time (number of days that Flashback Data Archive data
for the table is guaranteed to be stored).
In the first example shown in the slide, a default Flashback Data Archive named fla1 is created
that uses up to 10 GB of the tbs1 tablespace, whose data will be retained for five years. In the
second example, the default Flashback Data Archive is specified. By default, the system has no
Flashback Data Archive. You can set it in one of two ways:
• Specify the name of an existing Flashback Data Archive in the SET DEFAULT clause of
the ALTER FLASHBACK ARCHIVE statement.
• Include DEFAULT in the CREATE FLASHBACK ARCHIVE statement when you create a
Flashback Data Archive.
In the third example, Flashback Data Archive is enabled. If Automatic Undo Management is
disabled, you receive an ORA-55614 if you try to modify the table.
Oracle Database 11g: Administration Workshop II 12 - 26
Computer Pride Limited
Summary
Practice 12 Overview:
Working with Flashback Database
This practice covers the following topics:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta
Computer Pride Limited
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
DBA
Alert DBA
Auto-incident creation
1 2 Targeted health checks
First failure capture Assisted SR filling
No Known
ble
DBA bug?
fe r a
ans
- t
nYes r
EM Support
a no
Workbench:
EM Support Workbench: as
4
Package incident info
Apply patch/Datam ) h uideฺ DBA
repair
o
ilฺc ent G3
Data repair
a
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
i ( M to
Automatic Diagnostic
y u kWorkflow
s e
as licetracing
An always-on,Min-memory
n facility enables database components to capture diagnostic
l
data upon y failure for critical errors. A special repository, called Automatic Diagnostic
efirst
n
Sta
Repository, is automatically maintained to hold diagnostic information about critical error
events. This information can be used to create incident packages to be sent to Oracle Support
Services for investigation.
Here is a typical workflow for a diagnostic session:
1. Incident causes an alert to be raised in Enterprise Manager (EM).
2. The DBA can view the alert via the EM Alert page.
3. The DBA can drill down to incident and problem details.
4. The DBA or Oracle Support Services can decide or ask for that information to be packaged
and sent to Oracle Support Services via MetaLink. The DBA can add files to the data to be
packaged automatically.
CORE_DUMP_DEST
USER_DUMP_DEST
$ORACLE_HOME/log
ADR
Base
diag
rdbms
DB
Name
ADR
SID metadata
ble
Home
fe r a
ans
alert cdump incpkg incident hm trace (others)
n - t r
a no
incdir_1 … incdir_n
h a s ฺ
ADRCI ) i d eV$DIAG_INFO
log.xml m
co nt Gu
i l ฺ alert_SID.log
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Automatic Diagnostic k i
u nse (ADR)
Repository
s y
a licrepository
e
The ADR is aM file-based for database diagnostic data such as traces, incident dumps
y
le the alert log, Health Monitor reports, core dumps, and more. It has a unified
and packages,
t a n
directory structure across multiple instances and multiple products stored outside of any
S
database. It is, therefore, available for problem diagnosis when the database is down. Beginning
with Oracle Database 11g R1, the database, Automatic Storage Management (ASM), Cluster
Ready Services (CRS), and other Oracle products or components store all diagnostic data in the
ADR. Each instance of each product stores diagnostic data underneath its own ADR home
directory. For example, in a Real Application Clusters environment with shared storage and
ASM, each database instance and each ASM instance have a home directory within the ADR.
ADR’s unified directory structure, consistent diagnostic data formats across products and
instances, and a unified set of tools enable customers and Oracle Support to correlate and
analyze diagnostic data across multiple instances.
The ADR root directory is known as the ADR base. Its location is set by the
DIAGNOSTIC_DEST initialization parameter. If this parameter is omitted or left null, the
database sets DIAGNOSTIC_DEST upon startup as follows: If environment variable
ORACLE_BASE is set, DIAGNOSTIC_DEST is set to $ORACLE_BASE. If environment
variable ORACLE_BASE is not set, DIAGNOSTIC_DEST is set to $ORACLE_HOME/log.
system prompt.
• Using ADRCI, you can view diagnostic data within the
Automatic Diagnostic Repository.
$ adrci
ADRCI: Release 11.1.0.5.0 - On Sat Jul 7 08:01:40 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.
ble
ADRCI> show incident
fe r a
ADR Home = /u01/app/oracle/product/11.1.0/db_1/log/diag/rdbms/orcl/orcl:
ans
**************************************************************************
INCIDENT_ID PROBLEM_KEY CREATE_TIME n - t r
no
----------- ------------------------------------ ------------------------
a
1681
a s
ORA-600_dbgris01:1,_addr=0xa9876541 17-JAN-07 09.17.44.843125…
1682
) h d eฺ
ORA-600_dbgris01:12,_addr=0xa9876542 18-JAN-07 09.18.59.434775…
i
2 incident info records fetched m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
ADRCI: The ADR Command-Line
u nse Tool
s y
a licetool that is part of the database fault diagnosability infrastructure.
ADRCI is a command-line
M
ADRCI n l ey you to:
enables
S• taView diagnostic data within the Automatic Diagnostic Repository (ADR)
• Package incident and problem information into a zip file for transmission to Oracle Support
ADRCI has a rich command set, and can be used in interactive mode or within scripts. In
addition, ADRCI can execute scripts of ADRCI commands in the same way that SQL*Plus
executes scripts of SQL and PL/SQL commands.
There is no need to log in to ADRCI, because the data in the ADR is not intended to be secure.
ADR data is secured only by operating system permissions on the ADR directories.
The easiest way to package and otherwise manage diagnostic data is with Support Workbench of
Oracle Enterprise Manager. ADRCI provides a command-line alternative to most of the
functionality of Support Workbench, and adds capabilities such as listing and querying trace
files. The example in the slide shows you an ADRCI session where you are listing all open
incidents stored in ADR.
Note: For more information about ADRCI, refer to the Oracle Database Utilities guide.
NAME VALUE
------------------- -------------------------------------------------
Diag Enabled TRUE
ADR Base /u01/app/oracle
ADR Home /u01/app/oracle/diag/rdbms/orcl/orcl
Diag Trace /u01/app/oracle/diag/rdbms/orcl/orcl/trace
Diag Alert /u01/app/oracle/diag/rdbms/orcl/orcl/alert
Diag Incident /u01/app/oracle/diag/rdbms/orcl/orcl/incident
Diag Cdump /u01/app/oracle/diag/rdbms/orcl/orcl/cdump
Health Monitor /u01/app/oracle/diag/rdbms/orcl/orcl/hm
ble
Default Trace File /u01/app/oracle/diag/.../trace/orcl_ora_11424.trc
fe r a
Active Problem Count 3
ans
Active Incident Count 8
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
V$DIAG_INFO
a s yu ense
The V$DIAG_INFO
y M view lic lists all important ADR locations:
• ADR
a n leBase: Path of the ADR base
t
S• ADR Home: Path of the ADR home for the current database instance
• Diag Trace: Location of the text alert log and background/foreground process trace files
• Diag Alert: Location of an XML version of the alert log
• Diag Incident: Incident logs are written here.
• Diag Cdump: Diagnostic core files are written to this directory.
• Health Monitor: Location of logs from Health Monitor runs
• Default Trace File: Path to the trace file for your session. SQL trace files are written here.
ble
Incident dumps USER|BACKGROUND_DUMP_DEST ADR_HOME/incident/incdir_n fe r a
n s
n - tra
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Location for Diagnostic k i Traces
a s yu ense
The table in the
y lic the different classes of trace data and dumps that reside both in
Mslide compares
a le
OraclenDatabase 10g and Oracle Database 11g.
t
S Oracle Database 11g, there is no distinction between foreground and background traces
With
files. Both types of files go into the ADR_HOME/trace directory.
All nonincident traces are stored inside the trace subdirectory. This is the main difference
compared with previous releases where critical error information is dumped into the
corresponding process trace files instead of incident dumps. Incident dumps are placed in files
separated from the normal process trace files starting with Oracle Database 11g.
The main difference between a trace and a dump is that a trace is more of a continuous output
such as when SQL tracing is turned on, and a dump is a one-time output in response to an event
such as an incident. Also, a core is a binary memory dump that is port specific.
Note: In the slide, ADR_HOME represents the path
/u01/app/oracle/diag/rdbms/orcl/orcl, assuming an instance name of orcl.
However, there is no official environment variable called ADR_HOME.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Viewing the Alert Log k i
u nsEnterprise
Using e Manager
s y
aalert llog ewith a text editor, with Enterprise Manager, or with the ADRCI
You can viewM the i c
l
utility.nToeyview the alert log with Enterprise Manager:
S1.taAccess the Database Home page in Enterprise Manager.
2. Under Related Links, click Alert Log Contents. The View Alert Log Contents page appears.
3. Select the number of entries to view, and then click Go.
handling problems.
• You can perform the following tasks with Support
Workbench:
– View details on problems and incidents
– Run heath checks
– Generate additional diagnostic data
– Run advisors to help resolve problems le
a b
– Create and track service requests through MetaLink
s fer
– Generate incident packages - t r an
– Close problems when resolved n on
a s
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
EM Support Workbench: k i
u Overview
a s y e n se
Support Workbench
y M is an licEnterprise Manager wizard that helps you through the process of
handling
a n lecritical errors. It displays incident notifications, presents incident details, and enables
yout
S to select incidents for further processing. Further processing includes running additional
health checks, invoking the incident packaging service (IPS) to package all diagnostic data about
the incidents, adding SQL test cases and selected user files to the package, filing a service
request (SR) with Oracle Support, shipping the packaged incident information to Oracle
Support, and tracking the SR through its life cycle.
You can perform the following tasks with Support Workbench:
• View details about problems and incidents.
• Manually run health checks to gather additional diagnostic data for a problem.
• Generate additional dumps and SQL test cases to add to the diagnostic data for a problem.
• Run advisors to help resolve problems.
• Create and track a service request through MetaLink, and add the service request number to
the problem data.
• Collect all diagnostic data relating to one or more problems into an incident package and
then upload the incident package to Oracle Support Services.
• Close the problem when the problem is resolved.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Oracle Configuration k i
Manager
a s yu ense
Enterprise Manager
y M Support lic Workbench uses Oracle Configuration Manager to upload the
physical
a n lefiles generated by IPS to MetaLink. If Oracle Configuration Manager is not installed or
S t
properly configured, the upload may fail. In this case, a message is displayed with a path to the
incident package zip file and a request that you upload the file to Oracle Support manually. You
can upload manually with MetaLink.
During the database installation, the Oracle Universal Installer has a special Oracle
Configuration Manager Registration screen as shown in the slide. On that screen, you need to
select the Enable Oracle Configuration Manager check box and accept the license agreement
before you can enter your Customer Identification Number (CSI), your MetaLink account
username, and your country code.
If you do not configure Oracle Configuration Manager, you will still be able to manually upload
incident packages to MetaLink.
Note: For more information about Oracle Configuration Manager, see the “Oracle Configuration
Manager Installation and Administration Guide,” available at the following URL:
http://www.oracle.com/technology/documentation/oem.html
View critical
1 error alerts in
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Enterprise Manager
Gather additional
6 Track the SR and 3 diagnostic
implement repairs
information
ble
fe r a
ans
n - t r
Package and upload 4
Create a
a no
diagnostic data
a s
service request
to Oracle Support
) h i d eฺ
5 m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
EM Support Workbench k i
u Roadmap
a s y e n se
M in thelicslide is a summary of the tasks that you complete to investigate, report,
The graphic given
y
le cases, resolve a problem using Enterprise Manager Support Workbench:
and innsome
a
t
S1. Start by accessing the Database Home page in Enterprise Manager, and reviewing critical
error alerts. Select an alert for which to view details.
2. Examine the problem details and view a list of all incidents that were recorded for the
problem. Display findings from any health checks that were automatically run.
3. Optionally, run additional health checks and invoke the SQL Test Case Builder, which
gathers all required data related to a SQL problem and packages the information in a way
that enables the problem to be reproduced at Oracle Support.
4. Create a service request with MetaLink and optionally record the service request number
with the problem information.
5. Invoke a wizard that automatically packages all gathered diagnostic data for a problem and
uploads the data to Oracle Support. Optionally, edit the data to remove sensitive
information before uploading.
6. Optionally, maintain an activity log for the service request in Support Workbench. Run
Oracle advisors to help repair SQL failures or corrupted data.
7. Set the status for one, some, or all incidents for the problem to Closed.
Problem ID
Critical
Problem
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Error
Problem
Aut Key Incident Status
o ma
tica Collecting
Flood lly
control Automatic
Ready
Incident transition
Tracking
l ly Incident ID
nua Data-Purged
Ma
DBA Closed
Traces
ble
ADR
MMON Auto-purge
fe r a
ans
n - t r
Noncritical
a no
error
a s
Package to be
) h i d eฺ
sent to
Oracle Support m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Problems and Incidents k i
a s yu ense
To facilitate diagnosis
y M lic resolution of critical errors, the fault diagnosability infrastructure
and
introduces
a n le two concepts for Oracle Database—problems and incidents:
t
S• A problem is a critical error in the database. Problems are tracked in the ADR. Each
problem is identified by a unique problem ID and has a problem key, which is a set of
attributes that describe the problem. The problem key includes the ORA error number, error
parameter values, and other information. Here is a possible list of critical errors:
- All internal errors – ORA-60x errors
- All system access violations – (SEGV, SIGBUS)
- ORA-4020 (Deadlock on library object), ORA-8103 (Object no longer exists), ORA-
1410 (Invalid ROWID), ORA-1578 (Data block corrupted), ORA-29740 (Node
eviction), ORA-255 (Database is not mounted), ORA-376 (File cannot be read at this
time), ORA-4030 (Out of process memory), ORA-4031 (Unable to allocate more bytes
of shared memory), ORA-355 (The change numbers are out of order), ORA-356
(Inconsistent lengths in change description), ORA-353 (Log corruption), ORA-7445
(Operating System exception).
• An incident is a single occurrence of a problem. When a problem occurs multiple times, as
is often the case, an incident is created for each occurrence. Incidents are tracked in the
ADR. Each incident is identified by a numeric incident ID, which is unique within an ADR
home.
Oracle Database 11g: Administration Workshop II 13 - 12
Computer Pride Limited
Large amounts of diagnostic information can be created very quickly if a large number of
sessions stumble across the same critical error. Having the diagnostic information for more than
a small number of the incidents is not required. That is why ADR provides flood control so that
only a certain number of incidents under the same problem can be dumped in a given time
interval. Note that flood controlled incidents still generate incidents; they only skip the dump
actions. By default only five dumps per hour for a given problem are allowed.
You can view a problem as a set of incidents that are perceived to have the same symptoms. The
main reason to introduce this concept is to make it easier for users to manage errors on their
systems. For example, a symptom that occurs 20 times should only be reported to Oracle once. e
Mostly, you will manage problems instead of incidents using IPS to package a problem torbe a bl
sent to Oracle Support. Most commonly incidents are automatically created when ancritical s fe error
occurred. However, you are also allowed to create an incident manually, vianthe - a provided
trGUI
by the EM Support Workbench. Manual incident creation is mostly donenwhen o you want to
a
s theฺ Oracle code.
report problems that are not accompanied by critical errors raisedainside
h
) in the i de A retention policy
As time goes by, more and more incidents will be accumulated m
o tG u ADR.
allows you to specify how long to keep the diagnostic a ilฺcdata.eADR
n incidents are controlled by two
different policies: m
g Stu d
• The incident metadata retentionu i @
k controls
policy is how long the metadata is kept around. This
s y t h
( M u se
policy has a default settingaof one year.
• The incident files and
u ki dumps e to
retention policy controls how long generated dump files are
y
s policy
kept around.aThis s
enhas a default setting of one month.
You can e M
change l i c
y these setting using the Incident Package Configuration link on the EM Support
n l
S ta
Workbench page. Inside the RDBMS component, MMON is responsible for purging
automatically expired ADR data.
The Status of an incident reflects the state of the incident. If an incident has been in either the
Collection or the Ready state for over twice its retention length, the incident automatically
moves to the Closed state. You can manually purged incident files.
For simplicity, problem metadata is internally maintained by ADR. Problems are automatically
created when the first incident (of the problem key) occurs. The Problem metadata is removed.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Viewing Critical Error k i
u nsin
Alerts e Enterprise Manager
s y
a oflicinvestigating
e
You begin theMprocess problems (critical errors) by reviewing critical error alerts
le y
on thenDatabase Home page. To view critical error alerts, access the Database Home page in
t a
Enterprise
S Manager. From the Home page, you can look at the Diagnostic Summary section
where you can click the Active Incidents link if there are incidents. You can also use the Alerts
section and look for critical alerts flagged as Incidents.
When you click the Active Incidents link, you end up on the Support Workbench page from
where you can retrieve details about all problems and corresponding incidents. From there, you
can also retrieve all Health Monitor checker run and created packages.
Note: The tasks described in this section are all Enterprise Manager based. You can also
accomplish all of these tasks with the ADRCI command-line utility and PL/SQL package
procedures. See Oracle Database Utilities for more information about the ADRCI utility.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Viewing Problem Details k i
a s yu ense
On the Problems
y M subpagelicon the Support Workbench page, click the ID of the problem you want
t a nle This takes you to the corresponding Problem Details page.
to investigate.
S this page, you can see all incidents that are related to your problem. You can associate your
On
problem with a MetaLink service request and bug number. In the Investigate and Resolve
section of the page, you have a Self Service subpage that has direct links to the operation you
can perform on this problem. In the same section, the Oracle Support subpage has direct links to
MetaLink.
The Activity Log subpage shows you the system-generated operations that have occurred on
your problem so far. This subpage allows you to add your own comments while investigating
your problem.
On the Incidents subpage, you can click a related incident ID to access the corresponding
Incident Details page.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Viewing Incident Details k i
a s yu ense
On the Incident
y ic the Dump Files subpage appears and lists all corresponding dump
MDetailslpage,
files. You
a n lecan then click the eyeglasses icon for a particular dump file to visualize the file
t
content
S with its various sections.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Viewing Incident Details k i
u (continued)
a s y e n se
On the Incident
y ic click Checker Findings to view the Checker Findings subpage.
MDetailslpage,
This page
a n ledisplays findings from any health checks that were automatically run when the critical
t
error
S was detected. Most of the time, you have the possibility to select one or more findings, and
invoke an advisor to fix the issue.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Creating a Service Requestk i
a s yu ense
Before you can
y Mpackagelicand upload diagnostic information for the problem to Oracle Support,
you must
a n lecreate a service request. To create a service request, you need to go to MetaLink first.
S t
MetaLink can be accessed directly from the Problem Details page when you click the “Go to
Metalink” button in the Investigate and Resolve section of the page. On MetaLink, log in and
create a service request in the usual manner.
When done, you can enter that service request for your problem. This is entirely optional and is
for your reference only.
In the Summary section, click the Edit button that is adjacent to the SR# label, and in the
window that opens, enter the SR#, and then click OK.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Packaging and Uploadingk i
u nDiagnostic
e Data to Oracle Support
s y
a provides s
e two methods for creating and uploading an incident package: the
Support Workbench
M l i c
l ey method and the Advanced Packaging method. The example in the slide shows
QuicknPackaging
Stahow to use Quick Packaging.
you
Quick Packaging is a more automated method with a minimum of steps. You select a single
problem, provide an incident package name and description, and then schedule the incident
package upload, either immediately or at a specified date and time. Support Workbench
automatically places diagnostic data related to the problem into the incident package, finalizes
the incident package, creates the zip file, and then uploads the file. With this method, you do not
have the opportunity to add, edit, or remove incident package files or add other diagnostic data
such as SQL test cases. To package and upload diagnostic data to Oracle Support:
1. On the Problem Details page, in the Investigate and Resolve section, click Quick Package.
The Create New Package page of the Quick Packaging wizard appears.
2. Enter a package name and description.
3. Enter the service request number to identify your problem.
4. Click Next, and then proceed with the remaining pages of the Quick Packaging wizard.
Click Submit on the Review page to upload the package.
Tracking the SR
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Tracking the SR k i
a s yu ense
After uploading
y lic information to Oracle Support, you might perform various activities
M diagnostic
to track e service request and implement repairs. Among these activities are the following:
nlthe
t a
S an Oracle bug number to the problem information. To do so, on the Problem Details page,
Add
click the Edit button that is adjacent to the Bug# label. This is for your reference only.
Add comments to the problem activity log. To do so, complete the following steps:
1. Access the Problem Details page for the problem.
2. Click Activity Log to display the Activity Log subpage.
3. In the Comment field, enter a comment, and then click Add Comment. Your comment is
recorded in the activity log.
Respond to a request by Oracle Support to provide additional diagnostics. Your Oracle Support
representative might provide instructions for gathering and uploading additional diagnostics.
Implementing Repairs
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Implementing Repairs k i
a s yu ense
On the Incident
y ic you can run an Oracle advisor to implement repairs. Access the
MDetailslpage,
suggested
a n leadvisor in one of the following ways:
t
S• In the Self-Service tab of the Investigate and Resolve section of the Problem Details page
• On the Checker Findings subpage of the Incident Details page as shown in the slide
The advisors that help you repair critical errors are:
• Data Recovery Advisor: Corrupted blocks, corrupted or missing files, and other data
failures
• SQL Repair Advisor: SQL statement failures
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Closing Incidents and k i
Problems
a s yu ense
When a particular
y lic is no longer of interest, you can close it. By default, closed incidents
M incident
a le
are notndisplayed on the Problem Details page. All incidents, whether closed or not, are purged
t
after
S 30 days. You can disable purging for an incident on the Incident Details page.
To close incidents:
1. Access the Support Workbench home page.
2. Select the desired problem, and then click View. The Problem Details page appears.
3. Select the incidents to close and then click Close. A confirmation page appears.
4. Click Yes on the Confirmation page to close your incident.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Incident Packaging Configuration
a s yu ense
M you canlicconfigure various aspects of retention rules and packaging generation.
As already seen,
y
Usingn
a le Workbench, you can access the Incident Packaging Configuration page from the
Support
t
Related
S Links section of the Support Workbench page by clicking the Incident Package
Configuration link. Here are the parameters you can change:
• Incident Metadata Retention Period: Metadata is basically information about the data.
For incidents, the metadata includes the incident time, ID, size, problem, and so forth. Data
is the actual contents of an incident, such as traces.
• Cutoff Age for Incident Inclusion: This value includes incidents for packaging that are in
the range to now. If the cutoff date is 90, for instance, the system includes only the incidents
that are within the last 90 days.
• Leading Incidents Count: For every problem included in a package, the system selects a
certain number of incidents from the problem from the beginning and the end. For example,
if the problem has 30 incidents, and the leading incident count is 5 and the trailing incident
count is 4, the system includes the first five incidents and the last four incidents.
• Trailing Incidents Count: See above.
• Correlation Time Proximity: This parameter is the exact time interval that defines
“happened at the same time.” One criterion for correlation is time correlation: find the
incidents that happened at the same time as the incidents in a problem.
• Time Window: Number of hours in the time window for including incidents in a package
Oracle Database 11g: Administration Workshop II 13 - 23
Computer Pride Limited
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Custom Packaging: u k
Creating
o uPackage
i (M ea tNew
a sisya more
e n s
Custom Packaging
y M lic manual method than Quick Packaging, but gives you greater
le the incident package contents. You can create a new incident package with one or
controlnover
a
t
more
S problems, or you can add one or more problems to an existing incident package. You can
then perform a variety of operations on the new or updated incident package, including:
• Adding or removing problems or incidents
• Adding, editing, or removing trace files in the incident package
• Adding or removing external files of any type
• Adding other diagnostic data such as SQL test cases
• Manually finalizing the incident package and then viewing package contents to determine
whether you must edit or remove sensitive data or remove files to reduce incident package
size.
With the Custom Packaging method, you create the zip file and request upload to Oracle Support
as two separate steps. To package and upload a problem with Custom Packaging:
1. In the Problems subpage at the bottom of the Support Workbench home page, select the
first problem that you want to package, and then click Package.
2. Next, select the Custom Packaging option, and click Continue.
3. The Custom Packaging: Select Package page appears. To create a new incident package,
select the Create New Package option, enter an incident package name and description, and
then click OK.
Oracle Database 11g: Administration Workshop II 13 - 24
Computer Pride Limited
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Custom Packaging: u k i (M e to an
Manipulating Incident Package
s y
a Package, n s
eyou get the confirmation that your new package has been created.
On the Customize
y M l i c
n
This pagel edisplays the incidents that are contained in the incident package, plus a selection of
S t a
packaging tasks to choose from. You run these tasks against the new incident package or the
updated existing incident package.
As you can see from the slide, you can exclude/include incidents or files as well as many other
possible tasks.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Custom Packaging: u k i (M e an
Finalizing to Incident Package
s y
a package n s
e is used to add correlated files from other components, such as
Finalizing an M
incident l i c
l ey to the package. Recent trace files and log files are also included in the package.
HealthnMonitor,
Stacan finalize a package by clicking the Finish Contents Preparation link in the Packaging
You
Tasks section as shown in the slide. A confirmation page is displayed that lists all files that will
be part of the physical package.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Custom Packaging: u k
Generate
ou
i (M eatPackage
a y ens
spackage
After your incident
y M lic has been finalized, you can generate the package file. You need to
go back
t a nltoe the corresponding package page and click Generate Upload File.
S Generate Upload File page appears. There, select the Full or Incremental option to generate
The
a full incident package zip file or an incremental incident package zip file.
For a full incident package zip file, all the contents of the incident package (original contents
and all correlated data) are always added to the zip file.
For an incremental incident package zip file, only the diagnostic information that is new or
modified since the last time that you created a zip file for the same incident package is added to
the zip file.
When done, select the Schedule and click Submit. If you scheduled the generation immediately,
a Processing page appears until packaging is finished. This is followed by the Confirmation page
where you can click OK.
Note: The Incremental option is unavailable if a physical file was never created for the incident
package.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Custom Packaging: u k i (M e taoPackage
Uploading
a y ens
sthe
After you generate
y M lic package, you can go back to the Customize Package page from
physical
le can click the View/Send Uploaded Files link in the Packaging Tasks section.
wherenyou
a
t
S takes you to the View/Send Upload Files page from where you can select your package,
This
and click the “Send to Oracle” button.
The “Send to Oracle” page appears. Here, you can enter the service request number for your
problem, and choose a Schedule. You can then click Submit.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Viewing and Modifying k i
u nse Packages
Incident
s y
ais created, eyou always have the possibility to modify it through customization.
After a package
M l i c
n l ey go to the Support Workbench page and click the Packages tab. This takes you to
For example,
the
a
StPackages subpage. On this page, you can select a package and delete it, or click the package
link to go to the Package Details page. There, you can click Customize to go to the Customize
Package page from where you can manipulate your package by adding/removing problem,
incidents, or files.
Re hm
ac
ti v (reports)
e
ADR
Health
al HM Monitor
a nu S_
M M
DB
or V$HM_CHECK
EM
DBA Logical Block Check Undo Segment Check
ble
Table Row Check Data Block Check
fe r a
Transaction Check
ans
Table Check
Redo Check - t r
Database Cross Check
n
a no
Table-Index Row Mismatch
a s
) i d eฺ
Database Dictionary Check
h
m
co nt Gu
Table-Index Cross Check
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Health Monitor: Overview k i
a s yu ense
The Oracle database
y lic a framework called Health Monitor for running diagnostic checks
M includes
on various
a n le components of the database. Health Monitor checks examine various components of
the t
S database, including files, memory, transaction integrity, metadata, and process usage. These
checks generate reports of their findings as well as recommendations for resolving problems.
The fault diagnosability infrastructure can run Health Monitor checks automatically in response
to critical errors or the DBA, can manually run Health Monitor health checks using either the
DBMS_HM PL/SQL package or the Enterprise Manager interface.
For a complete description of all possible checks that Health Monitor can run, look at
V$HM_CHECK. These health checks fall into one of two categories:
• DB-online: These checks can be run while the database is open (that is, in OPEN mode).
• DB-offline: In addition to being “runnable” while the database is open, these checks can
also be run when the instance is available and the database itself is closed (NOMOUNT
mode).
After a checker has run, it generates a report containing information about the checker’s
findings, including the priorities (low, high, or critical), descriptions of the findings and their
consequences, and basic statistics about the execution. Health Monitor generates reports in XML
and stores the reports in ADR. You can view these reports using either V$HM_RUN, DBMS_HM,
ADRCI, or Enterprise Manager.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to uEM Example
Running Health Checks k i Manually:
a s yu ense
Enterprise Manager
y lic an interface for running Health Monitor checkers. You can find
M provides
a n le in the Checkers tab on the Advisor Central page. The page lists each checker type,
this interface
andt
S you can run a checker by clicking it and then OK on the corresponding checker page after
you entered the parameters for the run. This is illustrated in the slide, where you run the Data
Block Checker manually.
After a check is completed, you can view the corresponding checker run details by selecting the
checker run from the Results table and click Details. Checker runs can be reactive or manual.
On the Findings subpage, you can see the various findings and corresponding recommendations
extracted from V$HM_RUN, V$HM_FINDING, and V$HM_RECOMMENDATION.
If you click View XML Report on the Runs subpage, you can view the run report in XML
format. Viewing the XML report in Enterprise Manager generates the report for the first time if
it is not yet generated in your ADR. You can then view the report using ADRCI without needing
to generate it.
'mycheck',0,'TABLE_NAME=tab$');
DBMS_HM.GET_RUN_REPORT('mycheck')
--------------------------------------------------------------------------------
<?xml version="1.0" encoding="US-ASCII"?>
<HM-REPORT REPORT_ID="mycheck"><TITLE>HM Report: mycheck</TITLE>
<RUN_INFO>
<CHECK_NAME>Database Dictionary Check</CHECK_NAME>
<RUN_ID>21</RUN_ID><RUN_NAME>mycheck</RUN_NAME>
<RUN_MODE>MANUAL</RUN_MODE><RUN_STATUS>COMPLETED</RUN_STATUS> …
ble
</RUN_INFO>
fe r a
<RUN_PARAMETERS><RUN_PARAMETER>TABLE_NAME=tab$</RUN_PARAMETER> … </RUN_PARAMETERS>
ans
<RUN-FINDINGS><FINDING>
n - t r
<FINDING_NAME>Dictionary Inconsistency</FINDING_NAME><FINDING_ID>22</FINDING_ID>
<FINDING_TYPE>FAILURE</FINDING_TYPE><FINDING_STATUS>OPEN</FINDING_STATUS>
a no
<FINDING_PRIORITY>CRITICAL</FINDING_PRIORITY> …
a s
<FINDING_CREATION_TIME>…</FINDING_CREATION_TIME>
) h i d eฺ
m
co nt Gu
<FINDING_MESSAGE>…invalid column number 7 on Object tab$ Failed</FINDING_MESSAGE>
l ฺ
<FINDING_MESSAGE>Damaged … Object SH.JFVTEST is referenced </FINDING_MESSAGE> …
i
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Running Health Checks k i
u nse PL/SQL Example
Manually:
s y
aDBMS_HM.RUN_CHECK
e
You can use the
y M l i c procedure for running a health check. To call
RUN_CHECK,
a n le supply the name of the check found in V$HM_CHECK, the name for the run (this
t
isSjust a label used to retrieve reports later), and the corresponding set of input parameters for
controlling its execution. You can view these parameters using the V$HM_CHECK_PARAM.
In the slide example, you want to run a Database Dictionary Check for TAB$ table, considered
an important core dictionary object. You call this run MYCHECK, and you do not want to set any
timeout for this check.
When executed, you execute the DBMS_HM.GET_RUN_REPORT function to get the report
extracted from V$HM_RUN, V$HM_FINDING, and V$HM_RECOMMENDATION. The output
clearly shows you that a critical error was found in TAB$. This table contains an entry for a table
with an invalid number of columns. Furthermore, the report gives you the name of the damaged
table in TAB$.
When you call the GET_RUN_REPORT function, it generates the XML report file in the HM
directory of your ADR. In the example, the file is called HMREPORT_mycheck.hm.
Note: Refer to the Oracle Database PL/SQL Packages and Types Reference for more
information about DBMS_HM.
adrci>>show hm_run
…
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
----------------------------------------------------------
RUN_ID 11081
RUN_NAME HM_RUN_11081
CHECK_NAME Database Cross Check
NAME_ID 2
MODE 2
START_TIME 2007-04-13 03:20:31.161396 -07:00
RESUME_TIME
END_TIME 2007-04-13 03:20:37.903984 -07:00
MODIFIED_TIME 2007-04-17 01:16:37.106344 -07:00
TIMEOUT 0
FLAGS 0
STATUS 5
ble
SRC_INCIDENT_ID 0
fe r a
NUM_INCIDENTS 0
ans
ERR_NUMBER
REPORT_FILE
0
n - t r
…
a no
adrci>>create report hm_run HM_RUN_11081
a s
Adrci>>show report hm_run HM_RUN_11081
) h i d eฺ
…
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
Viewing HM ReportsuUsing k i (Mthee t o
ADRCI Utility
s y n s
a viewlicHealth
e Monitor checker reports using the ADRCI utility. To do that,
You can create
M and
l eyoperating system environment variables such as ORACLE_HOME are set properly,
ensure that
n
Stathen enter the following command at the operating system command prompt: adrci.
and
The utility starts and displays its prompt as shown in the slide. Optionally, you can change the
current ADR home. Use the SHOW HOMES command to list all ADR homes, and the SET
HOMEPATH command to change the current ADR home.
You can then enter the SHOW HM_RUN command to list all the checker runs registered in the
ADR repository and visible from V$HM_RUN. Locate the checker run for which you want to
create a report and note the checker run name using the corresponding RUN_NAME field. The
REPORT_FILE field contains a file name if a report already exists for this checker run.
Otherwise, you can generate the report using the CREATE REPORT HM_RUN command as
shown in the slide. To view the report, use the SHOW REPORT HM_RUN command.
SQL Generate
statement Execute Statement incident in ADR
crashes
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
automatically
Trace files
declare
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
rep_out clob;
t_id varchar2(50);
begin
t_id := dbms_sqldiag.create_diagnosis_task(
sql_text => 'delete from t t1 where t1.a = ''a'' and rowid <> (select max(rowid)
from t t2 where t1.a= t2.a and t1.b = t2.b and t1.d=t2.d)',
task_name => 'sqldiag_bug_5869490',
problem_type => DBMS_SQLDIAG.PROBLEM_TYPE_COMPILATION_ERROR);
dbms_sqltune.set_tuning_task_parameter(t_id,'_SQLDIAG_FINDING_MODE',
dbms_sqldiag.SQLDIAG_FINDINGS_FILTER_PLANS);
dbms_sqldiag.execute_diagnosis_task (t_id);
rep_out := dbms_sqldiag.report_diagnosis_task (t_id, DBMS_SQLDIAG.TYPE_TEXT);
ble
dbms_output.put_line ('Report : ' || rep_out);
fe r a
end;
/
ans
n - t r
execute dbms_sqldiag.accept_sql_patch(task_name => 'sqldiag_bug_5869490', a no
a s
) h
task_owner => 'SCOTT', replace => TRUE);
i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using SQL Repair Advisor k i
u nfrom e PL/SQL Example
s y
a about s
ean incident SQL failure, you can execute a SQL Repair Advisor task
After you getM
y
alerted l i c
using ntheleDBMS_SQLDIAG.CREATE_DIGNOSIS_TASK function like illustrated on the slide.
Yout a
S need to specify the SQL statement for which you want the analysis to be done, as well as a
task name and a problem type you want to analyze (possible values are
PROBLEM_TYPE_COMPILATION_ERROR, and
PROBLEM_TYPE_EXECUTION_ERROR).
You can then give the created task parameters using the
DBMS_SQLTUNE.SET_TUNING_TASK_PARAMETER procedure.
Once you are ready, you can then execute the task using the
DBMS_SQLDIAG.EXECUTE_DIAGNOSIS_TASK procedure.
Finally, you can get the task report using the DBMS_SQLDIAG.REPORT_DIAGNOSIS_TASK
function.
In the above example, it is assumed that the report asks you to implement a SQL Patch to fix the
problem. You can then use the DBMS_SQLDIAG.ACCEPT_SQL_PATCH procedure to
implement the SQL Patch.
performed.
– Block version
– DBA (data block address) value in cache as compared to the
DBA value in the block buffer
– Block-checksum, if enabled
• A corrupt block is identified as being one of the following:
– Media corrupt e
– Logically (or software) corrupt r a bl
s fe
- t r an
n
no
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
What Is Block Corruption? k i
a s yu ense
M block lisica block that is not in a recognized Oracle format, or whose contents
A corrupted data
y
a le
are notninternally consistent. Typically, corruptions are caused by faulty hardware or operating
t
system
S problems. The Oracle database identifies corrupt blocks as either “logically corrupt” or
“media corrupt.” If it is logically corrupt, then there is an Oracle internal error. Logically corrupt
blocks are marked corrupt by the Oracle database after it detects the inconsistency. If it is media
corrupt, then the block format is not correct; the information in the block does not make any
sense after being read from disk.
You can repair a media corrupt block by recovering the block or dropping the database object
that contains the corrupt block, or both. If media corruption is due to faulty hardware, the
problem will not be completely resolved until the hardware fault is corrected.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a u
(inMRealtoTime:
Verifying Block Integrityk i
u nse DB_BLOCK_CHECKING
s y
a licblock e checking by setting the DB_BLOCK_CHECKING initialization
You can enable M database
l
parameter
n eyto TRUE. This checks data and index blocks for internal consistency whenever they
are a
Stmodified. DB_BLOCK_CHECKING is a dynamic parameter, modifiable by the ALTER
SYSTEM SET statement. Block checking is always enabled for the system tablespace. Block
checking typically causes 1% to 10% overhead, depending on workload. The more updates or
inserts being executed, the more expensive it is to turn on block checking. The four possible
values for DB_BLOCK_CHECKING are:
• OFF: No block checking is performed in any tablespaces except for SYSTEM.
• LOW: Basic block header checks are performed after block contents change in memory (for
example, after UPDATE or INSERT statements and on-disk reads).
• MEDIUM: All LOW checks are performed. Semantic block checking for all non-index-
organized table blocks is performed.
• FULL: All LOW and MEDIUM checks. Semantic checks on index blocks are performed.
You should set DB_BLOCK_CHECKING to FULL if the performance overhead is acceptable.
The default value is FALSE, which, for backward compatibility, is equivalent to OFF. Even if
this is turned off, block checking for the SYSTEM tablespace is always turned on.
a n le is first encountered. No subsequent read of the block will be successful until the
corruption
t
block
S is recovered. You can only perform block recovery on blocks that are marked corrupt or
fail a corruption check. Block media recovery is performed using the RMAN
RECOVER...BLOCK command. By default, RMAN searches the flashback logs for good
copies of the blocks, and then searches for the blocks in full or level 0 incremental backups.
When RMAN finds good copies, it restores them and performs media recovery on the blocks.
Block media recovery can only use redo logs for media recovery, not incremental backups.
The V$DATABASE_BLOCK_CORRUPTION view displays blocks marked corrupt by database
components such as RMAN commands, ANALYZE, dbv, SQL queries, and so on. The
following types of corruption result in rows added to this view:
• Physical/Media corruption: The database does not recognize the block: the checksum is
invalid, the block contains all zeros, or the block header is fractured. Physical corruption
checking is enabled by default.
• Logical corruption: The block has a valid checksum, the header and footer match, but the
contents are inconsistent. Block media recovery cannot repair logical block corruption.
Logical corruption checking is disabled by default. You can turn it on by specifying the
CHECK LOGICAL option of the BACKUP, RESTORE, RECOVER, and VALIDATE commands.
REPAIR FAILURE Repairs and closes failures (after ADVISE in the same
RMAN session)
bl e
RMAN> LIST FAILURE;
fe r a
ans
List of Database Failures
========================= n - t r
a no
has ideฺ
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- ) -------
21-JUN-07 omOne orumore non-system
ilฺc edatafiles t G are missing
142 HIGH OPEN
a n
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Listing of Data Failures
y u ki se to
The RMAN LIST M asFAILURE
l i c encommand lists failures. If the target instance uses a recovery
y be in STARTED mode, otherwise it must be in MOUNTED mode. The LIST
catalog,litecan
n
Sta command lists the results of previously executed assessments. Repeatedly executing
FAILURE
the LIST FAILURE command revalidates all existing failures. If the database diagnoses new
ones (between command executions), they are displayed. If a user manually fixes failures, or if
transient failures disappear, then the Data Recovery Advisor removes these failures from the
LIST FAILURE output.
To learn more about the syntax:
• failnum: Number of the failure to display repair options for
• ALL: List failures of all priorities.
• CRITICAL: List failures of CRITICAL priority and OPEN status. These failures require
immediate attention, because the make the whole database unavailable.
• HIGH: List failures of HIGH priority and OPEN status. These failures make a database
partly unavailable or unrecoverable; so they should be repaired quickly (for example,
missing archived redo logs).
• LOW: List failures of LOW priority and OPEN status. Failures of a low priority can wait, until
more important failures are fixed.
• CLOSED: List only closed failures.
syu cense
'/u01/app/oracle/oradata/orcl/users01.dbf' is missing
a
Impact: Some objects in tablespace USERS might be unavailable
li
le yM
n RMAN>
Sta
Advising on Repair
• Syntax:
ADVISE FAILURE
[ ALL | CRITICAL | HIGH | LOW | failnum[,failnum,…] ]
[ EXCLUDE FAILURE failnum [,failnum,…] ]
Executing Repairs
Syntax: Example:
Summary
• Discovering corruptions
• Identifying the location of the corruption
• Employing Support Workbench
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Managing Memory
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
Computer Pride Limited
Objectives
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
a le
Oraclendatabase instance, you must pay attention to how memory is allocated. If too much
S t
memory is allowed to be used by a particular area that does not need it, then there is the
possibility that there are other functional areas unnecessarily doing without enough memory to
perform optimally. With the ability to have memory allocation automatically determined and
maintained for you, the task is simplified greatly. But even automatically tuned memory needs
to be monitored for optimization and may need to be manually configured to some extent.
SGA
Keep buffer
Shared pool Streams pool Large pool cache
Recycle ble
fe r a
buffer cache
Database Redo t r a ns
Java pool
buffer cache buffer o n
nK block
- size
s a n caches
buffer
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Oracle Memory Structures
y u ki se to
The basic memory
M asstructures
l i c enassociated with an Oracle instance include:
l ey Global Area (SGA): Shared by all server and background processes. Examples of
• System
n
Stadata stored in the SGA include cached data blocks and shared SQL areas.
• Program Global Area (PGA): Private to each server and background process; there is one
PGA for each process.
The SGA is a shared memory area that contains data and control information for the instance,
including the following:
• Database buffer cache: Caches blocks of data retrieved from disk
• Redo log buffer: Caches redo information until it can be written to disk
• Shared pool: Caches various constructs that can be shared among users
• Large pool: Optional area used for buffering large I/O requests in support of parallel query,
shared server, Oracle XA, and certain types of backup operations
• Java pool: Holds session-specific Java code and data within the Java Virtual Machine
(JVM)
• Streams pool: Used by Oracle Streams
• Keep buffer cache: Holds data that is kept in the buffer cache as long as possible
• Recycle buffer cache: Holds data that is quickly aged out of the buffer cache
• nK block size buffer caches: Caches data blocks that are of a different size than the default
database block size; used to support transportable tablespaces
Oracle Database 11g: Administration Workshop II 14 - 4
Computer Pride Limited
Buffer Cache
SGA
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
. .
. .
. .
. .
a b le
DB_BLOCK_SIZE
e r
DB_CACHE_SIZE a n sf
o n -tr
DB_RECYCLE_CACHE_SIZE
n
DBWn sa
DB_KEEP_CACHE_SIZE
ha ideฺ
m Gu)
ฺ c o t
Data files
a il e n
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Buffer Cache
y u ki se to
asthe buffer
You can configure
M l i c encache by specifying a value for the DB_CACHE_SIZE parameter.
l
The buffer
n eycache holds copies of the data blocks from the data files having a block size of
Sta
DB_BLOCK_SIZE. The buffer cache is a part of the SGA; so all users can share these blocks.
The server processes read data from the data files into the buffer cache. To improve
performance, the server process sometimes reads multiple blocks in a single read operation. The
DBWn process writes data from the buffer cache into the data files. To improve performance,
DBWn writes multiple blocks in a single write operation.
At any given time, the buffer cache may hold multiple copies of a single database block. Only
one current copy of the block exists, but to satisfy queries, server processes may need to
construct read-consistent copies from past image information. This is called a consistent read
(CR) block.
The least recently used (LRU) list reflects the usage of buffers. The buffers are sorted on the
basis of a combination of how recently and how often they have been referenced. Thus, buffers
that are most frequently and recently used are found at the most recently used end. Incoming
blocks are copied to a buffer from the least recently used end, which is then assigned to the
middle of the list, as a starting point. From here, the buffer works its way up or down the list,
depending on usage.
SGA
DB buffer caches
Recycle pool
Keep pool
ble
fe r a
ans
n - t r
Default pool a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using Multiple Buffer k i
Pools
a s yu ense
The database M
y lic (DBA) may be able to improve the performance of the database
administrator
le by creating multiple buffer pools. You assign objects to a buffer pool depending on
bufferncache
a
howt
S the objects are accessed. There are three buffer pools:
• Keep: This pool is used to retain objects in memory that are likely to be reused. Keeping
these objects in memory reduces I/O operations. Buffers are kept in this pool by ensuring
that the pool is sized larger than the total size of the segments assigned to the pool. This
means that buffers do not have to be aged out. The keep pool is configured by specifying a
value for the DB_KEEP_CACHE_SIZE parameter.
• Recycle: This pool is used for blocks in memory that have little chance of being reused.
The recycle pool is sized smaller than the total size of the segments assigned to the pool.
This means that blocks read into the pool will often have to age out a buffer. The recycle
pool is configured by specifying a value for the DB_RECYCLE_CACHE_SIZE parameter.
• Default: This pool always exists. It is equivalent to the buffer cache of an instance without
a keep pool or a recycle pool and is configured with the DB_CACHE_SIZE parameter.
Note: The memory in the keep or recycle pool is not a subset of the default buffer pool.
bl e
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using Multiple Buffer k i
u ns(continued)
Pools e
a s y e
The BUFFER_POOL
y M clausel ic is used to define the default buffer pool for an object. It is part of
a n le clause and is valid for CREATE and ALTER table, cluster, and index statements.
the STORAGE
Thet
S blocks from an object without an explicitly set buffer pool go into the default buffer pool.
The syntax is BUFFER_POOL [KEEP | RECYCLE | DEFAULT].
When the default buffer pool of an object is changed using the ALTER statement, blocks that are
already cached remain in their current buffers until they are flushed out by the normal cache
management activity. Blocks read from disk are placed into the newly specified buffer pool for
the segment.
Because buffer pools are assigned to a segment, objects with multiple segments can have blocks
in multiple buffer pools. For example, an index-organized table can have different pools defined
on both the index and the overflow segment.
Shared Pool
execution plan.
• Data dictionary cache contains definitions for tables,
columns, and privileges from the data dictionary tables.
• The User Global Area (UGA) contains session information if
using Oracle shared server.
Shared pool
Shared pool
Library cache ble
fe r a
n s
Shared n - a
Data dictionarytrcache
pool
a no
h a s
Result cache
ฺ
) id e
o m G u
a ilฺc ent UGA
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Shared Pool
y u ki se to
You can specify
M athes sizelicofethe
n shared pool with the SHARED_POOL_SIZE initialization
l
parameter.
n eyThe shared pool is a memory area that stores information shared by multiple sessions.
ta different types of data, as shown in the graphic in the slide.
ItScontains
Library cache: The library cache contains shared SQL and PL/SQL areas—the fully parsed or
compiled representations of PL/SQL blocks and SQL statements. PL/SQL blocks include:
• Procedures and functions
• Packages
• Triggers
• Anonymous PL/SQL blocks
Data dictionary cache: The data dictionary cache holds definitions of dictionary objects in
memory.
Result cache: The result cache comprises the SQL query result cache and PL/SQL function
result cache. This cache is used to store results of SQL queries or PL/SQL functions to speed up
their future execution.
User Global Area: The UGA contains the session information for the Oracle shared server. The
UGA is located in the shared pool when using a shared server session and if the large pool is not
configured.
Large Pool
Java Pool
Shared pool
Redo log Database Library cache Large pool
buffer buffer cache
bl e
fe r a
t r a ns
Dictionary cache -
Java pool
o n
s an
) ha ideฺ
c o m Gu
a il ฺ n t
gm Stud e
@
k© i2009, Oracle.
isAll rights reserved.
s y u
Copyright
t h
( M a use
Java Pool
y u ki se to
The Java poolM
s ceinn the SGA that is used for all session-specific Java code and data
isaa structure
li
l
withinntheeyJava engine.
Sta Pool
Shared
Shared pool memory is used by the class loader within the JVM. The class loader uses about
8 KB of memory per loaded class. The shared pool is also used when compiling Java source
code in the database or when using Java resource objects in the database. Shared pool memory is
also consumed when you create call specifications and as the system tracks dynamically loaded
Java classes at run time.
Java Pool
The Oracle JVM memory manager allocates all other Java states during run-time execution from
the Java pool, including the shared in-memory representation of Java method and class
definitions, as well as the Java objects migrated to session space at end-of-call.
Java pool memory is used in different ways, depending on whether the Oracle database server is
using shared servers or not.
For more information about Java pool memory usage, refer to the Oracle Database Java
Developer’s Guide.
Shared pool
Redo log Database
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
Dictionary cache
ble
Server
LGWR ARCn fe r a
process
ans
Control files
n - t r
SQL> UPDATE employees a no
a s
2 SET salary=salary*1.1
) h i d eฺ Archived
3 WHERE employee_id=736; Datao m Gulog files log files
c files ntRedo
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Redo Log Buffer k i
a s yu ense
The Oracle server
y lic copy redo entries from the user’s memory space to the redo log
M processes
leeach DML or DDL statement. The redo entries contain the information necessary to
buffernfor
a
S t
reconstruct or redo changes made to the database by DML and DDL operations. They are used
for database recovery and take up continuous sequential space in the buffer.
The redo log buffer is a circular buffer; the server processes can copy new entries over the
entries in the redo log buffer that have already been written to disk. The LGWR process normally
writes fast enough to ensure that space is always available in the buffer for new entries. The
LGWR process writes the redo log buffer to the active online redo log file (or members of the
active group) on disk. The LGWR process copies to disk all redo entries that have been entered
into the buffer since the last time LGWR wrote to disk.
What Causes LGWR to Write?
LGWR writes out the redo data from the redo log buffer:
• When a user process commits a transaction
• Every three seconds, or when the redo log buffer is one-third full
• When a DBWn process writes modified buffers to disk, if the corresponding redo log data
has not already been written to disk
Buffer cache
Buffer cache
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M to
Automatic Shared Memory
y u ki sManagement:
e Overview
Automatic Shared
s
a Memory c n
eManagement (ASMM) simplifies SGA memory management. You
M l i
l
specify the
n eytotal amount of SGA memory available to an instance using the SGA_TARGET
Sta
initialization parameter and Oracle Database automatically distributes this memory among the
various SGA components to ensure the most effective memory utilization.
For example, in a system that runs large online transactional processing (OLTP) jobs during the
day (requiring a large buffer cache) and runs parallel batch jobs at night (requiring a large value
for the large pool), you would have to simultaneously configure both the buffer cache and the
large pool to accommodate your peak requirements.
With ASMM, when the OLTP job runs, the buffer cache grabs most of the memory to allow for
good I/O performance. When the data analysis and reporting batch job starts up later, the
memory is automatically migrated to the large pool so that it can be used by parallel query
operations without producing memory overflow errors.
The Oracle Database remembers the sizes of the automatically tuned components across instance
shutdowns if you are using a server parameter file (SPFILE). As a result, the system does need
to learn the characteristics of the workload again each time an instance is started. It can begin
with information from the past instance and continue evaluating workload where it left off at the
last shutdown.
in the background.
• MMON uses memory advisors.
• Memory is moved to where it is needed the most by MMAN.
• If an SPFILE is used (which is recommended):
– Component sizes are saved across shutdowns
– Saved values are used to bootstrap component sizes
– There is no need to relearn optimal values ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
How ASMM Works uki
a s y ense
The Automatic
y ic
MShared lMemory Management feature uses the SGA memory broker that is
Behavior of Autotuned
SGA Parameters
• When SGA_TARGET is not set or is set to 0:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
SGA_TARGET = 8G
DB_CACHE_SIZE = 0
JAVA_POOL_SIZE = 0
LARGE_POOL_SIZE = 0
SHARED_POOL_SIZE = 0
STREAMS_POOL_SIZE = 0
ble
fe r a
ans
SELECT name, value, isdefault
n - t r
FROM v$parameter
a no
WHERE name LIKE '%size';
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
M to u
(View
Using the V$PARAMETER k i
a s yu ense
When you specify
y ic value for SGA_TARGET and do not specify a value for an
M a nonzero
l
autotuned
a n leSGA parameter, the value of the autotuned SGA parameters in the V$PARAMETER
t
view
S is 0, and the value of the ISDEFAULT column is TRUE.
If you have specified a value for any of the autotuned SGA parameters, the value that is
displayed when you query V$PARAMETER is the value that you specified for the parameter.
– Is dynamic
– Can be increased up to SGA_MAX_SIZE
– Can be reduced until all components reach their minimum
size
• A change in the value of SGA_TARGET affects only
automatically sized components.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(MParameter u
Modifying the SGA_TARGETk i t o
a s yu ense
SGA_TARGET
y l ic parameter and can be changed through Database Control or with
Mis a dynamic
t a nle SYSTEM command.
the ALTER
S
SGA_MAX_SIZE is the maximum amount of memory that can be allocated to the SGA. It
cannot be changed without restarting the database. SGA_TARGET can be increased up to the
value of SGA_MAX_SIZE. It can be reduced until any one of the autotuned components reaches
its minimum size: either a user-specified minimum or an internally determined minimum.
• If you increase the value of SGA_TARGET, the additional memory is distributed according
to the autotuning policy across the autotuned components.
• If you reduce the value of SGA_TARGET, the memory is taken away by the autotuning
policy from one or more of the autotuned components.
Suppose that SGA_MAX_SIZE is set to 10 GB and SGA_TARGET is set to 8 GB. If
DB_KEEP_CACHE_SIZE is set to 1 GB and you increase SGA_TARGET to 9 GB, then the
additional 1 GB is distributed only among the components controlled by SGA_TARGET. The
value of DB_KEEP_CACHE_SIZE is not affected. Likewise, if SGA_TARGET is reduced to
7 GB, then the 1 GB is taken from only those components that are controlled by SGA_TARGET.
This decrease does not affect the settings of manually controlled parameters such as
DB_KEEP_CACHE_SIZE.
Disabling ASMM
Parameters:
sga_target = 0
a b le
Parameters: db_cache_size = 5G
s fer
sga_target = 8G
shared_pool_size = - t r an
2G
shared_pool_size = 1G
large_pool_sizen on= 512M
s a
Original values a
h ideฺ= 256M
java_pool_size
)
om u
streams_pool_size = 256M
a ilฺc ent G
@ gm Stud
u
Copyright
y k© i2009, Oracle.
t h isAll rights reserved.
s
a use
( M
Disabling ASMM
y u ki se to
as choose
You can dynamically
M l i c ento disable Automatic Shared Memory Management by setting
l
SGA_TARGET
n ey to 0. In this case, the values of all the autotuned parameters are set to the current
Staof the corresponding components, even if the user had earlier specified a different nonzero
sizes
value for an autotuned parameter.
In the example in the slide, the value of SGA_TARGET is 8 GB and the value of
SHARED_POOL_SIZE is 1 GB. If the system has internally adjusted the size of the shared pool
component to 2 GB, then setting SGA_TARGET to 0 results in SHARED_POOL_SIZE being set
to 2 GB, thereby overriding the original user-specified value.
Manually Resizing
Dynamic SGA Parameters
• For autotuned parameters, manual resizing:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Manually Resizing Dynamic k i
u nsSGA e Parameters
s y
a parameter e is resized and SGA_TARGET is set, the resizing results in an
When an autotuned
M l i c
l
immediate
n eychange to the size of the component only if the new value is larger than the current
Staof the component. For example, if you set SGA_TARGET to 8 GB and set
size
SHARED_POOL_SIZE to 2 GB, ensure that the shared pool has at least 2 GB at all times to
accommodate the necessary memory allocations. After this, adjusting the value of
SHARED_POOL_SIZE to 1 GB has no immediate effect on the size of the shared pool. It allows
the automatic memory-tuning algorithm to later reduce the shared pool size to 1 GB if it needs
to. Alternatively, if the size of the shared pool is 1 GB to begin with, then adjusting the value of
SHARED_POOL_SIZE to 2 GB results in the shared pool component growing immediately to a
size of 2 GB. The memory used in this resize operation is taken away from one or more
autotuned components, and the sizes of the manual components are not affected.
Parameters for manually sized components can be dynamically altered as well, but the
difference is that the value of the parameter specifies the precise size of that component
immediately. Therefore, if the size of a manual component is increased, extra memory is taken
away from one or more automatically sized components. If the size of a manual component is
decreased, the memory that is released is given to the automatically sized components.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using the Memory Advisor k i
u nstoeSize the SGA
s y
a Advisor, eyou can tune the size of your memory structures. If ASMM is
With the MemoryM l i c
y can use this to tune the total size of the SGA. If ASMM is disabled, you can use
enabled,
n l eyou
Staadvisor to tune the different components of the SGA.
this
You can invoke the memory advisors by performing the following steps:
1. Click the Server folder tab from the database home pages.
2. Click Memory Advisors under the Database Configuration. The Memory Advisors page is
displayed. This page provides a breakdown of memory usage for the SGA.
3. Click Advice next to the Total SGA Size field to invoke the advisor.
PGA
Server Private Cursor
PGA Session Work
process
SQL and SQL
memory area
areas area
Dedicated
connections
ble
Shared
PGA fe r a
server Shared pool
t r a ns
or PGA n-
Shared server large pool a no
a s
connections
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Program Global Area k i
(PGA)
a s yu ense
The Program M
y
Global Area
l ic (PGA) is a memory region that contains data and control information
le process. It is nonshared memory created by the Oracle server when a server process
for a server
tan Access to it is exclusive to that server process. The total PGA memory allocated by all
isSstarted.
server processes attached to an Oracle instance is also referred to as the aggregated PGA
memory allocated by the instance.
Part of the PGA can be located in the SGA when using shared servers.
PGA memory typically contains the following:
Private SQL Area
A private SQL area contains data such as bind information and run-time memory structures. This
information is specific to each session’s invocation of the SQL statement; bind variables hold
different values, and the state of the cursor is different, among other things. Each session that
issues a SQL statement has a private SQL area. Each user that submits the same SQL statement
has his or her own private SQL area that uses a single shared SQL area. Thus, many private SQL
areas can be associated with the same shared SQL area. The location of a private SQL area
depends on the type of connection established for a session. If a session is connected through a
dedicated server, private SQL areas are located in the server process’s PGA. However, if a
session is connected through a shared server, part of the private SQL area is kept in the SGA.
Work Area
For complex queries (for example, decision support queries), a big portion of the PGA is
dedicated to work areas allocated by memory-intensive operators, such as:
• Sort-based operators, such as ORDER BY, GROUP BY, ROLLUP, and window functions
• Hash-join
• Bitmap merge
• Bitmap create
• Write buffers used by bulk load operations
A sort operator uses a work area (the sort area) to perform the in-memory sort of a set of rows.
a b le
f
Similarly, a hash-join operator uses a work area (the hash area) to build a hash table from
s erits left
input. - t r an
The size of a work area can be controlled and tuned. Generally, bigger n onareas can
work
s
significantly improve the performance of a particular operator atathe
a higher memory
cost of
consumption. m ) h uideฺ
o
Session Memory a ilฺc ent G
Session memory is the memory allocatedi@ to hold S tud variables (logon information) and
gma session’s
other information related to the session.
y h is server, the session memory is shared and
uk For atshared
s
not private. Ma use
i ( e to
u k
a sy cens
yM li
n le
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Automatic PGA Memory k i
u Management
a s y e n se
By default, Oracle
y M Databaselic automatically and globally manages the total amount of memory
dedicated
a n leto the instance PGA. You can control this amount by setting the initialization
S t
parameter PGA_AGGREGATE_TARGET. Oracle Database then tries to ensure that the total
amount of PGA memory allocated across all database server processes and background
processes never exceeds this target.
If you create your database with DBCA, you can specify a value for the total instance PGA.
DBCA then sets the PGA_AGGREGATE_TARGET initialization parameters in the server
parameter file (SPFILE) that it creates. If you do not specify the total instance PGA, DBCA
chooses a reasonable default.
When running in automatic PGA memory management mode, sizing of work areas for all
sessions becomes automatic and the *_AREA_SIZE parameters (such as SORT_AREA_SIZE)
are ignored by all sessions running in that mode. At any given time, the total amount of PGA
memory available to active work areas in the instance is automatically derived from the
PGA_AGGREGATE_TARGET initialization parameter. This amount is set to the value of
PGA_AGGREGATE_TARGET minus the amount of PGA memory allocated by other
components of the system (for example, PGA memory allocated by sessions). The resulting
PGA memory is then assigned to individual active work areas on the basis of their specific
memory requirements.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Using the Memory Advisork i
u nstoeSize the PGA
s y
a can ebe used to get advice on the size of the PGA. To do this, click the
The Memory M Advisor l i c
y then click Advice. In this example, the graph shows that raising the Aggregate
l
PGA tab,
n eand
StaTarget from 80 MB to approximately 140 MB will raise the cache hit percentage from 60%
PGA
to close to 100%.
300 MB
Memory Target
250 MB
Memory Target
ble
ALTER SYSTEM SET fe r a
ans
MEMORY_TARGET=300M;
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
Automatic Memory Management:
u nse Overview
s y
a Managemente
Automatic Memory
y M l i c (AMM) allows the Oracle Database to manage SGA memory
a n le PGA memory sizing automatically. To do so (on most platforms), you set only a
and instance
t
target
S memory size initialization parameter (MEMORY_TARGET) and a maximum memory size
initialization parameter (MEMORY_MAX_TARGET), and the database dynamically exchanges
memory between the SGA and the instance PGA as needed to meet processing demands. With
this memory management method, the database also dynamically tunes the sizes of the
individual SGA components and the sizes of the individual PGAs.
Because the target memory initialization parameter is dynamic, you can change the target
memory size at any time without restarting the database. The maximum memory size serves as
an upper limit so that you cannot accidentally set the target memory size too high. Because
certain SGA components either cannot easily shrink or must remain at a minimum size, the
database also prevents you from setting the target memory size too low.
This indirect memory transfer relies on the operating system (OS) mechanism of freeing shared
memory. After memory is released to the OS, the other components can allocate memory by
requesting memory from the OS.
Currently, Automatic Memory Management is implemented on Linux, Solaris, HPUX, AIX, and
Windows.
MEMORY_MAX_TARGET
SGA_MAX_SIZE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2012, Oracle and/or its affiliatesฺ
MEMORY_TARGET
SGA_TARGET PGA_AGGREGATE_TARGET
SHARED_POOL_SIZE Others
DB_CACHE_SIZE
LARGE_POOL_SIZE
ble
JAVA_POOL_SIZE
fe r a
STREAMS_POOL_SIZE
ans
n - t r
DB_KEEP_CACHE_SIZE LOG_BUFFER
a no
DB_RECYCLE_CACHE_SIZE
a s
DB_nK_CACHE_SIZE ) h i d eฺ
m u
ฺco t G
RESULT_CACHE_MAX_SIZE
ail den
m
g Stu
i @ isAll rights reserved.
s y uk© 2009, Oracle.
Copyright
t h
( M a use
Oracle Database Memory u ki Sizing
e toParameters
y
asslidelishowss
en you the memory initialization parameters hierarchy. Although
The graphic inMthe c
you haveletoyset only MEMORY_TARGET to trigger Automatic Memory Management, you still
n
Stathe possibility to set lower bound values for various caches. Therefore, if the child
have
parameters are user set, they will be the minimum values below which the Oracle database
server will not autotune that component.
N
MT=0 MMT>0
Y
ST>0 & PAT>0 ST+PAT<=MT<=MMT
Y
MT can be N
Minimum possible values
MT=0 dynamically
changed later. Y
ST>0 & PAT=0 PAT=MT-ST
SGA. PGA is autotuned independent of whether it is explicitly set or not. However, the
whole SGA(SGA_TARGET) and the PGA (PGA_AGGREGATE_TARGET) are not
autotuned, that is, do not grow or shrink automatically. If neither SGA_TARGET nor
PGA_AGGREGATE_TARGET is set, you follow the same policy as you have today; PGA is
autotuned, SGA is not autotuned, and parameters for some of the subcomponents need to be
set explicitly (for SGA_TARGET).
• If only MEMORY_MAX_TARGET is set, MEMORY_TARGET defaults to 0 in a manual setup
using text initialization file. Autotuning defaults to 10g R2 behavior for SGA and PGA.
• If SGA_MAX_SIZE is not user set, it is set internally to MEMORY_MAX_TARGET if the e
user sets MEMORY_MAX_TARGET (independent of SGA_TARGET being user set). rab
l
s e
fand
In a text initialization parameter file, if you omit the line for MEMORY_MAX_TARGET
tra n
include a value for MEMORY_TARGET, the database automatically sets n -
MEMORY_MAX_TARGET to the value of MEMORY_TARGET. If you omit a nothe line for
MEMORY_TARGET and include a value for MEMORY_MAX_TARGET, h a s the ฺMEMORY_TARGET
parameter defaults to 0. After startup, you can dynamically m )
change u i de to a
ฺ c o t G MEMORY_TARGET
l ofeMEMORY_MAX_TARGET.
nonzero value, provided that it does not exceed the aivalue n
@ gm Stud
y u ki this
a s se
( M u
y u ki se to
M as licen
le y
n
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
Enabling Automaticu k
Memory to u
i (M eManagement with EM
s y n s
a liceMemory Management using Enterprise Manager (EM) as shown in
You can enableMAutomatic
l
the slide.
n ey
Stathe Database Home page, click the Server tab. On the Server page, click the Memory
From
Advisors link in the Database Configuration section. This takes you to the Memory Advisors
page. On this page, you can click the Enable button to enable Automatic Memory Management.
The value in the “Total Memory Size for Automatic Memory Management” text box is set by
default to current SGA + PGA size. You can set it to anything more than this but less than the
value in “Maximum Memory Size” box.
Note: On the Memory Advisors page, you can also specify the Maximum Memory Size. If you
change this field, you will be prompted to restart your database for your change to take effect.
ble
fe r a
2 ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Monitor Automatic Memory k i
u nsManagement
e
a s y e
After Automatic
y M Memory licManagement is enabled, you can see the graphical representation of
a n le of your memory size components in the Allocation History section of the Memory
the history
S t
Advisors page. The top portion in the first histogram is tunable PGA only and the lower portion
is all of SGA. The top portion in the second histogram is the shared pool size and the lower
portion corresponds to buffer cache.
On this page, you can also access the memory target advisor by clicking the Advice button. This
advisor gives you the possible DB time improvement for various total memory sizes.
Note: You can also look at the memory target advisor using the
V$MEMORY_TARGET_ADVISOR view.
• Tune for a high buffer cache hit ratio, with the following
caveats:
– Even valid and necessary full table scans lower it.
– It is possible that unnecessary repeated reads of the same
blocks are artificially raising it.
• Use the Memory Advisors.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
Efficient Memory Usage: k i
u Guidelines
a s y e n se
If possible, it M
y icthe SGA into physical memory, which provides the fastest access.
is best to lfit
a n le the operating system may provide additional virtual memory, that memory, by its
Even though
t
nature,
S can often be swapped out to disk. On some platforms, you can use the LOCK_SGA
initialization parameter to lock the SGA into physical memory. This parameter cannot be used in
conjunction with AMM or ASMM.
When a SQL statement executes, data blocks are requested for reading or writing, or both. This
is considered a logical I/O. As the block is requested, the block is checked to see whether it
already exists in memory. If it is not in memory, it is read from the disk, which is called a
physical I/O. The number of times the block is found already in memory compared to the total
number of logical I/Os is referred to as the buffer cache hit ratio. A higher ratio is usually better
because that means more blocks are being found in memory without incurring disk I/O.
It is not uncommon to have a buffer cache hit ratio above 99% but that does not always mean the
system is well tuned. If there is a query that is executed more often than necessary, and it
constantly requests the same blocks over and over again, the ratio is raised. If it is an inefficient
or unnecessary query, then it artificially inflates the ratio. This is because it should not execute
in that manner or that often in the first place.
Use Enterprise Manager Memory Advisors. They can help you size the SGA on the basis of the
activity in your particular database.
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Rather than having the same SQL statement issued from several different places in an
application, put the statement or statements into a stored procedure by using PL/SQL. Then just
call the procedure. This guarantees that the SQL statement is shared because it exists only in one
location. Also, the SQL is already parsed and has an explain plan because it is in an already
compiled stored procedure.
Sequence numbers can be cached. Therefore, if there are some sequences with high activity,
determine a good setting for the cache size and take advantage of it.
You can use the DBMS_SHARED_POOL package to pin objects in the library cache. This
reduces the chance of reloading and recompiling objects. Refer to the PL/SQL Packages andble
Types Reference document for more information about how to use that package. fera
s
- t r an
no n
s a
) h a eฺ
m i d
i l ฺ co nt Gu
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
n le
Sta
Summary
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ isAllSrights reserved.
sy se th
Copyright © 2009, Oracle.
a
(M to u
k i
a syu cense
yM li
nle
Sta
ble
fe r a
ans
n - t r
a no
a s
) h i d eฺ
m
co nt Gu
i l ฺ
g ma tude
u k i@ is S
a sy se th
k i (M to u
a syu cense
yM li
nle
Sta