Você está na página 1de 485

INDICE

Principais conceitos e ferramentas de banco de dados Oracle 2,21

Configurando para recuperabilidade 22,48

Usando o catlogo de recuperao do RMAN 49,77

Configuraes de Backup 78,94

Criando Backups com RMAN 95,119

Tarefas de recuperao e restaurao 120,140

Usando o RMAN para executar a recuperao 141,165

Monitoramento e ajuste de RMAN 166,188

Diagnosticando o banco de dados 189,218

Usando a tecnologia de Flashback I 219,246

Usando a tecnologia de Flashback II 247,266

Realizando o Flashback Database 267,279

Gerenciamento da Memria 280,303

Gerenciando o Desempenho do Banco de Dados 304,327

Gerenciando o desempenho SQL Tuning 328,349

Gerenciando recursos 350,375

Automatizando tarefas 376,405

Gerenciando a Capacidade de Armazenamento 406,442

Gerenciando Espao do Banco de Dados 443,462

Duplicao de um banco de dados 463,485


Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Principais conceitos e ferramentas de banco
de dados Oracle

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Aps concluir esta lio, voc deve ser capaz de:


Descrever os principais conceitos da arquitetura de banco
de dados Oracle com Automatic Storage Management
(ASM)
Use ferramentas de configurao e gerenciamento de
DBA
Descrever o ambiente de curso tcnico

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Nomeando os principais componentes de um
servidor de banco de dados Oracle
Instance
PGA
Server
process Memory Structures
(System Global Area)

Server
Connection Process Structures

User
process

Client Database (Storage Structures)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Viso geral da arquitetura de servidor de banco
de dados Oracle
Instance
PGA
Server
process Memory structures
(System Global Area)

Server
Connection Process structures

User
process

Session Client Database (storage structures)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Configuraes de banco de dados instncia

Nonclustered system Clustered system

I1
I1 I2 I3
I2

D1

D2

Local
storage D

Shared storage

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Nomeando as estruturas de memria do banco de
dados Oracle
Program Global Area (PGA) Assign these names:
KEEP Server User
buffer process Global
pool
Recycle Area
buffer Shared
pool pool
nK buffer Redo log
cache
Large pool buffer

Database
buffer Java
cache pool

Stack

Streams Space
pool
System Global Area (SGA)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Estruturas de memria Oracle banco de dados

Program Global Area (PGA) PGA


Stack User Stack User
Space Global Space Global
Area Area
Server Server
process 1 process 2

KEEP
Database buffer pool
Redo log
Shared pool buffer
buffer
cache Recycle
buffer pool

Java pool Streams nK buffer


Large pool pool cache

System Global Area (SGA)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Arquitetura de processo

Processo do usurio
o aplicativo ou ferramenta que se conecta ao banco de
dados Oracle
Processos de banco de dados
Processo de servidor: conecta instncia Oracle e iniciado
quando um usurio estabelece uma sesso
Processos de fundo: so iniciados quando uma instncia
Oracle iniciada
Processos daemon/aplicativo
Listeners de Rede
Daemons de infra-estrutura de grade

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Estruturas de processo

Instances (ASM and Database separate)

System Global Area (SGA)


PGA
Server Background processes
process Required: DBWn CKPT LGWR SMON PMON RECO

Optional: ARCn ASMB RBAL Others


Listener

Grid Infrastructure Processes


(ASM and Oracle Restart)
User ohasd ocssd diskmon
process
orarootagent oraagent cssdagent

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Adicionando nomes de processo

1. The ______process writes the dirty A. Checkpoint process


buffers to the data files. (CKPT)
2. The ______process writes the redo B. System monitor
entries to the online redo log files. process (SMON)
3. The ______process writes checkpoint C. Recoverer process
information in the control file and each (RECO)
data file header.
D. Log writer process
4. The ______process performs recovery (LGWR)
on instance startup.
E. Archiver processes
5. The ______process performs process (ARCn)
recovery when a user process fails.
F. Process monitor
6. The ______process resolves in-doubt
process (PMON)
distributed transactions.
7. The ______processes copy redo log G. Database writer
files to a designated storage device. process (DBWn)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sequncia de inicializao de processo

Oracle Grid Infrastructure is started by the OS init daemon.

Operating System Grid Infrastructure Grid Infrastructure


Init Daemon Wrapper Script Daemons and Processes
init ohasd.bin
init.ohasd oraagent.bin ASM instance
(root) Listener
orarootagent.bin
DB instance
diskmon.bin User-defined
cssdagent applications
ocssd.bin

Oracle Grid Infrastructure installation modifies the


/etc/inittab file to ensure startup every time the
machine is started in the corresponding run level.
# cat /etc/inittab
..
h1:35:respawn:/etc/init.d/init.ohasd run >/dev/null 2>&1 </dev/null

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Arquitetura de armazenamento de banco de
dados

Control files Data files Online redo log files

Parameter file Backup files Archived redo log


files

Password file Alert log and trace files

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Estruturas de banco de dados lgico e fsico

Logical Physical

Database

Tablespace Data file

Segment
Storage system
SAN NFS
Extent
NAS ASM
Exadata RAW
Oracle data
block File system

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Automatic Storage Management

Is a portable and high-performance


cluster file system
Oracle
Manages Oracle database files Application Database
Manages application files with
ASM Cluster File System (ACFS) ASM
Spreads data across disks Cluster File ASM
System Files for
to balance load
Oracle
ASM Dynamic
Mirrors data in case of failures Volume
Database

Solves storage-management Manager


challenges Automatic Storage Management

Operating system

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
ASM Storage Components

ASM

Oracle
ASM
Database ASM file
disk group
Data file

ASM
extent

File system
or ASM allocation
Raw device ASM disk
Unit

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
ASM Instance

The ASM Instance is the process and memory components for


ASM.
System Global Area (SGA) memory

Shared Large ASM Free


pool pool cache memory

Processes CPU components


RBAL ARBn GMON Onnn PZ9n

MARK
Other misc. processes

ASM instance

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
DBA Configuration Tools

Setting up the technical environment for this course included


the following tasks and tools:
Installing and configuring the Oracle Grid Infrastructure for
a stand-alone server with the OUI, including:
Configuring a listener
Creating an ASM instance (+ASM) and configuring the +DATA
disk group
Configuring Oracle Restart
Creating and configuring additional ASM disk groups (such
as +FRA) with asmca
Installing the Oracle Database 11g software with OUI
Creating the orcl Oracle database with dbca
Note: These tasks have already been performed for you.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Management Framework and Related DBA Tools

The Oracle database Related tools and commands include:


management framework SQL*Plus:
includes:
Database instance SQL> startup
SQL> shutdown immediate
Listener
Management interface: Listener Control utility:
Management agent $ lsnrctl status
(when using Grid Control)
Database Control Enterprise Manager Control utility:
$ emctl status dbconsole
$ emctl start dbconsole
$ emctl stop dbconsole

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Facilitating Database Management with
Oracle Restart
Restarting Oracle components when the host computer
restarts or after hardware or software failure
Monitoring components and restarting them, if needed
For single-instance environments
Considering component dependencies:
Mounting disk groups and starting the ASM instance before
starting the database instance
Soft dependency between the database instance and the
listener
Starting Oracle Restart with the crsctl utility
Managing Oracle Restart components with the srvctl
utility
$ srvctl stop database d orcl o abort

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Descrever os principais conceitos da arquitetura de banco
de dados Oracle com ASM
Determinar quais ferramentas de configurao e
gerenciamento de DBA usar para qual tarefa
Descrever o ambiente de curso tcnico

orcl +asm

DATA
FRA
Enterprise Manager
Command line

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Configurando para recuperabilidade

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Aps concluir esta lio, voc deve ser capaz de:


Invocar e configurar o Recovery Manager (RMAN)
Configurar seu banco de dados em ARCHIVELOG mode
Configurar vrios destinos do arquivo do log de arquivo
para aumentar a disponibilidade
Configurar a rea de recuperao rpida (FRA)
Especificar uma poltica de reteno

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Purpose of Backup and Recovery Functionality

Backup and recovery functionality is needed for the following:


Data protection
Media failure
User errors
Application errors
Data preservation and historical retention
Data transfer

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Typical Backup and Recovery Tasks

To be able to recover from data loss problems with minimal


down time:
Configure the database for recoverability
Define a backup schedule
Plan and test different types of failure scenarios
Monitor, tune, and troubleshoot the backup and recovery
environment
Restore data from backups
Recover transactions to a desired point in time

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Oracle Backup and Recovery Solutions

For a recoverable system:


RMAN
Block media recovery
Unused block compression
Binary compression
Backup encryption
Solutions achieved via backup types:
All data blocks within your chosen files
(full or incremental level 0)
Only information that has changed since a previous backup
(incremental)
Cumulative (changes up to last level 0)
Differential (changes up to last incremental)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Oracle Backup Solutions

OS RMAN OSB
Back up as
backup set

Data file 2 Backup


piece
(filesperset 3)
Backup
image

Data file 3
Backup
piece

Backup
image
Data file 4

Backup set

File-system Backup
file image

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Terminology Review

Match the following terms and descriptions:


1. ___ backs up a portion of the database. The control file
may or may not be included.
2. ___ is a consistent backup because the SCN in data file
headers matches the SCN in the control files.
3. ___ backs up each data block that contains data and that
is within the files being backed up.
4. ___ is an inconsistent backup because there is no
guarantee that the data files are synchronized with the
control files.
5. ___ includes all data files and at least one control file.
(W) Whole database backup (F) Full backup (C) Cold or offline
backup (P) Partial database backup (O) Online backup

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Terminology Review

Which description fits best the following backup types:


1. Image copies
2. Backup sets
Description:
A) They are collections of one or more binary files that
contain one or more data files, control files, server
parameter files, or archived log files. Empty data blocks
and currently unused blocks are not stored.
B) They are duplicates of data or archived log files (similar to
a file copy).

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
What You Already Know:
Oracle-Suggested Backup

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using Recovery Manager

$ rman target /

RMAN> BACKUP DATABASE;


Starting backup at 10-JUN-07
.
.
RMAN> LIST BACKUP;
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ------- ----------- ------------ ---------------
1 Full 1.06G DISK 00:01:49 10-JUN-07
.
.
RMAN> DELETE OBSOLETE;
.
.
Do you really want to delete the above objects (enter YES or NO)? YES
deleted archived log
.
.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Types of RMAN Commands

RMAN commands are of the following types:


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
job command.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Job Commands: Example

Job commands appear inside a RUN command block:

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> }

Execution of the entire block starts


when this line is entered.

Deallocated after the


RUN block completes

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Configuring Your Database for Backup and
Recovery Operations
Operate the database in ARCHIVELOG mode.

Archiver
(ARCn)
Online redo Archived
log files redo log files

Configure the FRA.

Archived Control file Data file backups


redo log files backups

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
ARCHIVELOG Mode

Archiver
(ARCn)
Online redo Archived
log files redo log files

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Configuring ARCHIVELOG Mode

To place the database in ARCHIVELOG mode, perform the


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.
Using SQL commands
Mount the database.
Issue the ALTER DATABASE ARCHIVELOG command.
Open the database.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Configuring Archive Log Destinations

Best practice tip: Create multiple destinations. If you had only


one and it would fill up, the database would stop.

Local and remote


destinations:
Online redo
Archived
log files LOG_ARCHIVE_DEST_n redo log files
Archived
redo log files

Local-only destinations:

Online redo
LOG_ARCHIVE_DEST
log files LOG_ARCHIVE_DUPLEX_DEST
Archived
redo log files

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Guaranteeing Archive Log Success

1 3
Online redo
log files Standby1

LOG_ARCHIVE_MIN_SUCCEED_DEST = 2

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Specifying a Retention Policy

Retention policy: Describes which backups will be kept and


for how long
Two types of retention policies:
Recovery window: Establishes a period of time within which
point-in-time recovery must be possible

Backup Recovery
window SYSDATE
Redundancy: Establishes a fixed number of backups that
must be kept

Backup 1 Backup 2
SYSDATE
Retention policies are mutually exclusive.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
A Recovery Window
Retention Policy: Example

Log 100 Log 200 Log 300 Log 400 Log 500
Backup A Backup B Backup C

Now

Backup Obsolete Recovery window of 7 days

Backup Not obsolete

Backup B and archive logs 201 through 500 are required to


satisfy this retention policy.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using a Fast Recovery Area

Permanent items:
Multiplexed copies of the
current control file
Multiplexed copies of online redo logs
Transient items: Database
Archived redo logs
Data file copies
Control file copies
Control file autobackups
Backup pieces
Flashback logs

Fast Recovery Area

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Defining a Fast Recovery Area

The FRA is defined by setting two, dynamic initialization


parameters:
DB_RECOVERY_FILE_DEST_SIZE: Sets the disk limit
DB_RECOVERY_FILE_DEST: Sets the location for the FRA

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Fast Recovery Area Space Management

Space limit is
reached and a
Fast new file needs Files that are
Database file Recovery to be written no longer
backup Area into the Fast required on
1 Recovery Area. disk are
deleted.
2
3 Space pressure
4 occurs.

Warning issued
to user
RMAN updates 1
the list of files that 2
may be deleted. Backup files
to be deleted

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Fast Recovery Area Space Usage

Configure the retention policy to the minimum value


appropriate for your database.
Back up the archive log files regularly and delete the files
upon completion of the backup.
Optionally, configure an archive redo log deletion policy.
Use the RMAN REPORT OBSOLETE and DELETE
OBSOLETE commands to remove backups and file copies
that are not required.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
What Is Done Automatically for You

Simplified archive log management in a multiple-


component environment
Increased availability by failover of backup to optional
destinations

Target
Data files database Image copies

Backup pieces
Archive X
log files
Redundant Backup data
archive log
files Fast Recovery Area

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring the FRA

...

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Benefits of Using a Fast Recovery Area

Using the Fast Recovery Area for recovery-related files:


Simplifies the location of database backups
Automatically manages the disk space allocated for
recovery files

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Invocar e configurar RMAN
Configurar seu banco de dados em ARCHIVELOG mode
Configurar vrios destinos do arquivo do log de arquivo
para aumentar a disponibilidade
Configurar a rea de recuperao rpida
Especificar uma poltica de reteno
Descrever os benefcios de usar a rea de recuperao
rpida

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Usando o catlogo de recuperao do RMAN

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Aps concluir esta lio, voc deve ser capaz de:


Contraste com o uso de um catlogo de recuperao com
o do arquivo de controle para o repositrio do RMAN
Criar e configurar um catlogo de recuperao
Registrar um banco de dados do catlogo de recuperao
Sincronizar o catlogo de recuperao
Usar scripts RMAN armazenado
Fazer backup do catlogo de recuperao
Criar um catlogo virtual privado

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
RMAN Repository Data Storage:
Comparison of Options
Control file: Recovery catalog:
Simpler administration Replicates control file data
Default Stores longer history of
backups
Services many targets
Stores RMAN scripts

Metadata
Backup set list
Image copy list
.
.
.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Storing Information in the Recovery Catalog

Recovery
Manager
(RMAN)

Database structure
Archived redo logs
Target database Backup sets Recovery catalog
control file Data file copies database

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Reasons to Use a Recovery Catalog

Stores more historical information than the control file


Enables you to use RMAN stored scripts
Enables you to create customized reports for all registered
targets
Enables you to use the KEEP FOREVER clause of the
BACKUP command
Allows you to list the data files and tablespaces that are or
were in the target database at a given time

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating the Recovery Catalog: Three Steps

Configure the Create the


Create the
recovery catalog recovery catalog
recovery catalog.
database. owner.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Configuring the Recovery Catalog Database

Allocate space for the recovery catalog. Consider:


Number of databases supported by the recovery catalog
Number of archived redo log files and backups recorded
Use of RMAN stored scripts
Create a tablespace for the recovery catalog, which
becomes the default tablespace for the recovery catalog
owner.

SQL> CREATE TABLESPACE rcat_ts DATAFILE SIZE 15M;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating the Recovery Catalog Owner

Create the recovery catalog owner.


Grant the RECOVERY_CATALOG_OWNER role.

SQL> CREATE USER rcowner IDENTIFIED BY rcpass


2 TEMPORARY TABLESPACE temp
3 DEFAULT TABLESPACE rcat_ts
4 QUOTA UNLIMITED ON rcat_ts;
SQL> GRANT recovery_catalog_owner TO rcowner;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating the Recovery Catalog

Connect to the recovery catalog database as the catalog


owner:
$ rman
RMAN> CONNECT CATALOG username/password@net_service_name

Execute the CREATE CATALOG command:

RMAN> CREATE CATALOG;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Managing Target Database Records in the
Recovery Catalog
Registering a target database in the recovery catalog
Cataloging additional backup files
Unregistering a target database from the recovery catalog

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Registering a Database in the Recovery Catalog

RMAN performs the following actions:


Creates rows in the recovery catalog tables for the target
database
Copies data from the target database control file to the
recovery catalog tables
Synchronizes the recovery catalog with the control file

$ rman TARGET / CATALOG


username/password@net_service_name
RMAN> REGISTER DATABASE;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using Enterprise Manager to Register a Database

To register a database with a recovery catalog, perform the


following steps in Enterprise Manager (EM):
1. Run EM against the target database and navigate to the
Recovery Catalog Settings page.
2. Add the recovery catalog to the configuration, if not already
listed there.
3. Specify that the target database is to use the recovery
catalog chosen in the list.

The EM method of registration also causes EM to


use the recovery catalog for backup and
recoveryrelated operations.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Unregistering a Target Database from the
Recovery Catalog
This removes information about the target database from
the recovery catalog.
Use this when you no longer want the target database to
be defined in the recovery catalog.

$ rman TARGET / CATALOG


username/password@net_service_name
RMAN> UNREGISTER DATABASE;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Cataloging Additional Backup Files

CATALOG can be used to catalog existing backup files that


are no longer listed in the control file.
This enables RMAN to use the files during a restore
operation.
Use the CATALOG command to add the following types of
backup files to the recovery catalog:
Control file copies
Data file copies
Backup pieces
Archived redo log files

RMAN> CATALOG BACKUPPIECE 'file_name';

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recovery Catalog Resynchronization: Concepts

Partial: Archived redo logs


Backup sets
Data file copies

Target database Recovery catalog


control file

Full: Partial + database structure


Control file
snapshot

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Manually Resynchronizing the Recovery Catalog

Manually resynchronize the recovery catalog in the following


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

RMAN> RESYNC CATALOG;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using RMAN Stored Scripts

Stored scripts are:


An alternative to command files
Available to any RMAN client that can connect to the target
database and recovery catalog
Of two types: CREATE SCRIPT script_name
Local: Associated with the { <RMAN commands>}
target database to which RMAN is connected when the script
is created CREATE GLOBAL SCRIPT script_name
Global: Can be executed { <RMAN commands> }
against any database registered in the recovery catalog
Created from a text file (additional option)
CREATE [GLOBAL] SCRIPT script_name FROM FILE 'file_name';

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Executing RMAN Stored Scripts

Executing a script:

RUN { EXECUTE SCRIPT


script_name
; }

Executing a global script:


RUN { EXECUTE GLOBAL SCRIPT
script_name
; }

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Maintaining RMAN Stored Scripts

Displaying a script:
PRINT [GLOBAL] SCRIPT script_name;
Sending the contents of a script to a file:
PRINT [GLOBAL] SCRIPT script_name TO FILE 'file_name';
Displaying the names of defined scripts:
LIST [GLOBAL] SCRIPT NAMES;
Displaying a script:
REPLACE [GLOBAL] SCRIPT script_name
{ <RMAN commands> ; }
Updating a script from a file:
REPLACE [GLOBAL] SCRIPT script_name FROM FILE
'file_name';
Deleting a script:
DELETE SCRIPT script_name;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Backing Up the Recovery Catalog

Recovery
Manager
(RMAN)

Recovery catalog

Recovery catalog
control file

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Re-Creating an Unrecoverable Recovery Catalog

To partially re-create the contents of a lost recovery catalog,


use the following commands:
RESYNC CATALOG command: Updates the recovery
catalog with any RMAN repository information from the
control file of the target database or a control file copy
CATALOG START WITH command: Recatalogs any
available backups

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Exporting and Importing the Recovery Catalog

Use the Export and Import utilities or the Data Pump utilities to:
Move the recovery catalog from one database to another
Create a logical backup of the RMAN recovery catalog

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Upgrading and Dropping the Recovery Catalog

To upgrade the recovery catalog to the version required by the


RMAN client, use the UPGRADE CATALOG command:
UPGRADE CATALOG;

To drop the recovery catalog schema, use the DROP CATALOG


command:
DROP CATALOG;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
IMPORT CATALOG Command

1. Connecting to the destination recovery catalog:


CONNECT CATALOG cat111/oracle@destdb;

2. Importing metadata for all registered databases:


IMPORT CATALOG cat102/oracle@srcdb;

3. Importing metadata for two registered databases:


IMPORT CATALOG cat92/oracle@catdb DBID=1423241, 1423242;

4. Importing metadata from multiple catalogs:


Must be equal to the
IMPORT CATALOG cat102/rman@srcdb; current version of the
RMAN executable
IMPORT CATALOG cat101/rman@srcdb;
IMPORT CATALOG cat92/rman@srcdb NO UNREGISTER;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating and Using Virtual Private Catalogs

Databases registered in RMAN catalog

RMAN Enhancing security


base by restricting access
catalog to metadata

Virtual private catalogs (VPC)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using RMAN Virtual Private Catalogs

1. Create an RMAN base catalog:


RMAN> CONNECT CATALOG catowner/oracle@catdb
RMAN> CREATE CATALOG;

2. Grant RECOVERY_CATALOG_OWNER to VPC owner:


SQL> CONNECT SYS/oracle@catdb AS SYSDBA
SQL> GRANT RECOVERY_CATALOG_OWNER to vpcowner;

3a. Grant REGISTER to the VPC owner:


RMAN> CONNECT CATALOG catowner/oracle@catdb
RMAN> GRANT REGISTER DATABASE TO vpcowner;

3b. Or, grant CATALOG FOR DATABASE to the VPC owner:


RMAN>GRANT CATALOG FOR DATABASE db10g TO vpcowner;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using RMAN Virtual Private Catalogs

4a. Create a virtual catalog for 11g clients:


RMAN> CONNECT CATALOG vpcowner/oracle@catdb
RMAN> CREATE VIRTUAL CATALOG;

4b. Or, create a virtual catalog for pre-11g clients:


SQL> CONNECT vpcowner/oracle@catdb
SQL> exec catowner.dbms_rcvcat.create_virtual_catalog;

5. Register a new database in the catalog:


RMAN> CONNECT TARGET / CATALOG vpcowner/oracle@catdb
RMAN> REGISTER DATABASE;

6. Use the virtual catalog:


RMAN> CONNECT TARGET / CATALOG vpcowner/oracle@catdb;
RMAN> BACKUP DATABASE;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recovery Catalogs Summary

Managing recovery catalogs:


1. Create the recovery catalog.
2. Register your target databases in the recovery catalog.
3. If desired, merge recovery catalogs using the new IMPORT
CATALOG command.
4. If needed, catalog any older backups.
5. If needed, create new virtual recovery catalogs for specific
users.
6. Protect the recovery catalog.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Contraste com o uso de um catlogo de recuperao com
o do arquivo de controle para o repositrio do RMAN
Criar e configurar um catlogo de recuperao
Registrar um banco de dados do catlogo de recuperao
Sincronizar o catlogo de recuperao
Usar scripts RMAN armazenado
Fazer backup do catlogo de recuperao
Criar um catlogo virtual privado

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Configuraes de Backup

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Aps concluir esta lio, voc deve ser capaz de:


Use o Enterprise Manager para configurar configuraes
de backup
Permitir cpia automtica de arquivo de controle
Configurar destinos de backup
Alocar canais para destino de fita
Configurar a otimizao de backup
Criar um backup compactado
Criar um backup criptografado

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Configuring Persistent Settings for RMAN

RMAN is preset with default configuration settings.


Use the CONFIGURE command to:
Configure automatic channels
Specify the backup retention policy
Specify the number of backup copies to be created
Set the default backup type to BACKUPSET or COPY
Limit the size of backup pieces
Exempt a tablespace from backup
Enable and disable backup optimization
Configure automatic backups of control files
Define the archivelog deletion policy
Specify the parallelism for a device
Set the encryption and compression parameters to be used
for backups

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Viewing Persistent Settings

To examine the persistent RMAN settings for a database:


Connected only to the target, you enter SHOW ALL at the
RMAN prompt.
Or:
Logged in to the target database instance, you query the
V$RMAN_CONFIGURATION view.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Control File Autobackups

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

Best Practice Tip: Oracle recommends that you enable


control file autobackup.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Managing Persistent Settings

Use multiple streams of data to and from a device:


RMAN> CONFIGURE DEVICE TYPE sbt PARALLELISM 3;
Use the SHOW command to list current settings:
RMAN> SHOW CONTROLFILE AUTOBACKUP FORMAT;
RMAN> SHOW EXCLUDE;
RMAN> SHOW ALL;

Use the CLEAR option of the CONFIGURE command to


reset any persistent setting to its default value:
RMAN> CONFIGURE BACKUP OPTIMIZATION CLEAR;
RMAN> CONFIGURE MAXSETSIZE CLEAR;
RMAN> CONFIGURE DEFAULT DEVICE TYPE CLEAR;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using a Media Manager

Server
Recovery session
Manager (channel)

Media
Management
Library
Oracle Secure Or
Backup with
built-in MML Media
management
server software

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Specifying a Backup Destination

Backups can be written to:


Disk directory
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO DISK;

Tape, using Oracle Secure Backup


Media Management Library
Tape
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO TAPE;
Disk or tape, using proxy copy
Fast Recovery Area: Disk area set aside for backup and
recovery and flashback database purposes
Define the location and the size.
Files are automatically retained and deleted as necessary.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Configuring and Allocating Channels

Configure automatic channels with the CONFIGURE


command:
RMAN> CONFIGURE DEVICE TYPE sbt;
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO sbt;
RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt ...
RMAN> BACKUP DATABASE;

Allocate channels manually with the ALLOCATE CHANNEL


command within a RUN block:
RMAN> RUN
{
ALLOCATE CHANNEL ch1 DEVICE TYPE DISK;
BACKUP DATABASE PLUS ARCHIVELOG;
}

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Duplexed Backup Sets

To create a duplexed backup set, use:


CONFIGURE ... BACKUP COPIES
BACKUP...COPIES

Data file Data file


1 1 Data file
1
Data file
Data file 2 Data file
2 2
Data file
Data file 3 Data file
3 3
Backup set
Tablespace Backup set
copy 1
HR_DATA copy 2

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Duplexed Backup Sets Using
CONFIGURE BACKUP COPIES

Two copies of the


backup are made to
two different tapes.

RMAN> CONFIGURE ARCHIVELOG BACKUP COPIES


2> FOR DEVICE TYPE sbt TO 2;
RMAN> CONFIGURE DATAFILE BACKUP COPIES
2> FOR DEVICE TYPE sbt TO 2;
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
RMAN> BACKUP DEVICE TYPE DISK AS COPY DATABASE;

Not affected by the


COPIES configuration
setting. Only one
copy is made on disk.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Backup Optimization

Skips already backed-up files


Is used when:
Backup optimization is enabled
RMAN> CONFIGURE BACKUP OPTIMIZATION ON;
BACKUP DATABASE, BACKUP ARCHIVELOG with ALL or
LIKE options, or BACKUP BACKUPSET ALL commands are
executed
Only one type of channel is allocated
Can be overridden with the FORCE option
RMAN> BACKUP DEVICE TYPE sbt BACKUPSET ALL FORCE;
Is always used for RECOVERY AREA,
DB_RECOVERY_FILE_DEST, and RECOVERY FILES
backup options

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Saving Backup Space with
Unused Block Compression
The following blocks may be
skipped during certain types of
Unallocated
backup operations:
Unallocated blocks: These are HWM
above the data files high-
water mark (HWM).
Unused
Unused blocks: These are
blocks that have been
allocated but no longer belong Allocated
to a segment.
Data file

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Compressing Backups

RMAN can perform binary compression on any backup set that


is generated.
It can be performed in addition to unused block
compression.
Available compression algorithms are: HIGH, MEDIUM,
LOW, and BASIC.
No extra steps are required by the DBA to restore a
compressed backup.
CONFIGURE COMPRESSION ALGORITHM 'HIGH/MEDIUM/LOW/BASIC'

run {
SET COMPRESSION ALGORITHM 'HIGH/MEDIUM/LOW/BASIC';
..
}

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using RMAN Backup Compression

Compression Considerations Requires Advanced


Ratio or Level Compression Option
LOW Fastest. Best suited to address
backup: CPU resources

MEDIUM Fast. Good balance of CPU


usage and compression ratio

HIGH Best compression ratio at the


expense of high CPU
consumption. Best suited to
address backup constraint:
network.

BASIC Fair. Compression ratio similar to


MEDIUM at expense of
additional CPU usage.
Compression ratio between
MEDIUM and HIGH

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Encrypting Backups

Transparent encryption: With a wallet (default)


Password encryption: With a password (no wallet)
Dual mode encryption:
Has both transparent and password encryption modes
Can be restored in either transparent or password mode

Password: **********

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Use o Enterprise Manager para configurar configuraes
de backup
Permitir cpia automtica de arquivo de controle
Configurar destinos de backup
Alocar canais para destino de fita
Configurar a otimizao de backup
Criar um backup compactado
Criar um backup criptografado

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Criando Backups com RMAN

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Aps concluir esta lio, voc deve ser capaz de:


Criar imagem de backups de arquivos
Criar um backup de banco de dados inteiro
Criar um backup completo do banco de dados
Ativar backup incremental rpido
Criar conjuntos de backup duplex
Fazer backup de um conjunto de backup
Criar backup do RMAN multi-seo
Criar um backup arquivamento para reteno de longo
prazo
Relatrio sobre backups

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Backup Sets

RMAN> BACKUP AS BACKUPSET


2> FORMAT '/BACKUP/df_%d_%s_%p.bus'
3> TABLESPACE hr_data;

Data file Data file


1 1

Data file Data file


2 2

Data file Data file


3 3
Tablespace Backup
HR_DATA set

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Image Copies

RMAN> BACKUP AS COPY DATAFILE '/ORADATA/users_01_db01.dbf';


RMAN> BACKUP AS COPY ARCHIVELOG LIKE '/arch%';

Copy of data file 3


Data file 3 Data file 3

Copy of archived log


Archived Archived
log file log file

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating a Whole Database Backup

RMAN> BACKUP DATABASE


PLUS ARCHIVELOG;

Control
Archived log Data file file SPFILE
file copies copies

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
RMAN Backup Types

A full backup contains all used Full, or "level 0


incremental backup"
data file blocks.
A level 0 incremental backup is
equivalent to a full backup that
has been marked as level 0.
Cumulative
A cumulative level 1 incremental backup
incremental backup contains
only blocks modified since the
last level 0 incremental
backup.
Differential
A differential level 1 incremental backup
incremental backup contains
only blocks modified since the
last incremental backup.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Fast Incremental Backup

Implemented by block change tracking, which:


Maintains a record of what blocks have changed since the
last backup
Writes this record to a file, as redo is generated
Is automatically accessed when a backup is done, making
the backup run faster

List of changed
1011001010110 Change
blocks
CTWR 0001110100101 tracking
Redo 1010101110011 file
generation
SGA Redo log

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Enabling Fast Incremental Backup

ALTER DATABASE
{ENABLE|DISABLE} BLOCK CHANGE TRACKING
[USING FILE '...']

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring Block Change Tracking

SQL> SELECT filename, status, bytes


2 FROM v$block_change_tracking;
SQL> SELECT file#, avg(datafile_blocks),
2 avg(blocks_read),
3 avg(blocks_read/datafile_blocks)
4 * 100 AS PCT_READ_FOR_BACKUP,
5 avg(blocks)
5 FROM v$backup_datafile
6 WHERE used_change_tracking = 'YES'
7 AND incremental_level > 0
8 GROUP BY file#;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performing Proxy Copies

Server
Recovery session
Manager (channel)

Media
Management
Library

Media
management
server software

Storage Area Network (SAN)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Duplexed Backup Sets Using
BACKUP COPIES

RMAN> BACKUP AS BACKUPSET DEVICE TYPE sbt


2> COPIES 2
3> INCREMENTAL LEVEL 0
4> DATABASE;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Backups of Backup Sets

RMAN> BACKUP DEVICE TYPE DISK AS BACKUPSET


2> DATABASE PLUS ARCHIVELOG;
RMAN> BACKUP DEVICE TYPE sbt BACKUPSET ALL;

Data file Data file


1 1
Data file
Data file 2
2 Data file
3
Data file
3 Archived
redo logs
Archived
redo logs
Backup sets

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Backing Up Read-Only Tablespaces

Considerations for backing up read-only tablespaces:


Backup optimization causes RMAN to back up read-only
tablespaces only when there does not exist a backup that
satisfies the retention policy.
If you change the tablespace to read/write, back it up
immediately.
You can use the SKIP READONLY option of the RMAN
BACKUP command to skip read-only tablespaces or data
files.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Configuring Backup and Restore for Very Large
Files
Multisection backups of a single file:
Are created by RMAN, with your specified size value
Are processed independently (serially or in parallel)
Produce multipiece backup sets
Improve performance of the backup
Channel 1
Section 1

Channel 2
Section 2

Channel 3
Section 3

Channel 4
Section 4
One large data file Multipiece backup set

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating RMAN Multisection Backups

RMAN command syntax:

BACKUP <options> SECTION SIZE <integer> [K | M | G]

VALIDATE DATAFILE <options> SECTION SIZE <integer> [K | M | G]

Example:
RMAN> BACKUP DATAFILE 5 SECTION SIZE = 25M TAG 'section25mb';
backing up blocks 1 through 3200
piece handle=/u01/.../o1_mf_nnndf_SECTION25MB_382dryt4_.bkp
tag=SECTION25MB comment=NONE
...
backing up blocks 9601 through 12800
piece handle=/u01/.../o1_mf_nnndf_SECTION25MB_382dsto8_.bkp
tag=SECTION25MB comment=NONE

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Archival Backups: Concepts

Archival backup
Log 250 Log 900

Backup A Backup B Backup S

Now

End of Q1 Recovery window of 7 days

Log nnn and Backup Not needed for retention policy

Backup Needed for retention policy

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Archival Backups with EM

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Archival Backups with RMAN

Specifying the KEEP clause when the database is online


includes both data file and archive log backup sets:
KEEP {FOREVER | UNTIL TIME [=] ' date_string '}
NOKEEP
[RESTORE POINT rsname]

List all restore points known to the RMAN repository:


LIST RESTORE POINT ALL;

Display a specific restore point:


LIST RESTORE POINT 'rsname';

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Managing Archival Database Backups

1 Archiving a database backup:


RMAN> CONNECT TARGET /
RMAN> CONNECT CATALOG rman/rman@catdb
RMAN> CHANGE BACKUP TAG 'consistent_db_bkup'
2> KEEP FOREVER;

2 Changing the status of a database copy:


RMAN> CHANGE COPY OF DATABASE CONTROLFILE NOKEEP;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Backing Up Recovery Files

Back up only the files in the Fast Recovery Area:


RMAN> BACKUP RECOVERY AREA

Back up all recovery files:


RMAN> BACKUP RECOVERY FILES

Fast Recovery Area

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Managing Backups: Reporting

Use the following RMAN commands to obtain information about


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
needed to satisfy backup retention policies

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Managing Backups: Dynamic Performance Views

Query the following dynamic performance views in the target


database to obtain information about your backups:
V$BACKUP_SET: Backup sets created
V$BACKUP_PIECE: Backup pieces that exist
V$DATAFILE_COPY: Copies of data files on disk
V$BACKUP_FILES: Information about all files created
when creating backups

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using Enterprise Manager to View
Backup Reports

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Managing Backups: Cross-Checking and Deleting

Use the following RMAN commands to manage your backups:


CROSSCHECK: Verifies the status of backups and copies
recorded in the RMAN repository against media such as
disk or tape
DELETE EXPIRED: Removes only files whose status in the
repository is EXPIRED
DELETE OBSOLETE: Deletes backups that are no longer
needed

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Criar imagem de backups de arquivos
Criar um backup de banco de dados inteiro
Criar um backup completo do banco de dados
Ativar backup incremental rpido
Criar conjuntos de backup duplex
Fazer backup de um conjunto de backup
Criar backup do RMAN multi-seo
Criar um backup arquivamento para reteno de longo
prazo
Relatrio sobre e manter backups

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Tarefas de recuperao e restaurao

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Aps concluir esta lio, voc deve ser capaz de:


Descrever as causas da perda de arquivo e determinar a
ao apropriada
Descrever as operaes principais da recuperao
Fazer backup e recuperar um arquivo de controle
Recuperar-se de um grupo de log redo perdido

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Restoring and Recovering

Restore

Redo log

Recover

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Causes of File Loss

File loss can be caused by:


User error
Application error
Media failure

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Critical Versus Noncritical

A noncritical file loss is one where the database can continue to


function.

You fix the problem by taking one of these actions:


Create a new file.
Rebuild the file.
Recover the lost or damaged file.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Automatic Tempfile Recovery

SQL statements that require temporary space to execute may


fail if one of the tempfiles is missing.
SQL> select * from big_table order by
1,2,3,4,5,6,7,8,9,10,11,12,13;
select * from big_table order by
1,2,3,4,5,6,7,8,9,10,11,12,13
*
ERROR at line 1:
ORA-01565: error in identifying file
'/u01/app/oracle/oradata/orcl/temp01.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Good news:
Automatic re-creation of temporary files at startup
(Manual re-creation also possible)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Log Group Status: Review

A redo log group has a status of one of the


following values at any given time:
CURRENT: The LGWR process is
currently writing redo data to it.
ACTIVE: It is no longer being written to,
but it is still required for instance
recovery.
INACTIVE: It is no longer being written
to, and it is no longer required for
instance recovery.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recovering from the Loss of a Redo Log Group

Start

Yes Inactive Current


Fix Group
Done
media? status

No Active

Clear log Perform Perform No Instance


file. No checkpoint. log switch crashed?
Archived?
Back up
database.
Yes
Yes CKPT
Yes
Clear log file. successful?

No
Restore and perform
cancel-based point-in-time
recovery.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Clearing a Log File

Start

Yes
Log file
ALTER DATABASE CLEAR LOGFILE ...
archived?

No

Yes
Needed for
data file?

No
ALTER DATABASE CLEAR UNARCHIVED LOGFILE ...

ALTER DATABASE CLEAR UNARCHIVED LOGFILE ... UNRECOVERABLE DATAFILE

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recovering from a Lost Index Tablespace

A tablespace that contains only indexes may be recovered


without performing a RECOVER task.
If a data file that belongs to an index-only tablespace is
lost, it may be simpler to re-create the tablespace and re-
create the indexes.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Re-Creating Indexes

Use options to reduce the time it takes to re-create the index:


PARALLEL
NOLOGGING

SQL> CREATE INDEX rname_idx


2 ON hr.regions (region_name)
3 PARALLEL 4;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Authentication Methods for Database
Administrators

Remote database Local database


administration administration

Do you Yes Do you want Yes


have a secure to use OS Use OS
connection? authentication? authentication.

No No Use a
password file.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Re-creating a Password Authentication File

SQL> grant sysdba to admin2;


grant sysdba to admin2
*
ERROR at line 1:
ORA-01994: GRANT failed: password file missing or disabled

To recover from the loss of a password file:


1. Re-create the password file by using orapwd.
$ orapwd file=$ORACLE_HOME/dbs/orapworcl password=ora entries=5

2. Add users to the password file and assign appropriate


privileges to each user.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Comparing Complete and Incomplete Recovery

Recovery can have two kinds of scope:


Complete recovery: Brings the database up to the present,
including all committed data changes made to the point in
time when the recovery was requested
Incomplete or point-in-time recovery: Brings the database
up to a specified point in time in the past, before the
recovery operation was requested

Time of
Complete crash
recovery
Point-in-time
recovery Recovery
Restore from Missing transactions task started
this backup after point-in-time recovery at this time

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Complete Recovery Process

Archived
log Archived
log Online
Redo log

Changes applied Undo applied

2 4

1 3 5
Restored Data files containing
data files committed and uncommitted Recovered
transactions data files

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Point-in-Time Recovery Process

Archived
log Archived
log X
Online
Redo log X
Changes applied to point in time (PIT) Database
opened Undo applied
2
4 5

1 3 6
Restored data Data files containing
committed and PIT-recovered
files from as far
uncommitted data files
back as necessary
transactions up to PIT

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recovering a Read-Only Tablespace

Special user-managed backup and recovery considerations for


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.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recovering NOLOGGING Database Objects

Redo log

SQL> CREATE TABLE sales_copy NOLOGGING;


SQL> INSERT /*+ APPEND */ INTO sales_copy
2 SELECT * FROM sales_history;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recovering from the Loss of
All Control File Copies: Overview

Current Backup

Available Restore backup control file, Restore backup control file,


perform complete recovery, OPEN perform complete recovery,
RESETLOGS OPEN RESETLOGS

Unavailable Re-create control file, OPEN Restore backup control file,


RESETLOGS perform point-in-time
recovery, OPEN RESETLOGS

Online log status Data file status

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recovering the Control File
to the Default Location

Database No
Repair hardware.
open?

Yes Restore control file.

SHUTDOWN ABORT
STARTUP MOUNT Open database
using
RESETLOGS.
Start database recovery.

No
Archivelog
missing?

Yes Specify online log.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Descrever as causas da perda de arquivo e determinar a
ao apropriada
Descrever as operaes principais da recuperao
Fazer backup e recuperar um arquivo de controle
Recuperar-se de um grupo de log redo perdido

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Usando o RMAN para executar a recuperao

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Aps concluir esta lio, voc deve ser capaz de usar o RMAN
para:
Executar recuperao completa quando um arquivo de
dados crticos ou no-crtica perdido
Recuperar usando backups incrementalmente atualizados
Alternar para cpias de imagens para a recuperao
rpida
Restaurar um banco de dados para um novo hospedeiro
Recuperar usando um arquivo de backup do controle

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using RMAN RESTORE and RECOVER Commands

RESTORE command: Restores database files from backup


RECOVER command: Recovers restored files by applying
changes recorded in incremental backups and redo log
files
RMAN> SQL 'ALTER TABLESPACE inv_tbs OFFLINE IMMEDIATE';
RMAN> RESTORE TABLESPACE inv_tbs;
RMAN> RECOVER TABLESPACE inv_tbs;
RMAN> SQL 'ALTER TABLESPACE inv_tbs ONLINE';

The Enterprise Manager Recovery Wizard creates and


runs an RMAN script to perform the recovery.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performing Complete Recovery: Loss of a
Noncritical Data File in ARCHIVELOG Mode
If a data file is lost or corrupted, and that file does not belong to
the SYSTEM or UNDO tablespace, then restore and recover the
missing data file.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performing Complete Recovery: Loss of a
System-Critical Data File in ARCHIVELOG Mode
If a data file is lost or corrupted, and that file belongs to the
SYSTEM, UNDO (or SYSAUX) tablespace, then perform the
following steps:
1. The instance may or may not shut down automatically. If it
does not, use SHUTDOWN ABORT to shut the instance
down.
2. Mount the database.
3. Restore and recover the missing data file.
4. Open the database.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recovering Image Copies

RMAN can recover image copies by using incremental


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.
RMAN> RECOVER COPY OF
2> DATAFILE {n|'file_name'}

Incremental
backup files
Image copy
of data file

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recovering Image Copies: Example

If you run these commands daily:


RMAN> recover copy of database with tag 'daily_inc';
RMAN> backup incremental level 1 for recover of copy
2> with tag 'daily_inc' database;

This is the result:


RECOVER BACKUP

Day 1 Nothing Create image copies

Day 2 Nothing Create incremental level 1

Day 3 and Recover copies based on Create incremental level 1


onward incremental

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performing a Fast Switch to Image Copies

Perform fast recovery by Optionally, do the following


performing the following to put the files back into
steps: their original location:
1. Take data files offline. 5. Create an image copy of
2. Use the SWITCH TO ... the data file in the
COPY command to switch original location.
to image copies. 6. Take data files offline.
3. Recover data files. 7. SWITCH TO ... COPY
4. Bring data files online. 8. Recover data files.
9. Bring data files online.
Now the data files are recovered
and usable in their new location.

SQL> SWITCH DATAFILE 'filename' TO COPY;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using SET NEWNAME for Switching Files

Use the SET NEWNAME command in a RUN block to restore


to a nondefault location.
RUN
{ ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
ALLOCATE CHANNEL dev2 DEVICE TYPE sbt;
SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE";
SET NEWNAME FOR DATAFILE '/disk1/oradata/prod/users01.dbf'
TO '/disk2/users01.dbf';
RESTORE TABLESPACE users;
SWITCH DATAFILE ALL;
RECOVER TABLESPACE users;
SQL "ALTER TABLESPACE users ONLINE";
}

Instead of individual names, specify a default name format


for all files in a database or in a named tablespace.
The default name is used for DUPLICATE, RESTORE, and
SWITCH commands in the RUN block.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Substitution Variables for SET NEWNAME

Syntax Element Description


%b Specifies the file name without the directory path *NEW*

%f Specifies the absolute file number of the data file for which the
new name is generated

%I Specifies the DBID


%N Specifies the tablespace name

%U Specifies a system-generated file name of the format:


data-D-%d_id-%I_TS-%N_FNO-%f
RUN
{ SET NEWNAME FOR DATAFILE 1 TO '/oradata1/system01.dbf';
SET NEWNAME FOR DATAFILE 2 TO '/oradata2/sysaux01.dbf';
SET NEWNAME FOR DATAFILE 3 TO '/oradata3/undotbs01.dbf';
SET NEWNAME FOR DATAFILE 4 TO '/oradata4/users01.dbf';
SET NEWNAME FOR TABLESPACE example TO '/oradata5/%b';
DUPLICATE TARGET DATABASE TO dupldb; }

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performing Restore and Recovery of a Database
in NOARCHIVELOG Mode
If the database is in NOARCHIVELOG mode, and any data
file is lost, perform the following tasks:
Shut down the instance if it is not already down.
Restore the entire database, including all data and control
files, from the backup.
Open the database.
Users must reenter all changes made since the last
backup.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using Restore Points

A restore point provides a name to a point in time:


Now:
SQL> CREATE RESTORE POINT before_mods;

Some time in the past:


SQL> CREATE RESTORE POINT end_q1 AS OF SCN 100;

Timeline

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performing Point-in-Time Recovery

Perform server-managed point-in-time recovery by doing the


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.
5. Open the database in READONLY mode, and verify that
the recovery point is what you wanted.
6. Open the database using RESETLOGS.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performing Recovery with a Backup Control File

Restore and mount a backup control file when all copies of


the current control file are lost or damaged.
Execute the RECOVER command after restoring the backup
control file.
Open the database with the RESETLOGS option after
performing complete or point-in-time recovery.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recovery from Loss of Server Parameter File

The FROM MEMORY clause allows the creation of current


systemwide parameter settings.

SQL> CREATE PFILE [= 'pfile_name' ]


FROM { { SPFILE [= 'spfile_name'] } | MEMORY } ;

SQL> CREATE SPFILE [= 'spfile_name' ]


FROM { { PFILE [= 'pfile_name' ] } | MEMORY } ;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Restoring the Server Parameter File from the
Control File Autobackup
RMAN> STARTUP FORCE NOMOUNT;
RMAN> RESTORE SPFILE FROM AUTOBACKUP;
RMAN> STARTUP FORCE;

Recovery
Manager
(RMAN) Flash Recovery
Area

Server
parameter
file Database

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Restoring the Control File from Autobackup

Recovery
Manager
(RMAN) Flash Recovery
Area

Control
file
Database

RMAN> STARTUP NOMOUNT;


RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP;
RMAN> ALTER DATABASE MOUNT;
RMAN> RECOVER DATABASE;
RMAN> ALTER DATABASE OPEN RESETLOGS;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using Incremental Backups to Recover a
Database in NOARCHIVELOG Mode
Use incremental backups to perform limited recovery of a
database in NOARCHIVELOG mode.
STARTUP FORCE NOMOUNT;
RESTORE CONTROLFILE;
ALTER DATABASE MOUNT;
RESTORE DATABASE;
RECOVER DATABASE NOREDO;
ALTER DATABASE OPEN RESETLOGS;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Restoring and Recovering the Database
on a New Host
Use the procedure to:
Perform test restores
Move a production database to a new host

Backups RMAN>

Server Server
parameter file parameter file

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Preparing to Restore the Database to a New Host

To prepare to restore a database, perform the following steps:


Record the database identifier (DBID) of your source
database.
Copy the source database initialization parameter file to
the new host.
Ensure that source backups, including the control file
autobackup, are accessible on the restore host.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Restoring the Database to a New Host

Perform the following steps on the restore host to restore the


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.
6. Shut down the instance.
7. Edit the restored initialization parameter file.
8. Start the instance in NOMOUNT mode.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Restoring the Database to a New Host

9. Create a RUN block to:


Restore the control file
Mount the database
10. Create the RMAN recovery script to restore and recover
the database.
11. Execute the RMAN script.
12. Open the database with the RESETLOGS option.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performing Disaster Recovery

Disaster implies the loss of the entire target database, the


recovery catalog database, all current control files, all
online redo log files, and all parameter files.
Disaster recovery includes the restoration and recovery of
the target database.
Minimum required set of backups:
Backups of data files
Corresponding archived redo logs files
At least one control file autobackup

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performing Disaster Recovery

Basic procedure:
Restore an autobackup of the server parameter file.
Start the target database instance.
Restore the control file from autobackup.
Mount the database.
Restore the data files.
Recover the data files.
Open the database with the RESETLOGS option.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como usar o RMAN para
fazer o seguinte:
Executar recuperao completa quando um arquivo de
dados crticos ou no-crtica perdido
Recuperar usando backups incrementalmente atualizados
Alternar para cpias de imagens para a recuperao
rpida
Restaurar um banco de dados para um novo hospedeiro
Recuperar usando um arquivo de backup do controle

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoramento e ajuste de RMAN

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Aps concluir esta lio, voc deve ser capaz de:


Monitorar o progresso dos trabalhos RMAN
Configurar adequadamente o RMAN para e/s assncrona
Configurar o RMAN multiplexao por forma a manter a
transmisso eficiente de drives de fita
Avaliar o equilbrio entre a velocidade de backup versus
velocidade de recuperao
Explicar o efeito dos seguintes parmetros sobre o
desempenho do RMAN: MAXPIECESIZE, FILESPERSET,
MAXOPENFILES
Explicar como o RMAN BACKUP DURATION opo pode
causar os backups executar mais rapidamente ou levar
mais tempo, (liberando recursos para outros processos)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Parallelization of Backup Sets

For performance, allocate multiple channels and assign files to


specific channels.

Data file Data file Data file


1 4 5 Channel

MML Backup
piece 1

Data file Data file Data file


2 3 9 Channel

MML Backup
piece 2
Data file Data file Data file
6 7 8 Channel

MML Backup
Piece 3

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring RMAN Sessions

Query V$SESSION and V$PROCESS to identify the


relationship between server sessions and RMAN channels.
If you are monitoring multiple sessions, use the SET
COMMAND ID command to correlate a process with a
channel during a backup.

SQL> COLUMN CLIENT_INFO FORMAT a30


SQL> COLUMN SID FORMAT 999
SQL> COLUMN SPID FORMAT 9999
SQL> SELECT s.sid, p.spid, s.client_info
2 FROM v$process p, v$session s
3 WHERE p.addr = s.paddr
4 AND CLIENT_INFO LIKE 'rman%';

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring RMAN Job Progress

Monitor the progress of backup and restore operations by


querying V$SESSION_LONGOPS.

SQL> SELECT OPNAME, CONTEXT, SOFAR, TOTALWORK,


2 ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE"
3 FROM V$SESSION_LONGOPS
4 WHERE OPNAME LIKE 'RMAN%'
5 AND OPNAME NOT LIKE '%aggregate%'
6 AND TOTALWORK != 0
7 AND SOFAR <> TOTALWORK;

SID SERIAL# CONTEXT SOFAR TOTALWORK %_COMPLETE


--- ------- ------- ------- --------- ----------
13 75 1 9470 15360 61.65
12 81 1 15871 28160 56.36

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Interpreting RMAN Message Output

RMAN troubleshooting information can be found in:


RMAN command output
RMAN trace file
Alert log
Oracle server trace file
sbtio.log file

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using the DEBUG Option

The DEBUG option is used to:


View the PL/SQL that is generated
Determine precisely where an RMAN command is hanging
or faulting
The DEBUG option is specified at the RMAN prompt or
within a run block.
The DEBUG option creates an enormous amount of output,
so redirect the output to a trace file:

$ rman target / catalog rman/rman debug trace trace.log

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Interpreting RMAN Error Stacks

Read the stack from bottom to top.


Look for Additional information.
RMAN-03009 identifies the failed command.
RMAN-00571: ===========================================
RMAN-00569: ======= ERROR MESSAGE STACK FOLLOWS =======
RMAN-00571: ===========================================
RMAN-03009: failure of backup command on c1 channel at
09/04/2001 13:18:19
ORA-19506: failed to create sequential file,
name="07d36ecp_1_1", parms=""
ORA-27007: failed to open file
SVR4 Error: 2: No such file or directory
Additional information: 7005
Additional information: 1
ORA-19511: Error from media manager layer,error text:

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Tuning RMAN

RMAN BACKUP and RESTORE operations perform the


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.
Performance of backup versus recovery operations can be
balanced to suit your needs.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
RMAN Multiplexing

For reads:
Multiplexing Level Allocation Rule

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
for each file.

For writes, each channel allocates four output buffers of


1 MB each.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Allocating Disk Buffers: Example

Data files Input disk buffers

1 MB 1 MB
1 MB 1 MB

1 MB 1 MB
1 MB 1 MB
Channel
FILESPERSET = 4
MAXOPENFILES = 4
1 MB 1 MB
1 MB 1 MB

1 MB 1 MB
1 MB 1 MB

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Allocating Tape Buffers

From SGA (large pool) with BACKUP_TAPE_IO_SLAVES is


TRUE.
From PGA with BACKUP_TAPE_IO_SLAVES is FALSE.

Channel Tape buffers


256 KB 256 KB
256 KB 256 KB

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Comparing Synchronous and Asynchronous I/O

Synchronous I/O

Server process Server process waits;


1 2
writes data to buffer. tape process writes data.

Server/
0100100
channel
process 0100100
Tape
Server process buffers
4 writes data to
new buffer. Tape process
3
signals finish.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Comparing Synchronous and Asynchronous I/O

Asynchronous I/O

Server process
1 2 Tape process writes data.
writes data to buffer.

Server/
0100100
channel
process 0100100 0100100
Tape
buffers

3 Server process writes to new


buffer while step 2 completes.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring RMAN Job Performance

The following views can be used to monitor backup and


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
Whether or not I/O is synchronous depends on how the
controlling process views it.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Asynchronous I/O Bottlenecks

Use V$BACKUP_ASYNC_IO to monitor asynchronous I/O.


The file that has the largest ratio of LONG_WAITS to
IO_COUNT is probably the bottleneck.
IO_COUNT: Number of I/Os performed on the file
LONG_WAITS: Number of times the backup/restore process
told the OS to wait until I/O was complete
Wait times should be zero to avoid bottlenecks.
SHORT_WAIT_TIME_TOTAL
LONG_WAIT_TIME_TOTAL

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Synchronous I/O Bottlenecks

Synchronous I/O is considered to be a bottleneck.


Query the DISCRETE_BYTES_PER_SECOND column from
V$BACKUP_SYNC_IO to view the I/O rate.
Compare this rate with the devices maximum rate.
If the rate is lower than what the device specifies, this is a
tuning opportunity.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Channel Tuning

Use the CONFIGURE CHANNEL and ALLOCATE CHANNEL


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 to assign different data files to each one.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Tuning the BACKUP Command

MAXPIECESIZE limits the size of each backup piece.


FILESPERSET prevents RMAN from reading from too
many disks at once.
MAXOPENFILES may inhibit streaming to tape if not set
high enough.
BACKUP DURATION decreases the amount of load on the
system that the backup operation causes.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Tuning RMAN Backup Performance

To tune RMAN backup performance, follow these steps :


1. Remove RATE settings from configured and allocated
channels.
2. Set DBWR_IO_SLAVES if you use synchronous disk I/O.
3. Set LARGE_POOL_SIZE.
4. Tune RMAN tape streaming performance bottlenecks.
5. Query V$ views to identify bottlenecks.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Setting LARGE_POOL_SIZE

If LARGE_POOL_SIZE is not set, the Oracle server tries to


get memory from the shared pool.
If LARGE_POOL_SIZE is not big enough, the server does
not allocate buffers from the shared pool.
If the server cannot get enough memory, it allocates
buffers from the local process memory.
The Oracle server writes a message to the alert log
indicating that synchronous I/O is used for this backup.

ksfqxcre: failure to allocate shared memory means sync


I/O will be used whenever async I/O to file not
supported natively

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Tuning RMAN Tape Streaming
Performance Bottlenecks
Use BACKUP... VALIDATE to determine whether tape
streaming or disk I/O is the bottleneck.
Use multiplexing to improve tape streaming with disk
bottlenecks.
Use incremental backups to improve backup performance
with tape bottlenecks.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Monitorar o progresso dos trabalhos RMAN
Configurar adequadamente o RMAN para e/s assncrona
Configurar o RMAN multiplexao por forma a manter a
transmisso eficiente de drives de fita
Avaliar o equilbrio entre a velocidade de backup versus
velocidade de recuperao
Explicar o efeito dos seguintes parmetros sobre o
desempenho do RMAN: MAXPIECESIZE, FILESPERSET,
MAXOPENFILES
Explicar como o RMAN BACKUP DURATION opo pode
causar os backups executar mais rapidamente ou levar
mais tempo (liberando recursos para outros processos)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Diagnosticando o banco de dados

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Aps concluir esta lio, voc deve ser capaz de:


Detectar e reparar a corrupo de banco de dados
Lidar com a corrupo de bloco
Configurar o repositrio de diagnstico automtico
Executar verificaes de integridade

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
> Data Recovery Ad.
Block Corruption
Data Recovery Advisor ADR
Health Monitor

Fast detection, analysis, and repair of failures


Minimizing disruptions for users
Down-time and run-time failures
User interfaces:
EM GUI interface
(several paths)
RMAN command
line
Supported database configurations:
Single-instance
Not RAC
Supporting failover to standby, but not analysis and repair of
standby databases

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Data Recovery Advisor

Reducing down time by eliminating confusion:

1. Assess data failures. Health Monitor

2. List failures by severity.


Data
Recovery
3. Advise on repair. Advisor

4. Choose and execute repair.

5. Perform proactive checks. DBA

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Data Failures

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Data Failure: Examples

Not accessible components, for example:


Missing data files at the OS level
Incorrect access permissions
Offline tablespace, and so on
Physical corruptions, such as block checksum failures or
invalid block header field values
Logical corruptions, such as inconsistent dictionary,
corrupt row piece, corrupt index entry, or corrupt
transaction
Inconsistencies, such as control file is older or newer than
the data files and online redo logs
I/O failures, such as a limit on the number of open files
exceeded, channels inaccessible, network or I/O error

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Data Recovery Advisor
RMAN Command-Line Interface

RMAN Command Action


LIST FAILURE Lists previously executed failure assessment

ADVISE FAILURE Displays recommended repair option

REPAIR FAILURE Repairs and closes failures (after ADVISE in the same
RMAN session)

CHANGE FAILURE Changes or closes one or more failures

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Listing Data Failures

The RMAN LIST FAILURE command lists previously


executed failure assessment.
Including newly diagnosed failures
Removing closed failures (by default)

Syntax:

LIST FAILURE
[ ALL | CRITICAL | HIGH | LOW | CLOSED |
failnum[,failnum,] ]
[ EXCLUDE FAILURE failnum[,failnum,] ]
[ DETAIL ]

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Advising on Repair

The RMAN ADVISE FAILURE command:


Displays a summary of input failure list
Includes a warning, if new failures appeared in ADR
Displays a manual checklist
Lists a single recommended repair option
Generates a repair script (for automatic or manual repair)

. . .
Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_29791
28860.hm
RMAN>

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Executing Repairs

The RMAN REPAIR FAILURE command:


Follows the ADVISE FAILURE command
Repairs the specified failure
Closes the repaired failure

Syntax:

REPAIR FAILURE
[USING ADVISE OPTION integer]
[ { {NOPROMPT | PREVIEW}}...]

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Classifying (and Closing) Failures

The RMAN CHANGE FAILURE command:


Changes the failure priority (except for CRITICAL)
Closes one or more failures
Example:

RMAN> change failure 5 priority low;


List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
5 HIGH OPEN 20-DEC-06 one or more
datafiles are missing
Do you really want to change the above failures (enter YES or
NO)? yes
changed 1 failures to LOW priority

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Data Recovery Advisor Views

Querying V$ views:
V$IR_FAILURE: List of all failures, including closed ones
(result of the LIST FAILURE command)
V$IR_MANUAL_CHECKLIST: List of manual advice (result
of the ADVISE FAILURE command)
V$IR_REPAIR: List of repairs (result of the ADVISE
FAILURE command)
V$IR_FAILURE_SET: Cross-reference of failure and
advice identifiers

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Best Practice: Proactive Checks

Invoking proactive health check of the database and its


components:
Health Monitor or RMAN VALIDATE DATABASE command
Checking for logical and physical corruption
Findings logged in the ADR

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Data Recovery Ad.
What Is Block Corruption? > Block Corruption
ADR
Health Monitor

Whenever a block is read or written, a consistency check


is 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
Logically (or software) corrupt

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Block Corruption Symptoms: ORA-01578

The error ORA-01578: "ORACLE data block corrupted


(file # %s, block # %s)":
Is generated when a corrupted data block is found
Always returns the relative file number and block number
Is returned to the session that issued the query being
performed when the corruption was discovered
Appears in the alert.log file

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
How to Handle Corruption

Check the alert log and operating system log file.


Use available diagnostic tools to find out the type of
corruption.
Determine whether the error persists by running checks
multiple times.
Recover data from the corrupted object if necessary.
Resolve any hardware issues:
Memory boards
Disk controllers
Disks
Recover or restore data from the corrupt object
if necessary.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Setting Parameters to Detect Corruption

Prevent memory and data corruption

...
Detect I/O storage, disk corruption

...
Detect nonpersistent writes on physical standby

New
...
Specify defaults for corruption detection
EM > Server > Initialization Parameters

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Setting Parameters to Detect Corruption

DB_ULTRA_SAFE OFF DATA_ONLY DATA_AND_INDEX

DB_BLOCK_CHECKING OFF or MEDIUM FULL or TRUE


FALSE

DB_BLOCK_CHECKSUM TYPICAL FULL FULL

DB_LOST_WRITE_PROTECT TYPICAL TYPICAL TYPICAL

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Block Media Recovery

Block media recovery:


Lowers the mean time to recover (MTTR)
Increases availability during media recovery
The data file remains online during recovery
Only blocks being recovered are inaccessible
Is invoked using the RMAN RECOVER...BLOCK command
Restores blocks using flashback logs and full or level 0
backups
Media recovery is performed using redo logs
The V$DATABASE_BLOCK_CORRUPTION
view displays blocks marked corrupt

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Prerequisites for Block Media Recovery

The target database must be in ARCHIVELOG mode.


The backups of the data files containing the corrupt blocks
must be full or level 0 backups.
Proxy copies must be restored to a non-default location
before they can be used.
RMAN can use only archived redo logs for the recovery.
The corrupted data block can be restored from Flashback
Logs if available.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
The RECOVER...BLOCK Command

The RMAN RECOVER...BLOCK command:


Identifies the backups containing the blocks to recover
Reads the backups and accumulates requested blocks into
in-memory buffers
Manages the block media recovery session by reading the
archive logs from backup if necessary
RECOVER DATAFILE 6 BLOCK 3; Recover a single block

RECOVER Recover multiple


blocks
DATAFILE 2 BLOCK 43 in multiple data files
DATAFILE 2 BLOCK 79
DATAFILE 6 BLOCK 183;

RECOVER CORRUPTION LIST; Recover all blocks logged in

V$DATABASE_BLOCK_CORRUPTION

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Data Recovery Ad.
Block Corruption
Automatic Diagnostic Workflow .
> ADR
Health Monitor

Automatic
Critical Diagnostic
error Repository

DBA

Alert DBA
Auto-incident creation
1 2 Targeted health checks
First failure capture Assisted SR filling

No Known
DBA bug?

Yes

EM Support Workbench:
4 Package incident info EM Support Workbench:
Data repair Apply patch/Data repair 3 DBA

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Automatic Diagnostic Repository

DIAGNOSTIC_DEST
Support Workbench

$ORACLE_BASE
BACKGROUND_DUMP_DEST
CORE_DUMP_DEST
USER_DUMP_DEST
$ORACLE_HOME/log
ADR
Base

diag

rdbms

DB
Name

ADR SID metadata


Home

alert cdump incpkg incident hm trace (others)

incdir_1 incdir_n

ADRCI log.xml alert_SID.log V$DIAG_INFO

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
The ADR Command-Line Tool (ADRCI)

ADRCI provides interaction with ADR from an operating


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.

ADR base = "/u01/app/oracle"

ADRCI> show incident


ADR Home = /u01/app/oracle/product/11.1.0/db_1/log/diag/rdbms/orcl/orcl:
**************************************************************************
INCIDENT_ID PROBLEM_KEY CREATE_TIME
----------- ------------------------------------ ------------------------
1681 ORA-600_dbgris01:1,_addr=0xa9876541 17-JAN-07 09.17.44.843125
1682 ORA-600_dbgris01:12,_addr=0xa9876542 18-JAN-07 09.18.59.434775
2 incident info records fetched

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
The V$DIAG_INFO View

SQL> SELECT * FROM V$DIAG_INFO;

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
Default Trace File /u01/app/oracle/diag/.../trace/orcl_ora_11424.trc
Active Problem Count 3
Active Incident Count 8

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Location for Diagnostic Traces

Diag Data Previous Location ADR Location


Foreground USER_DUMP_DEST ADR_HOME/trace
process traces

Background BACKGROUND_DUMP_DEST ADR_HOME/trace


process traces

Alert log data BACKGROUND_DUMP_DEST ADR_HOME/alert


ADR_HOME/trace
Core dumps CORE_DUMP_DEST ADR_HOME/cdump

Incident dumps USER|BACKGROUND_DUMP_DEST ADR_HOME/incident/incdir_


n

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Data Recovery Ad.
Block Corruption
Health Monitor: Overview ADR
> Health Monitor

V$HM_RUN ADRCI EM
DBMS_HM

hm
(reports)
Critical
error

Health
ADR
Monitor

V$HM_CHECK
DBA Logical Block Check Undo Segment Check
Table Row Check Data Block Check
Transaction Check Table Check
Redo Check Database Cross Check

Table-Index Row Mismatch


Database Dictionary Check
Table-Index Cross Check

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Running Health Checks Manually:
PL/SQL Example
SQL> exec dbms_hm.run_check('Database Dictionary Check',
'mycheck',0,'TABLE_NAME=tab$');

SQL> set long 100000


SQL> select dbms_hm.get_run_report('mycheck') from dual;

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>
</RUN_INFO>
<RUN_PARAMETERS><RUN_PARAMETER>TABLE_NAME=tab$</RUN_PARAMETER> </RUN_PARAMETERS>
<RUN-FINDINGS><FINDING>
<FINDING_NAME>Dictionary Inconsistency</FINDING_NAME><FINDING_ID>22</FINDING_ID>
<FINDING_TYPE>FAILURE</FINDING_TYPE><FINDING_STATUS>OPEN</FINDING_STATUS>
<FINDING_PRIORITY>CRITICAL</FINDING_PRIORITY>
<FINDING_CREATION_TIME></FINDING_CREATION_TIME>
<FINDING_MESSAGE>invalid column number 7 on Object tab$ Failed</FINDING_MESSAGE>
<FINDING_MESSAGE>Damaged Object SH.JFVTEST is referenced </FINDING_MESSAGE>

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Viewing HM Reports Using the ADRCI Utility

adrci>>show hm_run

----------------------------------------------------------
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
SRC_INCIDENT_ID 0
NUM_INCIDENTS 0
ERR_NUMBER 0
REPORT_FILE

adrci>>create report hm_run HM_RUN_11081


Adrci>>show report hm_run HM_RUN_11081

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Detectar e reparar a corrupo de banco de dados:
Use os novos comandos de reparao de dados RMAN
para:
Lista de falhas
Receber um conselhos de reparao
Reparar falhas
Executar verificaes de falha proativo
Lidar com a corrupo de bloco:
Verificando a integridade do bloco em tempo real
Execuo de recuperao de mdia de bloco
Configurar o repositrio de diagnstico automtico
Executar verificaes de integridade

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Usando a tecnologia de Flashback I

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback
> - Overview
Objetivos - Query
- Table
- Transaction

Aps concluir esta lio, voc deve ser capaz de:


Descrever a tecnologia de Flashback
Executar consulta Flashback
Consulta de verso usar Flashback
Permitir o movimento da linha em uma tabela
Executar operaes de Flashback Table
Consulta de transao usar Flashback
Usar a transao de Flashback

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Technology
Object Scenario Examples Flashback Depends Affects
Level Technology On Data
Database Truncate table; Undesired Database Flashback TRUE
multitable changes made logs
Table Drop table Drop Recycle bin TRUE

Update with the wrong Table Undo data TRUE


WHERE clause
Compare current data Query Undo data FALSE
with data from the past
Compare versions of a Version Undo data FALSE
row
Keep historical Data Archive Undo data TRUE
transaction data
Transaction Investigate and back out Transaction Undo/redo TRUE
suspect transactions from Archive
logs

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Transactions and Undo

Original data
in
buffer cache

Undo old data


in undo tablespace

DML operations

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Guaranteeing Undo Retention

Retention guarantee:
15 minutes

Undo data in
undo
tablespace

SELECT statements A transaction that generates


running 15 minutes or less more undo than what there
are always satisfied. is space for will fail.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Preparing Your Database for Flashback

Creating an undo tablespace


Enabling Automatic Undo Management
Specifying versus guaranteeing undo retention

Default database initialization parameters:


UNDO_MANAGEMENT='AUTO'
UNDO_TABLESPACE='UNDOTBS1'
UNDO_RETENTION=900

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback
- Overview
Using Flashback Technology to > - Query
- Table
Query Data - Transaction

Flashback Query
Query all data at a specified point in time.
Flashback Version Query
See all versions of a row between two times.
See the transactions that changed the row.
Flashback Transaction Query
See all changes made by a transaction.

11:00 11:10

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Query

Use to query all data at a specified point in time.

employees Unwanted employees


updates

T1 T2

SELECT employee_id, salary FROM employees


AS OF TIMESTAMP <T1>
WHERE employee_id = 200

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Query: Example

employees employees employees

salary = 4,400 salary = 4,840 salary = 4,400

11:00 11:10
UPDATE employees
SET salary =
(SELECT salary FROM employees
AS OF TIMESTAMP TO_TIMESTAMP
('2005-05-04 11:00:00', 'yyyy-mm-dd hh24:mi:ss')
WHERE employee_id = 200)
WHERE employee_id = 200

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Version Query

Tx0 Tx1 Tx2

employees employees employees

200

t1 t2
SELECT versions_xid, salary FROM employees
VERSIONS BETWEEN TIMESTAMP <t1> and <t2>
WHERE employee_id = 200;

Tx0 Tx1 Tx2

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Version Query: Considerations

The VERSIONS clause cannot be used to query:


External tables
Temporary tables
Fixed tables
Views
The VERSIONS clause cannot span DDL commands.
Segment shrink operations are filtered out.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback
- Overview
Flashback Table: Overview - Query
> - Table
- Transaction

Flashback Table recovers tables to a specific point in time.


Flashback Table is an in-place operation.
The database stays online.

Erroneous Flashed back


DMLs User tables

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Table

Using Flashback Table, you can recover a table or tables


to a specific point in time without restoring a backup.
Data is retrieved from the undo tablespace to perform a
Flashback Table operation.
You require the FLASHBACK ANY TABLE or the
FLASHBACK object privilege on the specific table.
SELECT, INSERT, DELETE, and ALTER privileges on the
table to be flashed back are required.
You must enable row movement on the table that you are
performing the flashback operation on.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Enabling Row Movement on a Table

ALTER TABLE employees ENABLE ROW MOVEMENT;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performing Flashback Table

FLASHBACK TABLE hr.departments TO TIMESTAMP


TO_TIMESTAMP('2007-04-05 21:00:00',
'YYYY-MM-DD HH24:MI:SS');

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Table: Considerations

The FLASHBACK TABLE command executes as a single


transaction, acquiring exclusive DML locks.
Statistics are not flashed back.
Current indexes and dependent objects are maintained.
Flashback Table operations:
Cannot be performed on system tables
Cannot span DDL operations
Generate undo and redo data

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback
- Overview
Flashback Transaction Query - Query
- Table
> - Transaction

FLASHBACK_TRANSACTION_QUERY

DBA

Erroneous
DML Undo
SQL

User

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using Enterprise Manager to Perform
Flashback Transaction Query

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Transaction Query: Considerations

DDL commands are seen as dictionary updates.


Flashback Transaction Query on a transaction underlying
a DDL command displays the data dictionary changes.
Dropped objects appear as object numbers.
Dropped users appear as user identifiers.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Transaction

Setting up Flashback Transaction prerequisites


Stepping through a possible workflow
Using the Flashback Transaction Wizard
Querying transactions with and without dependencies
Choosing back-out options and flashing back transactions
Reviewing the results

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Prerequisites

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashing Back a Transaction

You can flash back a transaction with Enterprise Manager


or from the command line.
EM uses the Flashback Transaction Wizard, which calls
the DBMS_FLASHBACK.TRANSACTION_BACKOUT
procedure with the NOCASCADE option.
If the PL/SQL call finishes successfully, it means that the
transaction does not have any dependencies and a single
transaction is backed out successfully.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Possible Workflow

1. Viewing data in a table


2. Discovering a logical problem
3. Using Flashback Transaction
1. Performing a query
2. Selecting a transaction
3. Flashing back a transaction (with no conflicts)
4. Choosing other back-out options (if conflicts exists)
4. Reviewing Flashback Transaction results

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Transaction Wizard

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Choosing Other Back-out Options

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Choosing Other Back-out Options

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Final Steps Without EM

After choosing your back-out option, the dependency report is


generated in the DBA_FLASHBACK_TXN_STATE and
DBA_FLASHBACK_TXN_REPORT views.
Review the dependency report that shows all transactions
which were backed out.
Commit the changes to make them permanent.
Roll back to discard the changes.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Descrever a tecnologia de Flashback
Executar consulta Flashback
Consulta de verso usar Flashback
Permitir o movimento da linha em uma tabela
Executar operaes de Flashback Table
Consulta de transao usar Flashback
Usar a transao de Flashback

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Usando a tecnologia de Flashback II

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
> Total Recall
Flashback Drop
Objetivos

Aps concluir esta lio, voc deve ser capaz de:


Descrever e usar o Oracle Total Recall
Criando e ativando um arquivo de dados de Flashback
(FDA)
Gerenciando FDAs
Metadados de visualizao
Descrever e usar lixeiras flashback
Tabelas de restaurao caiu da lixeira
Gerenciar o uso do espao na lixeira
Consulta a lixeira

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Oracle Total Recall Overview

Automated tracking of historical database changes:


Enable at the table level with your specified retention
period.
All subsequent changes are transparently stored and
tamper proof.
Records older than retention period are automatically
removed.
Use Flashback technologies to retrieve history.
SELECT AS OF TIMESTAMP
SELECT VERSIONS BETWEEN TIMESTAMP and TIMESTAMP

Use Cases for Flashback request:


updates Base history Flashback queries Audit, compliance, historical
Table Data reports, ILM
Archive

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Setup Process

1. Create a new tablespace to hold the FDA.


2. With the FLASHBACK ARCHIVE ADMINISTER system
privilege: Create a Flashback Data Archive, assign it to the
tablespace, and specify its retention period.
CREATE FLASHBACK ARCHIVE fda1
TABLESPACE fda_tbs1 QUOTA 10M RETENTION 1 YEAR;

3. With the FLASHBACK ARCHIVE object privilege: Alter the


base tables to enable archiving and assign it to a flashback
archive.
ALTER TABLE HR.EMPLOYEES FLASHBACK ARCHIVE fda1;

Flashback
Data
Base table Archive

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
How Total Recall Works

History data:
Row captured asynchronously by background
processes at self-tuned intervals (default: 5 min)
Stored compressed and partitioned
DML

Automatically purged per


Original data in retention policy
buffer cache undo Undo
data

fbda slaves (as needed)


DML

fbda background
help ...
process
history data
Partitions automatically created
based on time and volume
Unrelated partitions skipped by
queries
EMPLOYEES FDA1

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Oracle Total Recall Scenario

Using Flashback Data Archive to access historical data:

-- create the Flashback Data Archive


CREATE FLASHBACK ARCHIVE DEFAULT fla1 1
TABLESPACE tbs1 QUOTA 10G RETENTION 5 YEAR;

-- Specify the default Flashback Data Archive


ALTER FLASHBACK ARCHIVE fla1 SET DEFAULT; 2

-- Enable Flashback Data Archive


ALTER TABLE inventory FLASHBACK ARCHIVE; 3
ALTER TABLE stock_data FLASHBACK ARCHIVE;

SELECT product_number, product_name, count FROM inventory AS OF


TIMESTAMP TO_TIMESTAMP ('2007-01-01 00:00:00', 'YYYY-MM-DD
HH24:MI:SS');

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Oracle Total Recall Scenario

Optionally, adding space:


ALTER FLASHBACK ARCHIVE fla1
ADD TABLESPACE tbs3 QUOTA 5G;
4

Optionally, changing retention time:


ALTER FLASHBACK ARCHIVE fla1 MODIFY RETENTION 2 YEAR; 5
Optionally, purging data:
ALTER FLASHBACK ARCHIVE fla1 PURGE BEFORE TIMESTAMP
6
(SYSTIMESTAMP - INTERVAL '1' day);

Optionally, dropping a Flashback Data Archive:


DROP FLASHBACK ARCHIVE fla1; 7

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Transparent Schema Evolution

DDL support for:


Add, drop, rename, and modify column
Drop and truncate partition
Rename and truncate table
Flashback Version Query
1 2 3
1
Add column
Drop Column

time

Flashback queries work across DDL changes.


All other DDL is not automatically supported (see next
slide).

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Full Schema Evolution

Disassociate or associate procedures in the


DBMS_FLASHBACK_ARCHIVE package:
Disable Total Recall on specified tables and allow more
complex DDL (upgrades, split tables, and so on).
Enforce schema integrity during association. (Base table
and history table must be the same schema.)
Note: This function should be used with care and with the
understanding that the archive can no longer be guaranteed to
be immutable because the history could have been altered
during the time of disassociation.
1 2
Base
disassociate Alter schema Table
History
Table associate Alter schema History
Table
4 3

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Restrictions

You cannot enable Total Recall for base tables with Hybrid
Columnar compression.
If disassociate is used, immutability of history is no longer
guaranteed (but you could always purge history previously
anyway with the right privilege).
There is no transportability of history tables.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Guidelines

Use SCN for precise queries.


or
Use Flashback technology for your convenience.
Flashback uses current system settings.
Ensure database consistency with a COMMIT or ROLLBACK
operation before querying past data.
You cannot retrieve past data from a dynamic performance
(V$) view. They contain current data.
However, you can perform queries on past data in static
data dictionary views, such as *_TABLES.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Viewing Flashback Data Archives

Viewing the results:


View Name (DBA/USER) Description

*_FLASHBACK_ARCHIVE Displays information about Flashback


Data Archives

*_FLASHBACK_ARCHIVE_TS Displays tablespaces of Flashback Data


Archives

*_FLASHBACK_ARCHIVE_TABLES Displays information about tables that are


enabled for flashback archiving

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Total Recall
Flashback Drop > Flashback Drop

and the Recycle Bin


RECYCLEBIN=ON

DROP TABLE employees; FLASHBACK TABLE


employees
TO BEFORE DROP;
By mistake

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recycle Bin

BIN$zbjrBdpw==$0 EMPLOYEES
BIN$zbjra9wy==$0 EMPLOYEES_PK
Recycle
bin
4

DBA_FREE_SPACE

EMPLOYEES BIN$zbjrBdpw==$0
3
EMPLOYEES_PK BIN$zbjra9wy==$0
Objects are:
Renamed
Not moved
1
2 DROP TABLE employees;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Restoring Tables from the Recycle Bin

Restore dropped tables and dependent objects.


If multiple recycle bin entries have the same original name:
Use unique, system-generated names to restore a particular
version
When using original names, the restored table is last in, first
out (LIFO)
Rename the original name if that name is currently used.

FLASHBACK TABLE <table_name> TO BEFORE DROP


[RENAME TO <new_name>];

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recycle Bin: Automatic Space Reclamation

Recycle bin

BIN$zbjrBdpw==$0
BIN$zbjra9wy==$0 BIN$zbjrBdpw==$0

BIN$zbjra9wy==$0

DBA_FREE_SPACE - RECYCLEBIN 1

Autoextend 3

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recycle Bin: Manual Space Reclamation

PURGE {TABLE <table_name>|INDEX <index_name>}

PURGE TABLESPACE <ts_name> [USER <user_name>]

PURGE [USER_|DBA_]RECYCLEBIN

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Bypassing the Recycle Bin

DROP TABLE <table_name> [PURGE] ;

DROP TABLESPACE <ts_name>


[INCLUDING CONTENTS] ;

DROP USER <user_name> [CASCADE] ;

Security considerations for the recycle bin:


ALTER SYSTEM SET RECYCLEBIN=OFF SCOPE=SPFILE;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Querying the Recycle Bin

SELECT owner, original_name, object_name,


type, ts_name, droptime, related, space
FROM dba_recyclebin
WHERE can_undrop = 'YES';

SQL> SELECT original_name, object_name, ts_name, droptime


FROM user_recyclebin WHERE can_undrop = 'YES';

ORIGINAL_NAME OBJECT_NAME TS_NAM DROPTIME


------------- ----------------------- ------ -------------------
EMPLOYEES2 BIN$NE4Rk64w...gbpQ==$0 USERS 2007-07-02:15:45:13

SQL> SHOW RECYCLEBIN

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Configurar e usar o Total Recall
Tabelas de restaurao da lixeira
Consulta a area de lixeira

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Realizando o Flashback Database

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Aps concluir esta lio, voc deve ser capaz de:


Configurar o banco de dados de Flashback
Executar operaes de Flashback de banco de dados
Monitor Flashback Database

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Database

The Flashback Database operation:


Works like a rewind button for the database
Can be used in cases of logical data corruptions made by
users

Errors are The "Press the rewind button" The


generated. database is (FLASHBACK DATABASE). database is
corrupted. "rewound."

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Database Architecture

SGA
Not every Redo log
Flashback
change! buffer
Buffer cache
buffer
Every LGWR
change

Periodically
log block-
before images

Flashback Redo
RVWR logs
logs
Do forward
Back out changes media recovery.
1 to database using 2
before images.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Configuring Flashback Database

1. Configure the 2. Set the retention 3. Enable Flashback


FRA. target. Database.
If your database is in
SQL> SHUTDOWN IMMEDIATE ARCHIVELOG mode,
SQL> STARTUP MOUNT there is no need to
SQL> ALTER DATABASE ARCHIVELOG; restart it.
SQL> ALTER SYSTEM SET
2 DB_FLASHBACK_RETENTION_TARGET=2880 SCOPE=BOTH;
SQL> ALTER DATABASE FLASHBACK ON; With open database
SQL> ALTER DATABASE OPEN;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
What You Need to Do

Configuration work flow:


1. Make sure that the
database is in
ARCHIVELOG mode.
2. Enable flashback
logging and specify
the Fast Recovery
Area.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Database: Examples

To flash back: Mounted (in exclusive mode) database


RMAN> FLASHBACK DATABASE TO TIME =
2> "TO_DATE('2009-05-27 16:00:00',
3> 'YYYY-MM-DD HH24:MI:SS')";

RMAN> FLASHBACK DATABASE TO SCN=23565;


RMAN> FLASHBACK DATABASE Monitor progress of Flashback
Database with the
2> TO SEQUENCE=223 THREAD=1; V$SESSION_LONGOPS view.

SQL> FLASHBACK DATABASE


2 TO TIMESTAMP(SYSDATE-1/24);
SQL> FLASHBACK DATABASE TO SCN 53943;
SQL> FLASHBACK DATABASE TO RESTORE POINT b4_load;

To review changes: Read-only opened database


To finalize: Read/write opened database with RESETLOGS

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Database Considerations

When the Flashback Database operation completes, open


the database:
In read-only mode to verify that the correct target time or
SCN was used
With a RESETLOGS operation to allow DML
The opposite of flash back is recover.
You cannot use Flashback Database in the following
situations:
The control file has been restored or re-created.
A tablespace has been dropped.
A data file has been reduced in size.
Use the TO BEFORE RESETLOGS clause to flash back to
before the last RESETLOGS operation.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring Flashback Database

To monitor the ability to meet your retention target:


View the Fast Recovery Area disk quota:
SQL> SELECT estimated_flashback_size,
2 flashback_size
3 FROM V$FLASHBACK_DATABASE_LOG;

Determine the current flashback window:

SQL> SELECT oldest_flashback_scn,


2 oldest_flashback_time
3 FROM V$FLASHBACK_DATABASE_LOG;

Monitor logging in the Flashback Database logs:


SQL> SELECT *
2 FROM V$FLASHBACK_DATABASE_STAT;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring Flashback Database with EM

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Guaranteed Restore Points

A guaranteed restore point ensures that you can perform a


FLASHBACK DATABASE command to that SCN at any time.

SQL> CREATE RESTORE POINT before_upgrade


2 GUARANTEE FLASHBACK DATABASE;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Flashback Database and
Guaranteed Restore Points
To use guaranteed restore points, the database must satisfy
the following prerequisites:
The COMPATIBLE initialization parameter must be set to
10.2 or greater.
The database must be running in ARCHIVELOG mode.
FLASHBACK DATABASE requires the use of archived redo
logs starting from around the time of the restore point.
A Fast Recovery Area must be configured.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Configurar o banco de dados de Flashback
Executar operaes de Flashback de banco de dados
Monitor Flashback Database

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Gerenciamento da Memria

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Apos concluir esta lio voc ser capaz de :

Descrever os componentes de memria na SGA


Implementar Gerenciamento automtico de memria
Configurao manual de parmetros SGA
Configurar o gerenciamento automtico de memria PGA

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Memory Management: Overview

DBAs deve considerar o gerenciamento de memria para ser


uma parte crucial do seu trabalho porque:

No existe uma quantidade finita de memria disponvel


Alocar mais memria para servir certos tipos de funes
podem melhorar o desempenho geral
Alocao de memria automaticamente sintonizado
muitas vezes a configurao adequada, mas ambientes
especficos ou mesmo condies de curto prazo podem
exigir mais ateno

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Reviso da Oracle estruturas de memria do
banco de dados

Stack User Stack User


space Global space Global
Area Area
Server Server
process 1 Program Global Area (PGA) process 2 PGA

Keep
Database buffer pool
Redo log
Shared pool buffer
buffer
cache Recycle
buffer pool
Streams nK buffer
Large pool Java pool
pool cache

System Global Area (SGA)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Buffer Cache
Pinned
Clean
Free/unused
SGA Dirty

Server LRU Checkpoint


lists queue DB buffer cache

. .
. .
. .
. .

DB_BLOCK_SIZE
DB_CACHE_SIZE

DBWn

Data files

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Usando vrios conjuntos de buffer

SGA
DB buffer caches
Recycle pool
DB_RECYCLE_CACHE_SIZE

Keep pool
DB_KEEP_CACHE_SIZE

Default pool
DB_CACHE_SIZE

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Usando vrios conjuntos de buffer

CREATE INDEX cust_idx


STORAGE (BUFFER_POOL KEEP);

ALTER TABLE oe.customers


STORAGE (BUFFER_POOL RECYCLE);

ALTER INDEX oe.cust_lname_ix


STORAGE (BUFFER_POOL KEEP);

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Shared Pool

Contedo:
Library cache: texto de comando, o cdigo analisado o
plano de execuo
Data dictionary cache: Definies para tabelas, colunas e
privilgios das tabelas de dicionrio de dados
Result Cache: Os resultados de consultas SQL e funes
PL / SQL
User Global Area (UGA): Shared Data dictionary
SQL area cache
As informaes da sesso para o
Servidor compartilhado da Oracle Result cache

Library UGA
cache

SHARED_POOL_SIZE Shared pool


SGA

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Large Pool

Fornece grandes alocaes de memria para:


Memria de sesso para o servidor compartilhado ea
interface do Oracle XA
I / O processos de servidor
O Oracle Database Backup e restaurao
Operaes de consulta paralela
Advanced Queuing armazenamento da tabela de memria
Reduz o potencial de fragmentao do pool compartilhado
gerido pela AMM e ASMM
dimensionado com o parmetro LARGE_POOL_SIZE

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Java Pool and Streams Pool
Java pool memory usada na memria do servidor para
todo o cdigo Java especficos de sesso e os dados na
JVM.
Streams pool memory utilizado exclusivamente pela
Oracle
Streams to:
Store buffered mensagens de filas
Fornecer memria para Oracle Streams processes
Keep
Database
Redo log buffer pool
Shared pool buffer
buffer
cache Recycle
buffer pool
Streams nK buffer
Large pool Java pool
pool cache

Java pool System Global Area (SGA) Streams pool

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Redo Log Buffer
um buffer circular no SGA
Contm informaes sobre as alteraes feitas no banco
de dados
Contm entradas de redo que tm a informao de refazer
as alteraes feitas por operaes como DML e DDL
Contedo transferido por processo escrito em log (LGWR):
Quando um processo de usurio comete uma transao
Quando o buffer de redo log um tero completo
Antes de um processo DBWn escreve buffers modificados
para o disco

LGWR

Redo log buffer LogWriter process Redo log files

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Automatic Memory Management: Overview
Com Gerenciamento automtico de memria, o tamanho do
banco de dados pode o SGA e PGA automaticamente de
acordo com a sua carga de trabalho.
11g 11g
350 MB 350 MB
Memory Memory
Max Target Max Target

300 MB
Memory Target

250 MB
Memory Target

ALTER SYSTEM SET


MEMORY_TARGET=300M;

A Oracle recomenda o uso de AMM, a menos que voc tem exigncias especiais.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Parmetros do Oracle Memory Database

MEMORY_MAX_TARGET

SGA_MAX_SIZE MEMORY_TARGET This enables AMM.

SGA_TARGET PGA_AGGREGATE_TARGET
This enables ASMM.
Changing SGA_TARGET
Child parameters:
affects only automatically Providing minimum values
sized components. Others
Automatic change of size only
LOG_BUFFER with autotuned parameters
SHARED_POOL_SIZE RESULT_CACHE_SIZE
DB_CACHE_SIZE
LARGE_POOL_SIZE DB_KEEP_CACHE_SIZE
JAVA_POOL_SIZE DB_RECYCLE_CACHE_SIZE
STREAMS_POOL_SIZE DB_nK_CACHE_SIZE

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoramento Gerenciamento automtico de
memria

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring Automatic Memory Management

Se voc quiser acompanhar as decises tomadas pelo


Gerenciamento automtico de memria atravs de uma linha
de comando:

V$MEMORY_DYNAMIC_COMPONENTS tem o status atual de


todos os componentes de memria
V$MEMORY_RESIZE_OPS tem uma histrico do buffer
circular dos ltimos 800 pedidos de redimensionamento de
memria
V$MEMORY_TARGET_ADVICE presta assessoria de ajuste
para o MEMORY_TARGET parmetro de inicializao.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Uso eficiente da memria : Guidelines

Montar o SGA em memria fsica.


Sintonize para uma cache de alta taxa de acerto, com as
seguintes ressalvas:
Mesmo varreduras de tabela cheia vlido e necessrio
reduzi-la.
possvel que desnecessrio repetir l os mesmos blocos
esto elevando artificialmente.
Use o Memory Advisors.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Memory Tuning Guidelines for the Library Cache

Establish formatting conventions for developers so that


SQL statements match in the cache.
Use bind variables.
Eliminate unnecessary duplicate SQL.
Consider using CURSOR_SHARING.
Use PL/SQL when possible.
Cache sequence numbers.
Pin objects in the library cache.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Automatic Shared Memory Management:
Overview
Automatically adapts to workload changes
Maximizes memory utilization
Helps eliminate out-of-memory errors

Buffer cache
Buffer cache

Example: Large pool


Large pool

Shared pool Shared pool

Java pool Java pool


Streams pool Streams pool
Online users Batch jobs

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
How ASMM Works

ASMM is based on workload information that MMON


captures 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

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Enabling Automatic Shared Memory Management

To enable ASMM from manual shared memory management:


1. Get a value for SGA_TARGET:
SELECT ((SELECT SUM(value) FROM V$SGA) - (SELECT CURRENT_SIZE
FROM V$SGA_DYNAMIC_FREE_MEMORY)) "SGA_TARGET" FROM DUAL;

2. Use that value to set SGA_TARGET.


3. Set the values of the automatically sized SGA components
to 0.
To switch to ASMM from Automatic Memory Management:
1. Set the MEMORY_TARGET initialization parameter to 0.
2. Set the values of the automatically sized SGA components
to 0.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Disabling ASMM

Setting SGA_TARGET to 0 disables autotuning.


Autotuned parameters are set to their current sizes.
The SGA size as a whole is unaffected.

SGA size = 8 GB SGA size = 8 GB


Parameters:
sga_target = 0
Parameters: db_cache_size = 5G
sga_target = 8G shared_pool_size = 2G
shared_pool_size = 1G large_pool_size = 512M
java_pool_size = 256M
Original values
streams_pool_size = 256M

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Program Global Area (PGA)

Server Private Cursor


PGA Session Work
process
SQL and SQL
memory area
areas area
Dedicated
connections PGA

Shared
PGA
server Shared pool
or PGA
Shared server large pool
connections

Automatic PGA memory management is enabled by default.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using the V$PARAMETER View

SGA_TARGET = 8G

DB_CACHE_SIZE = 0
JAVA_POOL_SIZE = 0
LARGE_POOL_SIZE = 0
SHARED_POOL_SIZE = 0
STREAMS_POOL_SIZE = 0

SELECT name, value, isdefault


FROM v$parameter
WHERE name LIKE '%size';

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Descrever os componentes de memria no SGA
Implementar o gerenciamento automtico de memria
Configurar manualmente os parmetros do SGA
Use o gerenciamento automtico de memria PGA

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Gerenciando o Desempenho do Banco de
Dados

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Depois de completar esta lio, voc deve ser capaz de :


Monitorar o desempenho das sesses e servios
Descrever os benefcios do Database Replay

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Tuning Activities

The three activities in performance management are:


Performance planning
Instance tuning
SQL tuning

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performance Planning

Investment options
System architecture
Scalability
Application design principles
Workload testing, modeling, and implementation
Deploying new applications

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Instance Tuning

Have well-defined goals.


Allocate memory to database structures.
Consider I/O requirements in each part of the database.
Tune the operating system for optimal performance of the
database.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performance Tuning Methodology

The tuning steps:


Tune from the top down. Tune:
1. The design
2. The application code
3. The instance
Tune the area with the greatest potential benefit. Identify
and tune:
SQL using the greatest resources
The longest waits
The largest service times
Stop tuning when the goal is met.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performance Monitoring

With Enterprise Manager:


Performance overview
Graphs of metrics and
details

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Performance Tuning Data

Type of data gathered:


Cumulative statistics:
Wait events with time information
Time model
Metrics: Statistic rates
Sampled statistics: Active session history
Statistics by session
Statistics by SQL
Statistics by service
Other dimensions

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Optimizer Statistics Collection

SQL performance tuning: Depends on collection of


accurate statistics
Optimizer statistics:
Object statistics
Operating system statistics
Ways to collect statistics:
Automatically: Automatic Maintenance Tasks
Manually: DBMS_STATS package
By setting database initialization parameters
By importing statistics from another database

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Statistic Preferences: Overview
Optimizer Statement level
statistics
Table level
gathering DBA_TAB_STAT_PREFS
task Schema level

Database level

Global level
CASCADE DEGREE
ESTIMATE_PERCENT METHOD_OPT
NO_INVALIDATE GRANULARITY
PUBLISH INCREMENTAL
STALE_PERCENT

set_global_prefs

set_database_prefs

set_schema_prefs

set_table_prefs

gather_*_stats DBA

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using Statistic Preferences

PUBLISH: Used to decide whether to publish the statistics


to the dictionary or to store them in a pending area before
STALE_PERCENT: Used to determine the threshold level
at which an object is considered to have stale statistics.
The value is a percentage of rows modified since the last
statistics gathering.
INCREMENTAL: Used to gather global statistics on
partitioned tables in an incremental way

exec dbms_stats.set_table_prefs('SH','SALES','STALE_PERCENT','13');

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Setting Global Preferences
with Enterprise Manager

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Oracle Wait Events

A collection of wait events provides information


about the sessions or processes that had to wait or must
wait for different reasons.
These events are listed in the V$EVENT_NAME view.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Instance Statistics

V$SYSSTAT V$SYSTEM_WAIT_CLASS V$SGASTAT


statistic# wait_class_id pool
name wait_class# name
class wait_class bytes
value total_waits
stat_id time_waited

V$EVENT_NAME
V$SYSTEM_EVENT
event_number
event
event_id
total_waits
name
total_timeouts
parameter1
time_waited
parameter2
average_wait
parameter3
time_waited_micro
wait_class

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring Session Performance

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Displaying Session-Related Statistics

V$STATNAME V$SESSTAT V$SESSION


statistic# sid sid
name statistic# serial#
class value username
command
osuser
seq#
event#
V$SESSION_EVENT V$EVENT_NAME event
sid event# p1/2/3text
event name p1/2/3
total_waits parameter1 p1/2/3raw
total_timeouts parameter2 wait_class
time_waited parameter3 wait_time
average_wait seconds_in_wait
max_wait state
time_waited_micro ...
event_id

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Displaying Service-Related Statistics

For n-tier environments, because session statistics are not as


helpful, you can see service-level statistics in these views:
V$SERVICE_EVENT: Aggregated wait counts and wait
times for each service, on a per event basis
V$SERVICE_WAIT_CLASS: Aggregated wait counts and
wait times for each service on a wait class basis

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Troubleshooting and Tuning Views

Instance/Database Disk
V$DATABASE V$DATAFILE
V$INSTANCE V$FILESTAT
V$PARAMETER V$LOG
V$SPPARAMETER V$LOG_HISTORY
V$SYSTEM_PARAMETER V$DBFILE
V$PROCESS V$TEMPFILE
V$BGPROCESS V$TEMPSEG_USAGE
V$PX_PROCESS_SYSSTAT V$SEGMENT_STATISTICS
V$SYSTEM_EVENT
Contention
Memory V$LOCK
V$BUFFER_POOL_STATISTICS V$UNDOSTAT
V$LIBRARYCACHE V$WAITSTAT
V$SGAINFO V$LATCH
V$PGASTAT

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Dictionary Views

The following dictionary and special views display object


statistics after use of the DBMS_STATS package:
DBA_TABLES, DBA_TAB_COLUMNS
DBA_CLUSTERS
DBA_INDEXES
DBA_TAB_HISTOGRAMS
This statistical information is static until you reexecute the
appropriate procedures in DBMS_STATS.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Automatic Workload Repository

ADDM finds
MMON
top problems.

SYSAUX
SGA
6:00 AM
Snapshot 1
In-memory 7:00 AM
Snapshot 2
statistics 8:00 AM Snapshot 3
9:00 AM
Snapshot 4

9:30 AM

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using Automatic Workload Repository Views

DBA_HIST_DB_CACHE_ADVICE
DBA_HIST_DISPATCHER
DBA_HIST_DYN_REMASTER_STATS
DBA_HIST_IOSTAT_DETAIL
DBA_HIST_SHARED_SERVER_SUMMARY

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Real Application Testing Overview:
Database Replay
Database Replay:
Captures production workloads
Tests with realistic workloads
Replays the same SQL against the same data in each test

Workload

Capture Replay

Production Test
database database

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
The Big Picture
Prechange production system Postchange test system

Clients/App servers
Capture directory Replay
system
Process capture files

Shadow capture file

Shadow capture file

Shadow capture file


Test
Production Shadow capture file system
system with
changes

Production Database Database


database backup restore
Can use Snapshot Standby as test system

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Monitorar o desempenho de sesses e servios
Descrever os benefcios da repetio de banco de dados

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Gerenciando o desempenho SQL Tuning

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Depois de completar esta lio, voc deve ser capaz de :


Use the SQL Tuning Advisor to:
Identificar instrues SQL que esto usando mais recursos
Ajustar instrues SQL que esto usando mais recursos
Use the SQL Access Advisor para ajustar uma carga de
trabalho

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
SQL Tuning

SQL tuning process


Identify poorly tuned SQL statements.
Tune the individual statements.
Tune the application as a whole.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
SQL Advisors

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Automatic SQL Tuning Results

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Implement Automatic Tuning
Recommendations

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
SQL Tuning Advisor: Overview

Comprehensive SQL tuning

Detect stale or missing


statistics

Tune SQL plan


(SQL profile)

SQL Tuning Add missing index


Advisor
Restructure SQL

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Usando o SQL Tuning Advisor

Use o SQL Tuning Advisor para analisar instrues SQL e


obter recomendaes de desempenho.
Sources for SQL Tuning Advisor to analyze:
Top Activity: Analisa as principais instrues SQL
atualmente ativo
SQL Tuning Sets: Analisa um conjunto de instrues SQL
que voc fornecer
Historical SQL (AWR): Analisa as instrues SQL de
depoimentos colhidos por snapshots do AWR

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
SQL Tuning Advisor Options

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
SQL Tuning Advisor Recommendations

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using the SQL Tuning Advisor: Example

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Duplicate SQL

Bind variable
candidates

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
SQL Access Advisor: Overview

Workload specification
Recommendations
-SQL statement
-Indexes
-SQL Tuning Set
-Materialized views
-SQL cache contents
-Materialized view logs
-Statistics
-Partitioning
-Schema name

SQL Access
Advisor

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Typical SQL Access Advisor Session

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Workload Source

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recommendation Options

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Recommendation Options

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Reviewing Recommendations

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
SQL Performance Analyzer: Overview

Targeted users: DBAs, QAs, application developers


Helps predict the impact of system changes on SQL
workload response time
Builds different versions of SQL workload performance
(that is, SQL execution plans and execution statistics)
Executes SQL serially (concurrency not honored)
Analyzes performance differences
Offers fine-grained performance analysis on individual
SQL
Is integrated with SQL Tuning Advisor to tune regressions

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
SQL Performance Analyzer: Use Cases

SQL Performance Analyzer is beneficial in the following use


cases:
Database upgrades
Implementation of tuning recommendations
Schema changes
Statistics gathering
Database parameter changes
OS and hardware changes
Accessible through Enterprise Manager and the DBMS_SQLPA
package

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using SQL Performance Analyzer

1. Capture SQL workload on production.


2. Transport the SQL workload to a test system.
3. Build before-change performance data.
4. Make changes.
5. Build after-change performance data.
6. Compare results from steps 3 and 5.
7. Tune regressed SQL.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Use o SQL Tuning Advisor para:
Identificar as instrues SQL que esto usando a maioria
dos recursos
Instrues SQL que esto usando a maioria dos recursos de
sintonia
Use o SQL Access Advisor para ajustar uma carga de
trabalho

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Gerenciando recursos

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Depois de completar esta lio, voc deve ser capaz de fazer o


seguinte: :
Configurar o Database Resource Manager
Acesso e criar planos de recursos
Criar grupos de consumidores
Especificar diretivas de alocao de recursos para grupos
de consumidores
Grupos de consumidores mapa para planos
Ativar um plano de recursos
Monitorar o Gerenciador de recursos

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Database Resource Manager: Overview

Use o Gerenciador de recursos para :


Gerenciar carga de trabalho mista
O desempenho do sistema de controle

Database
Resource Manager
OLTP users
More resources

DSS users
Fewer resources
Batch users
Least resources Oracle
database

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Database Resource Manager: Concepts

Os grupos de usurios ou
Resource
sesses com as
consumer necessidades de recursos
group semelhantes

Um modelo para a alocao


Resource plan de recursos entre grupos de
consumidores de recursos
(um plano ativo)

Especifica como um recurso


Resource plan
dividido entre os grupos
directives de consumidores de
recursos (no mbito dos
mtodos de alocao)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Por que usar o Resource Manager

Voc pode gerenciar banco de dados e sistema


operacional recursos, como : Access via:
Uso da CPU
EM
Grau de paralelismo
Nmero de sesses ativas
Desfazer gerao
Tempo de execuo da operao
DBMS_RESOURCE_MANA
GER package
Tempo ocioso
Consolidao do banco de dados
A consolidao de servidores
Voc tambm pode especificar critrios que, se cumpridos,
causam a comutao automtica de sesses para outro grupo
de consumidores.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Default Maintenance Resource Manager Plan

SQL> show parameter resource_manager_plan

NAME TYPE VALUE


---------------------- ------- ------------------------------------------
resource_manager_plan string SCHEDULER[0x2843]: DEFAULT_MAINTENANCE_PLAN

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Example: DEFAULT_PLAN

Allocation Methods
Resource Consumer
Group MGMT_P1 MGMT_P2 MGMT_P3

SYS_GROUP 100% 0% 0%

OTHER_GROUPS 0% 90% 0%

ORA$AUTOTASK_SUB_PLAN 0% 5% 0%

ORA$DIAGNOSTICS 0% 5% 0%

For automated
maintenance tasks

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Fluxo de Trabalho potencial
Seu fluxo de trabalho para objetos Manger recursos
obrigatrios :
Criao de um novo plano de recursos
Criao de um grupo de consumidores
Atribuir usurios a grupos
Especificando diretrizes do plano de recursos
A ativao de um plano de recursos

DBMS_RESOURCE_MANAGER.CREATE_
DBMS_RESOURCE_MANAGER_PRIVS.G
CONSUMER_GROUP(
RANT_SWITCH_CONSUMER_GROUP (
CONSUMER_GROUP => 'APPUSER',
grantee_name => 'PM',
MGMT_MTH => 'ROUND-ROBIN',
consumer_group => 'APPUSER',
COMMENT => '');
grant_option => FALSE );

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Especificando directivas do Plano de Recursos

1 2 3 4 5 6

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Mtodos de Alocao de Recursos para Planos
de Recursos
Parameter Possible Values
(Comments)
MGMT_MTH EMPHASIS, RATIO

Allocating CPU usage

PARALLEL_DEGREE_LIMIT_MTH PARALLEL_DEGREE_LIMIT_ABSOLUTE

Limiting degree of parallelism of any operation

ACTIVE_SESS_POOL_MTH PARALLEL_DEGREE_LIMIT_ABSOLUTE

Limiting number of active sessions, queuing inactive ones

QUEUING_MTH FIFO_TIMEOUT

Controlling queues, how inactive sessions enter active session pool

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Comparison of EMPHASIS and RATIO

EMPHASIS RATIO

The value specifies the maximum The value specifies a number that indicates
percentage of CPU resources a the ratio of CPU resources to be allocated to
consumer group can use. the consumer group.
You can allocate resources for up to 8 You can specify values for only one level.
different levels.
The sum of percentages at any given You must use integer values, but there is no
level must be less than or equal to 100. limit on the sum of values.
Default value is NULL. Default value is NULL.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Active Session Pool Mechanism

Sess4 Sess5 p001 p002 p003


Sess10

Sess3 Sess8
Sess9
Sess1 Sess2 Sess6 Sess7
DSS
active
session
queue
OLTP users DSS users
Active_sess_pool_P1=5 Active_sess_pool_P1=3

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Setting the Active Session Pool

50

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Specifying Thresholds

Specifying execution time limit:


Proactive estimation of the execution time for an operation
(via cost-based optimizer statistics), default: UNLIMITED
Specifying maximum estimated execution time at the
resource consumer group level
No start allowance for huge jobs, if the estimate is longer
than MAX_EST_EXEC_TIME:(ORA-07455)
Specifying other thresholds:
Limiting session I/O with SWITCH_IO_MEGABYTES (in MB)
Limiting session I/O requests with SWITCH_IO_REQS
Returning to original consumer group with SWITCH_FOR_CALL
(Default: FALSE, consumer group is not restored)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Setting Idle Timeouts

DBMS_RESOURCE_MANAGER.UPDATE_PLAN_DIRECTIVE
(PLAN => 'DAY_PLAN',
GROUP_OR_SUBPLAN => 'APPUSER',
COMMENT => 'Limit Idle Time Example',
NEW_MAX_IDLE_TIME => 600,
NEW_MAX_IDLE_BLOCKER_TIME => 300);

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Limiting CPU Utilization at the Database Level

Database consolidation requirements:


Applications isolated from each other
Consistent performance
CPU directives can be used to:
Specify a minimum CPU allocation for each application
Designate how unused allocations should be redistributed
Specify the MAX_UTILIZATION_LIMIT attribute to
impose an absolute upper limit on CPU utilization (which
overrides any redistribution of CPU within a plan)
Good candidate: Auto-maintenance tasks

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Limiting CPU Utilization at the Database Level

Specify minimum and maximum Specify maximum CPU utilization


CPU utilization limits. limits only.
DB Consolidation Plan #1 DB Consolidation Plan #2
CPU Maximum CPU Maximum
Allocation Utilization Limit Allocation Utilization Limit
App 1 50% 60% App 1 null 50%
App 2 20% 30% App 2 null 20%
App 3 20% 30% App 3 null 20%
App 4 10% 20% App 4 null 10%

EXEC DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE( -
plan => 'db_consolidation_plan',
group_or_subplan => 'App_1',
mgmt_p1 => 50,
max_utilization_limit => 60);

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Limiting CPU Utilization at the Server Level:
Instance Caging
Managing CPU allocations on a multi-CPU server with
multiple database instances
Enabling instance caging :
Enable any CPU resource plan.
alter system set resource_manager_plan = 'default_plan';
Specify the maximum number of CPUs that the instance can
use at any time. alter system set cpu_count=4;
Two approaches:
Over-provisioning: The sum of the CPU limit for each
instance exceeds the actual number of CPUs.
Partitioning: The sum of the CPU limit for each instance
equals the actual number of CPUs.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Instance Caging Examples

Over-provisioning approach: Partitioning approach:


One database instance One database instance
can still impact the others. cannot impact the others.
Sum of CPU_COUNTS settings = 32 Sum of CPU_COUNTS = 16

32 16 Total number
Instance D of CPUs = 16
Instance D
24 12 Instance C
Instance C Instance B
16 Total number
8
of CPUs = 16
Instance B
8 4 Instance A
Instance A

With all four instances active, Each instance has a


one instance can get dedicated number of CPUs.
4 / (4 + 4 + 4 + 4) = 25% of CPU.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring Instance Caging

View value of the CPU_COUNT parameter:


SELECT value FROM v$parameter WHERE name = 'cpu_count'
AND (isdefault = 'FALSE' OR ismodified != 'FALSE');

Determine the Resource Manager status:


SELECT name FROM v$rsrc_plan
WHERE is_top_plan = 'TRUE' AND cpu_managed = 'ON';

Manage throttling:
SELECT begin_time, consumer_group_name,
cpu_consumed_time, cpu_wait_time
FROM v$rsrcmgrmetric_history
ORDER BY begin_time;
SELECT name, consumed_cpu_time, cpu_wait_time
FROM v$rsrc_consumer_group;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Resource Consumer Group Mapping

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Activating a Resource Plan

EM > Server > Settings (in the Resource Manager section)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Database Resource Manager Information

View Name Information

DBA_RSRC_PLANS Plans and status

DBA_RSRC_PLAN_DIRECTIVES Plan directives

DBA_RSRC_CONSUMER_GROUPS Consumer groups

DBA_RSRC_CONSUMER_GROUP_PRIVS Users/roles

DBA_RSRC_GROUP_MAPPINGS Consumer group mapping

DBA_RSRC_MAPPING_PRIORITY Mapping priority

DBA_USERS Column
initial_rsrc_consumer_group
DBA_RSRC_MANAGER_SYSTEM_PRIVS Users/roles

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring the Resource Manager

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring the Resource Manager

V$SESSION: Contains the resource_consumer_group


column that shows the current group for a session
V$RSRC_PLAN: A view that shows the active resource plan
V$RSRC_CONSUMER_GROUP: A view that contains
statistics for all active groups

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como fazer o seguinte:


Configurar o Gerenciador de recursos de banco de dados
Acessar e criar planos de recursos
Criar grupos de consumidores
Especificar diretivas de atribuio de recursos para grupos
de consumidores
Mapa de grupos de consumidores de planos
Ativar um plano de recurso
Monitorar o Gerenciador de recursos

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Automatizando tarefas

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos
Depois de completar esta lio, voc deve ser capaz de :
Simplifique as tarefas de gerenciamento usando o
Scheduler
Crie um trabalho, programa e cronograma
Monitorar a execuo do trabalho
Use uma programao baseada em eventos, com base no
tempo ou para a execuo de trabalhos do Agendador
Descrever o uso de janelas, grupos de janelas, classes de
trabalho e grupos de consumidores
Use a notificao de e-mail
Use as correntes de trabalho para realizar uma srie de
tarefas relacionadas
Descreva atividades Scheduler em sistemas remotos
Use conceitos Programador Avanado de priorizar
atividades

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Simplifying Management Tasks

Performing a series Running a dequeue


Replicating table data
of month-end procedure as soon
via materialized
tasks on the last as a message is
day of each month enqueued view refreshes

Running a daily Computing table


job to back up and index statistics
database twice a day

Generating an Rebuilding an
Starting the batch
hourly report on index when
load as soon as the file
invalid server finished rebuilding
arrives on the file system access attempts the current index

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Core Components

Job
Program Schedule
attributes

Job

Arguments

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Your Basic Work Flow

To simplify management tasks with the Scheduler:


1. Create a program (enabled or disabled)optional
- To reuse this action within multiple jobs
- To change the schedule for a job without having to
re-create the PL/SQL block
2. Create and use a schedule.
3. Create and submit a job.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Persistent Lightweight Jobs

Persistent lightweight jobs:


Reduce the overhead and time required to start a job
Have a small footprint on disk for the job metadata and for
storing run-time data
Are created from a job template (in the command line)
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'my_lightweight_job2',
program_name => 'MY_PROG',
schedule_name => 'MY_SCHED',
job_style => 'LIGHTWEIGHT');
END;
/
Choosing the right job:
Use regular jobs for maximum flexibility.
Use persistent lightweight jobs when you need to create a large
number of jobs in a very short time.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using a Time-Based or Event-Based Schedule

Schedule

Time
-Calendaring expression Event
-Date-time expression

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating a Time-Based Job

Example: Create a job that calls a backup script every night at


11:00, starting tonight.

BEGIN
DBMS_SCHEDULER.CREATE_JOB(
job_name=>'HR.DO_BACKUP',
job_type => 'EXECUTABLE',
job_action =>
'/home/usr/dba/rman/nightly_incr.sh',
start_date=> SYSDATE,
repeat_interval=>'FREQ=DAILY;BYHOUR=23',
/* next night at 11:00 PM */
comments => 'Nightly incremental backups');
END;
/

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating an Event-Based Schedule

To create an event-based job, you must set:


A queue specification (where your application enqueues
messages to start a job)
An event condition (same syntax as an Oracle Streams AQ
rule condition) that if TRUE starts the job

Oracle Database

Scheduler

Event ADT
(Abstract
Application Queue
Data Type)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Event-Based Schedules
with Enterprise Manager

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating an Event-Based Job

Example: Create a job that runs if a batch load data file arrives
on the file system before 9:00 AM.
BEGIN
DBMS_SCHEDULER.CREATE_JOB(
job_name=>'ADMIN.PERFORM_DATA_LOAD',
job_type => 'EXECUTABLE',
job_action => '/loaddir/start_my_load.sh',
start_date => SYSTIMESTAMP,
event_condition => 'tab.user_data.object_owner =
event_condition => 'tab.user_data.object_owner
''HR'' and tab.user_data.object_name =
= ''DATA.TXT''
''HR''
and and tab.user_data.object_name
tab.user_data.event_type = ''DATA.TXT''
= ''FILE_ARRIVAL''
and tab.user_data.event_timestamp
and tab.user_data.event_type = ''FILE_ARRIVAL''
< 9 ',
and tab.user_data.event_timestamp
queue_spec < 9 ',
=> 'HR.LOAD_JOB_EVENT_Q');
queue_spec => 'HR.LOAD_JOB_EVENT_Q');
END;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Event-Based Scheduling

Event types:
User- or application-generated events
Scheduler-generated events
Events raised by Scheduler jobs:
JOB_STARTED JOB_SCH_LIM_REACHED
JOB_SUCCEEDED JOB_DISABLED
JOB_FAILED JOB_CHAIN_STALLED
JOB_BROKEN JOB_ALL_EVENTS
JOB_COMPLETED JOB_RUN_COMPLETED
JOB_STOPPED JOB_OVER_MAX_DUR
Example of raising an event:

DBMS_SCHEDULER.SET_ATTRIBUTE('hr.do_backup',
'raise_events', DBMS_SCHEDULER.JOB_FAILED);

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Complex Schedules

INCLUDE EXCLUDE INTERSECT

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using Email Notification

Email notifications for change of job state


Triggered by job state events
Multiple notifications, multiple recipients
*_SCHEDULER_NOTIFICATIONS views
Using Scheduler Email Notification:
1. Specify the address of the SMTP server you will use to
send email messages:
DBMS_SCHEDULER.SET_SCHEDULER_ATTRIBUTE
('email_server','host[:port]');

2. Optionally, set a default sender email address:


DBMS_SCHEDULER.SET_SCHEDULER_ATTRIBUTE
('email_sender','valid email address');
3. Add email notifications for a specified job. (continued)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Adding and Removing Email Notifications

DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION (
job_name IN VARCHAR2, Comma-separated list of
recipients IN VARCHAR2, email addresses
sender IN VARCHAR2 DEFAULT NULL,
subject IN VARCHAR2
DEFAULT dbms_scheduler.default_notification_subject,
body IN VARCHAR2
DEFAULT dbms_scheduler.default_notification_body,
events IN VARCHAR2 Mandatory comma-separated list
DEFAULT 'JOB_FAILED,JOB_BROKEN,JOB_SCH_LIM_REACHED,
JOB_CHAIN_STALLED,JOB_OVER_MAX_DUR',
filter_condition IN VARCHAR2 DEFAULT NULL);

DBMS_SCHEDULER.REMOVE_JOB_EMAIL_NOTIFICATION (
job_name IN VARCHAR2,
recipients IN VARCHAR2 DEFAULT NULL,
events IN VARCHAR2 DEFAULT NULL);

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Job Chains

1. Create a chain object.


Job chain
2. Define chain steps.
3. Define chain rules.
4. Starting the chain:
Enable the chain.
Job
Create a job that points to the chain.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Example of a Chain

Dependency scheduling

START
Job Load_data_evt 1 Do_bulk_load 2

Stop_when_
Rebuild_indx
Schedule disk_full_evt 5 3

Run_reports
END
(HR.GEN_REPORTS)
4

BULK_LOAD_CHAIN

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Advanced Scheduler Concepts

Resource DB
consumer service Resource Window
group name plan group

Job chain Job class Window

Program Job Schedule

Arguments Arguments Time Event

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Job Classes

Assign the same set of attribute values to member jobs


Are created by the CREATE_JOB_CLASS procedure
Specify jobs in a job class (with the SET_ATTRIBUTE
procedure )
Belong to the SYS schema
Set resource allocation for member jobs
Set the service attribute to a desired database service
name Resource DB
consumer group
Group jobs for prioritization Default:
service
DEFAULT_CONSUMER_GROUP name

Job class
Default: DEFAULT_JOB_CLASS

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Windows

Scheduler windows:
Can start jobs or change resource allocation among jobs
for various time periods
One active at a time
Created with the CREATE_WINDOW procedure

Resource
Resource
plan
consumer group

Window
Job class

Job

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Prioritizing Jobs Within a Window

Prioritizing jobs:
At the class level (via resource plans)
At the job level (with the job priority attribute)
Not guaranteed for jobs in different job classes

Job Priority
Job1 Job2
Job1 1
APPL_JOBS
Job3 Job2 2

Job4 Job5 OTHER Job3 3

ADMIN_JOBS Job4 5

Daytime window Job5 2

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating a Job Array

1. Declare variables of types sys.job and


sys.job_array:
DECLARE
newjob sys.job;
newjobarr sys.job_array;

2. Initialize the job array:


BEGIN
newjobarr := SYS.JOB_ARRAY();

3. Size the job array to hold the number of jobs needed:


newjobarr.EXTEND(100);

( continued)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating a Job Array

4. Place jobs in the job array:


FOR i IN 1..100 LOOP
newjob := SYS.JOB(job_name => 'LWTJK'||to_char(i),
job_style => 'LIGHTWEIGHT',
job_template => 'MY_PROG',
enabled => TRUE );
newjobarr(i) := newjob;
END LOOP;

5. Submit the job array as one transaction:


DBMS_SCHEDULER.CREATE_JOBS(newjobarr,
'TRANSACTIONAL');

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating a File Watcher and an Event-Based Job

Perform the following tasks:


1. Create a Scheduler credential object and grant EXECUTE.
2. Create a file watcher and grant EXECUTE.
3. Create a Scheduler program object with a metadata
argument that references the event message.
4. Create an event-based job that references the file
watcher. (Optionally, enable the job to run for each
instance of the file arrival event.)
5. Enable the file watcher, the program, and the job.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Enabling File Arrival Events from Remote
Systems
Perform the following tasks to enable the raising of file arrival
events at remote systems:
1. Set up the database to run remote external jobs.
2. Install, configure, register, and start the Scheduler agent
on the first remote system.
3. Repeat step 2 for each additional remote system.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Scheduling Remote Database Jobs

Create a job that runs stored procedures and anonymous


PL/SQL blocks on another database instance on the same
host or a remote host.
The target database can be any release of Oracle
Database.
DBMS_SCHEDULER.CREATE_DATABASE_DESTINATION
and DBMS_SCHEDULER.CREATE_CREDENTIAL can be
used for remote database jobs.
Jobs with job types of PLSQL_BLOCK and
STORED_PROCEDURE can be the subject of
SET_ATTRIBUTE calls for the DESTINATION and
CREDENTIAL attributes.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Remote Database Jobs

Perform the following tasks to create a remote job:


1. Set up the originating database for remote jobs.
2. Create the job by using DBMS_SCHEDULER.CREATE_JOB.
3. Create a credential by using
DBMS_SCHEDULER.CREATE_CREDENTIAL.
4. Set the job CREDENTIAL_NAME attribute by using
DBMS_SCHEDULER.SET_ATTRIBUTE.
5. Set the job DESTINATION attribute by using
DBMS_SCHEDULER.SET ATTRIBUTE.
6. Enable the job by using DBMS_SCHEDULER.ENABLE.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Scheduling Multiple Destination Jobs

This enables you to specify several targets on which your


jobs should execute.
It provides the ability to monitor and control the jobs from
the database on which they were created.
While running, a multiple-destination job is viewed as a
collection of jobs, which are near-identical copies of each
other.
All jobs will execute based on the time zone that is
specified in the start date of the job or will use the time
zone of the source database.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Viewing Scheduler Meta Data

Major Scheduler management views, displaying:


*_SCHEDULER_JOBS: All jobs, enabled and disabled
*_SCHEDULER_SCHEDULES: All schedules
*_SCHEDULER_PROGRAMS: All programs
*_SCHEDULER_RUNNING_JOBS: Active job states
*_SCHEDULER_JOB_LOG: All job state changes
*_SCHEDULER_JOB_RUN_DETAILS: All completed job runs
SELECT job_name, status, error#, run_duration
FROM USER_SCHEDULER_JOB_RUN_DETAILS;

JOB_NAME STATUS ERROR# RUN_DURATION


---------------- ------ ------ ------------
GATHER_STATS_JOB SUCCESS 0 +000 00:08:20
PART_EXCHANGE_JOB FAILURE 6576 +000 00:00:00

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Simplificar tarefas de gerenciamento usando o Agendador
Criar uma Atividade, programa e horrio
Execuo das Atividades monitorada
Usar um cronograma baseado em tempo ou evento para a
execuo de trabalhos de Agendador
Descrever o uso de janelas, janela grupos, classes de
trabalho e grupos de consumidores
Use o e-mail de notificao
Usar correntes de trabalho para executar uma srie de
tarefas relacionadas
Descrever empregos Agendador em sistemas remotos
Usar conceitos avanados de Agendador para priorizar os
trabalhos

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Gerenciando a Capacidade de
Armazenamento

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Depois de completar esta lio, voc deve ser capaz de :


Descreva como o servidor de banco de dados Oracle
gerencia automaticamente o espao
Economize espao usando a compactao
Proativamente monitorar e gerenciar o uso do espao de
tabela
Descreva criao segmento no banco de dados Oracle
Controle adiada criao segmento
Use o Segment Advisor
Recuperar o espao perdido de tabelas e ndices usando
a funcionalidade de reduo de segmento
Gerenciar alocao de espao resumable

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Space Management: Overview

Space is automatically managed by the Oracle database


server. It generates alerts about potential problems and
recommends possible solutions. Features include:
Oracle Managed Files (OMF)
Free-space management with bitmaps (locally managed)
and automatic data file extension
Proactive space management (default thresholds and
server-generated alerts)
Space reclamation (shrinking segments, online table
redefinition)
Capacity planning (growth reports)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Block Space Management

PCTFREE = 10

FS2

FS3

FS1
FS1

FS2
Inserts, Deletes Deletes
updates FS3

FS4
Full block Full block

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Row Chaining and Migration

Example:
On update: Row length increases,
exceeding the available free space Old
in the block.
Data needs to be stored in a new block. Original block
Original physical identifier of row with pointer
(ROWID) is preserved. to migrated
row
The Oracle database server needs
to read two blocks to retrieve data.
The Segment Advisor finds segments New data
containing the migrated rows.
There is automatic coalescing of fragmented
free space inside the block.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Free Space Management Within Segments

BMB BMB BMB BMB Tracked by bitmaps in


segments
BMB BMB
Benefits:
BMB
More flexible space
utilization
Run-time adjustment

Multiple process
search of BMBs

Data
block

Extent
Segment

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Types of Segments

A segment is a set of extents allocated for a certain logical


structure. The different types of segments include:
Table and cluster segments
Index segment
Undo segment
Temporary segment
Segments are dynamically allocated by the Oracle database
server.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Allocating Extents

Searching the data files bitmap for the required number of


adjacent free blocks
Sizing extents with storage clauses:
UNIFORM
AUTOALLOCATE
Viewing extent map
Obtaining deallocation
advice

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Allocating Space

New space allocation method:


DEFERRED_SEGMENT_CREATION = TRUE (default)
1. Table creation > Data dictionary operation
2. DML > Segment creation

CREATE TABLE INSERT INTO

Saving disk space


Improving installation time
of big applications

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating Tables Without Segments

SQL> SHOW PARAMETERS deferred_segment_creation


NAME TYPE VALUE
------------------------------------ ----------- ------
deferred_segment_creation boolean TRUE

SQL> CREATE TABLE seg_test(c number, d varchar2(500));


Table created.
SQL> SELECT segment_name FROM user_segments;
no rows selected

Inserting rows and creating segments:


SQL> INSERT INTO seg_test VALUES(1, 'aaaaaaa');
1 row created.

SQL> SELECT segment_name FROM user_segments;


SEGMENT_NAME
-------------------------------------------------------
SEG_TEST

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Controlling Deferred Segment Creation

With the DEFERRED_SEGMENT_CREATION parameter in the:


Initialization file
ALTER SESSION command
ALTER SYSTEM command
With the SEGMENT CREATION clause:
IMMEDIATE
DEFERRED (default in Oracle Database 11gR2)
CREATE TABLE SEG_TAB3(C1 number, C2 number)
SEGMENT CREATION IMMEDIATE TABLESPACE SEG_TBS;
CREATE TABLE SEG_TAB4(C1 number, C2 number)
SEGMENT CREATION DEFERRED;

Note: Indexes inherit table characteristics.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Restrictions and Exceptions

Segment creation on demand:


Only for nonpartitioned tables and indexes
Not for IOTs, clustered tables, or other special tables
Not for tables in dictionary-managed tablespaces

Note: If you were to migrate a table without segments from


a locally managed to a dictionary-managed tablespace,
you must drop and re-create it.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Additional Automatic Functionality

Without user intervention:


No segments for unusable indexes and index partitions
Creating an index without a segment:
CREATE INDEX test_i1 ON seg_test(c) UNUSABLE;
Removing any allocated space for an index:
ALTER INDEX test_i UNUSABLE;
Creating the segment for an index:
ALTER INDEX test_i REBUILD;

SELECT segment_name, partition_name,


segment_type
FROM user_segments
WHERE segment_name like '%DEMO';

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Table Compression: Overview

Reducing storage costs by compressing all data:


Basic compression for direct-path insert operations: 10x
OLTP compression for all DML operations: 24x

{ COMPRESS [ BASIC | FOR { OLTP} ] | NOCOMPRESS }

Compression Compress CPU CREATE and ALTER Typical


Method ion Ratio Overhead TABLE Syntax Applica
tions
Basic table High Minimal COMPRESS [BASIC] DSS
compression

OLTP table High Minimal COMPRESS FOR OLTP OLTP,


compression DSS

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Compression for Direct-Path Insert Operations

Is enabled with CREATE TABLE COMPRESS BASIC ;


Is recommended for bulk loading data warehouses
Replaces deprecated COMPRESS FOR DIRECT_LOAD
OPERATIONS
Maximizes contiguous free space in blocks

Header
PCTFREE
=0
Uncompressed

Free
data

space

Compressed
data

Data block
Inserts are PCTFREE reached Inserts are again PCTFREE reached
uncompressed. triggers compression. uncompressed. triggers compression.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
OLTP Compression for DML Operations

Is enabled with
CREATE TABLE COMPRESS FOR OLTP ;
Is recommended for active OLTP environments
Replaces deprecated COMPRESS FOR ALL OPERATIONS

G Y
Y Y Y Y Y Y
G Y G G Y G
G Y Y G G Y Y G
Uncompressed OLTP compression with symbol table at
block the beginning of the block

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Specifying Table Compression

You can specify table You cannot :


compression for: Specify basic and OLTP
An entire heap-organized compression on tables with
table more than 255 columns
A partitioned table (Each Drop a column if a table is
partition can have a different compressed for direct-loads,
type or level of but you can drop it if the
compression.) table is OLTP compressed
The storage of a nested
table

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using the Compression Advisor

The compression advisor:


Analyzes objects to give an estimate of space savings for
different compression methods
Helps in deciding the correct compression level for an
application
Recommends various strategies for compression
Picks the right compression algorithm for a particular data
set
Sorts on a particular column for increasing the compression
ratio
Presents tradeoffs between different compression algorithms
Works for OLTP compression (via EM)

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using the DBMS_COMPRESSION Package

To determine optimal compression ratios:


BEGIN
DBMS_COMPRESSION.GET_COMPRESSION_RATIO ('USERS','SH','SALES',
NULL,DBMS_COMPRESSION.COMP_FOR_OLTP, blkcnt_cmp, blkcnt_uncmp,
rowcnt_cmp, rowcnt_uncmp, comptype);
DBMS_OUTPUT.PUT_LINE('Blk count compressed = ' || blkcnt_cmp);
DBMS_OUTPUT.PUT_LINE('Blk count uncompressed = ' ||
blkcnt_uncmp);
DBMS_OUTPUT.PUT_LINE('Row count per block compressed = ' ||
rowcnt_cmp);
DBMS_OUTPUT.PUT_LINE('Row count per block uncompressed = ' ||
rowcnt_uncmp);
DBMS_OUTPUT.PUT_LINE('Compression type = ' || comptype);
DBMS_OUTPUT.PUT_LINE('Compression ratio =
'||blkcnt_uncmp/blkcnt_cmp||' to 1');

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Compressing Table Data

Compression Compress CPU CREATE and ALTER Typical


Method ion Ratio Overhead TABLE Syntax Applica
tions
Basic table High Minimal COMPRESS [BASIC] DSS
compression

OLTP table High Minimal COMPRESS FOR OLTP OLTP,


compression DSS

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Proactive Tablespace Monitoring

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Thresholds and Resolving Space Problems

97% full or 5 MB left


critical
Alert
85% full or 100 MB left DBA
warning
Resolve space
Locally managed tablespace problem
Resolve space problem by:
Adding or resizing data file
Setting AUTOEXTEND ON
Shrinking objects
Reducing UNDO_RETENTION
Checking for long-running queries in temporary
tablespaces

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Monitoring Tablespace Space Usage

Check every 10 min.


97% Critical Cleared
Alert
85% Warning Cleared
Alert

MMON

Read-only and offline tablespaces: Do not set up alerts.


Temporary tablespace: Threshold corresponds to space
currently used by sessions.
Undo tablespace: Threshold corresponds to space used by
active and unexpired extents.
Autoextensible files: Threshold is based on the maximum
file size.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Shrinking Segments

HWM

1 ALTER TABLE employees SHRINK SPACE COMPACT;

HWM
DML operations and queries can be issued during compaction.
2 ALTER TABLE employees SHRINK SPACE;

HWM
DML operations are blocked when the HWM is adjusted.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Results of Shrink Operation

Improved performance and space utilization


Indexes maintained
Triggers not executed
Number of migrated rows may be reduced.
Rebuilding secondary indexes on IOTs recommended

Index

Table Shrink
DBA

Triggers not executed

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Reclaiming Space Within ASSM Segments

Online and in-place operation


Applicable only to segments residing in ASSM tablespaces
Candidate segment types:
Heap-organized tables and index-organized tables
Indexes
Partitions and subpartitions
Materialized views and materialized view logs

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Segment Advisor: Overview

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Segment Advisor

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Implementing Recommendations

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Automatic Segment Advisor

The Automatic Segment Advisor:


Is started by a Scheduler job set to run during the default
maintenance window:
Weeknights, MondayFriday, from 10:00 PM to 2:00 AM
Saturday and Sunday, both windows start at 6:00 AM and
last for 20 hours
Examines database statistics, samples segment data, and
then selects the following objects to analyze:
Tablespaces that have exceeded a critical or warning
threshold
Segments that have the most activity
Segments that have the highest growth rate

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Manual Segment Shrink Using EM

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Shrinking Segments Using SQL

ALTER SHRINK SPACE [CASCADE][COMPACT]

TABLE [OVERFLOW] INDEX MATERIALIZED VIEW MATERIALIZED VIEW LOG

MODIFY PARTITION MODIFY SUBPARTITION MODIFY LOB

1 ALTER TABLE employees ENABLE ROW MOVEMENT;

2 ALTER TABLE employees SHRINK SPACE CASCADE;

ALTER TABLE employees MODIFY LOB(resume) (SHRINK


3 SPACE);

4 ALTER TABLE employees OVERFLOW SHRINK SPACE;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Managing Resumable Space Allocation

A resumable statement:
Enables you to suspend large operations instead of
receiving an error
Gives you a chance to fix the problem while the operation
is suspended, rather than starting over
Is suspended for the following conditions:
Out of space
Maximum extents reached
Space quota exceeded
A resumable statement can be suspended and resumed
multiple times.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using Resumable Space Allocation

Queries, DML operations, and certain DDL operations can


be resumed if they encounter an out-of-space error.
A resumable statement can be issued through SQL,
PL/SQL, SQL*Loader and Data Pump utilities, or the
Oracle Call Interface (OCI).
A statement executes in a resumable mode only if its
session has been enabled by one of the following actions:
The RESUMABLE_TIMEOUT initialization parameter is set to a
nonzero value.
An ALTER SESSION ENABLE RESUMABLE statement is
issued:
ALTER SESSION ENABLE RESUMABLE;
INSERT INTO sales_new SELECT * FROM sh.sales;
ALTER SESSION DISABLE RESUMABLE;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Resuming Suspended Statements

1 SQL statement

Full table

2 Suspended

Continue
SQL 3 4
Optionally
operation

5 Table AFTER
with free SUSPEND Abort
space trigger

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
What Operations Are Resumable?

The following operations are resumable:


Queries: SELECT statements that run out of temporary
space (for sort areas)
DML: INSERT, UPDATE, and DELETE statements
The following DDL statements:
CREATE TABLE ... AS SELECT
CREATE INDEX
ALTER INDEX ... REBUILD
ALTER TABLE ... MOVE PARTITION
ALTER TABLE ... SPLIT PARTITION
ALTER INDEX ... REBUILD PARTITION
ALTER INDEX ... SPLIT PARTITION
CREATE MATERIALIZED VIEW

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Descrever como o servidor de banco de dados Oracle
gerencia automaticamente o espao
Economizar espao usando compresso
Proativamente, monitorar e gerenciar o uso do espao no
tablespace
Descrever a criao de segmento no banco de dados
Oracle
Controlar a criao de segmento diferidos
Use o supervisor de segmento
Recuperar o espao desperdiado de tabelas e ndices
usando o segmento encolhem a funcionalidade
Gerenciar a alocao de espao retomvel

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Gerenciando Espao do Banco de Dados

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Depois de completar esta lio, voc deve ser capaz de :


Descrever os conceitos e uso de 4 discos KB do setor
Use tablespaces transportveis
Descrever os conceitos de bancos de dados
transportveis

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Database Storage

Instance
SMON PMON RECO Others

SGA
Database Redo log
Shared pool
buffer cache buffer
PGA
Server
DBWn CKPT LGWR ARCn
process

User
process Control Online redo
Data files files log files Archived
Database log files

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Supporting 4-KB Sector Disks

Emulation mode:
LBA0 LBA1 LBA2 LBA3 LBA4 LBA5 LBA6 LBA7

4,096-byte physical sector

Native mode:
Logical sector
LBA0

4,096-byte physical sector

Physical sector

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using 4-KB Sector Disks

Emulation mode: Native mode:


Recommended 4-KB block Mandatory 4-KB block size
size for logs for logs
Recommended 4-KB block Mandatory 4-KB block size
size (or larger) for data files (or larger) for data files
Not affected:
Control file block size: 16 KB

Control Online redo Archived


Data files files log files log files
Database

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Specifying the Disk Sector Size

Using the SECTOR_SIZE and BLOCKSIZE clauses of the


following commands:
CREATE DISKGROUP Tamanho do setor padro
baseado em hardware (e
ALTER DATABASE no os setores anteriores
512 bytes)
CREATE DATABASE
CREATE CONTROL FILE
CREATE DATABASE sample NORESETLOGS FORCE LOGGING
ARCHIVELOG
LOGFILE
GROUP 1 '$ORACLE_BASE/oradata/sample/redo01.log'
SIZE 100M BLOCKSIZE 4096,
GROUP 2 '$ORACLE_BASE/oradata/sample/redo02.log
SIZE 100M BLOCKSIZE 4096
DATAFILE
...

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Transporting Tablespaces

Cross-platform transportable tablespaces:


Simplify moving data between data warehouse and data
marts
Allow database migration from one platform to another
Supported platforms include:
Solaris[tm] OE (32-bit) HP-UX (64-bit) Microsoft Windows IA (64-bit)

Solaris[tm] OE (64-bit) HP Tru64 UNIX IBM zSeries Based Linux

Microsoft Windows IA (32-bit) HP-UX IA (64-bit) Linux 64-bit for AMD

Linux IA (32-bit) Linux IA (64-bit) Apple Mac OS

AIX-Based Systems (64-bit) HP Open VMS Microsoft Windows 64-bit AMD

IBM Power Based Linux HP IA Open VMS Solaris x86 and AMD64

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Concept: Minimum Compatibility Level

Both source and target databases must have


COMPATIBLE set to 10.0.0 or higher.
Data file headers are platform-aware.
Before transporting, make sure that all read-only and
offline files are platform-aware.

Read/ Read/
write write

Read- Read- Read/ Read-


only only write only
COMPATIBLE=9.2.0 COMPATIBLE=10.0.0

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Minimum Compatibility Level

Minimum Compatibility Setting


Source Database Target Database
Transport Scenario
Databases on the same platform 8.0 8.0
Tablespace with different database block 9.0 9.0
size than the target database
Databases on different platforms 10.0 10.0

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Transportable Tablespace Procedure

Source Make tablespaces read-only.

Use Data Pump to extract metadata.

Target
uses the same No
endian format?
Convert data files
by using RMAN.
Yes

Ship data files and dump file to target.

Use Data Pump to import metadata.

Target Make tablespaces read/write.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Determining the Endian Format of a Platform

SELECT tp.endian_format
FROM v$transportable_platform tp, v$database d
WHERE tp.platform_name = d.platform_name;

Source Target

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using the RMAN CONVERT Command

RMAN:
Converts tablespaces, data files, or databases to the
format of a destination platform
Does not change input files
Writes converted files to output destination
CONNECT TARGET SYS@orcl
RMAN>
SQL 'ALTER TABLESPACE hr READ ONLY';
CONVERT TABLESPACE hr
TO PLATFORM 'Solaris[tm] OE (64-bit)'
FORMAT '/tmp/transport_to_solaris/%U';;

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Transportable Tablespaces with
Enterprise Manager

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Transportable Tablespaces with
Enterprise Manager

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Transportable Tablespaces with
Enterprise Manager

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Transporting Databases

Generalize the transportable tablespace feature.


Data subsets can easily be distributed from a data
warehousing environment to data marts, which are usually
on smaller platforms.
A database can be migrated from one platform to another
very quickly.

Platform X Same endianness Platform Y

Database files transfer

Existing database New database

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Database Transportation Procedure:
Source System Conversion

Open database in READ ONLY mode


and COMPATIBLE=10.0.0 or higher.

Ship
Read- Read- Read- Read-
files only only
only CONVERT only
DATABASE
TO PLATFORM

Source Target
system system

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Database Transportation Procedure:
Target System Conversion

Open database in READ ONLY mode


and COMPATIBLE=10.0.0 or higher

CONVERT
DATABASE Read- Ship Read- Read- Read-
ON DESTINATION only only only only
files
PLATFORM

Source Target
system system

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Database Transportation: Considerations

Create the password file on the target platform.


Transport the BFILEs used in the source database.
The generated PFILE and transport script use OMF.
Use DBNEWID to change the DBID.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Descrevem os conceitos e o uso de discos de KB-setor 4
Descrever os conceitos de tablespaces transportveis e
bancos de dados

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Duplicao de um banco de dados

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Objetivos

Aps concluir esta lio, voc deve ser capaz de:


Lista de efeitos de criao de um banco de dados
duplicado
Escolher uma tcnica para duplicar a um banco de dados
Duplicar um banco de dados com o RMAN
Use um backup RMAN para duplicar um banco de dados
Duplicar um banco de dados com base em uma instncia
em execuo

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using a Duplicate Database

Using a duplicate database to:


Test backup and recovery procedures
Recover objects by creating an export and importing the
objects into the production database
Creating a duplicate database:
With the RMAN DUPLICATE command
On the same or separate hosts
With the identical content, or subset of source
Performed by auxiliary channels for backup-up based
duplication
Performed by target channels for active database duplication

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Choosing Database Duplication Techniques

Choosing a technique to duplicate your databasealways with


connection to the auxiliary instance:

From an active database,


connected to the target instance

With target
connection

From backups With recovery


catalog connection
Without target
connection
Without recovery
catalog connection

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Duplicating an Active Database

With network (no backups required)


Including customized SPFILE
Via Enterprise Manager or RMAN command line
Source Auxiliary
instance instance

Connect Connect
Source Duplicate
target auxiliary
database database

Source host Destination


host
RMAN client

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Duplicating a Database with a Target Connection

Connecting to the target (source database)


Connecting to the auxiliary instance
Optionally, connecting to the recovery catalog (or using
target control file)
Source Auxiliary
instance instance
RMAN
backups

Connect Connect
Source Duplicate
target auxiliary
database database

Source host Destination


host
RMAN client

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Duplicating a Database with Recovery Catalog
Without Target Connection
Connecting to a recovery catalog for backup metadata
Connecting to the auxiliary instance, which must have
access to the RMAN backups
Catalog Auxiliary
instance RMAN instance
backups

Connect Connect
Recovery Duplicate
catalog auxiliary
catalog database
database

Recovery Destination
catalog host host
RMAN client

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Duplicating a Database Without Recovery
Catalog or Target Connection
Connecting to the auxiliary instance, which must have access
to a disk BACKUP LOCATION

Auxiliary
instance

Backup location

Duplicate
database
Connect
auxiliary
Destination
host
RMAN client

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating a Backup-Based Duplicate Database

1. Create an Oracle password file for the auxiliary instance.


2. Establish Oracle Net connectivity to the auxiliary instance.
3. Create an initialization parameter file for the auxiliary
instance.
4. Start the auxiliary instance in NOMOUNT mode.
5. Mount or open the target database.
6. Ensure that backups and archived redo log files are
available.
7. Allocate auxiliary channels if needed.
8. Execute the DUPLICATE command.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Creating an Initialization Parameter File
for the Auxiliary Instance
Specify parameters as follows:
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.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Specifying New Names for Your Destination

Available techniques:
SET NEWNAME command
CONFIGURE AUXNAME command (deprecated for recovery
set data files)
DB_FILE_NAME_CONVERT parameter with the
DUPLICATE command

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using the SET NEWNAME Clauses

SET NEWNAME clauses enable you to specify a default


name format for all files in a database or in a named
tablespace.
The default name is used for DUPLICATE, RESTORE, and
SWITCH commands in the RUN block.
It enables you to set file names with a single command
rather than setting each file name individually.
SET NEWNAME FOR DATABASE
TO {NEW|'formatSpec'};

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Substitution Variables for SET NEWNAME

Syntax Description
Element
%b Specifies the file name without the directory path

%f Specifies the absolute file number of the data file for which the new
name is generated

%I Specifies the DBID

%N Specifies the tablespace name

%U Specifies a system-generated file name of the format:


data-D-%d_id-%I_TS-%N_FNO-%f

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Specifying Parameters for File Naming

Alternatively, specify the following parameters to explicitly


control the naming of the files of your auxiliary database:
CONTROL_FILES
DB_FILE_NAME_CONVERT
LOG_FILE_NAME_CONVERT
CONTROL_FILES='/u01/app/oracle/oradata/aux/control01.ctl',
'/u01/app/oracle/oradata/aux/control02.ctl',
'/u01/app/oracle/oradata/aux/control03.ctl'
DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl',
'/u01/app/oracle/oradata/aux'
LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl',
'/u01/app/oracle/oradata/aux'

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Starting the Instance in NOMOUNT Mode

Start the auxiliary instance in NOMOUNT mode.


Create a server parameter file (SPFILE) from the text
initialization parameter file you used to start the instance.
SQL> startup nomount pfile='$HOME/auxinstance/initAUX.ora'
ORACLE instance started.

Total System Global Area 285212672 bytes


Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
SQL> create spfile
2 from pfile='$HOME/auxinstance/initAUX.ora';

File created.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Ensuring That Backups and Archived Redo Log
Files Are Available
Backups of all target database data files must be
accessible on the duplicate host.
Backups can be a combination of full and incremental
backups.
Archived redo log files needed to recover the duplicate
database must be accessible on the duplicate host.
Archived redo log files can be:
Backups on a media manager
Image copies
Actual archived redo log files

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Allocating Auxiliary Channels

Auxiliary channels specify a connection between RMAN


and an auxiliary database instance.
If automatic channels are not configured, allocate auxiliary
channels:
Start RMAN with a connection to the target database
instance, the auxiliary instance, and recovery catalog if
applicable.
Allocate at least one auxiliary channel within the RUN block.
$ rman target sys/oracle_4U@trgt auxiliary
sys/oracle_4U@auxdb
RMAN> RUN
{ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK;

DUPLICATE TARGET DATABASE to auxdb; . . .

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Understanding the RMAN Duplication Operation

When you execute the DUPLICATE command, RMAN performs


the following operations:
1A. Creates a control file server parameter file for the auxiliary
instance (for active and for backup-based duplication with
target connection) , or:
1B. Restores from backup (for standby database and for
backup-based duplication without target connection)
2. Mounts the backup control file
3. For backup-based duplication: Selects the backups for
restoring the data files to the auxiliary instance
4. Restores the target data files to the duplicate database
5. Performs incomplete recovery using all available
incremental backups and archived redo log files

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Understanding the RMAN Duplication Operation

When you execute the DUPLICATE command, RMAN performs


the following operations:
6. Shuts down and restarts the auxiliary instance in NOMOUNT
mode
7. Creates a new control file, which then creates and stores
the new DBID in the data files
8. Opens the duplicate database with the RESETLOGS option
9. Creates the online redo log files for the duplicate database

Note: The database duplication process attempts to


resume from the point-of-failure upon reexecution.

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Specifying Options for the DUPLICATE Command

You can specify the following options with the DUPLICATE command:

Option Purpose
SKIP READONLY Excludes read-only tablespaces

SKIP TABLESPACE Excludes named tablespaces

TABLESPACE Includes named tablespaces

NOFILENAMECHECK Prevents checking of file names

OPEN RESTRICTED Enables RESTRICTED SESSION automatically

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using Additional DUPLICATE Command Options

Option Purpose

NOREDO Signals RMAN that the application of redo logs should be


suppressed during recovery
Must be used with targetless DUPLICATE when target
database is in NOARCHIVELOG mode at backup time
Can also be used to explicitly state that no archived redo
log files should be applied

UNDO TABLESPACE Must be specified when target database is not open and
there is no recovery catalog connection so that RMAN
does not check the tablespace for SYS-owned objects

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Using EM to Clone a Database

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br
Sumrio

Nesta lio, voc deve ter aprendido como:


Lista de efeitos de criao de um banco de dados
duplicado
Escolher uma tcnica para duplicar a um banco de dados
Duplicar um banco de dados com o RMAN
Use um backup RMAN para duplicar um banco de dados
Duplicar um banco de dados com base em uma instncia
em execuo

Trainning Education Services - Sede: Av. Paulista, 2006, 16 andar SP

So Paulo (11) 3171-2002 - Rio de Janeiro (21) 4063-6518 - Braslia (61) 4063-7766 - Belo Horizonte (31) 4063-8187
Vitria (27) 4062-9192 - Curitiba (41) 4063-8083 - Porto Alegre (51) 4063-9474 - Recife (81) 3301-1600 - Salvador (71) 4062-9323

www.trainning.com.br - comercial@trainning.com.br

Você também pode gostar