Download as pdf or txt
Download as pdf or txt
You are on page 1of 324

Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
a h
y 12c:
Oracle Database @ n t GBackup
k de
ac tuWorkshop
and Recovery
f r z S
A ( i s
L
AActivitysGuide
e t h
U
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

D78850GC10
Edition 1.0
August 2013
D83661
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Disclaimer

This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and
print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way.
Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display,
perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization
of Oracle.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

The information contained in this document is subject to change without notice. If you find any problems in the document, please
report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
warranted to be error-free.

Restricted Rights Notice

If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United
States Government, the following notice is applicable:

U.S. GOVERNMENT RIGHTS


The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted
a
by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract.
s
Trademark Notice
)h a
m
co eฺ
owners. o ฺ
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective

o uid
y a h
Author @ n t G
Maria Billings
k
ac tude
f r z
Technical Contributors and Reviewers L A ( this S
Chris Andrews,Tim Chien, Donna Cooksey,
A Constantin,
URaluca se Stefan Dolea, Gerlinde
H
Frenzen, Joel Goodman, Daniela Hansell,
O t o u
Dominique Jeunot, Sean Kim, Gwen Lazenby,
Naoki Kato, Olga Krakovna, Cris0 T C sPavan
Pedregal, e
% 2 c e nBreederode, Lachlan Williams Sangar, Ron Soltani,
Nisankara Rao, Puneet

E LI ble li
Jim Spiller, Branislav Valny, Harald van

A M e rausing: oracletutor
This book i ewas f
published
s
c h ar tran
Za non-
Table of Contents
Practices for Lesson 1: Introduction ..............................................................................................................1-1
Practices for Lesson 1: Overview ...................................................................................................................1-2
Practice 1-1: Exploring the Course Environment ...........................................................................................1-3
Practices for Lesson 2: Getting Started .........................................................................................................2-1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Practices for Lesson 2: Overview ...................................................................................................................2-2


Practice 2-1: Backing Up in NOARCHIVELOG Mode ....................................................................................2-3
Practice 2-2: Creating a Test Case ................................................................................................................2-10
Practice 2-3: Recovering in NOARCHIVELOG Mode ....................................................................................2-16
Practices for Lesson 3: Configuring for Recoverability ...............................................................................3-1
Practices for Lesson 3: Overview ...................................................................................................................3-2
Practice 3-1: Configuring the Default Backup Destination and ARCHIVELOG Mode ....................................3-3
Practice 3-2: Setting the Date and Time Format for RMAN ...........................................................................3-7
Practice 3-3: Configuring RMAN Settings ......................................................................................................3-11
s a
)h a
Practice 3-4: Configuring Control Files ...........................................................................................................3-15
m
Practice 3-5: Recovery Settings in Cloud Control ..........................................................................................3-20
co eฺ
o ฺ
Practice 3-6: Configuring Redo Log Files .......................................................................................................3-23
o uid
y a h
Practices for Lesson 4: Using the RMAN Recovery Catalog........................................................................4-1
@ n t G
k
Practices for Lesson 4: Overview ...................................................................................................................4-2
ac tude
( f z
Practice 4-1: Creating a Recovery Catalog Owner.........................................................................................4-3
r S
L s
Practice 4-2: Creating the Recovery Catalog .................................................................................................4-4
i
A .....................................................................4-5
t h
UA
Practice 4-3: Registering a Database in the Recovery Catalog
Practice 4-4: Configuring Enterprise Manager O for the RMANu se ...........................................................4-7
Catalog
Practice 4-5: Configuring the Recovery C H for eRecovery
Catalog to .......................................................................4-11
Practices for Lesson 5: Backup 2
T
0 and s
nTerminology
Practices for Lesson 5: L I % Strategies
l i c e ......................................................................5-1

Practice 5-1: Case M EOverviewa b le a Backup Strategy .............................................................................5-3


...................................................................................................................5-2
Study: Developing

r i e
Practice 5-2:
A a fBackup
Creatings er Schedule.....................................................................................................5-5
c ha for Lesson
Practices
- t r an6: Creating Backups ....................................................................................................6-1
a onfor Lesson 6: Overview...................................................................................................................6-2
Z Practices
n
Practice 6-1: Configuring Block Change Tracking ..........................................................................................6-3
Practice 6-2: Using Incremental Backup ........................................................................................................6-4
Practices for Lesson 7: Improving Your Backups ........................................................................................7-1
Practices for Lesson 7: Overview ...................................................................................................................7-2
Practice 7-1: Backing up Other Database Files .............................................................................................7-3
Practice 7-2: Backing up ASM Metadata........................................................................................................7-14
Practice 7-3: Creating an Archival Backup .....................................................................................................7-16
Practices for Lesson 8: Using RMAN-Encrypted Backups...........................................................................8-1
Practices for Lesson 8: Overview ...................................................................................................................8-2
Practice 8-1: Encrypting a Backup with RMAN ..............................................................................................8-3
Practice 8-2: Restoring an Encrypted Backup ................................................................................................8-7
Practices for Lesson 9: Diagnosing Database Failure ..................................................................................9-1
Practices for Lesson 9: Overview ...................................................................................................................9-2
Practice 9-1: Diagnosing and Repairing Database Failure .............................................................................9-3
Practice 9-2: Performing and Analyzing Instance Recovery ..........................................................................9-7
Practice 9-3: Analyzing Database Failure in ASM ..........................................................................................9-11
Practice 9-4: Repairing Block Corruption .......................................................................................................9-15
Copyright © 2013. Oracle and/or its affiliates. All rights reserved.

Oracle Database 12c: Backup and Recovery Workshop Table of Contents


i
Practices for Lesson 10: Restore and Recovery Concepts ..........................................................................10-1
Practices for Lesson 10: Overview .................................................................................................................10-2
Practice 10-1: Case Study: Determining Recovery Procedures .....................................................................10-3
Practices for Lesson 11: Performing Recovery.............................................................................................11-1
Practices for Lesson 11: Overview .................................................................................................................11-2
Practice 11-1: Recovering from Media Failure (Loss of a Data File) ..............................................................11-3
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Practice 11-2: Recovering from Media Failure - Incomplete Recovery ..........................................................11-11


Practices for Lesson 12: Performing Recovery II..........................................................................................12-1
Practices for Lesson 12: Overview .................................................................................................................12-2
Practice 12-1: Recovering the Loss of a Parameter File ................................................................................12-3
Practice 12-2: Restoring the Control File .......................................................................................................12-6
Practice 12-3: Recovering from the Loss of all Control Files ..........................................................................12-11
Practice 12-4: Restoring the Password File ...................................................................................................12-18
Practice 12-5: Recovering a Tempfile ............................................................................................................12-21
Practice 12-6: Creating Encrypted Backups ...................................................................................................12-23
s a
Practice 12-7: Recovering by Using an Encrypted Backup ............................................................................12-30
)h a
m
Practice 12-8: Recovering a Lost Encryption Wallet ......................................................................................12-35
co eฺ
o ฺ
Practices for Lesson 13: RMAN and Oracle Secure Backup ........................................................................13-1
o uid
a h
Practices for Lesson 13: Overview .................................................................................................................13-2
y
@ t G
Practice 13-1: Installing Oracle Secure Backup .............................................................................................13-3
n
ac tudek
Practice 13-2: Configuring Oracle Secure Backup .........................................................................................13-8
f r z
A ( this S
Practices for Lesson 14: Using Flashback Technologies ............................................................................14-1
L
UA ..............................................................................14-3
Practices for Lesson 14: Overview .................................................................................................................14-2
O
Practice 14-1: Preparing to use Flashback Technologies u se
Practice 14-2: Restoring a Dropped Table C H e to
.....................................................................................................14-8

2 T ns
0 ............................................................................................................14-11
Practice 14-3: Using Flashback Table
Practices for Lesson 15:L %
I leDatabase
Flashback
c e
li ..............................................................................................15-1
E
M 15: Overview
Practices for Lesson ab.................................................................................................................15-2
A
e ns f e r
a r i
Practice 15-1: Enabling Flashback Logging ...................................................................................................15-3

a c n ra Flashback Database .............................................................................................15-5


h 15-2:-tPerforming
Practice
ZPractices
nofor Lesson 16: Transporting Data ..................................................................................................16-1
Practices for Lesson 16: Overview .................................................................................................................16-2
Practice 16-1: Transporting a Tablespace .....................................................................................................16-3
Practices for Lesson 17: Performing Point-in-Time Recovery .....................................................................17-1
Practices for Lesson 17: Overview .................................................................................................................17-2
Practice 17-1: Recovering a Table from a Backup .........................................................................................17-3
Practices for Lesson 18: Duplicating a Database .........................................................................................18-1
Practices for Lesson 18: Overview .................................................................................................................18-2
Practice 18-1: Duplicating a Database ...........................................................................................................18-3
Practices for Lesson 19: RMAN Troubleshooting and Tuning.....................................................................19-1
Practices for Lesson 19: Overview .................................................................................................................19-2
Practice 19-1: Resetting Your Training Databases ........................................................................................19-3
Practices for Lesson 20: Workshop ...............................................................................................................20-1
Practices for Lesson 20: Overview .................................................................................................................20-2
Practice 20-1: Preparing for Backup and Recovery Workshop ......................................................................20-3
Practice 20-2: Experience the Real-Life Workshop ........................................................................................20-4
Practice 20-3: Your Scenarios........................................................................................................................20-5

Copyright © 2013. Oracle and/or its affiliates. All rights reserved.

Oracle Database 12c: Backup and Recovery Workshop Table of Contents


ii
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
Important Note )h a
m
co eฺ
o
o uidฺ
y a h
You can expect to find slight difference in sample outputs,kscreen@ n t G
a c d e
shots, etc. between
the training environment you are working on and what
( frz is sgiven
S tuin eKit (course material).
Since OU courses might have more than one
A LA e hi
trainingtenvironment such as Desktop,
Grid, Cloud environment etc. we are bound
H OU ttoo see
us slight differences.
Some of the known differences 0 T C
are: nse
I % 2 i c e
• Difference E L
in numberlof l
e available ASM disks / shared disk devices.
M a b
r i
• Slight e Adifference
s f erin sample outputs and screen grabs.
a c ha -tran
Z non
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lessonn t G1:
k
ac tude
Introduction
( f r z S
L A h i s
U AChapterse1 t
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Introduction


Chapter 1 - Page 1
Practices for Lesson 1: Overview
Practices Overview
In this practice, you will explore your course in Linux.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Introduction


Chapter 1 - Page 2
Practice 1-1: Exploring the Course Environment
Overview
In this optional practice you explore some elements of the setup provided to you. Throughout
the following practices, more elements will be introduced and you will change this configuration.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
The student has an ACES environment with a Linux operating system. Preinstalled are:
• Oracle Database 12c (12.1) with three active database instances:
• orcl (your main training database using Automatic Storage Management (ASM)
with its +ASM instance
• rcat (for your RMAN catalog)
• em12rep (for Oracle Enterprise Manager Cloud Control).
• Oracle Enterprise Manager Cloud Control s a
Staged software includes: )h a
m
co eฺ
• Oracle Secure Backup
o ฺ
o uid
y a h
Tasks
@ n t G
k
ac tude
1. Log in to the machine as oracle with the password of oracle.
f r z S icon or by right-
2. Open a terminal window, either by double-clicking( on the Terminal
L i
Ain Terminal.
h s
A se t
clicking the mouse button and selecting Open
U
H O to uorcl, rcat and em12rep. Confirm this, for
3. There should be four instances running: +ASM,
example, by using the pgrep C e command which displays the process monitor
(pmon) background process 0 T
2 ice
-lf pmon
with itsn s
instance name.
$ pgrep E
I %
-lf pmonle l
L
14366A f e ab
Mora_pmon_emrep
r
a ie ora_pmon_rcat
r19558 n s
h r a
Zac no21223n-t ora_pmon_orcl
23313 asm_pmon_+ASM
$
4. Optionally, if you want to see all processes associated with the orcl instance, use the
pgrep –lf orcl command.
$ pgrep -lf orcl
. . .
21271 oracle+ASM_asmb_orcl
(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
21273 ora_mmnl_orcl
. . .
The oracle+ASM_asmb_orcl process shows you that the ORCL instance is using ASM.
Note: The output above is abbreviated to save space and avoid cluttering this document
with information that is not required for a specific task.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Introduction


Chapter 1 - Page 3
5. Because there are several instances in your environment, you need to set environment
variables pointing to the correct instance. Use . oraenv to set your environment
variables.
Point to the +ASM instance (because the listener is running from the Grid Infrastructure
home). Because the Grid Infrastructure software is installed under the grid OS user, you
need to first log in as the grid user before executing ASM related commands.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

$ su - grid
Password: oracle <<< not displayed >>>
$ . oraenv
ORACLE_SID = [grid] ? +ASM
The Oracle base has been changed from /u01/app/oracle to
/u01/app/grid
$
6. a
Confirm that the listener is listening for each of the four instances. (You will see additional
s
XDB instances.)
) h a
$ lsnrctl status m
co12-JUN-
o o ฺ eฺ
LSNRCTL for Linux: Version 12.1.0.1.0 - Production
a h on
u i d
2013 10:21:08 y t G
c
Copyright (c) 1991, 2013, Oracle. All rights
a k@ dreserved.
e n
( frz s Stu
Connecting to
A LA e thi
OU to us
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER H
C se
0 T
2 icen LISTENER
------------------------
Alias I %
L ble l
E
AM fera
Version
-ieProduction
TNSLSNR for Linux: Version 12.1.0.1.0

a rStartaDaten s
a c h - t r 11-JUN-2013 12:46:33
Z noUptime n 0 days 21 hr. 34 min. 40 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File
/u01/app/grid/product/12.1.0/grid/network/admin/listener.ora
Listener Log File
/u01/app/grid/diag/tnslsnr/EDRSR39P1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edRSr39p1.us.oracle.co
m)(PORT=1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edRSr39p1.us.oracle.co
m)(PORT=5501))(Presentation=HTTP)(Session=RAW))

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Introduction


Chapter 1 - Page 4
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edRSr39p1.us.oracle.co
m)(PORT=5500))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

service...
Service "emrep" has 1 instance(s).
Instance "emrep", status READY, has 1 handler(s) for this
service...
Service "emrepXDB" has 1 instance(s).
Instance "emrep", status READY, has 1 handler(s) for this
service...
Service "orcl" has 1 instance(s).
s a
Instance "orcl", status READY, has 1 handler(s) for this
)h a
service...
m
co eฺ
Service "orclXDB" has 1 instance(s).
o ฺ
o uid
a h
Instance "orcl", status READY, has 1 handler(s) for this
y
service...
@ n t G
Service "rcat" has 1 instance(s). k
ac tude
f r z
A ( this S
Instance "rcat", status READY, has 1 handler(s) for this
L
UA use
service...
O
Service "rcatXDB" has 1 instance(s).
H e to
T C
Instance "rcat", status READY, has 1 handler(s) for this
0 ens
service... 2
I le lic
%
L
The command completed successfully
$ A ME erab
r ieto being
n s f
c a
7. Return
h $ exit tra
the oracle OS user.
a
Z no n -
logout
$ whoami
oracle
$
8. Confirm that the ORCL database is in NOARCHIVELOG mode. There are different ways to
do this. This activity guide shows you first the SQL*Plus way.
a. Use . oraenv to set your environment variables for the orcl database instance.
$ . oraenv
ORACLE_SID = [oracle] ? orcl
The Oracle base has been set to /u01/app/oracle
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Introduction


Chapter 1 - Page 5
b. Log into SQL*Plus with the SYSDBA privilege.
$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Wed Jun 12 10:25:15
2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 -
64bit Production
With the Partitioning, Automatic Storage Management, OLAP,
Advanced Analytics
and Real Application Testing options
SQL>
Note: To avoid cluttering the output, the above banner information will not be repeated.
s a
c. Query the LOG_MODE column of the v$database view (and any other information that
might interest you).
)h a
m
co eฺ
SQL> select name, log_mode, db_unique_name from v$database;
o ฺ
o uid
y a h
NAME LOG_MODE DB_UNIQUE_NAME
@ n t G
k
ac tude
--------- ------------ ------------------------------
( f r z S
ORCL NOARCHIVELOG orcl
L A h i s
SQL>
U A se t
H howeyoutoareucurrently logged into SQL*Plus.
d. Confirm your understanding of O
C
T DUAL;
SQL> SELECT USER0FROM
2 ns
% c e
E LI ble li
USER
A M era
a r ie nsf
------------------------------

a c h SYS-tra
Z non
SQL>
Note: When you execute sqlplus / as sysdba, you are using OS security credentials
and are logged in as the SYS user.
e. Optionally: If you want to test your logon with Oracle Net Services, use the service
name (@orcl in this example):
SQL> exit
$ sqlplus sys@orcl as sysdba
. . .
Enter password: oracle_4U <<<not displayed
Connected.
SQL>
Note: In this course, all Oracle training passwords are oracle_4U, all OS passwords are
oracle. This obviously not secure and only done for your convenience during the course.
Please refer to the Oracle Database Security Guide for guidelines on how to choose
passwords.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Introduction


Chapter 1 - Page 6
f. Exit SQL*Plus.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release
12.1.0.1.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

$
Note: To avoid cluttering the output, the above banner information will not be repeated.

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Introduction


Chapter 1 - Page 7
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 1: Introduction


Chapter 1 - Page 8
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lesson n t G2:
k
c ude
aStarted
Getting
( f r z S t
A LA e2 this
Chapter

H OU to us
0 T C se
I % 2 icen
E L ble l
A M era
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 1
Practices for Lesson 2: Overview
Practices Overview
In these practices you configure the default backup destination, set the RMAN display data and
time format, configure control file autobackup, configure the backup retention policy, and
configure a device for backup.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 2
Practice 2-1: Backing Up in NOARCHIVELOG Mode
Overview
In this mandatory practice, you invoke the RMAN client and perform a database backup with
default settings. The backup will be used in a later practice to perform recovery (after an
intentionally introduced “disaster”).
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
You start in a terminal window, in which the environment variables are pointing to the ORCL
instance. (Revisit the previous practice if you are not sure how to set the environment variables
with . oraenv.)

Tasks
1. Logged in to a terminal window as oracle OS user, invoke the RMAN client with the
SYSBACKUP role. Note that both double and single quotes are needed.
s a
$ rman target "'/ as sysbackup'"
)h a
Recovery Manager: Release 12.1.0.1.0 - Production on Wed Jun 12 m
co eฺ
10:29:38 2013
o ฺ
o uid
a h
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All
y
rights reserved. @ n t G
k
ac tude
f r z
connected to target database: ORCL (DBID=1345675044)
RMAN>
L A ( this S
Note: To avoid cluttering the output, the A banner
Uabove s e information will not be repeated.
2. Confirm that the ORCL database H O to u
is in NOARCHIVELOG mode.
T C e
RMAN> SELECT NAME,
% 2 0 DBID,
c e nsLOG_MODE FROM V$DATABASE;
E LI ble li
using M target a
A f e r database control file instead of recovery catalog

a ie ns
rNAME DBID LOG_MODE
h r a
Zac noORCLn-t
--------- ---------- ------------
1343765865 NOARCHIVELOG
RMAN>

3. Display the default user name with which you logged in.
RMAN> SELECT USER FROM DUAL;

USER
------------------------------
SYSBACKUP

RMAN>
Note: You logged in with the SYSBACKUP privilege (that connects you as the SYSBACKUP
user), which is very similar to the SYSDBA privilege, except that it does not include the
SELECT privileges for user-content tables. By default, SYSDBA can see the content of user
tables, but SYSBACKUP cannot. (Both can query the data dictionary and dynamic views.)

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 3
4. View the default parameters which will be used for your database backup. You will change
some of them in later practices.
RMAN> show all;

RMAN configuration parameters for database with db_unique_name


ORCL are:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default


CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO
BACKUPSET; # default
s a
)h a
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
default m
co eฺ
o ฺ
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
o uid
default
y a h
@
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
n t G
k
ac tude
f r z
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
A ( this S
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
L
UA use
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT'
O
H e to
OPTIMIZE FOR LOAD TRUE ; # default
C
T
0 ens
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
2
I le lic
%
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
L
A ME erab
CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/u01/app/oracle/product/12.1.0/dbhome_1/dbs/snapcf_orcl.f'; #
a r ie nsf
default
a c h -tra
Z noRMAN> n

5. Perform a backup of the ORCL database. Expect to get an error.


a. Use the BACKUP DATABASE command.
RMAN> BACKUP DATABASE;
Starting backup at 12-JUN-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=41 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
RMAN-03009: failure of backup command on ORA_DISK_1 channel at
06/12/2013 10:32:04
ORA-19602: cannot backup or copy active file in NOARCHIVELOG
mode
continuing other job steps, job failed will not be re-run
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 4
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 12-JUN-13
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

channel ORA_DISK_1: finished piece 1 at 12-JUN-13


piece
handle=+DATA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t103204
_0.271.817900327 tag=TAG20130612T103204 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
RMAN-00571: ===============================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
RMAN-00571: ===============================================
s a
RMAN-03009: failure of backup command on ORA_DISK_1 channel ) hata
06/12/2013 10:32:04 m
co eฺ
ORA-19602: cannot backup or copy active file in NOARCHIVELOG o ฺ
o uid
y a h
mode
@ n t G
k
ac tude
RMAN>
( f r z S
b. In a second terminal window (which has L A environment
the t h i s variables set to orcl), use
U A ofsthe
the oerr utility to determine the meaning e error code.
$ oerr ORA 19602 C HO e to u
19602, 00000, 2 0T ebackup
"cannot ns or copy active file in NOARCHIVELOG
mode" %
LI ble li c
E
M erYou a tried to copy or backup a file that was not
A
// *Cause:
ie ns f
a r//
closed cleanly,

a c h
n - tra the database was in NOARCHIVELOG mode. This is not
and
Z no allowed
// because when restored, the file will require redo application
// before it is usable, and redo is not currently being saved
// beyond the contents of the online redo logs.
// *Action: Take the tablespace offline clean or close the
database and retry
// the copy or backup.
$
Should you get "oerr: command not found", then the environment variables might not
be set.
Note: The next lesson reviews the database structures to deepen your understanding. Note
the suggested action.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 5
6. Remember that the database is in NOARCHIVELOG mode.
a. The database must be placed in the MOUNT state to do a consistent backup. This
practice shows the use of RMAN, but you could use other tools as well, such as
SQL*Plus. (Continue in your RMAN terminal session.)
RMAN> shutdown immediate;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

database closed
database dismounted
Oracle instance shut down

RMAN> startup mount;

connected to target database (not started)


s a
Oracle instance started
database mounted )h a
m
co eฺ
o ฺ
o uid
Total System Global Area 534462464 bytes
y a h
Fixed Size 2290416 bytes @ n t G
k
acbytestude
Variable Size 276827408
( f r z S
Database Buffers
A
247463936
L h i s
bytes
t bytes
Redo Buffers
U A 7880704
s e
RMAN>
C HO e to u
b. Perform your database
2 0Tbackup.e s should be no errors.
nThere
%
LI database;
RMAN> backup li c
E l e
M backup
Starting
A f e r ab at 12-JUN-13
a ie ns channel: ORA_DISK_1
rallocated
a c h - tra ORA_DISK_1: SID=15 device type=DISK
channel
n
Z nochannel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001
name=+DATA/ORCL/DATAFILE/system.257.817894153
input datafile file number=00003
name=+DATA/ORCL/DATAFILE/sysaux.256.817894089
input datafile file number=00002
name=+DATA/ORCL/DATAFILE/example.269.817894393
input datafile file number=00004
name=+DATA/ORCL/DATAFILE/undotbs1.259.817894231
input datafile file number=00006
name=+DATA/ORCL/DATAFILE/users.258.817894229
channel ORA_DISK_1: starting piece 1 at 12-JUN-13
channel ORA_DISK_1: finished piece 1 at 12-JUN-13
piece
handle=+DATA/ORCL/BACKUPSET/2013_06_12/nnndf0_tag20130612t103848
_0.272.817900729 tag=TAG20130612T103848 comment=NONE
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 6
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:05
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

channel ORA_DISK_1: starting piece 1 at 12-JUN-13


channel ORA_DISK_1: finished piece 1 at 12-JUN-13
piece
handle=+DATA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t103848
_0.273.817900857 tag=TAG20130612T103848 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 12-JUN-13
RMAN>
s a
Question: How many backup sets are shown in the output? How long did it take to create
the backups? )h a
m
co eฺ
Possible answer: In this example, two backup sets are created, which took a total of 2
minute, 8 seconds elapsed time. o ฺ
o uid
y a h
7. Open the database.
@ n t G
RMAN> ALTER DATABASE OPEN; k
ac tude
( f r z S
Statement processed
L A h i s
RMAN>
U A se t
8. List your backups.
C HO e to u
0T ens
RMAN> list backup;
2
L I% Sets
List of Backup
e l ic
ME erab l
===================
A
ie nsf
a r
a c n tra Type LV Size
h BS -Key Device Type Elapsed Time Completion
Z no Time
------- ---- -- ---------- ----------- ------------ ------------
---
1 Full 9.64M DISK 00:00:04 12-JUN-13
BP Key: 1 Status: AVAILABLE Compressed: NO Tag:
TAG20130612T103204
Piece Name:
+DATA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t103204_0.271.
817900327
SPFILE Included: Modification time: 12-JUN-13
SPFILE db_unique_name: ORCL
Control File Included: Ckp SCN: 1896328 Ckp time: 12-JUN-
13

BS Key Type LV Size Device Type Elapsed Time Completion


Time

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 7
------- ---- -- ---------- ----------- ------------ ------------
---
2 Full 1.30G DISK 00:01:59 12-JUN-13
BP Key: 2 Status: AVAILABLE Compressed: NO Tag:
TAG20130612T103848
Piece Name:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

+DATA/ORCL/BACKUPSET/2013_06_12/nnndf0_tag20130612t103848_0.272.
817900729
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1896642 12-JUN-13
+DATA/ORCL/DATAFILE/system.257.817894153
2 Full 1896642 12-JUN-13
s a
+DATA/ORCL/DATAFILE/example.269.817894393
)h a
3 Full 1896642 12-JUN-13
m
co eฺ
+DATA/ORCL/DATAFILE/sysaux.256.817894089
o ฺ
o uid
4 Full 1896642 12-JUN-13
y a h
+DATA/ORCL/DATAFILE/undotbs1.259.817894231
@ n t G
6 Full 1896642 12-JUN-13 k
ac tude
f r z
A ( this S
+DATA/ORCL/DATAFILE/users.258.817894229
L
BS Key Type LV Size
O UA
Devicese
u Type Elapsed Time Completion
Time H t o
C se-----------
------- ---- -- 0
2 T
----------n ------------ ------------
% li c e
---
E LI e
Full bl9.64M
3
A M BP eKey:
r a DISK 00:00:04 12-JUN-13

a r ie nsf 3 Status: AVAILABLE Compressed: NO Tag:

a c h -tra
TAG20130612T103848
n
Z no+DATA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t103848_0.273.
Piece Name:

817900857
SPFILE Included: Modification time: 12-JUN-13
SPFILE db_unique_name: ORCL
Control File Included: Ckp SCN: 1896642 Ckp time: 12-JUN-
13
RMAN>
Question: Which objects are in the backup sets, shown above?
Possible answer: The first and third backup set contain the control and SPFILE, the
second backup set contains data files.
When the RMAN configurable parameter CONTROLFILE AUTOBACKUP is disabled (OFF)
during a backup operation, then two control file backups are created: one before and one
after the backup, each for a different SCN with different tags.
The second backup set contains the data files.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 8
9. Use the DELETE OBSOLETE command, to save space by removing duplicates. Then exit
the RMAN client.
RMAN> delete obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

using channel ORA_DISK_1


Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ -----------------
---
Backup Set 1 12-JUN-13
Backup Piece 1 12-JUN-13
+DATA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t103204_0.271.
817900327
s a
)orh a
Do you really want to delete the above objects (enter o m
YES
NO)? y
o o ฺc eฺ
deleted backup piece
y ah Guid
backup piece
c k @ ent
d
frza s Stu
handle=+DATA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t103204
(
LA e thi
_0.271.817900327 RECID=1 STAMP=817900327
Deleted 1 objects A
RMAN> exit
H OU to us
0 T C se
Recovery Manager complete.
I % 2 icen
L ble l
$
E
M era
A
ie nsf
a r
h -tra
a c
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 9
Practice 2-2: Creating a Test Case
Overview
In this practice, you create your first test case which is a new tablespace, user and a table.

Assumptions
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

You completed practice 2-1 (and have a backup of your closed database in NOARCHIVELOG
mode).
The $LABS environment variable points to the /home/oracle/labs training directory (which
is your course home directory). Unless indicated otherwise, start all practices in this directory.

Tasks
1. In the $LABS directory is a Linux file that executes a test case. Navigate into your course
home directory and review the setup_02_02.sh file with the cat command. (Best
s a
Practice Tip: In later practices, it is also recommended to first review a script file before
executing it.) )h a
m
co eฺ
o ฺ
o uid
$ cd $LABS
y a h
$ cat setup_02_02.sh @ n t G
k
ac tude
#!/bin/sh
( f r z S
# -- DISCLAIMER:
L A t h i s
# -- This script is provided
U A forseeducational purposes only. It
is
HO t o u
# -- NOT supported
0 T Cby
s e
Oracle World Wide Technical Support.
%2 haslicbeen
# -- The script n
e tested and appears to work as
intended. LI
M E should
a b lealways run new scripts on a test instance
# --
i e A fer
You
a r n
initially.
a s
h # -t r
Zac no#nconfigure the environment
. $LABS/set_db.sh

# This script creates the BAR22 user, the BAR22TBS tablespace


# and BARCOPY table. The table is populated
# and a backup is made.
#

sqlplus -S /nolog > /tmp/setup.log 2>&1 <<EOF


connect / as sysdba

-- CLEANUP from previous run


DROP USER bar22 CASCADE;

DROP TABLESPACE bar22tbs INCLUDING CONTENTS AND DATAFILES;

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 10
-- Create tablespace
CREATE TABLESPACE bar22tbs
DATAFILE '/u01/backup/orcl/bar22tbs01.dbf' SIZE 10M REUSE
SEGMENT SPACE MANAGEMENT MANUAL;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

-- Create user
CREATE USER BAR22 IDENTIFIED BY oracle_4U
DEFAULT TABLESPACE bar22tbs
QUOTA UNLIMITED ON bar22tbs;

GRANT CREATE SESSION TO BAR22;

s a
-- create table and populate
)h a
-- be sure table is at least 2 blocks long m
co eฺ
CREATE TABLE BAR22.barcopy o ฺ
o uid
TABLESPACE bar22tbs
y a h
@ n t G
AS SELECT * FROM HR.EMPLOYEES;
k
ac tude
f r z
INSERT INTO BAR22.BARCOPY
L A ( this S
UA use
SELECT * FROM BAR22.BARCOPY;
O
C H e to
2 T
0 ens
INSERT INTO BAR22.BARCOPY
L %
SELECT * FROM
e l ic
I BAR22.BARCOPY;
ME erab l
A
ie nsf
a rEOF
h -tra
a c
Z no#n Switch logfile
sqlplus / as sysdba >> /tmp/setup.log 2>&1 <<EOF

ALTER SYSTEM SWITCH Logfile;


alter system checkpoint;
exit;
EOF
echo "Setup complete." >> /tmp/setup.log
exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 11
2. Note the location and name of the data file and that the script executes the set_db.sh file.
Review this file as well.
$ cat set_db.sh
ORACLE_SID=orcl
ORAENV_ASK='NO'
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

. oraenv >>/dev/null
ORAENV_ASK=''

$
Question: What do these two files do together?
Possible answer: set_db.sh uses . oraenv to set the environment variables for the
ORCL instance.
setup_02_02.sh first attempts to drop a user and tablespace (if they exist from previous
s a
tests). Then it creates the BAR22 user, BAR22TBS tablespace, and the BARCOPY table. The
BARCOPY table is filled with rows from the HR.EMPLOYEES table. )h a
m
co eฺ
After that, SYSDBA switches log files and executes a checkpoint.
o ฺ
osystemuoridin ASM)?
Question: Where is the data file for the tablespace located (in thea
y h
file
Possible answer: In the file system @ n t G
k
ac toruas deis recommended for
3. You can either perform these tasks by entering the commands
f r z
( window S as the default oracle OS
now, execute the setup_02_02.sh file in the terminal
L A h i s
user.
U A se t
$ ./setup_02_02.sh
H O to u
$ C
0T ense
2 c
I% toletheli/tmp/setup.log
4. The output is redirected file. You can review the output while the
E L
script is executing.
question A ab (Space lines have been removed
- If you
M instructor.
with yourfe r
do not understand it at the completion of the script, discuss your
to avoid cluttering the
r i e s
c ha $ cat
output).
- t r an
a
Z non /tmp/setup.log
DROP USER bar22 CASCADE
*
ERROR at line 1:
ORA-01918: user 'BAR22' does not exist

DROP TABLESPACE bar22tbs INCLUDING CONTENTS AND DATAFILES


*
ERROR at line 1:
ORA-00959: tablespace 'BAR22TBS' does not exist

Tablespace created.
User created.
Grant succeeded.
Table created.
107 rows created.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 12
214 rows created.

SQL*Plus: Release 12.1.0.1.0 Production on Wed Jun 12 13:36:01


2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 -
64bit Production
With the Partitioning, Automatic Storage Management, OLAP,
Advanced Analytics
and Real Application Testing options

SQL> SQL>
System altered.
s a
)h a
SQL> m
co eฺ
System altered. o ฺ
o uid
y a h
@Enterprise
n t G
SQL> Disconnected from Oracle Database c12c
a k d e Edition
Release 12.1.0.1.0 - 64bit Production z
fr s S
(Storage t u
With the Partitioning, Automatic
A L e thi Management, OLAP,
A
OU tooptions us
Advanced Analytics
and Real Application H
Setup complete. 0T
C seTesting

I % 2 icen
$
E L ble l
Question: Do
A M the efirstratwo error messages signal a problem with your setup?
r ie answer:
Possible n s f No. They occur when a user and tablespace do not exist (possibly from
c a
ha previous a
trexecution of the script). It is important that the object creation (marked in green)
a
Z isnexecuted
o n - without errors.
5. Optionally, log into SQL*Plus as SYSDBA, review the new table.
$ sqlplus / as sysdba

SQL> SELECT * FROM BAR22.BARCOPY;


. . .
EMPLOYEE_ID FIRST_NAME LAST_NAME
----------- -------------------- -------------------------
EMAIL PHONE_NUMBER HIRE_DATE JOB_ID
SALARY
------------------------- -------------------- --------- -------
---
COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
-------------- ---------- -------------
206 William Gietz

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 13
WGIETZ 515.123.8181 07-JUN-02
AC_ACCOUNT 8300
205 110
428 rows selected.
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Note: Only the last row of the BARCOPY table is displayed (to avoid clutter) with the total
count of rows. (The total should be 428; the last row could be different.)
6. Optionally, to list the archive log mode, execute the archive log list command in
SQL*Plus and then exit SQL*Plus.
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
s a
Oldest online log sequence
Current log sequence
10
12 )h a
m
co eฺ
SQL> exit
o ฺ
o uid
$
y a h
Note: Your sequence numbers may be different. @ n t G
7. Crash the ORCL database with the srvctl utility; thatais,
k
cperformudthee srvctl stop
f r z
database -d orcl -o abort command in a (terminal window. S t
$ srvctl stop database -d orcl A this
LA-o eabort
$ H OU to us
8. Optionally, list your pmon 0 T C ora_pmon_orcl
processes. se should not appear in the list.
% 2 c e n
$ pgrep -lf
E LI pmon l e li
14366 M
A r ab
ora_pmon_emrep
f e
a ie ora_pmon_rcat
r19558 n s
h r a
t asm_pmon_+ASM
Zac no$n-
23313

9. Optionally, log in to SQL*Plus as SYSDBA, attempt to query your test table, and exit.
$ sqlplus / as sysdba
...
Connected to an idle instance.
SQL> SELECT * FROM BAR22.BARCOPY;
SELECT * FROM BAR22.BARCOPY
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
SQL> exit
$
If you attempt to query your test file in the idle instance, the ORA-01034 error is displayed.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 14
10. Create an issue. If you want to create a test case for instance recovery, then all you need
to do is to execute step 11, because instance recovery happens automatically on startup
(after a shutdown abort). This practice creates a test case for media recovery. Simulate a
failure by removing the /u01/backup/orcl/bar22tbs01.dbf file.
$ rm /u01/backup/orcl/bar22tbs01.dbf
$
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

11. Attempt to start the ORCL database.


a. With the srvctl utility, perform the srvctl start database -d orcl
command in a terminal window. You should receive an ORA-01110 error.
$ srvctl start database -d orcl
PRCR-1079 : Failed to start resource ora.orcl.db
CRS-5017: The resource action "ora.orcl.db start" encountered
the following error:
ORA-01157: cannot identify/lock data file 5 - see DBWR trace s a
file
)h a
ORA-01110: data file 5: '/u01/backup/orcl/bar22tbs01.dbf' m
co eฺ
. For details refer to "(:CLSN00107:)" in o ฺ
o uid
y a h
"/u01/app/grid/product/12.1.0/grid/log/edrsr39p1/agent/ohasd/ora
@ n t G
agent_grid/oraagent_grid.log". k
ac tude
f r z S
CRS-2674: Start of 'ora.orcl.db'
L A (on 'edrsr39p1'
t h i s failed
$
O UA use
b. Logged in to SQL*Plus asC H eenter
SYSDBA, to startup. You should again see the ORA-
01110 error. 2 T
0 ens
... L I le lic
%
A ME to
Connected
e r aanb idle instance
ie startup
rSQL> n s f
h a r a
n-t instance started.
Zac noORACLE
Total System Global Area 534462464 bytes
Fixed Size 2290416 bytes
Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace
file
ORA-01110: data file 5: '/u01/backup/orcl/bar22tbs01.dbf'
SQL>
This practice step showed you in two different ways, how you can notice that your
bar22tbs01.dbf file is missing.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 15
Practice 2-3: Recovering in NOARCHIVELOG Mode

Overview
In this practice, you use the RMAN client to recover your ORCL database.

Assumptions
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

You have a terminal window open with the environment variables pointing to the ORCL database
instance. This practice has optional steps for learning purposes.

Tasks
1. Because the ORCL database is in NOARCHIVELOG mode, you know that you need to first
mount the instance.
a. Log in to RMAN.
$ rman target "'/ as sysbackup'"
s a
...
)h a
connected to target database: ORCL (DBID= 1345675044, not open) m
co eฺ
RMAN> o ฺ
o uid
y a h
b. Optionally, list your backups.
@ n t G
RMAN> list backup;
a k
c ude
using target database control file ( f r z t recovery catalog
insteadSof
A LA e this
List of Backup Sets
H OU to us
===================
0 T C se
I % 2 icen
E L ble l
A M Typee raLV Size
r i e
BS Key
s f Device Type Elapsed Time Completion

c ha -------
Time
- t r an---- -- ---------- ----------- ------------ ------------
a
Z no-n
2 Full 1.30G DISK 00:01:59 12-JUN-13
BP Key: 2 Status: AVAILABLE Compressed: NO Tag:
TAG20130612T103848
Piece Name:
+DATA/ORCL/BACKUPSET/2013_06_12/nnndf0_tag20130612t103848_0.272.
817900729
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1896642 12-JUN-13
+DATA/ORCL/DATAFILE/system.257.817894153
2 Full 1896642 12-JUN-13
+DATA/ORCL/DATAFILE/example.269.817894393
3 Full 1896642 12-JUN-13
+DATA/ORCL/DATAFILE/sysaux.256.817894089

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 16
4 Full 1896642 12-JUN-13
+DATA/ORCL/DATAFILE/undotbs1.259.817894231
6 Full 1896642 12-JUN-13
+DATA/ORCL/DATAFILE/users.258.817894229

BS Key Type LV Size Device Type Elapsed Time Completion


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Time
------- ---- -- ---------- ----------- ------------ ------------
-
3 Full 9.64M DISK 00:00:04 12-JUN-13
BP Key: 3 Status: AVAILABLE Compressed: NO Tag:
TAG20130612T103848
Piece Name:
+DATA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t103848_0.273.
817900857 s a
SPFILE Included: Modification time: 12-JUN-13 )h a
m
co eฺ
SPFILE db_unique_name: ORCL
o
o uidฺ
Control File Included: Ckp SCN: 1896642 h
Ckp time: 12-JUN-
y a
13
@ n t G
RMAN> k
ac tude
f r z
( it was
Note: There is no data file for your test case because S
created after your backup.
2. Attempt to recover the database with the A L A t h i s command. Expect an error.
U s e
RECOVER DATABASE
Then exit RMAN.
C HO e to u
RMAN> recover database;
2 0atT ns
Starting recover
I % l i e
c12-JUN-13
allocated L
E channel:
b le ORA_DISK_1
M er
A ORA_DISK_1: a
r i e
channel
s f SID=249 device type=DISK

c ha RMAN-00571:
- t r an ===============================================
a n
Z noRMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
RMAN-00571: ===============================================
RMAN-03002: failure of recover command at 12-JUN-13
RMAN-06094: datafile 5 must be restored
RMAN> exit
Recovery Manager complete.
$
Note the error about your missing data file. – A complete recovery in NOARCHIVELOG mode
is only possible, if all the changes since the last backup are contained in the online redo
logs. In real life, this is highly unlikely and you have two possible recovery paths:
1) Drop the missing tablespace or
2) Recover the entire database to the time of the last backup.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 17
The following steps show you option 1.
a. In a terminal window pointing to the ORCL instance, you are logged into SQL*Plus as
SYSDBA. Set the bar22tbs01.dbf file OFFLINE FOR DROP and open the database.
SQL> ALTER DATABASE DATAFILE '/u01/backup/orcl/bar22tbs01.dbf'
OFFLINE FOR DROP;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Database altered.

SQL> ALTER DATABASE OPEN;


Database altered.
SQL>
b. Drop the BAR22TBS tablespace definition.
SQL> DROP TABLESPACE BAR22TBS INCLUDING CONTENTS AND DATAFILES;
Tablespace dropped.
s a
c.
)h a
Now your ORCL database is open, users can access it, but you “lost” the BAR22TBS
tablespace (for training purposes). m
co eฺ
d. o ฺ
Optionally (if you have extra time), list the data file names and tablespace names via
o uid
the DBA_DATA_FILES view.
y a h
@ n t G
SQL> col file_name format a44 k
c ude
SQL> col tablespace_name format a10rza t
( f S
s dba_data_files;
LA e thifrom
SQL> select file_name, tablespace_name
A
O U us
FILE_NAME
C H e to TABLESPACE
2 0 T n s
% c e
-------------------------------------------- ----------

E LI ble li
+DATA/ORCL/DATAFILE/system.257.810505935 SYSTEM

A M era
+DATA/ORCL/DATAFILE/sysaux.256.810505861 SYSAUX
ie ns f
r+DATA/ORCL/DATAFILE/users.258.810506011 USERS
h a r a
n-t
Zac no+DATA/ORCL/DATAFILE/undotbs1.259.810506011
+DATA/ORCL/DATAFILE/example.269.810506153 EXAMPLE
UNDOTBS1
SQL>
Note: ASM assigns unique filenames, expect you numbers to be different.
e. To cleanup this test case, drop the BAR22 user and then exit SQL*Plus.
SQL> DROP USER bar22 CASCADE;
User dropped.
SQL> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 2: Getting Started


Chapter 2 - Page 18
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @Lesson n t G3:
k
ac for de
Configuring
f r z t u
A ( this S
Recoverability
L
O UA use
C H e Chapter
to 3
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 1
Practices for Lesson 3: Overview
Practices Overview
In these practices you multiplex the control files, configure the fast recovery area, configure redo
log files, and configure the database for ARCHIVELOG mode.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

In these practices you configure the default backup destination, set the RMAN display data and
time format, configure control file autobackup, configure the backup retention policy, and
configure a device for backup.

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 2
Practice 3-1: Configuring the Default Backup Destination and
ARCHIVELOG Mode

Overview
In this practice you determine the default backup destination setting, change it to the +FRA disk
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

group, set the DB_RECOVERY_FILE_DEST_SIZE initialization parameter, and verify that the
default location is being used.
Next, you enable ARCHIVELOG mode and restart the ORCL database instance.

Assumptions
You have two terminal windows open, each with the environment variables set for the ORCL
database instance. Use $LABS as your working directory. Unless otherwise indicated, always
work from that directory.

s a
Tasks
)h a
1. The DB_RECOVERY_FILE_DEST parameter specifies the default location for the m Fast
coshoweฺ
o ฺ
Recovery Area. View the parameter by logging in to SQL*Plus and using the
o uid
parameter command.
y a h
$ sqlplus / as sysdba @ n t G
k
ac tude
f r z
A ( this S
SQL> show parameter db_recovery_file_dest
L
O UA use TYPE
NAME
C H e to VALUE

2 0T ens
------------------------------------ ----------- -------------

L I% le lic
db_recovery_file_dest string +DATA

A ME erab
db_recovery_file_dest_size big integer 4800M

a r ie nsf
a c h SQL>
n - tra
Z2. Change
no the parameter to use the +FRA disk group as the default backup destination.
SQL> ALTER SYSTEM SET db_recovery_file_dest ="+FRA";

System altered.
SQL>
3. Verify your changed parameter.
SQL> show parameter db_recovery_file_dest

NAME TYPE VALUE


------------------------------------ ----------- -------------
db_recovery_file_dest string +FRA
db_recovery_file_dest_size big integer 4800M
SQL>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 3
4. Determine the total size of the FRA disk group. There are several tools available: SQL*Plus,
ASMCMD and Enterprise Manager to accomplish this task. SQL*Plus is shown in the
solution.
SQL> SELECT name, total_mb FROM V$ASM_DISKGROUP;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

NAME TOTAL_MB
------------------------------ ----------
FRA 14628
DATA 21942
SQL>
Note: These (or similar) values are expected for your training environment. If you had need
to change the FRA size, you could do it with the ALTER SYSTEM SET
db_recovery_file_dest_size = nn command.
5. s a
Place the ORCL database in archive log mode. Several tools are available to change the log
)h a
mode for a database: Enterprise Manager and SQL*Plus which is shown in the solution.
a. Place the ORCL database in MOUNT mode m
co eฺ
o ฺ
o uid
SQL> SHUTDOWN IMMEDIATE
y a h
Database closed.
@ n t G
Database dismounted. k
ac tude
f r z
ORACLE instance shut down.
L A ( this S
O UA use
SQL> STARTUP MOUNT
C H e to
T
0 Area
ORACLE instance started.
2 ns 534462464 bytes
Total System% c e
LI ble li
Global
Fixed Size
M E a 2290416 bytes

r i e A Size
Variable
s f er 276827408 bytes

c ha Database
- t r an Buffers 247463936 bytes
a
Z noRedo n Buffers 7880704 bytes
Database mounted.
SQL>
b. Execute the ALTER DATABASE ARCHIVELOG command.
SQL> ALTER DATABASE ARCHIVELOG;
Database altered.
SQL>
c. Open the database, list the archive logs, and then exit SQL*Plus
SQL> ALTER DATABASE OPEN;
Database altered.

SQL> archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 4
Oldest online log sequence 11
Next log sequence to archive 13
Current log sequence 13
SQL> exit
$
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Note: The database is now in ARCHIVELOG mode. After a mode change like this, it is best
practice to perform a backup of the entire database.
6. In a terminal window (which is pointing to ORCL), log in to the RMAN client and execute the
BACKUP DATABASE command, and then exit RMAN.
$ rman target "'/ as sysbackup'"
connected to target database: ORCL (DBID=1345675044, not open)

RMAN> BACKUP DATABASE;


s a
)h a
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1 m
co eฺ
channel ORA_DISK_1: SID=250 device type=DISK o ฺ
o uid
y a h
channel ORA_DISK_1: starting full datafile backup set
@ n t G
k
ac tude
channel ORA_DISK_1: specifying datafile(s) in backup set
r z
input datafile file number=00001
f
A ( this S
name=+DATA/ORCL/DATAFILE/system.257.817894153
L
UA use
input datafile file number=00003
O
H e to
name=+DATA/ORCL/DATAFILE/sysaux.256.817894089
C
T
0 ens
input datafile file number=00002
2
I le lic
%
name=+DATA/ORCL/DATAFILE/example.269.817894393
L
ME erab
input datafile file number=00004
A
name=+DATA/ORCL/DATAFILE/undotbs1.259.817894231
ie nsf
a r
h -tra
input datafile file number=00006
a c
Z non
name=+DATA/ORCL/DATAFILE/users.258.817894229
channel ORA_DISK_1: starting piece 1 at 12-JUN-13
channel ORA_DISK_1: finished piece 1 at 12-JUN-13
piece
handle=+FRA/ORCL/BACKUPSET/2013_06_12/nnndf0_tag20130612t145740_
0.256.817916261 tag=TAG20130612T145740 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 12-JUN-13
channel ORA_DISK_1: finished piece 1 at 12-JUN-13
piece
handle=+FRA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t145740_
0.257.817916399 tag=TAG20130612T145740 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 5
Finished backup at 12-JUN-13
RMAN> exit
Note the +DATA input and the +FRA output locations. In other words, you verify your first
task, that the backup destination is the +FRA disk group.
Also note, that the dates do not include the time (just the date).
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 6
Practice 3-2: Setting the Date and Time Format for RMAN
Overview
In this practice, you set the date/time format that RMAN uses for displaying timestamps. The
default date format does not include the time of day information. In this workshop, you will be
performing several backups and recoveries in the same day and in some cases will need to
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

determine which backup to use.

Assumptions
You completed the previous practice.
You have two terminal windows open, each with the environment variables set for the ORCL
database instance. Use $LABS as your working directory. Unless otherwise indicated, always
work from that directory.

Tasks
s a
1. Set the NLS_LANG and NLS_DATE_FORMAT variables such that RMAN includes time )h a
m
information in any timestamp values.
Use the editor of your choice (vi, gedit) and add the following two o o
lines
ฺctoothe end
eฺ of the
a h u i d
~oracle/.bashrc file: y t G
export NLS_LANG=american_america.al32utf8
a c k@ den
(
export NLS_DATE_FORMAT="yyyy-mm-dd:hh24:mi:ss"frz s Stu
a. In a terminal window, invoke your editor.
A LA thi use the gedit editor.
The solutions
e
$ gedit ~oracle/.bashrcOU us
H
C se t o
0 T
b. Copy and paste%
I using
l en buttons and icons in the editor, then save your
2 the imouse
c
changes and
M ELcloseabthelegedit window.
i e A fer
a r a n s
h t r
Zac non-

Note: If you are not copying and pasting the variables, then double-check that the
NLS_LANG value is written correctly: with... a (letter "l", not digit '1').

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 7
c. View the modified file with the cat command.
$ cat ~oracle/.bashrc
# bashrc file for D78850GC10
# Source global definitions
if [ -f /etc/bashrc ]; then
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

. /etc/bashrc
fi

# User specific aliases and functions


export LABS=/home/oracle/labs
export SOLNS=/home/oracle/solutions
export DEMOS=/home/oracle/demos
export WORKS=/home/oracle/workshop
s a
export NLS_LANG=american_america.al32utf8
)h a
export NLS_DATE_FORMAT="yyyy-mm-dd:hh24:mi:ss" m
co eฺ
$ o ฺ
o create
d. Exit out off all your terminal windows. This ensures that when y a hyou
G uidnew ones,
these settings will be in effect.
c k @ ent
( f zastarting
2. Start a new terminal window, and verify the settingsrby
S t ud and listing the
RMAN
A file.this
backups in the recovery catalog or from the control
L
a. Set up the environment for the orclA eand log in to RMAN.
O U database
u s
$ . oraenv
C H e to
ORACLE_SID = [oracle]
2 T
0 e?norcl s
$ rman target
L % c
I "'/le asli sysbackup'"
RMAN> M E ab
A f e r
ie the backups,
b. rList
a n s and note the timestamp format. The output is reduced to the last few
h r a
n-t list backup;
Zac noRMAN>
lines.

. . .
BS Key Type LV Size Device Type Elapsed Time Completion
Time
------- ---- -- ---------- ----------- ------------ ------------
-
2 Full 1.30G DISK 00:01:59 2013-06-
12:10:40:47
BP Key: 2 Status: AVAILABLE Compressed: NO Tag:
TAG20130612T103848
Piece Name:
+DATA/ORCL/BACKUPSET/2013_06_12/nnndf0_tag20130612t103848_0.272.
817900729
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 8
1 Full 1896642 2013-06-12:10:37:04
+DATA/ORCL/DATAFILE/system.257.817894153
2 Full 1896642 2013-06-12:10:37:04
+DATA/ORCL/DATAFILE/example.269.817894393
3 Full 1896642 2013-06-12:10:37:04
+DATA/ORCL/DATAFILE/sysaux.256.817894089
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

4 Full 1896642 2013-06-12:10:37:04


+DATA/ORCL/DATAFILE/undotbs1.259.817894231
6 Full 1896642 2013-06-12:10:37:04
+DATA/ORCL/DATAFILE/users.258.817894229

BS Key Type LV Size Device Type Elapsed Time Completion


Time
------- ---- -- ---------- ----------- ------------ ------------
- s a
3 Full 9.64M DISK 00:00:04 2013-06- )h a
12:10:40:58 m
co eฺ
BP Key: 3 o ฺ
o uid
Status: AVAILABLE Compressed: NO Tag:
y a h
TAG20130612T103848
@ n t G
Piece Name: k
ac tude
r z
+DATA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t103848_0.273.
f
817900857
L A ( this S
UA use
SPFILE Included: Modification time: 2013-06-12:10:37:45
O
H e to
SPFILE db_unique_name: ORCL
C
T
0 ens
Control File Included: Ckp SCN: 1896642
2 Ckp time: 2013-
I le lic
06-12:10:37:04
L %
A METypee r aLVb Size
r i e
BS Key
s f Device Type Elapsed Time Completion

c ha -------
Time
- t r an---- -- ---------- ----------- ------------ ------------
a
Z no-n
4 Full 1.31G DISK 00:02:06 2013-06-
12:14:59:46
BP Key: 4 Status: AVAILABLE Compressed: NO Tag:
TAG20130612T145740
Piece Name:
+FRA/ORCL/BACKUPSET/2013_06_12/nnndf0_tag20130612t145740_0.256.8
17916261
List of Datafiles in backup set 4
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
1 Full 1930404 2013-06-12:14:53:14
+DATA/ORCL/DATAFILE/system.257.817894153
2 Full 1930404 2013-06-12:14:53:14
+DATA/ORCL/DATAFILE/example.269.817894393

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 9
3 Full 1930404 2013-06-12:14:53:14
+DATA/ORCL/DATAFILE/sysaux.256.817894089
4 Full 1930404 2013-06-12:14:53:14
+DATA/ORCL/DATAFILE/undotbs1.259.817894231
6 Full 1930404 2013-06-12:14:53:14
+DATA/ORCL/DATAFILE/users.258.817894229
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

BS Key Type LV Size Device Type Elapsed Time Completion


Time
------- ---- -- ---------- ----------- ------------ ------------
-
5 Full 9.64M DISK 00:00:04 2013-06-
12:15:00:00
BP Key: 5 Status: AVAILABLE Compressed: NO Tag:
TAG20130612T145740 s a
Piece Name: )h a
+FRA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t145740_0.257.8 m
co eฺ
17916399 o
o uidฺ
y a h
SPFILE Included: Modification time: 2013-06-12:14:54:07
@ n t G
SPFILE db_unique_name: ORCL k
ac tude
f r z
A ( this S
Control File Included: Ckp SCN: 1930404 Ckp time: 2013-
06-12:14:53:14
L
RMAN>
O UA use
3. Job Tip: Because the output of C H RMAN
the
e o
tcommands can be quite long, consider using the
RMAN SPOOL LOG TO <file>
2 0 T n s
command to direct the output to your specified file.
% c e
li TO /tmp/test.log in your RMAN window.
E LI SPOOL
a. Optionally, enter
l e LOG
b. RepeatM
A f e r abLIST BACKUP command.
the previous
ie thatnthes output is not displayed in your window. In a second terminal window,
c. rNote
a
c h enter
- a /tmp/test.log to view the output.
trcat
a n
Z noNote: This course does not use the SPOOL LOG command to show you the output
directly.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 10
Practice 3-3: Configuring RMAN Settings
Overview
In this practice, you configure or confirm RMAN settings for the following tasks:
• To back up the control file and server parameter file (SPFILE) each time RMAN takes a
backup of anything in the orcl database.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

• To ensure that one redundant backup is kept.


Then you perform a tablespace backup to verify these settings.

Assumptions
You completed the previous practice.
You have two terminal windows open, each with the environment variables set for the ORCL
database instance. Use $LABS as your working directory.
s a
Tasks a
) h is
1. Logged in to an RMAN session as SYSBACKUP, check whether control file autobackup m
co eฺ
enabled. o ฺ
o uid
a
See step 2a in the previous practice, if you wish to review the login.
y h
@ n t G
RMAN> show controlfile autobackup; k
ac tude
f r z Swith db_unique_name
RMAN configuration parametersLfor A ( database
h i s
ORCL are: U A se t
O to u OFF; # default
CONFIGURE CONTROLFILEHAUTOBACKUP
C
0T ense
2
I% le lic
RMAN>
L
ME eisrnot
Note: Autobackup
A abenabled.
riecontrol
2. Enable
n f
s autobackup.
file
h a r a
n-t configure controlfile autobackup on;
Zac noRMAN>
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN>
Note: The control file and SPFILE will be automatically backed.
3. View the current retention policy setting.
RMAN> show retention policy;

RMAN configuration parameters for database with db_unique_name


ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
RMAN>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 11
4. If your redundancy is 1, go to the next step.
a. If your redundancy has another value, change it to ensure that one copy of each file is
backed up.
RMAN> configure retention policy to redundancy 1;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

old RMAN configuration parameters:


CONFIGURE RETENTION POLICY TO NONE;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters are successfully stored

RMAN>
b. Check the retention policy setting again.
s a
RMAN> show retention policy;
)h a
m
co eฺ
RMAN configuration parameters for database with db_unique_name o ฺ
o uid
ORCL are:
a h
CONFIGURE RETENTION POLICY TO REDUNDANCY @ 1; y n t G
k
ac tude
RMAN>
f r z S OBSOLETE command.
with(the DELETE
5. Delete obsolete backups from prior practices A i s
L
A se t h
RMAN> DELETE OBSOLETE; U u
O betoapplied
RMAN retention policy C Hwill e to the command
0 T
RMAN retention2policy is s
n set to redundancy 1
ice
I% le lORA_DISK_1
allocated Lchannel:
A
channelMEORA_DISK_1:
e r ab SID=280 device type=DISK
f
ie nsthe following obsolete backups and copies:
rDeleting
c h a tra
a n -
Type Key Completion Time
Z no-------------------- ------ ------------------ -----------------
Filename/Handle

---
Backup Set 2 2013-06-12:10:40:47
Backup Piece 2 2013-06-12:10:40:47
+DATA/ORCL/BACKUPSET/2013_06_12/nnndf0_tag20130612t103848_0.272.
817900729
Backup Set 3 2013-06-12:10:40:58
Backup Piece 3 2013-06-12:10:40:58
+DATA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t103848_0.273.
817900857

Do you really want to delete the above objects (enter YES or


NO)? y
deleted backup piece
backup piece
handle=+DATA/ORCL/BACKUPSET/2013_06_12/nnndf0_tag20130612t103848
_0.272.817900729 RECID=2 STAMP=817900729
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 12
deleted backup piece
backup piece
handle=+DATA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t103848
_0.273.817900857 RECID=3 STAMP=817900857
Deleted 2 objects
RMAN>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Note: These are old backup pieces which were created with default parameters. So they
were stored in the +DATA disk group (before you changed the backup destination to the
+FRA disk group).
6. Review the schema to see which data file contains the USERS tablespace.
RMAN> REPORT SCHEMA;
using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name ORCL
s a
List of Permanent Datafiles )h a
m
co eฺ
===========================
o ฺ
o Name
File Size(MB) Tablespace h
RB segs Datafile
y a G uid
c k @ ent
---- -------- -------------------- ------- --------------------
d
frza s Stu
1 800 SYSTEM ***
(
+DATA/ORCL/DATAFILE/system.257.817894153
2 357 EXAMPLE
A LA e*** thi
O U us
+DATA/ORCL/DATAFILE/example.269.817894393
3 800 SYSAUXC H e to ***
0 T
2 icen s
+DATA/ORCL/DATAFILE/sysaux.256.817894089
165 LI% UNDOTBS1
l
4
E
M rab l e ***
+DATA/ORCL/DATAFILE/undotbs1.259.817894231
6ie A5 sfe USERS
a r
h -tra n ***

a c
Z non
+DATA/ORCL/DATAFILE/users.258.817894229

List of Temporary Files


=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- ----------------
1 88 TEMP 32767
+DATA/ORCL/TEMPFILE/temp.268.817894345
RMAN>
Note: If you are not connected to the recovery catalog, the RB segs column contains ***
as a value. It contains the YES and NO values when you are connected to the recovery
catalog.
Note: The USERS tablespace is file number 6 in this example. Yours might be different.
You can back up the tablespace either as data file or as tablespace. The solutions show the
backup with the TABLESPACE option.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 13
7. Back up the USERS tablespace.
RMAN> backup tablespace users;
Starting backup at 2013-06-12:15:22:44
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

channel ORA_DISK_1: specifying datafile(s) in backup set


input datafile file number=00006
name=+DATA/ORCL/DATAFILE/users.258.817894229
channel ORA_DISK_1: starting piece 1 at 2013-06-12:15:22:44
channel ORA_DISK_1: finished piece 1 at 2013-06-12:15:22:45
piece
handle=+FRA/ORCL/BACKUPSET/2013_06_12/nnndf0_tag20130612t152244_
0.258.817917765 tag=TAG20130612T152244 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
s a
Finished backup at 2013-06-12:15:22:45
)h a
c m
o ฺ
o ฺ
o uide
Starting Control File and SPFILE Autobackup at 2013-06-
y a h
12:15:22:45
@ n t G
piece k
ac tude
f r z
handle=+FRA/ORCL/AUTOBACKUP/2013_06_12/s_817917765.259.817917767
comment=NONE
L A ( this S
Finished Control File and SPFILE
O UA usAutobackup
e at 2013-06-
12:15:22:52
C H e to
RMAN>
2 T
0 ens
In the RMAN output,
L I le lic
%note:

A ME
Your data file number
r a b for the USERS tablespace (6 in this example)
ie nsisfeenabled for the Control File and SPFILE files.
• rAutobackup
a
8. ch
a -
Exit RMAN.
n tra
Z noRMAN> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 14
Practice 3-4: Configuring Control Files
Overview
In this practice you multiplex your control files to reduce the chances of failure or data loss. You
use the following tools:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

• Enterprise Manager Database Express 12 (EM Express) to view the existing control
files (as SYSDBA).
• srvctl to stop and start the database (as oracle OS user).
• asmcmd to copy the control file from the +DATA to the +FRA diskgroup (as grid OS
user).
• SQL*Plus and an editor to update the CONTROL_FILES parameter in the initialization
parameter file (as SYSDBA).

Assumptions s a
You completed the previous practice and have two terminal windows open (each pointing ) a
hto the
ORCL instance). m
co eฺ
o
o uidฺ
Tasks y a h
@ G
onnat different disk to
k
Your overall task is to verify that you have at least two control files,
ac tools
each e

( f r z
ensure redundancy. This practice also introduces you to different
S tudfor learning purposes.
1. Using a Browser, launch EM Express for yourA
L ORCL database
t h is by entering
http://<hostname>:5500/em as theA
O U URL.use
CH if sthe
Note: EM Express is only available
explore in a later practice,0isTavailable e to ofistheopen.
database
regardless
(Cloud Control, which you
state of the target database.)
I
If you are unsure about % l i c en you can query it in a terminal window.
2your hostname,
M
$ hostname EL --long
a b le
i e A fer
a r a n s
edRSr39p1.us.oracle.com
h r
Zac a.noLog n-int as the SYS user with the oracle_4U password, using the SYSDBA role.
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 15
2. Click Storage.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

3. Click Control Files.

s a
)h a
m
co eฺ
o
o uid ฺ
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie n1:sfOn the Control Files: General page, how many control files do you have?
Question
a c h Answer:
n - tra 2
Z noQuestion 2: Are they located on different disks?
Answer: No
4. When you are finished reviewing the information available in this interface, click Logout
(top-right).
Note: EM Express is designed for open databases (not for closed or mounted ones).

To ensure redundancy, "move" one control file to a location on the +FRA disk group. Name the
mulitplexed control file: +FRA/ORCL/CONTROLFILE/control02.ctl.
5. Confirm and note the current location and name of one control file.
a. Switch to the grid OS user with the oracle password and point your environment
variables to the +ASM instance.
$ su - grid
Password: oracle <<< not displayed
[grid@host01 ~]$ . oraenv
ORACLE_SID = [grid] ? +ASM

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 16
The Oracle base remains unchanged with value /u01/app/oracle
$
b. Invoke the ASMCMD utility and list the control files.
$ asmcmd
ASMCMD> ls +DATA/orcl/controlfile
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Current.260.821786929
Current.261.817894297
ASMCMD>
Note: You can list the control files with multiple tools, in SQL*Plus with the SHOW
PARAMETER CONTROL_FILES command.
Note the precise name and location of one control file that you will keep in the +DATA disk
group. You need it in a later task step.
________________________________________________________________________
s a
__
)h a
6. m
Confirm or create a synonym for the controlfile directory in the +FRA disk group.
o create
cgroup,
o
a. If there is no synonym for the controlfile directory in the +FRA disk
o ฺ e ฺ
one. a h u i d
y t G
ASMCMD> ls +FRA/orcl/controlfile
a c k@ den
ASMCMD-08002: entry 'controlfile' does
( frz not S tu in directory
exist
'+FRA/orcl/'
A LA e this
OU to us
ASMCMD> mkdir +FRA/orcl/controlfile
ASMCMD> H
C se
b. Exit the asmcmd tool 0 T
2 ithe
and n OS user.
I % l c egrid
ASMCMD> exit
E L ble
$ A M e ra
i e s f
c h ar$ exitt r an
a
Z no$n -
logout

Use RMAN to mulitplex the control file and restart the database instance with the control files in
the +DATA and +FRA disk groups. Optionally, view the control_files parameter. The
commands include:
a. rman target "'/ as sysbackup'"
b. ALTER SYSTEM SET CONTROL_FILES = '<+DATA location1>, <'+FRA'>'
SCOPE=SPFILE;
c. SHUTDOWN IMMEDIATE;
d. STARTUP NOMOUNT;
e. RESTORE CONTROLFILE FROM '+DATA location1';
f. ALTER DATABASE MOUNT;
g. ALTER DATABASE OPEN;
$ rman target "'/ as sysbackup'"

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 17
RMAN> ALTER SYSTEM SET CONTROL_FILES =
'+DATA/ORCL/CONTROLFILE/current.260.821786929','+FRA/ORCL/CONTRO
LFILE/control02.ctl' SCOPE=SPFILE;
using target database control file instead of recovery catalog
Statement processed
RMAN>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Note for after class: To use an automatically generated file name, enter '+FRA'. In class,
enter the entire control file name as shown above, so that future scripts can work with
control02.ctl.
RMAN> shutdown immediate;
database closed
database dismounted
Oracle instance shut down
s a
RMAN> STARTUP NOMOUNT; )h a
m
co eฺ
connected to target database (not started)
o ฺ
o uid
Oracle instance started
a h
534462464 bytesy t G
Total System Global Area
k @ n
Fixed Size 2290416
f r z acbytestude
Variable Size (
276827408
A i s S
bytes
Database Buffers L
A 247463936
e h
t bytes
U s
Redo Buffers
C HO e to u7880704 bytes
2 0T ens FROM
RMAN> RESTORE
L I% le lic
CONTROLFILE

MErestore
'+DATA/ORCL/CONTROLFILE/current.260.821786929';
A
Starting
f e r ab at 2013-07-27:15:08:12
a ie channel
rusing n s ORA_DISK_1
h r a
n-t ORA_DISK_1: copied control file copy
Zac nochannel
output file name=+DATA/ORCL/CONTROLFILE/current.260.821786929
output file name=+FRA/ORCL/CONTROLFILE/control02.ctl
Finished restore at 2013-07-27:15:08:16

RMAN> ALTER DATABASE MOUNT;


Statement processed
released channel: ORA_DISK_1

RMAN> ALTER DATABASE OPEN;


Statement processed

RMAN> SELECT name, value FROM v$parameter WHERE name =


'control_files';

using target database control file instead of recovery catalog


Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 18
NAME
----------------------------------------------------------------
-
VALUE
----------------------------------------------------------------
-
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

control_files
+DATA/ORCL/CONTROLFILE/current.260.821786929,
+FRA/ORCL/CONTROLFILE/control02.ctl

RMAN> exit
$
7. Optionally, view the modified control files in SQL*Plus.
SQL> show parameter control_files s a
)h a
m
co eฺ
NAME TYPE

VALUE
o
o---------------
------------------------------------ -----------
y a h
G uid
-
c k @ ent
rza Stud
control_files string
+DATA/ORCL/CONTROLFILE/current.260.821786929,
( f
+FRA/ORCL/CONTROLFILE/control02.ctl
A LA e this
SQL>
O U us
C H
8. Optionally, view the modified control files into
EM Express. (If you would like to review the
e practice
0 T
navigation, see the first three
2 ofsthis
steps n 3-4.)
% c e
E LI ble li
A M era
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 19
Practice 3-5: Recovery Settings in Cloud Control
Overview
In this practice you confirm and configure settings to reduce the chances of failure or data loss.
This practice also has the aim to introduce you to different tools which are available for backup
and recovery.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
You completed the previous practices and have a terminal window open (pointing to the ORCL
instance).

Tasks
1. Using a Browser, launch Cloud Control for your ORCL database by entering
https://<hostname>:7802/em as the URL.
s a
The first time you enter, you must accept the untrusted connection. In Firefox, click I
)h a
Understand the Risks > Add Exception > With "Permanently store this exception"
selected, click Confirm Security Exception. m
co eฺ
2. o ฺ
o uid
Log in as the SYSMAN user with the oracle_4U password.
y a h
@ n t G
a. If the License Agreement page is displayed, click I Accept.
k
ac tude
b. You do not need to select any item on the Select Enterprise Manager Home page.
f r z
A ( this S
3. Configure the Databases page as your home page in Cloud Control.
L
a. Click Targets (top-left) > Databases > Search List.
O UA use
b. For your own convenience, make this your home page by clicking SYSMAN (top-right)
C H e to
> Set Current Page as My Home.
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Note - only if you are new to Cloud Control: For your "after-class" learning, consider
viewing videos on OLL or youTube.
• Oracle Enterprise Manager 12c: Perform a Simple Installation
• Oracle Enterprise Manager 12c: Console Overview and Customization
If you query OLL with the search "Enterprise Manager Cloud Control", you will receive over
140 suggestions. View anything that interests you.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 20
4. Click the orcl link. - This orcl home page will be a starting point in later navigation tips.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
coas part
o
Note: The databases appear on this list because they have been "discovered"
o ฺ e ฺ of
the course setup. a h u i d
5. To confirm your current recovery settings, click Availability >
y
@ en
Backup &t G
Recovery >
c k
Recovery Settings.
a. The first time you perform this task, you need(fto provide
tud credentials. Click
rza Sdatabase
Named. A LA e this
Note: The NC_SYSDBA named credential
H OU hast o us set up for you in Cloud Control. For
been

0 T C viewing
your "after-class" learning, consider
s e ortheyouTube.
Oracle Enterprise Manager 12c: Create
n
I%2 le lice
and Use Named Credentials video on OLL
L
A ME erab
a r ie nsf
a c h -tra
Z non

b. Ensure that NC_SYSDBA is selected and then click Login.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 21
6. Review the entire page. (Use the scrollbars, as needed.)
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
a. Question: Is ARCHIVELOG mode enabled?
)h a
m
Answer: Yes, because it was configured in a previous practice.
co eฺ
b. Question: Is the fast recovery area enabled? o ฺ
o uid
y a h
Answer: Yes, because the FRA was configured in a previous practice.
@ n t G
c. k
ac tude
Question: Where is the location of the fast recovery area?
Answer: +FRA f r z
d. L A ( this S
Question: Which essential DBA tasks can you perform in this section?
UA use
Answer: You can change the location, size or retention time for the fast recovery area,
O
H e to
as well as enable the Flashback Database functionality.
C
e. 2 T
0 ens
Question: Does changing the size of the Fast Recovery Area require the database to
I le lic
%
be restarted?
L
ME erab
Answer: No, a restart is not required for this change.
A
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 22
Practice 3-6: Configuring Redo Log Files
Overview
In this practice you check how many members are in each redo log group. Ensure that there are
at least two redo log members in each group. One set of members should be stored in the Fast
Recovery Area.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
You completed the previous practice and are logged in to Cloud Control as the SYSMAN user.

Tasks
1. Click Administration > Storage > Redo Log Groups and note how many members are in
the “# of Members” column.
Answer: There are two members in each group.
s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a
2. c hSelect one
n - traof your Inactive Redo Log Groups and click Edit to see where each member of
Z that nogroup is stored. You will see both members in the +DATA disk group.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 23
3. Drop one of the redo log members. (It doesn't matter which one.) Select a member, click
Remove.
Note: You cannot remove a member of a current log group
− If the log group is current, return to the redo groups page.
− Select "Switch logfile" in the Actions pull down, then click Go.
− Select Force Checkpoint in the Actions pull down, then click Go.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

− Select the group you wish to modify and click edit. Select a member and click
Remove.
a. On the Edit Redo Log Group page, click Add.
b. Set Disk Group to FRA, click Continue.
c. Click Apply.

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L %
e l ic provided.
I is automatically
E ab
Note: The file name
M l
4. Click Redo
r i e A
s f er in the locator link and repeat the previous task step 3 for each of
Log Groups

c a tran
the redo log
hOptionally, groups.
a
5.
Z thenoSQL n-command
on the Edit Redo Log Group page, click Show SQL, and then Return to view
that will be executed on your behalf.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 24
6. Optionally, review your modified redo logs in EM Express (Storage > Redo Log Groups).
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 25
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 3: Configuring for Recoverability


Chapter 3 - Page 26
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lesson n t G4: Using
k
ac Recovery de Catalog
the RMAN
( f r z S t u
L A h i s
U AChapterse4 t
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 1
Practices for Lesson 4: Overview
Practices Overview
In these practices, you will perform the one-time setup tasks:
• To create a recovery catalog owner
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

• To create a recovery catalog


• To register the ORCL database in the recovery catalog
• To perform EM setup tasks
And then you will prepare your training environment by creating a backup that will enable you to
restore the database if you are unable to complete the practices as described.

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 2
Practice 4-1: Creating a Recovery Catalog Owner
Overview
In this practice, you create a user and grant appropriate privileges.

Assumptions
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

The rcat database has been created as part of the practice setup. The initialization parameters
have been set as follows:
DB_RECOVERY_FILE_DEST = /u01/app/oracle/fast_recovery_area
DB_RECOVERY_FILE_DEST_SIZE = 10000M
You are in a terminal window with the environment variables pointing to the rcat database
instance.

Tasks
s a
1. Log in to SQL*Plus as the SYS user with the SYSDBA role and create a tablespace named
)h a
RCATBS to hold the repository data. Make it 15 MB in size. m
$ sqlplus / as sysdba o ฺ co eฺ
a h o uid
@ y t G
SQL> CREATE TABLESPACE rcatbs DATAFILE
k n
de15M REUSE;
'/u01/app/oracle/oradata/rcat/rcat01.dbf'
f r z ac SIZE t u
Tablespace created.
A ( i s S
L
A se t h
SQL>
U
HO ecatalog
2. Create a user that will own the recovery
C t o udata. Name the user RCATOWNER. The
default tablespace should0
2 Tthe RCAT
be
n stablespace, and the user should have unlimited
quota on that tablespace.
I% l ic e
SQL> CREATE L
E ab USERl e
rcatowner IDENTIFIED BY "oracle_4U" DEFAULT
M
A fercatbs
TABLESPACE r QUOTA unlimited on rcatbs;
r i e s
c ha SQL>
User
- t r an
created.
a
Z non
3. Grant the RECOVERY_CATALOG_OWNER role to the RCATOWNER user. Exit from SQL*Plus.
SQL> GRANT recovery_catalog_owner to rcatowner;
Grant succeeded.
SQL> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 3
Practice 4-2: Creating the Recovery Catalog
In this practice, you use RMAN to create the recovery catalog in the recovery catalog database.

Assumptions
You finished the previous practice. A terminal window is open with the environment variables
pointing to the rcat database instance.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Tasks
1. Connect to the recovery catalog database by using RMAN. Log in as the recovery catalog
owner you just created.
$ rman catalog rcatowner@rcat

recovery catalog database Password: oracle_4U <<<not displayed


connected to recovery catalog database
s a
RMAN>
)h a
m
2. Create the recovery catalog. - This command may take a couple of minutes toocomplete.
When you see the RMAN> prompt, exit the RMAN session. o o ฺc eฺ
y ah Guid
RMAN> create catalog;
c k @ ent
d
recovery catalog created ( frza s Stu
A LA e thi
RMAN> exit
H OU to us
$
0 T C se
I % 2 icen
E L ble l
A M era
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 4
Practice 4-3: Registering a Database in the Recovery Catalog
In this practice, you use RMAN to register the ORCL database in the recovery catalog that you
just created.

Assumptions
You finished the previous practices. A terminal window is open.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Tasks
1. Set up the environment for the ORCL database. (If you were to continue in your previous
RMAN session, you would be pointing to the wrong database.)
$ . oraenv
ORACLE_SID = [orcl] ? orcl
$
2. a
Connect to the target database (to be registered) and the recovery catalog database by
s
using RMAN.
)h a
$ rman target "'/ as sysbackup'" catalog rcatowner@rcat m
co eฺ
o ฺ
o uid
y a h
connected to target database: ORCL (DBID=1345675044)
@ n t G
recovery catalog database Password: oracle_4U
a k
c ude <<<not displayed
connected to recovery catalog database z
(fr is S t
A
L e th
U A
RMAN>
H O to us
C se
3. Register the database in theTcatalog.
0
RMAN> register
I % 2database;
l i c en
M EL able
r i e
database
s f er
A registered in recovery catalog

c ha starting
- t r an full resync of recovery catalog
a
Z nofull n resync complete
RMAN>
4. To verify that the registration was successful, execute the REPORT SCHEMA command.
Then exit.
RMAN> REPORT SCHEMA;
Report of database schema for database with db_unique_name ORCL

List of Permanent Datafiles


===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ---------------------
-
1 800 SYSTEM YES
+DATA/ORCL/DATAFILE/system.257.817894153

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 5
2 357 EXAMPLE NO
+DATA/ORCL/DATAFILE/example.269.817894393
3 800 SYSAUX NO
+DATA/ORCL/DATAFILE/sysaux.256.817894089
4 165 UNDOTBS1 YES
+DATA/ORCL/DATAFILE/undotbs1.259.817894231
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

6 5 USERS NO
+DATA/ORCL/DATAFILE/users.258.817894229

List of Temporary Files


=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- -----------------
-
s a
1 88 TEMP 32767
+DATA/ORCL/TEMPFILE/temp.268.817894345 )h a
m
co eฺ
RMAN> exit
o ฺ
o uid
$
y a h
Note: @ n t G
k
c ude
• The size of the data files may vary in your setup.za t
( f r S

LA when
If you are not connected to the recovery catalog, s segs column contains ***
theiRB
thyou
as a value. It contains the YES and A
U us
NO values e are connected to the recovery
catalog.. O
H e to
• 0
The data file name ends T C
in a s system assigned identifiers which is different for
unique
2 e n
each setup.
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 6
Practice 4-4: Configuring Enterprise Manager for the RMAN Catalog
In this practice, you register the recovery catalog to be used by Enterprise Manager Cloud
Control.

Assumptions
You completed the previous practices.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Enterprise Manager Cloud Control 12c is installed. The ORCL and RCAT database instances are
added as managed targets.
If you would like to review the Cloud Control login procedure, see practice 3-5 for the Enterprise
Manager login as the SYSMAN user and the Database Login with the named NC_SYSDBA
credentials. Navigate to the orcl home page.

Tasks
1. In Enterprise Manager, navigate to Availability > Backup & Recovery > Recovery
s a
Catalog Settings.
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non
2. Login with the named NC_SYSDBA credentials and then click the Add Recovery Catalog
button.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 7
3. On the Add Recovery Catalog: Database page, ensure that rcat (Database
Instance) is selected as Database Target, and then click Next.
4. On the Add Recovery Catalog: Credentials page perform the following steps:
a. Click Named in the Host Credentials section and ensure that NC_ORACLE is selected.
b. Click More Details, then click Test. - You should get a Success message.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
%
c. Click NamedLinI the Database
e l ic Credentials section and ensure that NC_SYSDBA is
ME erab
selected. l
A
itoeseeMore f
d. rClick
a a n s
Details, then click Test. - You should get a Success message.(Scroll down

a c h -trit.)
Z no n

e. Click Next.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 8
5. On the Add Recovery Catalog: User page, specify NC_SYSTEM credentials for the
RCATOWNER user.
a. Click Named and select NC_SYSTEM as Credential Name.
b. Click More Details, then click Test. - You should get a Success message.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
c. Click Next. ( f r z S
L A h i s
t configuration and click Finish. (A
Processing window may appear.) OU
A review
6. On the Add Recovery Catalog: Review page,
s e your

C H e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non
7. Back on the Recovery Catalog Settings page, select Use Recovery Catalog.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 9
8. Specify Host Credentials. Click Named, confirm NC_ORACLE and click OK.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
( f r z S
A information
The processing window may appear, followed byLthe h i s
t that the target database has
been registered in the recovery catalog. UA e
H O to us
0 T C se
I % 2 icen
E L ble l
A M era
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 10
Practice 4-5: Configuring the Recovery Catalog for Recovery
Overview
Your organization determined that if the recovery catalog is lost or damaged, it needs to be
restored quickly and completely.
In this practice, you configure the retention policy for the recovery catalog (retaining two
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

backups), enable archive log mode, and back up your RCAT database.
You back up the recovery catalog to implement a backup strategy of incremental backups
applied to image copies. This provides a method of fast restore by switching to the image copy
rather than copying the backups back to the original location.
The practice performs the tasks in command line, but a SYSDBA can also perform them in Cloud
Control. (Perform the tasks in one chosen interface.)
Navigation tips:
• a
To configure the retention policy: RCAT home page > Availability > Backup & Recovery
s
a
> Backup Settings > Policy tab > Delete archived redo log files after they have been
)h
backed up the specified number of times > Backups: 2
m
co eฺ
• ฺ
To enable archive log mode: RCAT home page > Availability > Backup & Recovery >
o
o uid
y a h
Recovery Settings > ARCHIVELOG Mode* The database must be restarted. (A wizard
will guide you through the steps.)
@ n t G
• k
ac tude
To back up the database: RCAT home page > Availability > Backup & Recovery >
f r z
A ( this S
Schedule Backup > Schedule Customized Backup > Full > Next > Disk > Next > One
L
Time (Immediately) > Next > Submit Job.
A se
U
Assumptions
C H e to u
O
0 T A terminal
You finished the previous practices.
2 ns window is open with the environment variables
% c e
E LI ble li
pointing to the ORCL database instance.

Tasks A M era
r s f policy with at least redundancy 2.
ie thenretention
c a
1. Configure
ra and use the recovery catalog database as the target, with no catalog
ha. Start-tRMAN
a n
Z nospecified.
$ rman target sys@rcat

target database Password: oracle_4U <<< not displayed


connected to target database: RCAT (DBID=590042858)
RMAN>
b. Make sure that the retention policy for the recovery catalog is set to redundancy
greater than 1. If it is not, set it to at least 2. Exit RMAN.
RMAN> show retention policy;

using target database control file instead of recovery catalog


RMAN configuration parameters for database with db_unique_name
RCAT are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 11
RMAN> configure retention policy to redundancy 2;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

RMAN> exit
$
2. To enable archive log mode:
a. Ensure that the environment variables are set for the RCAT database.
$ . oraenv
ORACLE_SID = [rcat] ? rcat
The Oracle base remains unchanged with value /u01/app/oracle
b. a
Log in to SQL*Plus. Configure the recovery catalog database for ARCHIVELOG mode.
s
Exit SQL*Plus.
)h a
$ sqlplus / as sysdba m
co eฺ
SQL> SHUTDOWN IMMEDIATE o ฺ
o uid
y a h
Database closed.
@ n t G
Database dismounted. k
ac tude
f r z
A ( this S
ORACLE instance shut down.
L
SQL> STARTUP MOUNT O UA use
C H e to
2 T
ORACLE instance started.
0 ens
L %
I Globale l icArea 743243776 bytes
E ab
Total System
MSize l
A
Fixed
e f e r 2292816 bytes
i
arVariable s
n Size
c h t r a 301990832 bytes
n-
Za noDatabase Buffers 432013312 bytes
Redo Buffers 6946816 bytes
Database mounted.

SQL> ALTER DATABASE ARCHIVELOG;


Database altered.

SQL> ALTER DATABASE OPEN;


Database altered.

SQL> archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 16
Next log sequence to archive 18
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 12
Current log sequence 18
SQL> EXIT
$
The recovery catalog database has been placed in archive log mode in order to do a complete
restore.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

3. Back up the recovery catalog database as an image copy and a base for incremental
backups. This provides a method of fast restore by switching to the image copy rather than
copying the backups back to the original location. (You can use a terminal window pointing
to RCAT).
a. Start RMAN and use the recovery catalog database as the target, with no catalog
specified.
$ rman target sys@rcat

target database Password: oracle_4U <<< not displayed


s a
connected to target database: RCAT (DBID=590042858)
)h a
m
co eฺ
RMAN> o ฺ
o uid
y a h
b. Back up the recovery catalog database as an image copy and
@
a base
n t G
for incremental
backups.
z a ck ude
RMAN> BACKUP AS COPY INCREMENTAL LEVEL
( S t
fr 0s DATABASE;
A LA e thi
O U us
Starting backup at 2013-06-13:16:29:11
using target database C H e tofile instead of recovery catalog
control
2 T ns
0 ORA_DISK_1
allocated channel:
% c e
E LI ble li SID=31 device type=DISK
channel ORA_DISK_1:
A
channel M ORA_DISK_1:
e ra starting datafile copy
i e s f
c h arinput
t r a n
datafile file number=00003
n- file
Za nooutput
name=/u01/app/oracle/oradata/rcat/sysaux01.dbf

name=/u01/app/oracle/fast_recovery_area/RCAT/datafile/o1_mf_sysa
ux_8vmwtscl_.dbf tag=TAG20130613T162912 RECID=2 STAMP=818008172
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:26
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001
name=/u01/app/oracle/oradata/rcat/system01.dbf
output file
name=/u01/app/oracle/fast_recovery_area/RCAT/datafile/o1_mf_syst
em_8vmwvlw5_.dbf tag=TAG20130613T162912 RECID=3 STAMP=818008196
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002
name=/u01/app/oracle/oradata/rcat/example01.dbf

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 13
output file
name=/u01/app/oracle/fast_recovery_area/RCAT/datafile/o1_mf_exam
ple_8vmwwfjn_.dbf tag=TAG20130613T162912 RECID=4 STAMP=818008225
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:25
channel ORA_DISK_1: starting datafile copy
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

input datafile file number=00004


name=/u01/app/oracle/oradata/rcat/undotbs01.dbf
output file
name=/u01/app/oracle/fast_recovery_area/RCAT/datafile/o1_mf_undo
tbs1_8vmwx6nk_.dbf tag=TAG20130613T162912 RECID=5
STAMP=818008238
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:16
channel ORA_DISK_1: starting datafile copy
s a
input datafile file number=00005
)h a
name=/u01/app/oracle/oradata/rcat/rcat01.dbf m
co eฺ
output file o ฺ
o uid
a h
name=/u01/app/oracle/fast_recovery_area/RCAT/datafile/o1_mf_rcat
y
@ n t G
bs_8vmwxpdz_.dbf tag=TAG20130613T162912 RECID=6 STAMP=818008247
k
ac tude
f r z
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:03
L A ( this S
UA use
channel ORA_DISK_1: starting datafile copy
O
H e to
copying current control file
output file T C
0 ens
2
I le lic
name=/u01/app/oracle/fast_recovery_area/RCAT/controlfile/o1_mf_T
%
L
AG20130613T162912_8vmwxsgn_.ctl tag=TAG20130613T162912 RECID=7
ME erab
STAMP=818008251
A
a r ie nsf
channel ORA_DISK_1: datafile copy complete, elapsed time:

a c h -tra00:00:03
Z non channel ORA_DISK_1: starting datafile copy
input datafile file number=00006
name=/u01/app/oracle/oradata/rcat/users01.dbf
output file
name=/u01/app/oracle/fast_recovery_area/RCAT/datafile/o1_mf_user
s_8vmwxx6w_.dbf tag=TAG20130613T162912 RECID=8 STAMP=818008253
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:03
channel ORA_DISK_1: starting incremental level 0 datafile backup
set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2013-06-13:16:30:56
channel ORA_DISK_1: finished piece 1 at 2013-06-13:16:30:59
piece
handle=/u01/app/oracle/fast_recovery_area/RCAT/backupset/2013_06

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 14
_13/o1_mf_nnsn0_TAG20130613T162912_8vmwy0dv_.bkp
tag=TAG20130613T162912 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 2013-06-13:16:30:59
RMAN>
Question: Is the current SPFILE included?
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Answer: Yes
c. Review the output (find the tablespace that you created for the recovery catalog) and
then exit.
RMAN> exit
$

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 15
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 4: Using the RMAN Recovery Catalog


Chapter 4 - Page 16
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lesson n t G5:
k
c ude and
aStrategies
Backup( f r z S t
A LA e this
Terminology
H OU Chapter
t o us5
0 T C se
I % 2 icen
E L ble l
A M era
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Backup Strategies and Terminology


Chapter 5 - Page 1
Practices for Lesson 5: Overview
Practices Overview
In this practice you will develop backup strategies for different types of databases with different
requirements.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Backup Strategies and Terminology


Chapter 5 - Page 2
Practice 5-1: Case Study: Developing a Backup Strategy
Overview
In this practice you will develop backup strategies for different types of databases with different
requirements.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
The full range of Oracle backup and recovery tools are available.

Tasks
1. The first case is an online transaction processing (OLTP) database, handling a large
number of transactions per day. The business requirements are no data loss, with minimal
downtime. The time to restore and recover must be less than an hour. The database is 300
GB. Several TB of disk space is available for backups. All the available disks have the
same properties (size, I/O rate, and latency). Tape backup is available.
s a
)h
Question: What steps do you take to protect the database (for instance place the database a
in ARCHIVELOG mode)? m
co eฺ
Question: How much disk space will you need? o ฺ
o uid
Question: What is the retention policy? y a h
@ n t G
Question: Will you use a Fast Recovery Area? k
ac tude
Question: Will you use backupsets or image copies? f r z
L A ( this S
Questions: Will you use full or incremental backups?
Question: What recovery method will you use?
O UA use
C H e to
2. The database is a Decision 2 T
0 Support s (DSS). Data is loaded via SQL*Loader files
nSystem
% c e
li databases. The database DSS keeps data for 10 years.
E LI btransaction
each night from several
l e
A M
The transaction databases
r a only keep 1 year worth of data. The data is updated only in the
r n s fe and
ie are databases,
transaction is replaced in the DSS database. Only new and updated

c a
records
htablespaces
t r aare used to hold the
transferred to the DSS database. The DSS database is 10 TB. Separate
a -
non What else do you need to know to design a backup strategy?
data by year. There are approximately 200 tablespaces.
Z Question:
Examples: What is the cost, availability, and speed of disk storage?
Question: What steps do you take to protect the database?
Question: How much disk or tape space will you need?
Question: What is the retention policy?
Question: Will you use a Fast Recovery Area?
Question: Will you use backupsets or image copies?
Questions: Will you use full or incremental backups?
Question: What recovery method will you use?

3. The database is a recovery catalog, holding the RMAN catalog information for more than 20
databases in the company. Backups and restore operations may be going on at anytime.
The databases are mission critical.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Backup Strategies and Terminology


Chapter 5 - Page 3
4. Question: How are the database recovered if the recovery catalog is unavailable?
Question: What is the retention policy?
Question: Will you use a fast recovery area?
Question: Will you use backupsets or image copies?
Questions: Will you use full or incremental backups?
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Question: What recovery method will you use?

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Backup Strategies and Terminology


Chapter 5 - Page 4
Practice 5-2: Creating a Backup Schedule
Overview
In this practice you will create a backup schedule in Cloud Control. You can view the RMAN
Script on the Review page (step 6).
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
The previous practices have been completed.
You are logged into Cloud Control as SYSMAN and have the menus of the rcat home page
displayed.

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
Tasks O UA use
Schedule nightly disk-based incrementalC H online
e o
tbackups for your whole database, including
0
2 ce
archive logs. Configure the archive
T logs n s
for deletion from disk after the backup is complete.
Schedule the backup L forI%
executionliat 11:00 PM. The schedule should be in effect indefinitely.
M
1. In Cloud Control,
E navigate
a b leto Availability > Backup & Recovery > Schedule Backup.
e r
AchoosefeNC_SYSDBA
r i
2. If needed,
a n s as Database Credentials.
h t r a
Zac non-

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Backup Strategies and Terminology


Chapter 5 - Page 5
3. Confirm or select Whole Database as the object to be backed up and NC_ORACLE as Host
Credentials, and then click Schedule Customized Backup.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o
o uid ฺ
y a h
@ n t G
k
ac tude
f r z
( confirm Sor select the following settings
4. On the Schedule Customized Backup: Options
L A page,
h i s
and then click Next.
U A se t
Backup Type HO e to u
Incremental Backup
C
Backup Mode 0T ens
Online2Backup
L I%• Also e l ic up all archived logs on disk
Advanced
ME era b l back
A f • Delete all archived logs from disk after they are successfully
h a rie ans backed up
c t r
Za non- • Delete obsolete backups

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Backup Strategies and Terminology


Chapter 5 - Page 6
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o
o uidฺ
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 Backup:nsSettings page, select Disk as your backup location,
5. On the Schedule Customized % c e
and then click E LI ble li
Next.
A
6. On the Schedule M Customized
e ra Backup: Schedule page, confirm or select the following
r i e s f
c
settings
hJoba Name-
and
t r an
then click Next.
a
Z non NIGHTLY_BACKUP
Job Description Whole Database Backup
Repeating Selected (Notice how additional context-sensitive details are
displayed.)
Frequency By Days
Type
Repeat Every 1
Repeat Until Indefinite
Start Time. 11:00 PM (This time should not interfere with your regular course
hours; so your instructor might suggest a different time.)
Time Zone Your time zone (you instructor might suggest a time zone.)

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Backup Strategies and Terminology


Chapter 5 - Page 7
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
cothe RMAN
o
7. On the Schedule Customized Backup: Review page, review your settings
o ฺ
and e ฺ
script, and then click Submit Job. a h u i d
y t G
a c k@ den
( frz s Stu
A LA e thi
H OU to us
0 T C se
I % 2 icen
E L ble l
A M era
a r ie nsf
a c h -tra
Z non

8. You should receive a success message. Click View Job.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Backup Strategies and Terminology


Chapter 5 - Page 8
9. On the Execution:rcat page, you should see your job scheduled. Note some of the
characteristics that you provided.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
10. Click the Job Activity link in the navigation bar.
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
T
The Job Activity page displays
2 ns > Job
0 a summary of your jobs. You might decide to use it in later
%
I le li
practices also by navigating: c e
Enterprise > Activity.
L
A MEfrom
Navigation Tip: There
r a b ways to navigate to a database home page, for example, if
are multiple
e RCAT to the ORCL database, you can click: Targets > All Targets,
you wish to navigate
r i e s f the
then click
c an Database Instance link or use the History pull-down.
ha the-trorcl
a
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Backup Strategies and Terminology


Chapter 5 - Page 9
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 5: Backup Strategies and Terminology


Chapter 5 - Page 10
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lesson n t G6:
k
acBackups de
Creating
( f r z S t u
L A h i s
U AChapterse6 t
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 1
Practices for Lesson 6: Overview
Practices Overview
In these practices, you will configure block change tracking, create incremental backups, back
up the control file, back up the archived redo log files, and back up ASM metadata.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 2
Practice 6-1: Configuring Block Change Tracking
Overview
In this practice you will configure Block Change Tracking (BCT). Although BCT is optional, it
reduces the time required for an incremental backup from the time to scan all the blocks in the
database to a time proportional to the number of blocks that have changed since the last
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

backup.
Note: The BCT file can only contain 8 bitmaps, so the backup cannot be optimized if there have
been more than 8 incremental backups since the parent level backup that the new incremental
will be based on. Consider the 8-bitmap limit when developing your incremental backup
strategy. For example, if you make a level 0 database backup followed by 7 differential
incremental backups, then the block change tracking file now includes 8 bitmaps. If you then
make a cumulative level 1 incremental backup, RMAN cannot optimize the backup because the
bitmap corresponding to the parent level 0 backup is overwritten with the bitmap that tracks the
current changes.
s a
Assumptions )h a
co eฺm
The previous practices have been completed.
o ฺ
o database
You have a terminal window open in the $LABS directory pointing to the h
y a orcl
G uid
instance.
c k @ ent
d
Tasks ( frza s Stu
1. Configure block change tracking to place the A file tinhthe
LBCT i default data file creation
destination. A
U us e
H O to database with administrator privileges.
a. Start SQL*Plus and connect
T C
0 ens
to your orcl
e
$ sqlplus / as2sysdba
L %
e l ic
I DB_CREATE_FILE_DEST
b. Ensure that
M E ab
the l initialization parameter is set to the correct

i e A fer
location.
a r a n s PARAMETER DB_CREATE_FILE_DEST
h SQL>
rSHOW
Zac noNAME n-t TYPE VALUE
------------------------------------ ----------- -------------
db_create_file_dest string +DATA
SQL>
c. Enable block change tracking. Execute the following ALTER DATABASE statement:
SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;
Database altered.
SQL>
Note: In practice 6-2, step 6, you will disable block change tracking again, because it is not
a meaningful setting for this training environment.
2. Exit SQL*Plus.
SQL> exit

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 3
Practice 6-2: Using Incremental Backup
Overview
In this practice you create an image copy of the target database for use as a base for an
incremental backup strategy. You perform an incremental level 1 backup, and apply the
incremental to the level 0 backup.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Note: Applying the incremental backup to the level 0 image copies makes the level 0 backup
the same as if you had taken a level 0 instead of the level 1.

Assumptions
The previous practices have been completed.
You have two terminal windows open in the $LABS directory, each pointing to the orcl
database instance.

Tasks s a
1. Execute the lab_06_02_01.sh script from the labs directory. This script creates) theh a
m
INVENTORY tablespace, the INVENTORY user, and populates the schema in
mode. (The execution of the script might take a while because severalo o ฺcoNOLOGGING
tables with eฺ
over
a h u i d
90,000 rows are created. Your row count might be different.) y t G
$ cd $LABS
a c k@ den
$ ./lab_06_02_01.sh
( frz s Stu
. . .
A LA e thi
5 U6 7s
SQL> 2 3
91418 rows created.C
4
H O t o u 8 9 10

0 T s e
I % 2 icen
SQL> 2 L
E l e l
A
Commit Mcomplete.
f e r ab
a ie n2 s
rSQL>
a c h
n -
Tabletraaltered.
Z noSQL> SQL>
Index created.
SQL> SQL>
Table altered.
SQL> SQL>
Table altered.

SQL> SQL> SQL> Disconnected from Oracle Database 12c Enterprise


Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP,
Advanced Analytics
and Real Application Testing options
$
Note: This script can be run multiple times, but note that it completely resets the
INVENTORY schema each time it runs.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 4
2. Back up the orcl database to the /u01/backup/orcl directory.
Note: This is not the default area.
Use the RMAN command-line and set the incremental level to 0.
a. Perform a database incremental level 0 backup. Allocate a channel to use the
/u01/backup/orcl directory for the data file copies destination.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

$ rman target "'/ as sysbackup'"

RMAN> run {
2> ALLOCATE CHANNEL "ch1" DEVICE TYPE DISK FORMAT
"/u01/backup/orcl/%U";
3> BACKUP AS COPY TAG 'BASE01' INCREMENTAL LEVEL 0 DATABASE;
4> }

allocated channel: ch1 s a


channel ch1: SID=48 device type=DISK )h a
m
co eฺ
o ฺ
o uid
Starting backup at 2013-06-14:10:47:56
y a h
channel ch1: starting datafile copy
@ n t G
input datafile file number=00003 k
ac tude
f r z
A ( this S
name=+DATA/ORCL/DATAFILE/sysaux.256.817894089
L
output file name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-
SYSAUX_FNO-3_0eoc5ket tag=BASE01
O UA usRECID=3
e STAMP=818074120
channel ch1: datafile H
C copy e t o
complete, elapsed time: 00:00:45
channel ch1: starting 0 T n s
2 icedatafile copy
I % l
M EL able
input datafile file number=00001
name=+DATA/ORCL/DATAFILE/system.257.817894153
r i e A file
output s f ername=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-
c - t an
ha SYSTEM_FNO-1_0goc5kga
r tag=BASE01 RECID=4 STAMP=818074156
a
Z no n
channel ch1: datafile copy complete, elapsed time: 00:00:35
channel ch1: starting datafile copy
input datafile file number=00002
name=+DATA/ORCL/DATAFILE/example.269.817894393
output file name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-
EXAMPLE_FNO-2_0hoc5khd tag=BASE01 RECID=5 STAMP=818074174
channel ch1: datafile copy complete, elapsed time: 00:00:25
channel ch1: starting datafile copy
input datafile file number=00004
name=+DATA/ORCL/DATAFILE/undotbs1.259.817894231
output file name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-
UNDOTBS1_FNO-4_0ioc5ki6 tag=BASE01 RECID=6 STAMP=818074203
channel ch1: datafile copy complete, elapsed time: 00:00:25
channel ch1: starting datafile copy
input datafile file number=00007
name=+DATA/ORCL/DATAFILE/inventory02.dbf

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 5
output file name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-
INVENTORY_FNO-7_0joc5kj0 tag=BASE01 RECID=7 STAMP=818074213
channel ch1: datafile copy complete, elapsed time: 00:00:07
channel ch1: starting datafile copy
input datafile file number=00005
name=/u01/backup/orcl/inventory01.dbf
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

output file name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-


INVENTORY_FNO-5_0koc5kj7 tag=BASE01 RECID=8 STAMP=818074217
channel ch1: datafile copy complete, elapsed time: 00:00:03
channel ch1: starting datafile copy
input datafile file number=00006
name=+DATA/ORCL/DATAFILE/users.258.817894229
output file name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-
USERS_FNO-6_0loc5kja tag=BASE01 RECID=9 STAMP=818074220
s a
channel ch1: datafile copy complete, elapsed time: 00:00:03
)h a
Finished backup at 2013-06-14:10:50:21 m
co eฺ
o ฺ
o uid
Starting Control File and SPFILE Autobackup at
y a h
2013-06-
14:10:50:22 @ n t G
k
ac tude
piece
f r z
A ( this S
handle=+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818074222.280.818074225
L
comment=NONE
A sAutobackup
USPFILE e
Finished Control File and
H O t o u at 2013-06-
14:10:50:29
0 T C se
released channel:
I % 2 icen
ch1

E L ble l
A
RMAN> M era
iethe backup
b.arAs n s f is performed, notice where the backup files are created. Be sure to
a c h create
n - traa tag for this backup. In this example 'BASE01' is the tag.
Z3. Innanother
o terminal window (in the $LABS directory, pointing to the orcl database
instance), start a workload that updates your database by executing the
lab_06_02_03.sh script.
Note: The script updates over 2000 rows (but this is not important.)
$ ./lab_06_02_03.sh
. . .
2745 rows updated.
. . .
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 6
4. In your RMAN session, perform an incremental level 1 backup to the /u01/backup/orcl
directory. Use the RMAN command as shown.
RMAN> run {
2> ALLOCATE CHANNEL "ch1" DEVICE TYPE DISK FORMAT
"/u01/backup/orcl/%U";
3> BACKUP TAG 'incr_update' INCREMENTAL LEVEL 1 DATABASE;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

4> }
allocated channel: ch1
channel ch1: SID=48 device type=DISK

Starting backup at 2013-06-14:10:58:52


channel ch1: starting incremental level 1 datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00003 s a
name=+DATA/ORCL/DATAFILE/sysaux.256.817894089
)h a
m
co eฺ
channel ch1: starting piece 1 at 2013-06-14:10:58:53
o ฺ
o uid
y a h
channel ch1: finished piece 1 at 2013-06-14:10:58:56
t G
piece handle=/u01/backup/orcl/0noc5l3d_1_1 tag=INCR_UPDATE
@ n
comment=NONE k
ac tude
f r z
A ( this S
channel ch1: backup set complete, elapsed time: 00:00:03
L
channel ch1: starting incremental level 1 datafile backup set

O UA use
channel ch1: specifying datafile(s) in backup set
C H e to
input datafile file number=00001
2 T
0 ens
name=+DATA/ORCL/DATAFILE/system.257.817894153
L I le lic
%
channel ch1: starting piece 1 at 2013-06-14:10:58:56

A ME erab
channel ch1: finished piece 1 at 2013-06-14:10:58:59

a r ie nsf
piece handle=/u01/backup/orcl/0ooc5l3g_1_1 tag=INCR_UPDATE
a c h -tracomment=NONE
Z non channel ch1: backup set complete, elapsed time: 00:00:03
channel ch1: starting incremental level 1 datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00002
name=+DATA/ORCL/DATAFILE/example.269.817894393
channel ch1: starting piece 1 at 2013-06-14:10:58:59
channel ch1: finished piece 1 at 2013-06-14:10:59:02
piece handle=/u01/backup/orcl/0poc5l3j_1_1 tag=INCR_UPDATE
comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:03
channel ch1: starting incremental level 1 datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00005
name=/u01/backup/orcl/inventory01.dbf
input datafile file number=00004
name=+DATA/ORCL/DATAFILE/undotbs1.259.817894231

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 7
input datafile file number=00006
name=+DATA/ORCL/DATAFILE/users.258.817894229
input datafile file number=00007
name=+DATA/ORCL/DATAFILE/inventory02.dbf
channel ch1: starting piece 1 at 2013-06-14:10:59:03
channel ch1: finished piece 1 at 2013-06-14:10:59:18
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

piece handle=/u01/backup/orcl/0qoc5l3n_1_1 tag=INCR_UPDATE


comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:15
Finished backup at 2013-06-14:10:59:18

Starting Control File and SPFILE Autobackup at 2013-06-


14:10:59:18
piece
s a
handle=+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818074758.281.818074761
)h a
comment=NONE
m
co eฺ
Finished Control File and SPFILE Autobackup at 2013-06-
o ฺ
o uid
14:10:59:25
y a h
released channel: ch1
@ n t G
RMAN> k
ac tude
f r z
( is faster S the original level 0 and
Note: The time of the incremental data file backup
some data files do not need to be backedA L A h i s than
up at all, fortexample the users data file.
5. Apply the incremental backups to the O U u se0 backup. Notice the recovery of the
existing level
data file copy and the restore C H e to
operation.
T
0 ens
RMAN> run { %2
L I CHANNELe l ic"ch1" DEVICE TYPE DISK FORMAT
ME erab
2> ALLOCATE l
A
"/u01/backup/orcl/%U";
ie RECOVER f COPY OF DATABASE WITH TAG 'BASE01';
a r n s
a c h 4> -}tra
3>
n
Z noallocated channel: ch1
channel ch1: SID=48 device type=DISK

Starting recover at 2013-06-14:11:07:31


channel ch1: starting incremental datafile backup set restore
channel ch1: specifying datafile copies to recover
recovering datafile copy file number=00003
name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-SYSAUX_FNO-
3_0eoc5ket
channel ch1: reading from backup piece
/u01/backup/orcl/0noc5l3d_1_1
channel ch1: piece handle=/u01/backup/orcl/0noc5l3d_1_1
tag=INCR_UPDATE
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:01
channel ch1: starting incremental datafile backup set restore
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 8
channel ch1: specifying datafile copies to recover
recovering datafile copy file number=00001
name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-SYSTEM_FNO-
1_0goc5kga
channel ch1: reading from backup piece
/u01/backup/orcl/0ooc5l3g_1_1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

channel ch1: piece handle=/u01/backup/orcl/0ooc5l3g_1_1


tag=INCR_UPDATE
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:01
channel ch1: starting incremental datafile backup set restore
channel ch1: specifying datafile copies to recover
recovering datafile copy file number=00002
a
name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-EXAMPLE_FNO-
s
2_0hoc5khd
)h a
channel ch1: reading from backup piece
m
co eฺ
/u01/backup/orcl/0poc5l3j_1_1
o ฺ
o uid
y a h
channel ch1: piece handle=/u01/backup/orcl/0poc5l3j_1_1
tag=INCR_UPDATE
@ n t G
k
ac tude
channel ch1: restored backup piece 1
f r z
A ( this S
channel ch1: restore complete, elapsed time: 00:00:01
L
UA use
channel ch1: starting incremental datafile backup set restore
O
channel ch1: specifying datafile copies to recover
H e to
T C
recovering datafile copy file number=00004
0 ens
2
name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-UNDOTBS1_FNO-
I le lic
%
L
4_0ioc5ki6
ME erab
recovering datafile copy file number=00005
A
a r ie nsf
name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-INVENTORY_FNO-

a c h -tra5_0koc5kj7
Z non recovering datafile copy file number=00006
name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-USERS_FNO-
6_0loc5kja
recovering datafile copy file number=00007
name=/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-INVENTORY_FNO-
7_0joc5kj0
channel ch1: reading from backup piece
/u01/backup/orcl/0qoc5l3n_1_1
channel ch1: piece handle=/u01/backup/orcl/0qoc5l3n_1_1
tag=INCR_UPDATE
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:03
Finished recover at 2013-06-14:11:07:38

Starting Control File and SPFILE Autobackup at 2013-06-


14:11:07:38

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 9
piece
handle=+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818075259.282.818075261
comment=NONE
Finished Control File and SPFILE Autobackup at 2013-06-
14:11:07:46
released channel: ch1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

RMAN>
6. Disable block change tracking in the training environment. You can execute the command
either in SQL*Plus or in RMAN.
RMAN> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;
Statement processed
RMAN>
7. Exit the RMAN client and cleanup your test data by executing the cleanup_06_02.sh
script which removes the INVENTORY tablespace and the INVENTORY user. s a
RMAN> exit )h a
m
co eฺ
$ ./cleanup_06_02.sh
o ฺ
o uid
$
y a h
8. Optionally, use another terminal window to view the output in@ n t G
the /tmp/cleanup.log file
c k e
while the script is executing.
( f r z a
S t ud
$ cat /tmp/cleanup.log
A thison Thu Mar 21 20:13:45
LProduction
SQL*Plus: Release 12.1.0.1.0 A
U use
2013 O
H Oracle.
to
Copyright (c) 1982, T
0 enC2013,se All rights reserved.
SQL> Connected. 2
I% le lic
L
SQL>
A ME edropped.
r ab
ie ns
Tablespace
rSQL> f
c h a a
trdropped.
a
Z no n -
User
SQL> Disconnected from Oracle Database 12c Enterprise Edition
Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP,
Advanced Analytics
and Real Application Testing options
$
9. As SYSBACKUP, delete obsolete backups.
$ rman target "'/ as sysbackup'"

RMAN> delete obsolete;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 10
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ -----------------
---
Backup Set 5 2013-06-12:14:59:59
Backup Piece 5 2013-06-12:14:59:59
+FRA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t145740_0.257.8
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

17916399
Backup Set 6 2013-06-12:15:22:45
Backup Piece 6 2013-06-12:15:22:45
+FRA/ORCL/BACKUPSET/2013_06_12/nnndf0_tag20130612t152244_0.258.8
17917765
Archive Log 7 2013-06-12:21:00:51
+FRA/ORCL/ARCHIVELOG/2013_06_12/thread_1_seq_13.260.817938049
Backup Set 7 2013-06-12:15:22:48
s a
Backup Piece 7 2013-06-12:15:22:48
)h
+FRA/ORCL/AUTOBACKUP/2013_06_12/s_817917765.259.817917767
a
m
co eฺ
Archive Log 8 2013-06-12:22:05:18
o ฺ
o uid
+FRA/ORCL/ARCHIVELOG/2013_06_12/thread_1_seq_14.261.817941915
y a h
Archive Log 9 2013-06-12:22:11:44
@ n t G
k
ac tude
+FRA/ORCL/ARCHIVELOG/2013_06_12/thread_1_seq_15.262.817942299
f r z
A ( this S
Archive Log 10 2013-06-12:22:13:36
L
+FRA/ORCL/ARCHIVELOG/2013_06_12/thread_1_seq_16.263.817942411
Archive Log
O UA use
11 2013-06-13:03:10:29
H e to
+FRA/ORCL/ARCHIVELOG/2013_06_13/thread_1_seq_17.264.817960227
C
Archive Log
2 T
0 ens 12 2013-06-13:09:16:53
I le lic
%
+FRA/ORCL/ARCHIVELOG/2013_06_13/thread_1_seq_18.268.817982211
L
A ME erab
Backup Set 8 2013-06-13:09:23:03

a r ie nsf
Backup Piece 8 2013-06-13:09:23:03

a c h -tra+FRA/ORCL/AUTOBACKUP/2013_06_13/s_817982579.270.817982583
Z non Backup Set
Backup Piece
9
9
2013-06-13:16:45:36
2013-06-13:16:45:36
+FRA/ORCL/BACKUPSET/2013_06_13/nnndf0_tag20130613t164329_0.271.8
18009011
Backup Set 10 2013-06-13:16:45:51
Backup Piece 10 2013-06-13:16:45:51
+FRA/ORCL/AUTOBACKUP/2013_06_13/s_818008864.272.818009151
Backup Set 11 2013-06-13:17:08:11
Backup Piece 11 2013-06-13:17:08:11
+FRA/ORCL/BACKUPSET/2013_06_13/nnndf0_tag20130613t170556_0.273.8
18010363
Control File Copy 2 2013-06-13:17:09:19
/u01/backup/dontouch/control.ctl
Backup Set 12 2013-06-13:17:08:22
Backup Piece 12 2013-06-13:17:08:22
+FRA/ORCL/AUTOBACKUP/2013_06_13/s_818009728.256.818010501

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 11
Archive Log 13 2013-06-13:22:00:53
+FRA/ORCL/ARCHIVELOG/2013_06_13/thread_1_seq_19.274.818028049
Archive Log 14 2013-06-13:22:04:54
+FRA/ORCL/ARCHIVELOG/2013_06_13/thread_1_seq_20.275.818028291
Archive Log 15 2013-06-14:09:00:13
+FRA/ORCL/ARCHIVELOG/2013_06_14/thread_1_seq_21.276.818067611
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Archive Log 16 2013-06-14:10:43:38


+FRA/ORCL/ARCHIVELOG/2013_06_14/thread_1_seq_22.277.818073815
Archive Log 17 2013-06-14:10:44:42
+FRA/ORCL/ARCHIVELOG/2013_06_14/thread_1_seq_23.278.818073877
Backup Set 13 2013-06-14:10:48:13
Backup Piece 13 2013-06-14:10:48:13
+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818074084.279.818074091
Backup Set 14 2013-06-14:10:50:25
s a
Backup Piece 14 2013-06-14:10:50:25
)h
+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818074222.280.818074225
a
m
co eฺ
Backup Set 15 2013-06-14:10:58:54
o ฺ
o uid
Backup Piece 15 h
2013-06-14:10:58:54
y a
/u01/backup/orcl/0noc5l3d_1_1
@ n t G
Backup Set 16 k
ac tude
2013-06-14:10:58:57
f r z
A ( this S
Backup Piece 16 2013-06-14:10:58:57
L
/u01/backup/orcl/0ooc5l3g_1_1
Backup Set
O UA use
17 2013-06-14:10:59:00
Backup Piece C H e to
17 2013-06-14:10:59:00
2 T
0 ens
/u01/backup/orcl/0poc5l3j_1_1
L I le lic
%
Backup Set 18 2013-06-14:10:59:16

A ME erab
Backup Piece 18 2013-06-14:10:59:16

a r ie nsf
/u01/backup/orcl/0qoc5l3n_1_1

a c h -traBackup Set 19 2013-06-14:10:59:21


Z non Backup Piece 19 2013-06-14:10:59:21
+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818074758.281.818074761
Datafile Copy 15 2013-06-14:11:07:37
/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-INVENTORY_FNO-
7_0joc5kj0
Datafile Copy 16 2013-06-14:11:07:38
/u01/backup/orcl/data_D-ORCL_I-1345675044_TS-INVENTORY_FNO-
5_0koc5kj7
Backup Set 20 2013-06-14:11:07:41
Backup Piece 20 2013-06-14:11:07:41
+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818075259.282.818075261
Backup Set 21 2013-06-14:11:23:11
Backup Piece 21 2013-06-14:11:23:11
+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818076188.283.818076191

Do you really want to delete the above objects (enter YES or


NO)? y
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 12
deleted backup piece
backup piece
handle=+FRA/ORCL/BACKUPSET/2013_06_12/ncsnf0_tag20130612t145740_
0.257.817916399 RECID=5 STAMP=817916399
deleted backup piece
backup piece
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

handle=+FRA/ORCL/BACKUPSET/2013_06_12/nnndf0_tag20130612t152244_
0.258.817917765 RECID=6 STAMP=817917764
deleted archived log
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_12/thread_1_seq_13.260.8179380
49 RECID=7 STAMP=817938051
deleted backup piece
backup piece
s a
handle=+FRA/ORCL/AUTOBACKUP/2013_06_12/s_817917765.259.817917767
RECID=7 STAMP=817917767
)h a
deleted archived log m
co eฺ
archived log file o ฺ
o uid
y a h
@ n t G
name=+FRA/ORCL/ARCHIVELOG/2013_06_12/thread_1_seq_14.261.8179419
15 RECID=8 STAMP=817941918 k
ac tude
deleted archived log
f r z
archived log file
L A ( this S
UA use
name=+FRA/ORCL/ARCHIVELOG/2013_06_12/thread_1_seq_15.262.8179422
O
H e to
99 RECID=9 STAMP=817942304
C
T
0 ens
deleted archived log
2
I le lic
%
archived log file
L
ME erab
name=+FRA/ORCL/ARCHIVELOG/2013_06_12/thread_1_seq_16.263.8179424
A
11 RECID=10 STAMP=817942416
ie nsf
a r
h -tra
deleted archived log
a c
Z non archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_13/thread_1_seq_17.264.8179602
27 RECID=11 STAMP=817960229
deleted archived log
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_13/thread_1_seq_18.268.8179822
11 RECID=12 STAMP=817982213
deleted backup piece
backup piece
handle=+FRA/ORCL/AUTOBACKUP/2013_06_13/s_817982579.270.817982583
RECID=8 STAMP=817982582
deleted backup piece
backup piece
handle=+FRA/ORCL/BACKUPSET/2013_06_13/nnndf0_tag20130613t164329_
0.271.818009011 RECID=9 STAMP=818009011
deleted backup piece

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 13
backup piece
handle=+FRA/ORCL/AUTOBACKUP/2013_06_13/s_818008864.272.818009151
RECID=10 STAMP=818009150
deleted backup piece
backup piece
handle=+FRA/ORCL/BACKUPSET/2013_06_13/nnndf0_tag20130613t170556_
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

0.273.818010363 RECID=11 STAMP=818010362


deleted control file copy
control file copy file name=/u01/backup/dontouch/control.ctl
RECID=2 STAMP=818010559
deleted backup piece
backup piece
handle=+FRA/ORCL/AUTOBACKUP/2013_06_13/s_818009728.256.818010501
RECID=12 STAMP=818010501
deleted archived log s a
archived log file )h a
m
co eฺ
name=+FRA/ORCL/ARCHIVELOG/2013_06_13/thread_1_seq_19.274.8180280
49 RECID=13 STAMP=818028053 o ฺ
o uid
y a h
deleted archived log
@ n t G
archived log file k
ac tude
f r z
name=+FRA/ORCL/ARCHIVELOG/2013_06_13/thread_1_seq_20.275.8180282
A ( this S
91 RECID=14 STAMP=818028294
L
deleted archived log
O UA use
archived log file
C H e to
T
0 ens
name=+FRA/ORCL/ARCHIVELOG/2013_06_14/thread_1_seq_21.276.8180676
2
I le lic
%
11 RECID=15 STAMP=818067613
L
ME erab
deleted archived log
A
ie nsf
archived log file
a r
h -tra
name=+FRA/ORCL/ARCHIVELOG/2013_06_14/thread_1_seq_22.277.8180738
a c
Z non
15 RECID=16 STAMP=818073818
deleted archived log
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_14/thread_1_seq_23.278.8180738
77 RECID=17 STAMP=818073882
deleted backup piece
backup piece
handle=+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818074084.279.818074091
RECID=13 STAMP=818074091
deleted backup piece
backup piece
handle=+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818074222.280.818074225
RECID=14 STAMP=818074224
deleted backup piece
backup piece handle=/u01/backup/orcl/0noc5l3d_1_1 RECID=15
STAMP=818074734
deleted backup piece

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 14
backup piece handle=/u01/backup/orcl/0ooc5l3g_1_1 RECID=16
STAMP=818074737
deleted backup piece
backup piece handle=/u01/backup/orcl/0poc5l3j_1_1 RECID=17
STAMP=818074740
deleted backup piece
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

backup piece handle=/u01/backup/orcl/0qoc5l3n_1_1 RECID=18


STAMP=818074755
deleted backup piece
backup piece
handle=+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818074758.281.818074761
RECID=19 STAMP=818074760
deleted datafile copy
datafile copy file name=/u01/backup/orcl/data_D-ORCL_I-
s a
1345675044_TS-INVENTORY_FNO-7_0joc5kj0 RECID=15 STAMP=818075257
)h a
deleted datafile copy
m
co eฺ
datafile copy file name=/u01/backup/orcl/data_D-ORCL_I-
o
o uidฺ
1345675044_TS-INVENTORY_FNO-5_0koc5kj7 RECID=16 STAMP=818075258
y a h
deleted backup piece
@ n t G
backup piece k
ac tude
f r z
A ( this S
handle=+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818075259.282.818075261
RECID=20 STAMP=818075261 L
deleted backup piece
O UA use
backup piece C H e to
2 T
0 ens
handle=+FRA/ORCL/AUTOBACKUP/2013_06_14/s_818076188.283.818076191
I le lic
%
RECID=21 STAMP=818076190
L
ME erab
Deleted 31 objects
A
a r ie nsf
RMAN>

a c hNote: Your
n - traoutput may be different depending on the repetition of practices.
Z10. Optionally,
no crosscheck all data file copies of the ORCL database. Then exit.
RMAN> crosscheck datafilecopy all;

released channel: ORA_DISK_1


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=276 device type=DISK
validation succeeded for datafile copy
datafile copy file name=/u01/backup/orcl/data_D-ORCL_I-
1345675044_TS-SYSTEM_FNO-1_0goc5kga RECID=11 STAMP=818075253
validation succeeded for datafile copy
datafile copy file name=/u01/backup/orcl/data_D-ORCL_I-
1345675044_TS-EXAMPLE_FNO-2_0hoc5khd RECID=12 STAMP=818075254
validation succeeded for datafile copy
datafile copy file name=/u01/backup/orcl/data_D-ORCL_I-
1345675044_TS-SYSAUX_FNO-3_0eoc5ket RECID=10 STAMP=818075252
validation succeeded for datafile copy
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 15
datafile copy file name=/u01/backup/orcl/data_D-ORCL_I-
1345675044_TS-UNDOTBS1_FNO-4_0ioc5ki6 RECID=14 STAMP=818075257
validation succeeded for datafile copy
datafile copy file name=/u01/backup/orcl/data_D-ORCL_I-
1345675044_TS-USERS_FNO-6_0loc5kja RECID=13 STAMP=818075256
Crosschecked 5 objects
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

RMAN> exit
$
Note: Five validated backup should remain.
11. Optionally, view your backups in Cloud Control.
a. Navigate from the orcl home page: Availability > Backup & Recovery > Backup
Reports.
b. If needed, select the NC_SYSDBA as your Named Credential for the database login.
s a
c. You can customize the View Backup Report page. By default, the all types of backups
are displayed, sorted by start time in descending order. )h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Note: Some practices intentionally introduce errors for your learning purpose. Your output
might look different, but it should have a mixture of COMPLETED and FAILED backups.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 6: Creating Backups


Chapter 6 - Page 16
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lesson n t G7:
k
ac Your e
dBackups
Improving
( f r z S t u
L A h i s
U AChapterse7 t
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 1
Practices for Lesson 7: Overview
Practices Overview
In these practices, you will back up the control file, back up the archived redo log files, back up
ASM metadata, and create a KEEP FOREVER database backup that you can use for recovery if
some of your activities were to require it.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 2
Practice 7-1: Backing up Other Database Files
Overview
In this practice you create backups of important database files that are not part of the default
backup set.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
The previous practices have been completed.
You are in a terminal window pointing to the orcl database instance.

Tasks
1. Log in to SQL*Plus and back up the control file to a binary file in the /u01/backup/orcl
directory.
Note: You have already configured automatic backup for the control file. These commands
show you how to perform a manual backup of the control file (for learning purposes). s a
a. Log in to SQL*Plus as SYSBACKUP. )h a
m
co eฺ
$ sqlplus / as sysbackup
o ฺ
o uid
. . .
y a h
SQL> show user @ n t G
k
ac tude
USER is "SYSBACKUP"
f r z
SQL>
L A ( this S
b. Use the ALTER DATABASE BACKUP U A se command.
CONTROLFILE
O
H CONTROLFILE
t o u TO
SQL> ALTER DATABASE BACKUP
0 C
T nse
'/u01/backup/orcl/control.ctl';

I % 2 i ce
Database altered.
SQL> L
E able l
M
A to record er the names of all data files that are included in the control file at the
c. Be
r i esure
s f
a c ha time-tofrathisn backup.
Z noSQL> n SELECT name FROM v$datafile;
NAME
--------------------------------------------------------------
+DATA/ORCL/DATAFILE/system.257.817894153
+DATA/ORCL/DATAFILE/example.269.817894393
+DATA/ORCL/DATAFILE/sysaux.256.817894089
+DATA/ORCL/DATAFILE/undotbs1.259.817894231
+DATA/ORCL/DATAFILE/users.258.817894229
SQL>
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 3
d. Be sure to record the names of all redo log files that are included in the control file at
the time of this backup.
SQL> SELECT member FROM v$logfile;

MEMBER
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

--------------------------------------------------------------
+FRA/ORCL/ONLINELOG/group_3.269.817982249
+DATA/ORCL/ONLINELOG/group_3.267.817894323
+FRA/ORCL/ONLINELOG/group_2.267.817982173
+DATA/ORCL/ONLINELOG/group_2.265.817894313
+FRA/ORCL/ONLINELOG/group_1.266.817982075
+DATA/ORCL/ONLINELOG/group_1.263.817894305
6 rows selected.
s a
)h a
SQL>
m
co eฺ
--------------------------------------------------------------
o
o uidฺ
--------------------------------------------------------------
y a h
@ n t G
k
--------------------------------------------------------------
ac tude
r z
--------------------------------------------------------------
f
A ( this S
--------------------------------------------------------------
L
UA use
--------------------------------------------------------------
O
2. Back up the control file to a traceH file. Thento
view the trace file and exit SQL*Plus.
Note: This command creates T C
0 a SQL e
s to re-create a control file.
% 2 c e nscript
a. Use the ALTERLIDATABASE e i
lBACKUP CONTROLFILE TO TRACE SQL command.
E l
ab BACKUP CONTROLFILE TO TRACE AS
M eDATABASE
A
SQL> ALTER
f r
h a rie ans
'/u01/backup/orcl/control.sql';

a c n - tr
Z noDatabase altered.
SQL> exit
b. View the trace file in a terminal window. What can you learn from its content?
$ cat /u01/backup/orcl/control.sql
-- The following are current System-scope REDO Log Archival
related
-- parameters and can be included in the database initialization
file.
--
-- LOG_ARCHIVE_DEST=''
-- LOG_ARCHIVE_DUPLEX_DEST=''
--
-- LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf
--
-- DB_UNIQUE_NAME="orcl"

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 4
--
-- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'
-- LOG_ARCHIVE_MAX_PROCESSES=4
-- STANDBY_FILE_MANAGEMENT=MANUAL
-- STANDBY_ARCHIVE_DEST=?/dbs/arch
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

-- FAL_CLIENT=''
-- FAL_SERVER=''
--
-- LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST'
-- LOG_ARCHIVE_DEST_1='MANDATORY NOREOPEN NODELAY'
-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM EXPEDITE NOVERIFY SYNC'
-- LOG_ARCHIVE_DEST_1='NOREGISTER NOALTERNATE NODEPENDENCY'
-- LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED
s a
NODB_UNIQUE_NAME'
-- LOG_ARCHIVE_DEST_1='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)' )h a
m
co eฺ
-- LOG_ARCHIVE_DEST_STATE_1=ENABLE
o ฺ
o uid
y a h
-- @ n t G
k
ac each dofe which creates a
-- Below are two sets of SQL statements,
( f r z S t u
new
L A
-- control file and uses itAto open the h i s
t database. The first set
opens U
O to u s e
C H e
-- the database with
0 T the NORESETLOGS
n s option and should be used

I%2versionsce of all online logs are available. The


only if
L l i
E able
-- the current
M
i e A fer the database with the RESETLOGS option and should
second

a r-- s
set opens
a n
h t r
Zac no--n-if online logs are unavailable.
be used

-- The appropriate set of statements can be copied from the


trace into
-- a script file, edited as necessary, and executed when there
is a
-- need to re-create the control file.
--
-- Set #1. NORESETLOGS case
--
-- The following commands will create a new control file and use
it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- Additional logs may be required for media recovery of offline
-- Use this only if the current versions of all online logs are
-- available.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 5
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
s a
LOGFILE
)h a
GROUP 1 ( m
co eฺ
o
'+DATA/ORCL/ONLINELOG/group_1.263.817894305',ฺ
o uid
a h
'+FRA/ORCL/ONLINELOG/group_1.266.817982075'
y
@ n t G
) SIZE 50M BLOCKSIZE 512,
k
ac tude
GROUP 2 (
f r z
A ( this S
'+DATA/ORCL/ONLINELOG/group_2.265.817894313',
L
UA use
'+FRA/ORCL/ONLINELOG/group_2.267.817982173'
O
H e to
) SIZE 50M BLOCKSIZE 512,
C
2
GROUP 3 ( T
0 ens
L I le lic
%
'+DATA/ORCL/ONLINELOG/group_3.267.817894323',

A ME erab
'+FRA/ORCL/ONLINELOG/group_3.269.817982249'

a r ie nsf
) SIZE 50M BLOCKSIZE 512

a c h -tra-- STANDBY LOGFILE


Z non DATAFILE
'+DATA/ORCL/DATAFILE/system.257.817894153',
'+DATA/ORCL/DATAFILE/example.269.817894393',
'+DATA/ORCL/DATAFILE/sysaux.256.817894089',
'+DATA/ORCL/DATAFILE/undotbs1.259.817894231',
'+DATA/ORCL/DATAFILE/users.258.817894229'
CHARACTER SET AL32UTF8
;

-- Configure RMAN configuration record 1


VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE
AUTOBACKUP','ON');
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 6
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '+FRA';
-- ALTER DATABASE REGISTER LOGFILE '+FRA';
-- Recovery is required if any of the datafiles are restored
backups,
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

-- or if the last shutdown was not normal or immediate.


RECOVER DATABASE

-- All logs need archiving and a log switch is needed.


ALTER SYSTEM ARCHIVE LOG ALL;

-- Database can now be opened normally.


ALTER DATABASE OPEN;
s a
-- Commands to add tempfiles to temporary tablespaces. )h a
-- Online tempfiles have complete space information.ฺco
m
h o o ideฺ
-- Other tempfiles may require adjustment.
y a G u
ALTER TABLESPACE TEMP ADD TEMPFILE
k@ den t
'+DATA/ORCL/TEMPFILE/temp.268.817894345' a c
(
SIZE 92274688 REUSE AUTOEXTEND S tu655360 MAXSIZE
frz ONsNEXT
32767M;
A LA e thi
OU to us
-- End of tempfile additions.
H
0TC enscase
e
--
Set #2.2RESETLOGS
I% le lic
--
-- L
E ab commands will create a new control file and use
A
-- The Mfollowing
er
r i e n s f
ha -- -to
it
c t r aopen
a
Z no--n Data usedthebydatabase.
Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.

-- After mounting the created controlfile, the following SQL


-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE

STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 7
MAXLOGHISTORY 292
LOGFILE
GROUP 1 (
'+DATA/ORCL/ONLINELOG/group_1.263.817894305',
'+FRA/ORCL/ONLINELOG/group_1.266.817982075'
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

) SIZE 50M BLOCKSIZE 512,


GROUP 2 (
'+DATA/ORCL/ONLINELOG/group_2.265.817894313',
'+FRA/ORCL/ONLINELOG/group_2.267.817982173'
) SIZE 50M BLOCKSIZE 512,
GROUP 3 (
'+DATA/ORCL/ONLINELOG/group_3.267.817894323',
'+FRA/ORCL/ONLINELOG/group_3.269.817982249'
s a
) SIZE 50M BLOCKSIZE 512
)h a
-- STANDBY LOGFILE m
co eฺ
DATAFILE o ฺ
o uid
'+DATA/ORCL/DATAFILE/system.257.817894153',
y a h
@ n t G
k
'+DATA/ORCL/DATAFILE/example.269.817894393',
ac tude
r z
'+DATA/ORCL/DATAFILE/sysaux.256.817894089',
f
A ( this S
'+DATA/ORCL/DATAFILE/undotbs1.259.817894231',
L
UA use
'+DATA/ORCL/DATAFILE/users.258.817894229'
O
CHARACTER SET AL32UTF8
C H e to
;
2 T
0 ens
L I le lic
%
ME eraRMAN
-- Configure
A b configuration record 1
r ie ns
VARIABLE f
RECNO NUMBER;
c a
h EXECUTE tra :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE
a
Z no n -
AUTOBACKUP','ON');
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '+FRA';
-- ALTER DATABASE REGISTER LOGFILE '+FRA';
-- Recovery is required if any of the datafiles are restored
backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE

-- Database can now be opened zeroing the online logs.


ALTER DATABASE OPEN RESETLOGS;

-- Commands to add tempfiles to temporary tablespaces.


Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 8
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE
'+DATA/ORCL/TEMPFILE/temp.268.817894345'
SIZE 92274688 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE
32767M;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

-- End of tempfile additions.


--
$
Note: The trace file requires some editing before it can be used.
3. Back up the archive log files of the ORCL database, deleting all the archive files once the
backup is complete. (Enter command on one line.)
$ rman target "'/ as sysbackup'" catalog
rcatowner/oracle_4U@rcat
s a
)h a
RMAN> run { m
o ฺ
2> allocate channel "CH1" DEVICE TYPE DISK FORMAT oฺc
'/u01/backup/orcl/%U';
a h o uide
@ y t G
3> backup archivelog all delete all input;
k n
4> }
f r z ac tude
A (catalog i s S
L
A se t
starting full resync of recovery h
U
HO e to u
full resync complete
allocated channel: C
0T device
CH1
2
channel CH1: SID=254
% c e ns type=DISK
E LI ble li
A
StartingM backup
e ra at 2013-06-17:09:16:29
i e s f
c h arcurrent
t r a nlog archived
n-
Za nochannel CH1: starting archived log backup set
channel CH1: specifying archived log(s) in backup set
input archived log thread=1 sequence=24 RECID=18 STAMP=818092807
input archived log thread=1 sequence=25 RECID=19 STAMP=818114517
input archived log thread=1 sequence=26 RECID=20 STAMP=818132435
input archived log thread=1 sequence=27 RECID=21 STAMP=818143355
input archived log thread=1 sequence=28 RECID=22 STAMP=818157724
input archived log thread=1 sequence=29 RECID=23 STAMP=818172168
input archived log thread=1 sequence=30 RECID=24 STAMP=818186577
input archived log thread=1 sequence=31 RECID=25 STAMP=818201035
input archived log thread=1 sequence=32 RECID=26 STAMP=818229718
input archived log thread=1 sequence=33 RECID=27 STAMP=818240435
input archived log thread=1 sequence=34 RECID=28 STAMP=818244609
input archived log thread=1 sequence=35 RECID=29 STAMP=818262025
input archived log thread=1 sequence=36 RECID=30 STAMP=818287581
input archived log thread=1 sequence=37 RECID=31 STAMP=818307007
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 9
input archived log thread=1 sequence=38 RECID=32 STAMP=818327792
channel CH1: starting piece 1 at 2013-06-17:09:16:33
channel CH1: finished piece 1 at 2013-06-17:09:17:08
piece handle=/u01/backup/orcl/0vocdc7h_1_1
tag=TAG20130617T091632 comment=NONE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

channel CH1: backup set complete, elapsed time: 00:00:35


channel CH1: deleting archived log(s)
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_14/thread_1_seq_24.283.8180928
05 RECID=18 STAMP=818092807
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_14/thread_1_seq_25.282.8181145
13 RECID=19 STAMP=818114517
archived log file
s a
33 RECID=20 STAMP=818132435 )h a
name=+FRA/ORCL/ARCHIVELOG/2013_06_15/thread_1_seq_26.281.8181324

m
co eฺ
archived log file
o ฺ
o uid
name=+FRA/ORCL/ARCHIVELOG/2013_06_15/thread_1_seq_27.280.8181433
y a h
51 RECID=21 STAMP=818143355
@ n t G
archived log file k
ac tude
f r z
name=+FRA/ORCL/ARCHIVELOG/2013_06_15/thread_1_seq_28.279.8181577
A ( this S
21 RECID=22 STAMP=818157724
L
archived log file
O UA use
H e to
name=+FRA/ORCL/ARCHIVELOG/2013_06_15/thread_1_seq_29.278.8181721
C
2 T
65 RECID=23 STAMP=818172168
0 ens
I le lic
%
archived log file
L
ME erab
name=+FRA/ORCL/ARCHIVELOG/2013_06_15/thread_1_seq_30.277.8181865
75 RECID=24 STAMP=818186577
A
ie nsf
a r
h -tra
archived log file

a c
Z non
name=+FRA/ORCL/ARCHIVELOG/2013_06_15/thread_1_seq_31.276.8182010
31 RECID=25 STAMP=818201035
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_16/thread_1_seq_32.275.8182297
13 RECID=26 STAMP=818229718
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_16/thread_1_seq_33.274.8182404
33 RECID=27 STAMP=818240435
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_16/thread_1_seq_34.256.8182446
05 RECID=28 STAMP=818244609
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_16/thread_1_seq_35.273.8182620
21 RECID=29 STAMP=818262025
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_16/thread_1_seq_36.272.8182875
77 RECID=30 STAMP=818287581

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 10
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_17/thread_1_seq_37.271.8183070
05 RECID=31 STAMP=818307007
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_17/thread_1_seq_38.270.8183277
91 RECID=32 STAMP=818327792
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Finished backup at 2013-06-17:09:17:13

Starting Control File and SPFILE Autobackup at 2013-06-


17:09:17:13
piece
handle=+FRA/ORCL/AUTOBACKUP/2013_06_17/s_818327834.270.818327837
comment=NONE
Finished Control File and SPFILE Autobackup at 2013-06-
17:09:17:20
s a
released channel: CH1
)h a
RMAN> m
co eฺ
Note: The number of your archive log files is most likely different. ho o ฺ
y a id
uone
4. List the backup archivelog files that could be used to recover to a
@ n G
point int time hour ago
('sysdate-1/24'). Then exit. k
ac tutodewhat is meaningful in
f r z
A ( this S indicates 5 minutes ago.
Note: You may need to adjust the following SYSDATE expression
L
your training environment. For example, 'sysdate-05/60/24'
RMAN> list backup of archivelogO UA uuntil se time 'sysdate-05/60/24';
C H e to
0 T s
List of Backup2Sets cen
%
LI ble li
E
===================
M era
A
ie nSize f
a r a s
a c h -------
BS Key
- t r Device Type Elapsed Time Completion Time
Z non ---------- ----------- ------------ -------------------
23 561.04M DISK 00:00:26 2013-06-17:09:16:59
BP Key: 23 Status: AVAILABLE Compressed: NO Tag:
TAG20130617T091632
Piece Name: /u01/backup/orcl/0vocdc7h_1_1

List of Archived Logs in backup set 23


Thrd Seq Low SCN Low Time Next SCN Next
Time
---- ------- ---------- ------------------- ---------- -------
-
1 24 2088424 2013-06-14:10:44:36 2103968 2013-
06-14:16:00:03
1 25 2103968 2013-06-14:16:00:03 2120995 2013-
06-14:22:01:51
1 26 2120995 2013-06-14:22:01:51 2134879 2013-
06-15:03:00:31
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 11
1 27 2134879 2013-06-15:03:00:31 2146113 2013-
06-15:06:02:28
1 28 2146113 2013-06-15:06:02:28 2159899 2013-
06-15:10:02:00
1 29 2159899 2013-06-15:10:02:00 2173109 2013-
06-15:14:02:45
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

1 30 2173109 2013-06-15:14:02:45 2185175 2013-


06-15:18:02:53
1 31 2185175 2013-06-15:18:02:53 2198035 2013-
06-15:22:03:50
1 32 2198035 2013-06-15:22:03:50 2218529 2013-
06-16:06:01:51
1 33 2218529 2013-06-16:06:01:51 2228835 2013-
06-16:09:00:32
1 34 2228835 2013-06-16:09:00:32 2236346 s a 2013-
06-16:10:10:05
) h a
2013-06-16:10:10:05 2248992 o 2013- m
1 35
06-16:15:00:20
2236346
o o ฺc eฺ
1 36 2248992 2013-06-16:15:00:20 y h
a2268147 G uid2013-
06-16:22:06:15
c k @ ent
d
1 37 2268147
frza s Stu 2281989 2013-
2013-06-16:22:06:15
(
LA e thi
06-17:03:30:04
1 38 2281989 A
U us
2013-06-17:03:30:04 2293549 2013-
06-17:09:16:29 O
H e to
RMAN> exit T C
0 ens
$ % 2
I le lic
L
A MEtheearchive
5. Optionally, view
r a b logs in Cloud Control.
ie nfrom
a. Navigate
r s f the orcl home page: Administration > Storage > Archive Logs.
c a tra select the NC_SYSDBA as your Named Credential for the database login.
hb. If needed,
a
Z no n -

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 12
6. Optionally, view the archive logs in EM Express.
a. Navigate: Storage > Archive Logs.
b. If you want to change the default display order of the archive logs, you can click the
column name. They toggle between ascending and descending.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Note: A downward pointing triangle marks this column as "order by descending" First
Change Number.

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 13
Practice 7-2: Backing up ASM Metadata
Overview
In this practice you create a backup of ASM metadata in the /home/grid/backup directory.
This backup provides a way to re-create the ASM disk groups and directory structure without
having to document and re-create them manually.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
The ORCL target database has at least some of the data files are stored in ASM. The Grid
Infrastructure was installed by the grid OS user.
You are logged in to a terminal window.

Tasks
1. Switch to the grid OS user and set the environment to connect to the +ASM instance
s a
$ su - grid
)h a
Password: oracle <<< not displayed m
co eฺ
$ . oraenv o ฺ
o uid
ORACLE_SID = [grid] ? +ASM
y a h
@ n t G
The Oracle base for k
ac tude
r z
ORACLE_HOME=/u01/app/oracle/product/12.1.0/grid is
f
/u01/app/oracle
L A ( this S
$
O UA use
2. Invoke asmcmd.
C H e to
$ asmcmd
2 T
0 ens
ASMCMD>
L I le lic
%
ME emdbackup
3. Use the ASMCMD
A r ab command to create a backup of ASM metadata. Place the
riein the
backup
n s f
/u01/backup/asm_meta directory.
h a r a
Zac noDiskn-t group
ASMCMD> md_backup /u01/backup/asm_meta/asm_metadata_BAR1
metadata to be backed up: FRA
Disk group metadata to be backed up: DATA
Current alias directory path: ASM/CONTROLFILE
Current alias directory path: ORCL/AUTOBACKUP/2013_06_17
Current alias directory path: ORCL/ONLINELOG
Current alias directory path: ORCL/AUTOBACKUP/2013_06_14
Current alias directory path: ASM
Current alias directory path: ORCL
Current alias directory path: ORCL/controlfile
Current alias directory path: ORCL/AUTOBACKUP
Current alias directory path: ORCL
Current alias directory path: ORCL/CONTROLFILE
Current alias directory path: DB_UNKNOWN
Current alias directory path: ORCL/ONLINELOG
Current alias directory path: DB_UNKNOWN/PARAMETERFILE

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 14
Current alias directory path: ORCL/TEMPFILE
Current alias directory path: ORCL/DATAFILE
ASMCMD>
4. Exit ASMCMD and exit the grid OS user.
ASMCMD> exit
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

$ exit
logout
$
5. Optionally, display your current OS user log in.
$ whoami
oracle
$
Note: You are again logged in as the oracle OS user. s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 15
Practice 7-3: Creating an Archival Backup
Overview
In this practice, you create an archival backup, that is, a backup which is not under your normal
retention policies and it is not in your normal FRA destination. This KEEP FOREVER database
backup could be used for recovery if some of your later hands-on activities were to require it.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Archival backups can be created with an open or with a mounted database.

Assumptions
You are in a terminal window as oracle OS user, pointing to the orcl database instance.

Tasks
1. Ensure that you are logged in to RMAN using the recovery catalog.
$ rman target "'/ as sysbackup'" catalog rcatowner@rcat
s a
...
)h a
recovery catalog database Password: oracle_4U <<<not displayed
m
co eฺ
connected to recovery catalog database
o ฺ
o uid
y a h
@ n t G
RMAN>
k
ac state.tude
f r z
2. Create a backup copy of the entire database in a mounted
RMAN> SHUTDOWN IMMEDIATE;
L A ( this S
O UA use
database closed C H e to
2
database dismounted T
0 ens
L %
I lshut
Oracle instance
e l icdown
A ME erab
r ie STARTUP
n s f MOUNT;
c a RMAN>
h -tra
a n
Z noconnected to target database (not started)
Oracle instance started
database mounted

Total System Global Area 534462464 bytes

Fixed Size 2290416 bytes


Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
RMAN>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 16
3. Backup your ORCL database as an archival backup. Expect an error.
RMAN> backup as copy database keep forever;

Starting backup at 2013-06-17:09:50:51


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

allocated channel: ORA_DISK_1


channel ORA_DISK_1: SID=15 device type=DISK
backup will never be obsolete
archived logs will not be kept or backed up
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003
name=+DATA/ORCL/DATAFILE/sysaux.256.817894089
RMAN-03009: failure of backup command on ORA_DISK_1 channel at
06/17/2013 09:50:54 s a
)h a
ORA-19811: cannot have files in DB_RECOVERY_FILE_DEST with keep
attributes m
co eฺ
o ฺ
o uid
y a h
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting datafile copy
@ n t G
input datafile file number=00001 k
ac tude
f r z
A ( this S
name=+DATA/ORCL/DATAFILE/system.257.817894153
L
RMAN-03009: failure of backup command on ORA_DISK_1 channel at
06/17/2013 09:50:54
O UA use
C H e to
ORA-19811: cannot have files in DB_RECOVERY_FILE_DEST with keep
attributes
2 T
0 ens
I le lic
%
continuing other job steps, job failed will not be re-run
L
ME erab
channel ORA_DISK_1: starting datafile copy
A
a r ie nsf
input datafile file number=00002

a c h -traname=+DATA/ORCL/DATAFILE/example.269.817894393
Z non RMAN-03009: failure of backup command on ORA_DISK_1 channel at
06/17/2013 09:50:54
ORA-19811: cannot have files in DB_RECOVERY_FILE_DEST with keep
attributes
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004
name=+DATA/ORCL/DATAFILE/undotbs1.259.817894231
RMAN-03009: failure of backup command on ORA_DISK_1 channel at
06/17/2013 09:50:56
ORA-19811: cannot have files in DB_RECOVERY_FILE_DEST with keep
attributes
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006
name=+DATA/ORCL/DATAFILE/users.258.817894229
RMAN-00571: ===============================================
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 17
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
RMAN-00571: ===============================================
RMAN-03002: failure of backup command at 06/17/2013 09:50:56
ORA-19811: cannot have files in DB_RECOVERY_FILE_DEST with keep
attributes
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

RMAN>
Question: Why did the backup command fail?
Possible answer: It failed because a backup with the KEEP attribute (an archival backup)
cannot be written to the Flash Recovery Area. Allowing this has the potential of causing the
Flash Recovery Area to quickly run out of space. This error forces you to specify a different
location.
4. Create an archival backup with a FORMAT clause that causes the backup to be written to
the /u01/backup directory.
RMAN> BACKUP DATABASE FORMAT '/u01/backup/%U' TAG keep_db_tag
s a
KEEP forever RESTORE POINT KEEPDB;
)h a
m
co eฺ
Starting backup at 2013-06-17:09:53:45 o ฺ
o uid
y a h
@ n t G
using channel ORA_DISK_1 k
ac tude
f r z S
Aor( backed
backup will never be obsolete
archived logs will not be kept L t h i s up
U A fullsedatafile
channel ORA_DISK_1: starting
H O o u backup set
t datafile(s) in backup set
channel ORA_DISK_1:Cspecifying
0 T s e
I % l i en
input datafile2file number=00003
c
EL abfile
le number=00001
name=+DATA/ORCL/DATAFILE/sysaux.256.817894089
input M
i e A fer datafile

a r a n s
name=+DATA/ORCL/DATAFILE/system.257.817894153

a c h -
input t r datafile file number=00002
Z no n
name=+DATA/ORCL/DATAFILE/example.269.817894393
input datafile file number=00004
name=+DATA/ORCL/DATAFILE/undotbs1.259.817894231
input datafile file number=00006
name=+DATA/ORCL/DATAFILE/users.258.817894229
channel ORA_DISK_1: starting piece 1 at 2013-06-17:09:53:46
channel ORA_DISK_1: finished piece 1 at 2013-06-17:09:55:21
piece handle=/u01/backup/16ocdeda_1_1 tag=KEEP_DB_TAG
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:35

using channel ORA_DISK_1


backup will never be obsolete
archived logs will not be kept or backed up
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 18
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2013-06-17:09:55:23
channel ORA_DISK_1: finished piece 1 at 2013-06-17:09:55:24
piece handle=/u01/backup/17ocdegb_1_1 tag=KEEP_DB_TAG
comment=NONE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

using channel ORA_DISK_1


backup will never be obsolete
archived logs will not be kept or backed up
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
s a
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 2013-06-17:09:55:33 )h a
m
co eฺ
channel ORA_DISK_1: finished piece 1 at 2013-06-17:09:55:34
o ฺ
o uid
piece handle=/u01/backup/18ocdege_1_1 tag=KEEP_DB_TAG
y a h
comment=NONE
@ n t G
k
ac tude
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
f r z
Finished backup at 2013-06-17:09:55:34
L A ( this S
RMAN> O UA use
C H e to
5. Open the database and exitT
RMAN> alterI%
RMAN.
20 icopen;
e ns
E
database
Lprocessedl e l
Mexit erab
Statement
A
a r ie nsf
RMAN>

a c h $ -tra
Z6. Fornoannalternate view of the backups, optionally, log in to Cloud Control as the SYSMAN user
and navigate to Availability > Backup & Recovery > Manage Current Backups. (Look
for the KEEP_DB_TAG tag.)
7. If you do not see your archival backup (that is, there is no backup with Forever in the
Keep column), then:
a. Set the NC_ORACLE host credentials at the bottom of the page, click Crosscheck All.
b. Execute the job Immediately. Click Submit Job > View Job to confirm that the job
execution succeeds.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 19
c. When the job succeeded, navigate again to the Manage Current Backups page (for
example via: History > orcl > Availability > Backup & Recovery > Manage Current
Backups).
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tudeSPFILE, and
Note: The Backup Sets tabbed page shows the archival CONTROLFILE,
( f r z S
DATAFILE.
L A h i s
t navigate; Availability > Backup &
8. Optionally, to view your restore points In A
Cloud Control,
U s e
Recovery > Restore Points.
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Question: Does a non-guaranteed restore point use additional space?


Answer: No.

Not to be executed now!


Recovery steps for possible later use of the archival backup:
a. With your environment variables pointing to the ORCL instance, log in to RMAN and
connect to the RMAN catalog:
rman target "'/ as sysbackup'" catalog rcatowner@rcat
b. Confirm the name of the restore point to be used, KEEPDB in this example:
LIST RESTORE POINT ALL;

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 20
c. Restore and recover your database by using your restore point:
RESTORE DATABASE UNTIL RESTORE POINT 'KEEPDB';
RECOVER DATABASE UNTIL RESTORE POINT 'KEEPDB';
d. Because your database is now at an earlier point in time, open it with the RESETLOGS
option, and display the newly created DBID:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

ALTER DATABASE OPEN RESETLOGS;


SELECT DBID FROM V$DATABASE;
e. In most environments, Oracle recommends to perform a new backup after a recovery:
BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 21
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 7: Improving Your Backups


Chapter 7 - Page 22
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lessonn t G8: Using
k
ac tudeBackups
( f z
RMAN-Encrypted
r S
L A h i s
U AChapterse8 t
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using RMAN-Encrypted Backups


Chapter 8 - Page 1
Practices for Lesson 8: Overview
Practices Overview
In these practices, you will use RMAN to encrypt a backup with a password.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using RMAN-Encrypted Backups


Chapter 8 - Page 2
Practice 8-1: Encrypting a Backup with RMAN
Overview
In this practice you create a password encrypted backup of the ENCTBS tablespace. The
practice shows the steps in Cloud Control. For command line, see the RMAN Script in step 10.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
You logged in to Enterprise Manger Cloud Control as the SYSMAN user and have the orcl
home page displayed.
You also have a terminal window open in the /home/oracle/labs directory pointing to the
orcl instance.

Tasks
1. In a terminal window, execute the lab_08_01_01.sh script (as oracle OS user). This
s a
script creates the ENC user and the ENCTBS tablespace for this practice. The output can be
viewed in the /tmp/setup.log file. )h a
m
co eฺ
$ ./lab_08_01_01.sh
o ฺ
o uid
$ a h
y If tneeded,
@
Backup. n
G log in with
2. Navigate to Availability > Backup & Recovery > Schedule k
ac tude
the NC_SYSDBA named credentials.
f r z
( CredentialsS are set to NC_ORACLE .
3. On the Schedule Backup page, ensure that the
L A Host
h i s
t Backup.
A Customized
select Tablespaces, and then click Schedule
U s e
4. On the Schedule Customized Backup:
t o u page, click Add.
HO Tablespaces
C
0T then
5. Select the ENCTBS tablespace, se the Select button.
click
2 e n
I%Customized
6. Back on the Schedule
L e l ic Backup: Tablespaces page, click Next.
ME erab l
A
ie nsf
a r
h -tra
a c
Z non

7. On the Schedule Customized Backup: Options page:


a. Confirm the following selections
− Full Backup
− Also back up all archived logs on disk
All other choices should be deselected.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using RMAN-Encrypted Backups


Chapter 8 - Page 3
b. Expand the Encryption section and select the following options:
− Use Recovery Manager encryption
− Encryption Algorithm: AES128
− Backups will be encrypted using the following password
c. Enter oracle_4U as Password and Confirm Password. If you choose another
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

password, but please ensure that you will remember it. When you use password
encryption, you must provide the same password for the backup and restore
operations. This is an appropriate technique for backups that will be restored at a
remote location.

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
Note: You can use the Oracle Encryption AWallet s(also
Ulater e known as keystore) only after it is
created and opened which is done O
H e to
in a u
practice.
d. Click Next. T C
0 ens
% 2 ic Settings page, accept Disk as the destination, and
I le lBackup:
8. On the Schedule Customized
L
click Next.
A ME Customized
e rab Backup: Schedule page, enter BACKUP_ENC as Job Name,
9. On theeSchedule
ri the Job n s f
c h a
accept
t r a Description, ensure the Schedule is One Time (Immediately), and then
a
Z non -
click Next.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using RMAN-Encrypted Backups


Chapter 8 - Page 4
10. Review the entire Schedule Customized Backup: Review page and then click Submit Job.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
T
0 inentexts form because that would be a security violation.
Note: The password is not displayed
2
L I% lline
If you are using the command
e l ic
interface, then you also use the SET ENCRYPTION ON...
IDENTIFIED BY E b ONLY command in your RMAN script to enable password
encryption. A
Mpasswordr a
e Job.
riView n s fe
11. h
c a
Click
tra orcl page click the Show link of the Backup Script.
a
Z no
12. On n
the -
Execution:

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using RMAN-Encrypted Backups


Chapter 8 - Page 5
13. Note that also the backup script itself does not show the password. Click OK.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

14. If your backup job is still running, click the Refresh icon (top-right).

15. Optionally, click the Succeeded link in the Status column for Step: Backup, review the
Output Log, and then click Execution:orcl in the navigation bar.

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
( howisyouScan return to the orcl home
16. From the Execution:orcl page there are several Aways
page. For example, click History > orcl. U A se th
L
HO e> orcl
(Alternatives are Targets > Databases
C t o uor All Targets > orcl (Database Instance).
2 0T ens
L I% le lic
A ME erab
Note: Most
r s f practice is optional, but the last cleanup and backup tasks (step 16) are
ieof the nnext
a
h -tra
mandatory.
c
a
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using RMAN-Encrypted Backups


Chapter 8 - Page 6
Practice 8-2: Restoring an Encrypted Backup
Overview
This is an optional challenge practice (because most likely you have not yet covered the restore
and recover operations in class). Attempt this challenge only if you have enough time to
complete it.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

In this practice, you will restore a password-encrypted backup.


Only the last cleanup and backup tasks are mandatory for all.

Assumptions
You completed the previous practice and remember your encryption password.
You are logged in to Cloud Control as the SYSMAN user and have the orcl home page
displayed.
You also have a terminal window open. a
as
Tasks
m )h
1. In the terminal window create an issue by aborting the ORCL database andฺc o the
data file of the ENCTBS tablespace. Then mount the database. h o o deleting
i d eฺ
a u
$ srvctl stop database -d orcl -o abort @y t G
a c k den
frz s Stu
$
(
LA e thi
$ rm /u01/backup/orcl/enctbs01.dbf
A
O-dU orcl u-os mount
$
$ srvctl start database
C seH t o
0 T
enis removed.
$
I % 2the dataicfile
2. Optionally, confirm that
EL able l
M
A fer
$ ls /u01/backup/orcl

a r i e n
0vocdc7h_1_1s
h r a
n-t
Zac nocontrol.sql
control.ctl

data_D-ORCL_I-1345675044_TS-EXAMPLE_FNO-2_0hoc5khd
data_D-ORCL_I-1345675044_TS-SYSAUX_FNO-3_0eoc5ket
data_D-ORCL_I-1345675044_TS-SYSTEM_FNO-1_0goc5kga
data_D-ORCL_I-1345675044_TS-UNDOTBS1_FNO-4_0ioc5ki6
data_D-ORCL_I-1345675044_TS-USERS_FNO-6_0loc5kja
$
Your output may look different, but you should not see the enctbs01.dbf data file.
3. In Cloud Control, navigate to Availability > Backup & Recovery > Perform Recovery. (If
needed, log in with the NC_SYSDBA named credentials.)
Note: It could be that the database failure was already discovered, but for the sake of your
learning experience execute the following steps.
4. On the Perform Recovery page:
a. Select Tablespaces as Recovery Scope.
b. Ensure that "Recover to current time or a previous point-in-time" is selected.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using RMAN-Encrypted Backups


Chapter 8 - Page 7
c. Expand Decrypt Backups and enter the password from the previous practice (either
oracle_4U or your own password) as Password and Confirm Password.
d. Confirm the NC_ORACLE host credentials and click Recover.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H eTablespaces
to
5. On the Perform Object Level
0 T Recovery:
n s page, click Next.
Note: If the ENCTBS% is2 c e click Add, select ENCTBS, and click the Select
not displayed
i
L I l
button.
M E able
i e A fer
a r a n s
h t r
Zac non-

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using RMAN-Encrypted Backups


Chapter 8 - Page 8
6. Confirm "No. Restore the files to the default location. " and then click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

7. On the Perform Object Level Recovery: Schedule page, enter RECOVERY_ENC as Job
Name, accept the Job Description, and click Next.
8. On the Perform Object Level Recovery: Review page, click Edit RMAN Script.

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac in tthisde
For the command line interface, you enter the commands ( f r zshown
u
S RMAN script.
A
Note: The password is not displayed for securityLreasons. th i s
A sdatabase,
inUan online
e
H O
Note: If you perform this type of recovery
t o u you would see the following

0TC enseby '%PASSWORD';


commands:
set decryption2identified
L I% le lic
ME etablespace
run {
sql A'alter
f r ab "ENCTBS" offline immediate';
i e
arrestore s
ntablespace 'ENCTBS';
c h t r a
Za norecovern- tablespace 'ENCTBS';
sql 'alter tablespace "ENCTBS" online';
}
9. Click Submit Job.
10. Click View Job.
11. On the Execution: orcl page, optionally to view the recovery script click the Show link,
review the script, and then click OK.
12. Refresh the Execution: orcl page until you see that the job has the status Succeeded.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using RMAN-Encrypted Backups


Chapter 8 - Page 9
13. Open the ORCL database, if you executed step 1 of this practice.
$ sqlplus / as sysdba
SQL> ALTER DATABASE OPEN;
Database altered.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

SQL> exit
$
14. Mandatory cleanup and backup tasks:
a. Execute the cleanup_08_02.sh script from the $LABS directory to remove the test
data used in this practice. The output can be viewed in the /tmp/cleanup.log file.
$ ./cleanup_08_02.sh
$
s a
b. Execute the backup_orcl.sh script from the $LABS directory to create a new )h a
database backup for the next practices. The output can be viewed in the om
/tmp/backup.log file.
o o ฺc eฺ
$ ./backup_orcl.sh y ah Guid
c k @ ent
$
d
( frza s Stu
A LA e thi
H OU to us
0 T C se
I % 2 icen
E L ble l
A M era
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 8: Using RMAN-Encrypted Backups


Chapter 8 - Page 10
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lesson n t G9:
k de
ac Database
Diagnosing
( f r z S t u Failure
A LA e9 this
Chapter

H OU to us
0 T C se
I % 2 icen
E L ble l
A M era
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 1
Practices for Lesson 9: Overview
Practices Overview
In these practices, you will use the Data Recovery Advisor to diagnose database failure.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 2
Practice 9-1: Diagnosing and Repairing Database Failure
Overview
In this practice you will use Data Recovery Advisor via the RMAN client interface to diagnose
and repair the loss of a data file.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
In the $LABS directory, you have a terminal window open, pointing to the orcl instance.

Tasks
1. Execute the setup_09_01.sh script. This script creates the BAR91TBS tablespace in the
file system, the BAR91 user, the BARCOPY table and populates the table. The script
continues and takes a backup of the tablespace and updates the table. The output of the
script can be viewed in the /tmp/setup.log file.
s a
$ ./setup_09_01.sh
)h a
$
m
co theeฺ
2. Execute the break_09_01.sh script. This script deletes a data file ando ฺ
causes
o uidfile.
a h
database to fail. The output of the script can be viewed in the /tmp/break.log
y
@ n t G
$ ./break_09_01.sh k
ac tude
$
f r z S
3. Continue in another terminal window as theL A ( user
oracle t h i s
with the environment variables
A
U uObserve
pointing to orcl. Attempt to start the database. s e the error message. Exit SQL*Plus.
H O o
$ sqlplus / as sysdba
0 T C se t
I % 2 icen
Connected Lto an idle
E l e l instance.
A M erab
r ie startup
n s f
c a SQL>
h Total traSystem Global Area 534462464 bytes
a n
Z noFixed Size-
2290416 bytes
Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace
file
ORA-01110: data file 5: '/u01/backup/orcl/bar91tbs01.dbf'

SQL> exit

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 3
Optionally, in Cloud Control, if you try to navigate to the orcl home page, it displays
Incidents and Problems similar to this.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

4. Use the Data Recovery Advisor to list the database failure.


$ rman target "'/ as sysbackup'"
s a
)h a
connected to target database: ORCL (DBID=1338286807, not m open)
co eฺ
o ฺ
o uid
RMAN> LIST FAILURE;
y a h
@ n t G catalog
using target database control file instead
k of recovery
ac tude
Database Role: PRIMARY
f r z
L A ( this S
List of Database FailuresUA e
O u s
=========================
C H e to
2 T
0 ens
Failure ID IPrioritylic
%
E L l e Status Time Detected Summary

A f r ab --------- ------------------- -------


M e--------
----------

a r8ie ns HIGH OPEN 2013-06-17:17:57:14 One or more

a c n - tra datafiles are missing


h non-system
Z no RMAN>
Note: If you see more than one failure ID, focus on Failure ID 8. The same applies to
the following steps.
5. Use the Data Recovery Advisor to obtain advice on how to repair the failure.
RMAN> ADVISE FAILURE;
Database Role: PRIMARY

List of Database Failures


=========================

Failure ID Priority Status Time Detected Summary


---------- -------- --------- ------------------- -------
8 HIGH OPEN 2013-06-17:17:57:14 One or more
non-system datafiles are missing

analyzing automatic repair options; this may take some time


Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 4
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=15 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

========================
no manual actions available

Optional Manual Actions


=======================
1. If file /u01/backup/orcl/bar91tbs01.dbf was unintentionally
renamed or moved, restore it

s a
Automated Repair Options
======================== )h a
m
co eฺ
Option Repair Description
o
o uidฺ
------ ------------------
y a h
1 Restore and recover datafile 5 @ n t G
k
ac tude
f r z
Strategy: The repair includes complete media recovery with no
data loss
L A ( this S
UA use
Repair script:
O
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2262014231.hm
H e to
RMAN>
T C
Note: If you see more % 2
than c e ns manual action, focus on the one that references
0one optional
bar91tbs01.dbf. E LI ble li
6. Use the DataA MRecovery
e ra Advisor to repair the failure. Examine the script that was generated
i e s f
r repairanbefore it executes. Enter Y or YES when prompted to execute the script and
forathis
a c h
to open - tr database.
the
n
Z noRMAN> repair failure;
Strategy: The repair includes complete media recovery with no
data loss
Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2262014231.hm

contents of repair script:


# restore and recover datafile
restore ( datafile 5 );
recover datafile 5;
sql 'alter database datafile 5 online';

Do you really want to execute the above repair (enter YES or


NO)? y
executing repair script

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 5
Starting restore at 2013-06-17:18:01:08
using channel ORA_DISK_1

channel ORA_DISK_1: restoring datafile 00005


input datafile copy RECID=19 STAMP=818358829 file
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

name=+FRA/ORCL/DATAFILE/bar91tbs.274.818358829
destination for restore of datafile 00005:
/u01/backup/orcl/bar91tbs01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00005
output file name=/u01/backup/orcl/bar91tbs01.dbf RECID=0 STAMP=0
Finished restore at 2013-06-17:18:01:10

Starting recover at 2013-06-17:18:01:10


using channel ORA_DISK_1 s a
)h a
m
co eฺ
starting media recovery
media recovery complete, elapsed time: 00:00:01ho o ฺ
y a G uid
c k @ ent
d
frza s Stu
Finished recover at 2013-06-17:18:01:12
(
A thi5 online
sql statement: alter database A Ldatafile
repair failure completeOU u se
C H e to
T
0 the s
ndatabase
Do you want to2open c e
L I % l i (enter YES or NO)? y
databaseEopened le
A M erab
a r ie nsf
RMAN>aexit
a c h -tr
Z no$n
7. Clean up the environment following this practice by executing the cleanup_09_01.sh.
script. The output is in the /tmp/cleanup.log file.
$ ./cleanup_09_01.sh
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 6
Practice 9-2: Performing and Analyzing Instance Recovery
Overview
In this practice you will force an instance failure and examine the steps taken by the instance
during instance recovery.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
In the $LABS directory, you have a terminal window open, pointing to the orcl instance.

Tasks
1. Abort the instance and restart it. You can abort the instance in multiple ways:
• The simplest is to use the SQL*Plus SHUTDOWN ABORT command or the stop
database –d orcl –o abort SRVCTL command (shown below).
• Other methods, such as finding the process id of the SMON process and executing the
s a
kill -9 <pid> OS command may not be effective if you are working in a
)h a
environment where Oracle Restart is installed, as in the classroom. m
co eฺ
$ srvctl stop database -d orcl -o abort o
o uidฺ
y a h
$
@ n t G
$ srvctl start database -d orcl k
ac the most de
2. Examine the alert log for the orcl instance. Starting( f r zfrom t u
S recent entries at the
A Whatth i s
U
to recover the instance and ensure database ALconsistency?
bottom of the file find the restart of the instance.
s e
are the steps the instance performed

a. Using the ADRCI show alert H Ocommand,


t o uview the alert log for the orcl instance. Set
T
the editor to gedit to0view
Cthe alerts e
% 2 c e n log more easily. The default editor is vi. The
L ble li you select an alert log.
gedit windowIopens after
E
$ adrci
A M era
r ie nRelease
ADRCI: s f 12.1.0.1.0 - Production on Mon Jun 17 18:06:44
h a r a
n-t
Zac noCopyright
2013
(c) 1982, 2013, Oracle and/or its affiliates. All
rights reserved.
ADR base = "/u01/app/oracle"

adrci> set editor gedit


adrci> show alert

Choose the home from which to view the alert log:

1: diag/rdbms/orcl/orcl
2: diag/rdbms/emrep/emrep
3: diag/rdbms/rcat/rcat
Q: to quit
Please select option:

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 7
b. Your might have different alert logs based on prior activities. Select your orcl alert
log.
Please select option: 1
Output the results to file: /tmp/alert_4196_14017_orcl_1.ado
Please select option:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

c. Examine the alert log in the gedit window. Interesting portions of an alert log are
shown in the next few steps.
d. Find the output from "terminating" (start your search from the bottom upwards).

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

e. Find the release of the database that you started and its spfile location.

Starting up:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 -
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options.
ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1
System name:Linux
Node name:EDRSR39P1

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 8
Release:2.6.39-200.24.1.el6uek.x86_64
Version:#1 SMP Sat Jun 23 02:39:07 EDT 2012
Machine:x86_64
Using parameter settings in server-side spfile
+DATA/orcl/spfileorcl.ora
System parameters with non-default values:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

processes = 300

f. Find the instance recovery action. The redo roll forward action makes the database
consistent.
. . .
Completed: ALTER DATABASE MOUNT /* db agent *//* {0:0:9369} */
ALTER DATABASE OPEN /* db agent *//* {0:0:9369} */
2013-06-17 18:05:52.096000 +00:00
s a
Beginning crash recovery of 1 threads
)h a
parallel recovery started with 2 processes m
co eฺ
Started redo scan o ฺ
o uid
Completed redo scan
y a h
@ n t G
k
read 623 KB redo, 323 data blocks need recovery
ac tude
Started redo application at
f r z
A ( this S
Thread 1: logseq 48, block 3
L
UA use
2013-06-17 18:05:53.520000 +00:00
O
H e to
Recovery of Online Redo Log: Thread 1 Group 3 Seq 48 Reading mem
C
0
2 T
0 ens
I le lic
%
Mem# 0: +DATA/ORCL/ONLINELOG/group_3.267.817894323
L
ME erab
Mem# 1: +FRA/ORCL/ONLINELOG/group_3.269.817982249
A
Completed redo application of 0.51MB
ie nsf
a r
h -tra
2013-06-17 18:05:55.515000 +00:00
a c
Z non
Completed crash recovery at
Thread 1: logseq 48, block 1250, scn 2412497
323 data blocks read, 323 data blocks written, 623 redo k-bytes
read
. . .
Completed: ALTER DATABASE OPEN /* db agent *//* {0:0:9369} */
CJQ0 started with pid=56, OS id=4097
2013-06-17 18:06:38.382000 +00:00
db_recovery_file_dest_size of 4800 MB is 35.23% used. This is a
user-specified limit on the amount of space that will be used by
this
database for recovery-related files, and does not reflect the
amount of
space available in the underlying filesystem or ASM diskgroup.
...
Note: After other processes perform their activities, transaction rollback is enabled and any
transactions that were incomplete are rolled back.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 9
After the database is opened, you get recovery related space information.
g. Exit the editor by clicking the x (close Window) icon.
h. Enter Q to quit the show alert command in ADRCI.
Please select option: q
adrci>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

i. Enter exit to exit ADRCI.


adrci> exit
$

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 10
Practice 9-3: Analyzing Database Failure in ASM
Overview
In this optional practice, you repeat the previous topics, but you will use a tablespace in ASM
(rather than the file system, as above). You will see how the failure is automatically recovered.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
You completed the previous practices and have time for this additional one.
In the $LABS directory, you have a terminal window open, pointing to the orcl instance.

Tasks
1. To prepare your practice environment, execute the setup_09_03.sh script.. This script
creates a tablespace in ASM, a user, a table and populates the table. Then the script takes
a backup of the tablespace and updates the table. The output of the script is redirected to
s a
/tmp/setup.log.
)h a
$ ./setup_09_03.sh
m
co eฺ
$
o ฺ
oto fail.uToiddelete an
2. Execute the break_09_03.sh script. This script causes the database a h
y as training
ASM file, the session switches to the grid user (which has oracle@ n t G password),
then returns as the oracle user. The output of the script
k de to
acis redirected
( f r z S t u
/tmp/break.log.
L A h i s
$ ./break_09_03.sh
U A se t
Password: oracle <<< H notO displayed
t o u
$ C
0T ense
3. Start the database Iin%
2 icview the error, and then exit.
L l e l
SQL*Plus,

A ME /erasabsysdba
$ sqlplus

a r ie nsf
a c h Connected
n - tra to an idle instance.
Z no
SQL> startup
ORACLE instance started.

Total System Global Area 534462464 bytes


Fixed Size 2290416 bytes
Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace
file
ORA-01110: data file 5: '+DATA/ORCL/DATAFILE/bar93tbs01.dbf'
SQL>
SQL> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 11
4. Use the Data Recovery Advisor via the RMAN client interface to fix the problem.
a. Which commands can you use? (If you do not recall them, review the first practice)
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
b. Execute the commands.
$ rman target "'/ as sysbackup'"
. . .
connected to target database: ORCL (DBID=1345675044, not open)
RMAN> list failure;

s a
using target database control file instead of recovery catalog
)h a
Database Role: PRIMARY m
co eฺ
o ฺ
o uid
List of Database Failures
y a h
@ n t G
========================= k
ac tude
f r z S
Failure ID Priority Status
L A ( Detected
Time
t h i s Summary
---------- -------- --------- A
U us e
------------------- -------
O
H e to2013-06-17:18:40:42 One or more
8 HIGH
T C
0 are
OPEN
smissing
non-system datafiles
2 e n
L I% le lic
RMAN> M E afailure;
advise b
A f e r
a r ie ns
Database Role: PRIMARY

a c h -tra
Z noList n of Database Failures
=========================

Failure ID Priority Status Time Detected Summary


---------- -------- --------- ------------------- -------
8 HIGH OPEN 2013-06-17:18:40:42 One or more
non-system datafiles are missing

analyzing automatic repair options; this may take some time


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=16 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions


========================
no manual actions available
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 12
Optional Manual Actions
=======================
1. If file +DATA/ORCL/DATAFILE/bar93tbs01.dbf was
unintentionally renamed or moved, restore it
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Automated Repair Options


========================
Option Repair Description
------ ------------------
1 Restore and recover datafile 5
Strategy: The repair includes complete media recovery with no
data loss
Repair script: s a
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_706892101.hm
)h a
RMAN> m
co eฺ
RMAN> repair failure; o
o uidฺ
a h
Strategy: The repair includes complete cmedia k @yrecovery
e n t G
z a t u d with no
data loss
A (fr is S
AL se th
Repair script:
U
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_706892101.hm

C HO e to u
contents of repair
2 0T script:
e ns
# restore
L % li c
I andlerecover datafile
E b
M e(radatafile
restore 5 );
A f
h a rie recover
a n s datafile 5;
a c n - t
sqlr 'alter database datafile 5 online';
Z no
Do you really want to execute the above repair (enter YES or
NO)? y
executing repair script

Starting restore at 2013-06-17:18:44:19


using channel ORA_DISK_1

channel ORA_DISK_1: restoring datafile 00005


input datafile copy RECID=20 STAMP=818361402 file
name=+FRA/ORCL/DATAFILE/bar93tbs.275.818361401
destination for restore of datafile 00005:
+DATA/ORCL/DATAFILE/bar93tbs01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00005
output file name=+DATA/ORCL/DATAFILE/bar93tbs01.dbf RECID=0
STAMP=0
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 13
Finished restore at 2013-06-17:18:44:22

Starting recover at 2013-06-17:18:44:23


using channel ORA_DISK_1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

starting media recovery


media recovery complete, elapsed time: 00:00:01

Finished recover at 2013-06-17:18:44:25

sql statement: alter database datafile 5 online


repair failure complete

s a
Do you want to open the database (enter YES or NO)? y
)h a
database opened m
co eฺ
o
o uidฺ
RMAN> exit
y a h
@ n t G
$
k
acthe orcl e
dinstance.
( f r
5. Optionally, as oracle OS user examine the alert log zfor
S t u For sample
questions, review the previous practice.
LA e thfile is
A
U us
6. As oracle OS user execute the cleanup_09_03.sh to remove the practice
O
H toetheto/tmp/cleanup.log file. Close all terminal
environment. The output is redirected
windows. T
0 ensC
% 2
I le lic
$ ./cleanup_09_03.sh
L
$
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 14
Practice 9-4: Repairing Block Corruption
Overview
In this practice you will use the Data Recovery Advisor to setup, discover, and repair a
corrupted block in a data file.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
In the $LABS directory, you have two terminal windows open, pointing to the orcl instance.

Tasks
1. Set up for this practice by executing the setup_09_04.sh. This script creates the BC
user, the BCTBS tablespace, and the BCCOPY table. The table is populated, a backup is
taken and the table is updated to prepare for this practice. The output can be viewed with
the cat /tmp/setup.log Linux command.
s a
$ ./setup_09_04.sh
$ )h a
m
co eฺ
o ฺ
2. Corrupt a data file created in the previous step by executing the break_09_04.sql
o uid
script.
a h
Note: The corrupt block error is expected. The script performs @ayquery against
t G the BCCOPY
k n
table to force the corrupt block to be discovered.
f r z ac tude
$ sqlplus /nolog @break_09_04.sql(
A i s S
. . . L
A se t h
BLOCK_NO OU
FILE_NO
C H e to u
---------- ----------
2 0T129 ens
I% le lic
7
L
E ab
A
System Maltered.
er
r i e s f
c ha 'Enter- t r anBlock number when prompted'
a
Z noEnter n value for block_no: 129 <<< enter your BLOCK_NO
0+1 records in
0+1 records out
80 bytes (80 B) copied, 4.1543e-05 s, 1.9 MB/s
0+1 records in
0+1 records out
79 bytes (79 B) copied, 4.2713e-05 s, 1.8 MB/s

SELECT * from bc.bccopy


*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 5, block # 129)
ORA-01110: data file 5: '/u01/backup/orcl/bctbs01.dbf'

. . .
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 15
3. Using RMAN as SYSBACKUP, connect to the orcl instance and check for failures with the
LIST FAILURE command.
$ rman target "'/ as sysbackup'"
...
RMAN> LIST FAILURE;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

using target database control file instead of recovery catalog


Database Role: PRIMARY

List of Database Failures


=========================

Failure ID Priority Status Time Detected Summary


---------- -------- --------- ------------------- -------
s a
2063 HIGH OPEN 2013-06-18:11:38:11 Datafile 5:
'/u01/backup/orcl/bctbs01.dbf' contains one or more corrupt )h a
blocks m
co eฺ
o ฺ
o uid
y a h
RMAN>
@ n t G
4. Use the RMAN ADVISE FAILURE command and view k de repair strategy.
c suggested
athe
f r z t u
RMAN> ADVISE FAILURE;
L A ( this S
O UA use
Database Role: PRIMARY
C H e to
2 T ns
0Failures
% c e
LI ble li
List of Database
E
M era
=========================
A
r ie nID s f
c a
h -tra Priority Status Time Detected
Failure Summary
a n
Z no---------- -------- --------- ------------------- -------
2063 HIGH OPEN 2013-06-18:11:38:11 Datafile 5:
'/u01/backup/orcl/bctbs01.dbf' contains one or more corrupt
blocks

analyzing automatic repair options; this may take some time


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=16 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions


========================
no manual actions available

Optional Manual Actions


=======================
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 16
no manual actions available

Automated Repair Options


========================
Option Repair Description
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

------ ------------------
1 Recover multiple corrupt blocks in datafile 5
Strategy: The repair includes complete media recovery with no
data loss
Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_3058543729.hm
RMAN>
5. Use the RMAN REPAIR FAILURE command to recover the corrupted blocks.
s a
Note: The name of the repair script is listed so that you can inspect it before you execute it.
)h a
RMAN> REPAIR FAILURE;
m
cowitheฺno
Strategy: The repair includes complete media recovery
o ฺ
o uid
data loss
y a h
Repair script:
@ n t G
k
ac tude
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_3058543729.hm
f r z
L A ( this S
contents of repair script:
A multiple
Ufor se blocks
# block media recovery O
H e t129 u
o to 130;
T
recover datafile C
0 ens
5 block

% 2
I want ic execute the above repair (enter YES or
L l e l
ME erab
Do you really to
NO)?Ay
a r ie nsfrepair script
executing
a c h -tra
n
Z noStarting recover at 2013-06-18:11:40:32
using channel ORA_DISK_1

channel ORA_DISK_1: restoring block(s) from datafile copy


+FRA/ORCL/DATAFILE/bctbs.270.818422617

starting media recovery


media recovery complete, elapsed time: 00:00:01

Finished recover at 2013-06-18:11:40:36


repair failure complete

RMAN>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 17
6. Optionally, confirm that there are no other failures.
RMAN> list failure;
Database Role: PRIMARY
no failures found that match specification
RMAN>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

7. Exit RMAN and clean up from the block corruption practice by executing the
cleanup_09_04.sh script. The output can be viewed with the cat
/tmp/cleanup.log Linux command.
RMAN> exit
...
$ ./cleanup_09_04.sh
$

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 9: Diagnosing Database Failure


Chapter 9 - Page 18
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @Lesson n t G10:
k de
c Recovery
aand
Restoref r z t u
A ( this S
Concepts
L
O UA use
C H e Chapter
to 10
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Restore and Recovery Concepts


Chapter 10 - Page 1
Practices for Lesson 10: Overview
Practices Overview
In this practice you will consider the circumstances of a failure and the backup setting to
determine a strategy for restoration and recovery.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Restore and Recovery Concepts


Chapter 10 - Page 2
Practice 10-1: Case Study: Determining Recovery Procedures
Overview
In this practice you will consider the circumstances of a failure and the backup setting to
determine a strategy for restoration and recovery.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
You are familiar with Oracle backup and recovery.

Tasks
Case 1: The backups are taken during a nightly shutdown, with an incremental backup strategy.
A level 1 backup is applied to the previous Level 0 backup each night. The ARCHIVE LOG LIST
command shows the following:
SQL> archive log list
s a
Database log mode No Archive Mode
)h a
Automatic archival Disabled
m
co eฺ
Archive destination
o ฺ
USE_DB_RECOVERY_FILE_DEST
o uid
Oldest online log sequence 61
y a h
@ n t G
Next log sequence to archive 63
k
ac tude
Current log sequence
f r z 63
S
A disk containing the SYSAUX tablespace data files
L Ahas( crashed.
t h i s
a. Is complete recovery possible? What U Aare thessteps?
e
Answer: Yes, if all the redo logC HO
files t
from most o u
the recent backup to the current log file are
available. Restore the SYSAUX
2 0T data e n se recover the data files, and open the database.
files,
b. If complete recovery
L I% islenotlicpossible what are the steps to recover as much as possible.
What data
A ME(transactions)
r a b will be lost?
r ie current
Answer: feANY missing redo log files, between the time the backup was taken
If theresare
n
c a the a
hthis case,-trrestore
and time (when the database shutdown) a complete recovery is not possible. In
a
non command), and open the database with the RESETLOGS option. Any transactions
Z RECOVER all the database files, apply the most recent incremental backups (RMAN

between the time of the backup and the current time will be lost.

Case 2: The database backups are taken nightly online, with an incremental backup strategy. A
level 1 backup is applied to the previous level 0 backup each night. The ARCHIVE LOG LIST
command shows the following:
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 61
Next log sequence to archive 63
Current log sequence 63
A data file that is part of the application tablespace, containing critical data has been lost.
Describe the steps to perform a complete recovery.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Restore and Recovery Concepts


Chapter 10 - Page 3
Answer: Use the Data Recovery Advisor to determine which files have been lost, restore
the data files, recover the data files, and open the database.

Case 3: The effects of a batch job that was incorrectly executed on the database last night at
8:00 p.m. have been removed by performing an incomplete recovery to 6:00 p.m. After the
incomplete recovery the database was reopened. The checks that were performed following the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

recovery revealed that some critical transactions performed prior to 7:15 p.m. are not in the
database.
c. What are valid options to recover these transactions?
Answer: The incomplete recovery can be restarted by using a control file that matches the
structure of the previous incarnation of the database at 7:15 p.m. and restoring a backup of
the database from before 6:00 p.m. Then an incomplete recovery using the archive log files
from the previous incarnation can be performed to recover the database to its state at
7:15pm.
d. Describe the requirements for recovering these transactions.
s a
)h a
Answer: The backup used in the previous incomplete recovery or an older backup must be
m
available. The archive log files and redo for that incarnation must be available. When using
co eฺ
o ฺ
RMAN, set the incarnation number to get the proper set of redo and archive logs.
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 10: Restore and Recovery Concepts


Chapter 10 - Page 4
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lesson n t G11:
k
ac Recovery de
Performing
( f r z S t u
L A h i s
U AChapterse11 t
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 1
Practices for Lesson 11: Overview
Practices Overview
In these practices, you will recover from a number of different database failures. It is highly
recommended to complete the ones you start, because it affects the following practices.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Ensure that you completed the practice 7-3 "Creating an Archival Backup", because in case a
recovery fails the duplicated database files can be used for a "rescue" operation.
Possible recovery steps by using the archival backup:
a. With your environment variables pointing to the ORCL instance, log in to RMAN and
connect to the RMAN catalog:
rman target "'/ as sysbackup'" catalog rcatowner@rcat
b. Confirm the name of the restore point to be used, KEEPDB in this example:
LIST RESTORE POINT ALL;
c. Restore and recover your database by using your restore point: s a
RESTORE DATABASE UNTIL RESTORE POINT 'KEEPDB'; )h a
m
co eฺ
RECOVER DATABASE UNTIL RESTORE POINT 'KEEPDB';
o ฺ
o theuRESETLOGS
d. Because your database is now at an earlier point in time, open ithwith
y a id
option, and display the newly created DBID:
@ ent G
c k d
frza s Stu
ALTER DATABASE OPEN RESETLOGS;
SELECT DBID FROM V$DATABASE; (
A
e. In most environments, Oracle recommends thi a new backup after a recovery:
LA to eperform
H
BACKUP DATABASE PLUS ARCHIVELOGOU to uDELETEs INPUT;
C
0T ense
2
I% le lic
L
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 2
Practice 11-1: Recovering from Media Failure (Loss of a Data File)
Overview
In this practice you will first create an issue by deleting the USERS data file. Then you perform a
complete recovery of the database because of the loss of an essential data file. In this case
Data Recovery Advisor cannot be used.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
In the $LABS directory, you have three terminal windows open, pointing to the orcl instance.

Tasks
1. Execute the setup_11_01.sh script and ensure that you have a backup of the entire
database in ARCHIVELOG mode. For example, use the RMAN client to execute:
BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
s a
or use the backup_orcl.sh script. The output is in /tmp/backup.log.
)h a
$ ./setup_11_01.sh m
co eฺ
$ o ฺ
o uid
y a h
$ ./backup_orcl.sh
@ n t G
$
c k de
frza s Stu script which removes
2. Cause a failure in the database by executing the (break_11_01.sh
the USERS tablespace.
A LA e thi
O U environment,
To delete a file in ASM in the Oracle training
u s you need to execute the rm
command as the GRID user, so C H o
you will betasked for the password. Enter oracle when
e output of the script is redirected to
prompted (it might take a 0
2 T
little n
while). sThe
/tmp/break.log.I% l ic e
L l e
ME erab
$ ./break_11_01.sh
A
a r ie nsforacle <<< not displayed
Password:

a c n ra base has been changed from /u01/app/oracle to


h The-tOracle
Z no/u01/app/grid
$
3. Optionally, view the output file in a different terminal window with the cat
/tmp/break.log Linux command. You can view the output while the break_11_01.sh
file is executing.
$ cat /tmp/break.log
orcl
BREAK_11_01.SH: Abort ORCL database
Tue Jul 23 20:14:43 UTC 2013
Confirm: ora_pmon_orcl should NOT be listed
3169 ora_pmon_emrep
3256 asm_pmon_+ASM
16194 ora_pmon_rcat
Remove data file as GRID user. Enter oracle as password
+ASM

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 3
Issue created.
$
4. Optionally, if you wish to confirm that the USERS data file is removed, execute the following
commands:
$ su - grid
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Password: oracle <<< not displayed


$ . oraenv
ORACLE_SID = [grid] ? +ASM
The Oracle base has been changed from /u01/app/oracle to
/u01/app/grid
$ asmcmd ls +DATA/ORCL/DATAFILE
EXAMPLE.269.817894393
SYSAUX.256.817894089
s a
UNDOTBS1.259.817894231
)h a
SYSTEM.257.817894153
m
co eฺ
$ exit
o ฺ
o uid
logout
y a h
@ n t G
$ whoami
k
ac tude
oracle
f r z
$ echo $ORACLE_SID
L A ( this S
orcl
O UA use
$
C H e to
2 T
0 asethensoracle user with the environment variables pointing
5. Continue in a terminal window
%
to the orcl instance.
L e l ic attempt to start the orcl database instance. Notice the
I In SQL*Plus
ME erab
error messages. l
A
$iesqlplus f/ as sysdba
a r n s
a c h -tra
n
Z noConnected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 534462464 bytes


Fixed Size 2290416 bytes
Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 6 - see DBWR trace
file
ORA-01110: data file 6:
'+DATA/ORCL/DATAFILE/users.258.817894229'
SQL>
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 4
6. Diagnose the failure. Follow the error message directions (for training purposes).
a. What is the meaning of the error message codes?
Use the oerr utility to determine the meaning of the error codes.
− ORA-01110 ____________________________
− ORA-01157 ____________________________
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

SQL> ! oerr ORA 01110


01110, 00000, "data file %s: '%s'"
// *Cause: Reporting file name for details of another error.
The reported
// name can be of the old file if a data file move
operation is
// in progress.
// *Action: See associated error message.
s a
SQL>
)h a
m
co eฺ
SQL> ! oerr ORA 1157 o ฺ
o- seeuDBWR
01157, 00000, "cannot identify/lock data file a%s
y h id
@ ent G
trace file"
c k
// *Cause: The background process was
( S tudunable to find one
frza either
of the data
files or failed A
A is
toLlock itthbecause the file was
//
already in use. OU to us e
H
C will e prohibit access to this file but
//
0 T
The database
n s
Ibe%2unaffected.
ce However the first instance to open the
other files will
L l i
//
M Ewillable
A feneed
database
e r to access all online data files. Accompanying
r i
// s
n the
a c ha error
- t r afrom
Z no//n operating system describes why the file could not be
identified.
// *Action: Have operating system make file available to
database. Then either
// open the database or do ALTER SYSTEM CHECK DATAFILES.
SQL>
b. Find and examine the DBWR trace file listed in the output from the STARTUP command
in step 5. The trace file will be in the directory listed in the DIAGNOSTIC_DEST
parameter, in the diag/rdbms/orcl/orcl/trace subdirectory.
SQL> show parameter DIAG

NAME TYPE VALUE


------------------------------------ ----------- ---------------
diagnostic_dest string /u01/app/oracle
SQL>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 5
c. Add the diag/rdbms/orcl/orcl/trace subdirectory to the path name or display
the BACKGROUND_DUMP_DEST parameter. Then exit SQL*Plus.
SQL> show parameter dump_dest

NAME TYPE VALUE


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

---------------------- ----------- ---------------------------


background_dump_dest string
/u01/app/oracle/diag/rdbms/orcl/orcl/trace
core_dump_dest string
/u01/app/oracle/diag/rdbms/orcl/orcl/cdump
user_dump_dest string
/u01/app/oracle/diag/rdbms/orcl/orcl/trace
SQL>
SQL> exit
s a
$
)h a
d. Use another terminal window. The ls –ltr Linux command lists files c ino m
the trace
o
directory in reverse order by time. The most recent file is listed last. o ฺ eฺ
a h u i d
$ cd /u01/app/oracle/diag/rdbms/orcl/orcl/trace y t G
$ ls -ltr *dbw*
a c k@ den
… ( frz s Stu
-rw-r----- 1 oracle asmadmin LA
A 459 Jul
e thi23 20:20
orcl_dbw0_5287.trm
O U us
H
-rw-r----- 1 oracleCasmadminto1708 Jul 23 20:20
orcl_dbw0_5287.trc 2 0T ense
$ L I% le lic
e. Review A MtheElastertrace
ab dbw trace file. Usually, the last error message lists the cause.
n s f
r$iecataorcl_dbw0_5287.trc
h a r
n-t file
Zac noTrace
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_dbw0_5287.trc
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 -
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real
Application Testing options
ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1
System name: Linux
Node name: EDFAR7P1
Release: 2.6.39-200.24.1.el6uek.x86_64
Version: #1 SMP Sat Jun 23 02:39:07 EDT 2012
Machine: x86_64
Instance name: orcl
Redo thread mounted by this instance: 0 <none>
Oracle process number: 11
Unix process pid: 5287, image: oracle@EDFAR7P1 (DBW0)

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 6
*** 2013-07-23 20:20:21.254
*** CLIENT ID:() 2013-07-23 20:20:21.254
*** SERVICE NAME:() 2013-07-23 20:20:21.254
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

*** MODULE NAME:() 2013-07-23 20:20:21.254


*** ACTION NAME:() 2013-07-23 20:20:21.254

2013-07-23 20:20:21.253469 :kjcipctxinit(): (pid|psn)=(11|1):


initialised and linked pctx 0x7e70fcb0 into process list

*** 2013-07-23 20:20:31.949


*** SESSION ID:(242.1) 2013-07-23 20:20:31.949
s a
*** SERVICE NAME:() 2013-07-23 20:20:31.949
)h a
m
co eฺ
DDE rules only execution for: ORA 1110
o ฺ
o uid
----- START Event Driven Actions Dump ----
a h
---- END Event Driven Actions Dump ---- @y t G
k n
----- START DDE Actions Dump -----
f r z ac tude
Executing SYNC actions
A ( i s S
L
A se t h
----- START DDE Action: 'DB_STRUCTURE_INTEGRITY_CHECK' (Async) -
U
----
C HO e to u
----- END DDE 2
0T ns
Successfully dispatched
Action: e'DB_STRUCTURE_INTEGRITY_CHECK'
L I% le lic (SUCCESS, 0

ME ASYNC
csec) -----
A
Executing
f e r ab actions
a ie END
r----- n s DDE Actions Dump (total 0 csec) -----
h -t r a
Zac noORA-01157:
n
file
cannot identify/lock data file 6 - see DBWR trace

ORA-01110: data file 6:


'+DATA/ORCL/DATAFILE/USERS.257.817894153'
ORA-17503: ksfdopn:2 Failed to open file +DATA/ORCL/DATAFILE/
USERS.257.817894153
ORA-15173: entry 'USERS.257.817894153' does not exist in
directory 'DATAFILE'
[oracle@EDFAR7P1 trace]$
?
Question: What is the problem?
Answer: A data file in the USERS tablespace is missing.
7. Using the RMAN command line (pointing to the orcl instance), check what Data
Recovery Adviser reports about the failure.
$ rman target "'/ as sysbackup'"

connected to target database: ORCL (DBID=1345675044, not open)

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 7
RMAN> list failure;
using target database control file instead of recovery catalog
Database Role: PRIMARY
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

List of Database Failures


=========================

Failure ID Priority Status Time Detected Summary


---------- -------- --------- ------------------- -------
8 HIGH OPEN 2013-07-23:20:20:33 One or more
non-system datafiles are missing
RMAN>
s a
8. a
Using the RMAN command line, gather advise and repair the failure. Restore, recover and
open the database. )h
m
co eฺ
a. To gather advice:
o ฺ
o uid
RMAN> advise failure;
y a h
@ n t G
Database Role: PRIMARY
k
ac tude
f r z
List of Database Failures
L A ( this S
========================= A
O U use
C H e to
2 T
0 ens Time Detected
Failure ID Priority Status Summary

L %
---------- I--------
e l ic--------- ------------------- -------
8 ME eHIGH a l
b OPEN 2013-07-23:20:20:33 One or more
A r
a r ie nsf
non-system datafiles are missing

a c h -tra
n
Z noanalyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=248 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions


========================
no manual actions available

Optional Manual Actions


=======================
1. If file +DATA/ORCL/DATAFILE/users01.dbf was unintentionally
renamed or moved, restore it

Automated Repair Options


========================
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 8
Option Repair Description
------ ------------------
1 Restore and recover datafile 6
Strategy: The repair includes complete media recovery with no
data loss
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1589431370.hm
RMAN>
b. Optionally, to preview the potential repair:
RMAN> repair failure preview;

Strategy: The repair includes complete media recovery with no


data loss
Repair script: s a
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1589431370.hm
)h a
c m
o ฺ
o ฺ
o uide
contents of repair script:
y a h
# restore and recover datafile
@ n t G
restore ( datafile 6 ); k
ac tude
f r z S
A6( online';
recover datafile 6;
L h i s
sql 'alter database datafile
U A se t
RMAN>
H O to u
C e
c. To repair the failure andTopen thesdatabase:
0
2 e n
RMAN> repair
L I%failure;e l ic
ME The
Strategy:
a b l
repair includes complete media recovery with no
dataAloss
fe r
a r ie nscript:
s
a c n - tra
h /u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1589431370.hm
Repair
Z no
contents of repair script:
# restore and recover datafile
restore ( datafile 6 );
recover datafile 6;
sql 'alter database datafile 6 online';

Do you really want to execute the above repair (enter YES or


NO)? yes
executing repair script

Starting restore at 2013-07-23:20:34:30


using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 9
channel ORA_DISK_1: specifying datafile(s) to restore from
backup set
channel ORA_DISK_1: restoring datafile 00006 to
+DATA/ORCL/DATAFILE/users01.dbf
channel ORA_DISK_1: reading from backup piece
+FRA/ORCL/BACKUPSET/2013_07_23/nnndf0_tag20130723t194112_0.290.8
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

21562075
channel ORA_DISK_1: piece
handle=+FRA/ORCL/BACKUPSET/2013_07_23/nnndf0_tag20130723t194112_
0.290.821562075 tag=TAG20130723T194112
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2013-07-23:20:34:32

s a
Starting recover at 2013-07-23:20:34:32
)h a
using channel ORA_DISK_1
m
co eฺ
o ฺ
o uid
starting media recovery
y a h
media recovery complete, elapsed time: 00:00:02 @ n t G
k
ac tude
f r z
Finished recover at 2013-07-23:20:34:36
L A ( this S
A se
sql statement: alter H OU todatafile
database u 6 online
C
0T ense
repair failure complete
2
I% le lic
L
E toabopen the database (enter YES or NO)? y
A M
Do you want
er
r i e
database
s f
openend.
c ha RMAN>
- t r an
a
nonData Recovery Advisor for other failures.
Z9. Check
RMAN> list failure;
Database Role: PRIMARY
no failures found that match specification
RMAN>
10. Cleanup your test case with the cleanup_11_01.sh script from the $LABS directory
(output is in /tmp/cleanup.log).
$ ./cleanup_11_01.sh
$
11. In your RMAN session, back up the database with the BACKUP DATABASE PLUS
ARCHIVELOG command. The output is in /tmp/backup.log. Then exit.
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
RMAN> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 10
Practice 11-2: Recovering from Media Failure - Incomplete Recovery
Overview
In this practice you set up a scenario that requires an incomplete recovery. Then you perform
the steps that are needed when an archive log is missing after the last backup (and transactions
exist that cannot be recreated); therefore, complete recovery is not possible.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
A full backup exists and the archive log files from the time of the backup to the current time are
available.

Tasks
1. Set up for this practice by executing the setup_11_02.sh script from the $LABS directory.
With this script a new tablespace and user are created. The user creates a table and
populates it. A backup of the tablespace is performed and then the table is updated. The
s a
output is in the /tmp/setup.log file.
)h a
$ ./setup_11_02.sh m
co eฺ
$ o
o uidฺ
a h
y script.
2. Cause a failure in the database by executing the break_11_02.sh
@ n t GBefore the
a k
c ude is simulated and
failure the user table is updated several times. An extended period of time
several log switches occur.
( z
fr s St
Because a file is deleted in ASM, you need L
A toA hi password for the grid user.
providetthe
e
/tmp/break.log file. H OU tpassword.
When prompted, enter oracle as training
o us The output is in the
0 T C se
$ ./break_11_02.sh
I % 2 icen
L
The last digit
E l e l salary indicates how many times this table
of the
has been
A M updated
f e r ab
h a rie SALARY
a n s
t r
Zac non- 24009
----------

System altered.

Password: oracle <<< not displayed


$
3. Attempt to start the database instance. Notice the error messages. These are the same
error messages as seen in practice 11-1.
$ sqlplus / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 534462464 bytes


Fixed Size 2290416 bytes
Variable Size 276827408 bytes

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 11
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace
file
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

ORA-01110: data file 5: '/u01/backup/orcl/bartbs.dbf'


SQL>
4. Note your data file number. _____
5 in this example. You must use your own data file number for recovery.
5. Optionally in another terminal window, check the DBWR trace file, then return to the $LABS
directory.
$ cd /u01/app/oracle/diag/rdbms/orcl/orcl/trace
$ ls -ltr *dbw*
s a
. . .
)h a
-rw-r----- 1 oracle asmadmin 897 Jul 23 19:56 m
co eฺ
orcl_dbw0_1159.trc
o ฺ
o uid
-rw-r----- 1 oracle asmadmin 663 Jul 23 20:34
y a h
orcl_dbw0_5287.trm
@ n t G
k
ac tude
-rw-r----- 1 oracle asmadmin 3056 Jul 23 20:34
f r z
A ( this S
orcl_dbw0_5287.trc
L
UA use
-rw-r----- 1 oracle asmadmin 460 Jul 24 12:00
orcl_dbw0_24999.trm
O
H e to
T C
-rw-r----- 1 oracle asmadmin 1678 Jul 24 12:00
0 ens
2
orcl_dbw0_24999.trc
I le lic
%
L
E ab
$ cat A Morcl_dbw0_24999.trc
er
r i e s f
c ha ORA-01157:
. .
- t
.
r an cannot identify/lock data file 5 - see DBWR trace
a
Z nofile n
ORA-01110: data file 5: '/u01/backup/orcl/bartbs.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
$
$ cd $LABS
$
6. Use the RMAN LIST FAILURE command to find more information.
$ rman target "'/ as sysbackup'"

RMAN> list failure;


using target database control file instead of recovery catalog
Database Role: PRIMARY

List of Database Failures


Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 12
=========================

Failure ID Priority Status Time Detected Summary


---------- -------- --------- ------------------- -------
8 HIGH OPEN 2013-07-24:12:00:04 One or more
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

non-system datafiles are missing


RMAN>
7. Use the RMAN ADVISE FAILURE command to determine if automated recovery is
available.
RMAN> ADVISE FAILURE;

Database Role: PRIMARY

List of Database Failures s a


========================= )h a
m
co eฺ
8 HIGH OPEN 2013-07-24:12:00:04 One or more
non-system datafiles are missing o ฺ
o uid
y a h
analyzing automatic repair options; thisk@ n t G time
ac tude
may take some
allocated channel: ORA_DISK_1
f r z S
L
channel ORA_DISK_1: SID=240 deviceA ( type=DISK
t h i s
analyzing automatic repair U A s
options e complete

C HO e to u
T ns
Mandatory Manual0Actions
2
I% le lice
========================
L
A MEor e/u01/backup/orcl/bartbs.dbf
1. If file
r a b restore it was unintentionally

a r ie nsfhave an export of tablespace BARTBS, offline its data


renamed
2. Ifayou
moved,

a c h files,- tr open the database read/write, then drop and re-create the
n
Z notablespace and import the data.
3. Contact Oracle Support Services if the preceding
recommendations cannot be used, or if they do not fix the
failures selected for repair

Optional Manual Actions


=======================
no manual actions available

Automated Repair Options


========================
no automatic repair options available

RMAN> no automatic repair options available


RMAN>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 13
8. There is only one data file missing, but there is no automatic recovery available. This
indicates the advisor found some problem with the restoration or recovery. Attempt a
restore and recovery of the data file specified by the list failure command. The data file
number on your system may vary.
Note: DO NOT perform any action that is not reversible. You are expecting this restore and
recovery to fail. You are looking for errors and information that will help you to diagnose the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

cause of this failure.


RMAN> restore datafile 5; (enter your datafile number)
Starting restore at 2013-07-24:12:14:20
using channel ORA_DISK_1

channel ORA_DISK_1: restoring datafile 00005


input datafile copy RECID=9 STAMP=821620592 file
name=/u01/backup/orcl/bartestdata_D-ORCL_I-1349223352_TS-
BARTBS_FNO-5_0tofhrrf s a
destination for restore of datafile 00005: )h a
/u01/backup/orcl/bartbs.dbf m
co eฺ
o ฺ
o uid
y a h
channel ORA_DISK_1: copied datafile copy of datafile 00005
t G
output file name=/u01/backup/orcl/bartbs.dbf RECID=0 STAMP=0
@ n
Finished restore at 2013-07-24:12:14:22 k
ac tude
f r z
A ( this S
RMAN>
L
A se
U(enter
RMAN> recover datafile
C H e to u your datafile number)
O
5;

2 0 T ns
e
I% leatlic2013-06-24:14:59:54
Starting recover
L
ME eraORA_DISK_1
using channel
A b
f
ie nsmedia recovery
rstarting
c h a tra
a
Z no n -
archived log for thread 1 with sequence 21 is already on disk as
file
+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_21.292.818952643
archived log for thread 1 with sequence 22 is already on disk as
file
+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_22.291.818952645
archived log for thread 1 with sequence 23 is already on disk as
file
+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_23.290.818952649
archived log for thread 1 with sequence 24 is already on disk as
file
+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_24.289.818952653
archived log for thread 1 with sequence 25 is already on disk as
file
+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_25.288.818952655

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 14
archived log for thread 1 with sequence 27 is already on disk as
file
+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_27.285.818952661
archived log for thread 1 with sequence 28 is already on disk as
file
+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_28.286.818952665
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

RMAN-00571: ===============================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
RMAN-00571: ===============================================
RMAN-03002: failure of recover command at 06/24/2013 14:59:55
RMAN-06053: unable to perform media recovery because of missing
log
RMAN-06025: no backup of archived log for thread 1 with sequence
26 and starting SCN of 2280353 found to restore
s a
)h a
RMAN>
m
co eฺ
The error message indicates that archive log file 26 is missing. o ฺ
othat is,uthe
Note: If you get two RMAN-06025 error messages, focus on the latest a
y h
one, idone with
the highest digits also in the following steps. @ ent G
c k
In a production system you would determine if there z
( fris aanother S ud of this file, possibly in
tcopy
an OS backup that is unknown to RMAN. If the archive logsfile can be found and restored, a
A
complete recovery is possible. For this practice LA assume
e thi the archive log file is lost.
Note: The archive log sequence number
H OU that t o usfind may be different than the one shown
you
in the example. Make note of your
0 T C missing s e archive log sequence number:
n
Iis%not2 possible
______________
9. Complete recovery L l i cein this situation. Use your SQL*Plus session to determine
how much dataM Ewill bealost.
b leIn this example, the current redo log file is sequence number 29
and logi e A 26feisrmissing. So all the data contained in log files 26 through 29 will
number
r
bealost. ran
s
h
Zac noSQL> n-t archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 27
Next log sequence to archive 29
Current log sequence 29
SQL>
Note: If you attempt to query the CURRENT_SCN column of the V$DATABASE view, you will
get a value of 0 (zero), not the last "current" SCN.
RMAN> SELECT NAME, DBID, CURRENT_SCN, LOG_MODE, OPEN_MODE FROM
V$DATABASE;

NAME DBID CURRENT_SCN LOG_MODE OPEN_MODE


--------- ---------- ----------- ------------ ------------------
-
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 15
ORCL 1346372794 0 ARCHIVELOG MOUNTED
RMAN>
10. Determine the starting SCN and start time of your missing log (log 26 in this example).
Record the values from the FIRST_CHANGE# and FIRST_TIME columns.
The value in FIRST_TIME can be used to inform users how far back they have to go to
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

recover any transactions that have been lost.


SQL> select sequence#, first_change#, first_time, status
from v$archived_log
where sequence# = 26 and name is not null; (Enter your missing log
sequence number)

SEQUENCE# FIRST_CHANGE# FIRST_TIME STATUS


---------- ------------- ------------------- ------
s a
26 2280353 2013-06-24:14:50:54 A
)h a
SQL>
m
o timeฺthat
cfirst
Note: The SCN was already displayed in the RMAN error message, but o ฺ
the
o uide
this archivelog was used, was not previously displayed.
y a h
Also note, that the V$ARCHIVED_LOG view contains historic @ n
information ofG
t prior database
c k e
incarnations. The NAME column of the active database a
name of the archive log; historic incarnations have(
incarnation
farznull value.
S udcontains
tThe status
the path and
is for archived
L A h i s A
logs, D is for deleted ones.
U A se t
controlufile first for incomplete recovery so that
11. It is recommended to always restore
C HOtheeare
potential changes in the data structures toknown to RMAN.
T
0 enstate. s
a. Bring the database2 in NOMOUNT
% li
LI bimmediate; c
E
RMAN> shutdown
M era l e
A f
ie nsdismounted
a rdatabase
a c h Oracle
n - tra instance shut down
Z no
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started

Total System Global Area 534462464 bytes


Fixed Size 2290416 bytes
Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
RMAN>
b. Restore the control file from autobackup.
RMAN> restore controlfile from autobackup;
...

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 16
c. Mount the database.
RMAN> alter database mount;
Statement processed
released channel: ORA_DISK_1
RMAN>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

12. Restore the entire database from a backup that was taken before the missing archive log
file with the RESTORE DATABASE UNTIL SEQUENCE nn command.
RMAN> RESTORE DATABASE UNTIL SEQUENCE 26; (Enter your missing log
sequence number)

Starting restore at 2013-06-24:16:01:06


using channel ORA_DISK_1

s a
skipping datafile 5; already restored to file
)h a
/u01/backup/orcl/bartbs.dbf
m
co eฺ
o ฺ
channel ORA_DISK_1: starting datafile backup set restore
o uid
a h
channel ORA_DISK_1: specifying datafile(s) to restore from
y
backup set
@ n t G
k
ac tude
channel ORA_DISK_1: restoring datafile 00001 to
f r z
A ( this S
+DATA/ORCL/DATAFILE/system.261.818611365
L
UA use
channel ORA_DISK_1: restoring datafile 00002 to
O
+DATA/ORCL/DATAFILE/example.264.818592141
H e to
T C
channel ORA_DISK_1: restoring datafile 00003 to
0 ens
2
+DATA/ORCL/DATAFILE/sysaux.270.818591867
I le lic
%
L
channel ORA_DISK_1: restoring datafile 00004 to
ME erab
+DATA/ORCL/DATAFILE/undotbs1.267.818592009
A
a r ie nsf
channel ORA_DISK_1: restoring datafile 00006 to

a c h -tra+DATA/ORCL/DATAFILE/users.268.818592007
Z non channel ORA_DISK_1: reading from backup piece
+FRA/ORCL/BACKUPSET/2013_06_24/nnndf0_tag20130624t144541_0.295.8
18952345
channel ORA_DISK_1: piece
handle=+FRA/ORCL/BACKUPSET/2013_06_24/nnndf0_tag20130624t144541_
0.295.818952345 tag=TAG20130624T144541
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:25
Finished restore at 2013-06-24:16:03:31
RMAN>
13. Recover the database through your last available log file.
Note: If incremental backups are available they will be applied first, then the archive logs.
The number of log files that need to be applied may vary from the example shown.
RMAN> recover database until sequence 26; (Enter your missing log
sequence number)
Starting recover at 2013-06-24:16:05:20

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 17
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 21 is already on disk as


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

file
+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_21.292.818952643
archived log for thread 1 with sequence 22 is already on disk as
file
+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_22.291.818952645
archived log for thread 1 with sequence 23 is already on disk as
file
+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_23.290.818952649
archived log for thread 1 with sequence 24 is already on disk as
file s a
)h a
+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_24.289.818952653
m
co eฺ
archived log for thread 1 with sequence 25 is already on disk as
file o ฺ
o uid
y a h
+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_25.288.818952655
@ n t G
k
ac tude
channel ORA_DISK_1: starting archived log restore to default
destination
f r z
A ( this S
channel ORA_DISK_1: restoring archived log
L
UA use
archived log thread=1 sequence=20
O
H e to
channel ORA_DISK_1: reading from backup piece
C
T
0 ens
+FRA/ORCL/BACKUPSET/2013_06_24/annnf0_tag20130624t144800_0.300.8
2
I le lic
18952481
L %
ME erab
channel ORA_DISK_1: piece
A
handle=+FRA/ORCL/BACKUPSET/2013_06_24/annnf0_tag20130624t144800_
ie nsf
a r
h -tra
0.300.818952481 tag=TAG20130624T144800

a c
Z non
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_20.287.8189571
23 thread=1 sequence=20
channel default: deleting archived log(s)
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_20.287.8189571
23 RECID=50 STAMP=818957122
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_21.292.8189526
43 thread=1 sequence=21
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_22.291.8189526
45 thread=1 sequence=22
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_23.290.8189526
49 thread=1 sequence=23

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 18
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_24.289.8189526
53 thread=1 sequence=24
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_25.288.8189526
55 thread=1 sequence=25
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

media recovery complete, elapsed time: 00:00:07


Finished recover at 2013-06-24:16:05:31
RMAN>
The number of log files in your environment may be different.
14. Open the database using the RESETLOGS option and display the new DBID.
RMAN> alter database open resetlogs;
Statement processed.
s a
RMAN> SELECT NAME, DBID, CURRENT_SCN, LOG_MODE, OPEN_MODE )FROM h a
V$DATABASE; m
co eฺ
o ฺ
o uid
y a h
NAME DBID CURRENT_SCN LOG_MODE
@ G
OPEN_MODE
n t
--------- ---------- ----------- ------------ k
ac tude ------------------
-
f r z S READ WRITE
L A (ARCHIVELOG
h i s
A se t
ORCL 1346372794 2281516
RMAN> U u
C
15. Use the Data Recovery Advisor HO FAILURE
e t o command to verify that the failures have
0 T LIST
s
been repaired. Then you
I % l en
2 musticexit.
RMAN> listL failure;
M le
ERole:abPRIMARY
i e A fer
Database
a rno n s found that match specification
failures
a
h r
Zac noRMAN> n-t exit
$
16. Because the break_11_02.sh script removed an archive log to create an issue for your
learning purpose, crosscheck all archive logs connected to the recovery catalog.
$ rman target "'/ as sysbackup'" catalog rcatowner@rcat

RMAN> CROSSCHECK ARCHIVELOG ALL;

released channel: ORA_DISK_1


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=15 device type=DISK
validation succeeded for archived log
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_21.292.8189526
43 RECID=42 STAMP=818952642
validation succeeded for archived log

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 19
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_22.291.8189526
45 RECID=43 STAMP=818952644
validation succeeded for archived log
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_23.290.8189526
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

49 RECID=44 STAMP=818952649
validation succeeded for archived log
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_24.289.8189526
53 RECID=45 STAMP=818952652
validation succeeded for archived log
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_25.288.8189526
55 RECID=46 STAMP=818952655
s a
validation failed for archived log
)h a
archived log file m
co eฺ
o ฺ
o uid
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_26.287.8189526
59 RECID=47 STAMP=818952659
y a h
@ n t G
k
ac tude
validation succeeded for archived log
archived log file
f r z
A ( this S
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_27.285.8189526
L
UA use
61 RECID=48 STAMP=818952661
O
H e to
validation succeeded for archived log
C
T
0 ens
archived log file
2
I le lic
%
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_28.286.8189526
L
ME erab
65 RECID=49 STAMP=818952664
A
validation succeeded for archived log
ie nsf
a r
h -tra
archived log file
a c
Z non
name=+FRA/ORCL/ARCHIVELOG/2013_06_24/thread_1_seq_29.287.8189572
03 RECID=51 STAMP=818957202
Crosschecked 9 objects
RMAN>
Note: Your number of objects might be different.
17. Delete obsolete backups and then exit the RMAN client. The output is reduced to avoid
clutter.
RMAN> delete noprompt obsolete;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
. . .
deleted backup piece
backup piece
handle=+FRA/ORCL/AUTOBACKUP/2013_06_24/s_818952564.293.818952565
RECID=36 STAMP=818952565
Deleted 11 objects
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 20
RMAN> exit
$
Note: Your number of objects might be different.
18. Optionally, return to your SQL*Plus session. Select the SALARY column from one row of the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

BAR.BARCOPY table. The last digit of the salary indicates the number of times the BARCOPY
table has been updated. The difference between this result and the result in step 2
illustrates that multiple updates could be missing after an incomplete recovery. Exit from
SQL*Plus.
SQL> select salary from bar.barcopy where rownum < 2;

SALARY
----------
2605 s a
SQL> exit )h a
m
co eฺ
$
o ฺ
o utheidnew user
19. Execute the cleanup_11_02.sh script from the $LABS directory tohremove
y a G file.
k @ n t
and tablespace created in this practice. The output is in the /tmp/cleanup.log
$ ./cleanup_11_02.sh
f r z ac tude
20. Back up the database. You have a new incarnation A ( oftthe S and the older backups
isdatabase
L h
new incarnation of the database was O UA uwhere
are obsolete, although there are certain cases
sethetheRESETLOGS
created when
older backups can be used. A

C H toecreatet o a new, full backup: command was


executed. Either use the RMAN
2 T ns
0PLUS client
BACKUP DATABASE
I % l i e
cARCHIVELOG DELETE INPUT;
L
E able script in a terminal window. The output is in
or use the backup_orcl.sh
M
A fer
/tmp/backup.log.
a r i e n s
h r a
$ ./backup_orcl.sh
t
Zac no$n-

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 21
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 11: Performing Recovery


Chapter 11 - Page 22
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lesson n t G12:
k de
ac Recovery
Performing
( f r z S t u II
A LA e12 this
Chapter

H OU to us
0 T C se
I % 2 icen
E L ble l
A M era
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 1
Practices for Lesson 12: Overview
Practices Overview
In these practices, you will recover from a number of different database failures. It is highly
recommended to complete the ones you start, because it affects the following practices.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 2
Practice 12-1: Recovering the Loss of a Parameter File
Overview
In this practice you will create an issue by deleting the initorcl.ora parameter file. After
creating the issue, you must restore the parameter file.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
A full backup of the database is assumed. Autobackup of the control file and SPFILE is
assumed to be configured to be in the +FRA disk group.
Two terminal windows are open in the $LABS directory, pointing to the orcl instance. You are
acting as the oracle OS user.

Tasks
1. Set up for this practice by executing the setup_12_01.sh script from the $LABS directory.
s a
In this script:
)h a
• The initorcl.ora file is deleted from the $ORACLE_HOME/dbs directory; m
• A new tablespace and user are created. o ฺ co eฺ
• The user creates a table and populates it. a h o uid
@ y t G
A backup of the tablespace is performed and then thek n
ac tude
• table is updated.
• The output is in the /tmp/setup.log file. frz
L A ( this S
UA use
$ ./setup_12_01.sh
$ O
H e tothe break_12_01.sh script from the $LABS
2. Cause a failure in the databaseT C by executing
0oracleeasnstraining password for the grid OS user because the
directory. You must enter2
script deletes aEfile
%
LIin ASM.l e licoutput is in the /tmp/break.log file.
The
A M erab
a r ie nsforacle <<< not displayed
$ ./break_12_01.sh

a c h $ -tra
Password:
Z non
3. Attempt to start the database instance. Notice the error messages. Exit from SQL*Plus.
$ sqlplus / as sysdba

Connected to an idle instance.

SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorcl.ora'
SQL> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 3
4. Start the database by using RMAN.
$ rman target "'/ as sysbackup'"

connected to target database (not started)


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

RMAN> startup;

startup failed: ORA-01078: failure in processing system


parameters
LRM-00109: could not open parameter file
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorcl.ora'

starting Oracle instance without parameter file for retrieval of


spfile
s a
Oracle instance started
)h a
RMAN-00571: =============================================== m
co eฺ
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS o
o uidฺ
y a h
RMAN-00571: ===============================================
@ n t G
k
ac tude
RMAN-03002: failure of startup command at 06/25/2013 09:35:19
f r z
A ( this S
ORA-00205: error in identifying control file, check alert log
for more info L
RMAN>
O UA use
Note: The database has beenC H with
started e taodummy parameter file to allow the SPFILE to
be restored. 2 T
0 ens
L %
I Because l c database has been started with a dummy parameter file,
ithe
5. Restore the SPFILE.
the locationM
l e
E ab must be specified. In this case we are using the recovery
of the autobackup
e
areariand
A f r to specify that the autobackups can be found in the +FRA ASM
eoptions
DB_NAMEs
anthe +FRA/ORCL/ path.
a grouptrand
a c hdisk -
Z noRMAN> n restore spfile from autobackup recovery area '+FRA'
db_name 'orcl';

Starting restore at 2013-06-25:09:36:19


using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=11 device type=DISK

recovery area destination: +FRA


database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: AUTOBACKUP
+FRA/ORCL/AUTOBACKUP/2013_06_25/s_819019841.294.819019843 found
in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID
was not set

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 4
channel ORA_DISK_1: restoring spfile from AUTOBACKUP
+FRA/ORCL/AUTOBACKUP/2013_06_25/s_819019841.294.819019843
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 2013-06-25:09:36:27
RMAN>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

6. Shut down the database instance and restart it with the restored SPFILE.
RMAN> shutdown;
Oracle instance shut down

RMAN> startup;
connected to target database (not started)
Oracle instance started
database mounted
s a
database opened
)h a
m
co eฺ
Total System Global Area 534462464 bytes o
o uidฺ
2290416 bytesah
Fixed Size
276827408 bytesk@
y t G
n
ac tude
Variable Size
Database Buffers
f z
247463936 rbytes
S
Redo Buffers
L A ( bytes
7880704
h i s
U A se t
RMAN>
C HO e to u
7. Execute the cleanup_12_01.sh2 0T escript ns to clean up from this practice. The output is in the
%
LI file. li c
/tmp/cleanup.log
E
M erab l e
A
$ ./cleanup_12_01.sh
ie nforsfthe next practice, backup your orcl database, remove obsolete backups,
8. Ina r
a c n - trathat no failures are listed. (The output is removed to not clutter this activity
preparation
hand ensure
Z guide.)
no Then exit.
RMAN> BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;

RMAN> delete noprompt obsolete;

RMAN> list failure;

RMAN> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 5
Practice 12-2: Restoring the Control File
Overview
In this practice, you first create an issue for recovery by deleting the control02.ctl control
file in +FRA/ORCL/CONTROLFILE. (In an earlier practice, you copied this control file to the
+FRA disk group for increased media failure protection.) After creating the issue, you must
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

restore this single "lost" control file.

Assumptions
A full backup of the database is available. Autobackup of the control file and SPFILE is
configured to the +FRA disk group.
Two terminal windows are open in the $LABS directory, pointing to the orcl instance. You are
acting as the oracle OS user.

Tasks s a
1. Set up for this practice by executing the setup_12_02.sh script from the $LABS )directory. h a
In this script a new tablespace and user are created. The user creates a table c m
oand ฺ
o ฺ
populates it. A backup of the tablespace is performed and then the table
a h o is updated.
u i de
The output is redirected to /tmp/setup.log and can be viewed
@ y there also
t Gduring the
k n
execution of the script.
f r z ac tude
A ( this S
$ ./setup_12_02.sh
L
UA theusbreak_12_02.sh
$
O
2. Cause a failure in the database by executing
e script from the $LABS
directory. When prompted, enter C H e t
as
o training password for the grid OS user. The
0 T
2 ice
output is in the /tmp/break.log
oracle
n s
file.
L I % l
E l e
ab <<< not displayed
$ ./break_12_02.sh
A M oracle e r
Password:
r$ie ans f
c h a trstart the database. Notice the error messages. Then exit SQL*Plus.
a
Z no
3. Attemptn -to
$ sqlplus / as sysdba
Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 534462464 bytes


Fixed Size 2290416 bytes
Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
ORA-00205: error in identifying control file, check alert log
for more info

SQL> exit
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 6
4. View the orcl/orcl alert log. Scroll to the most recent entries to see the errors from this
practice.
$ adrci

adrci> set editor gedit


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

adrci> show alert

Choose the alert log from the following homes to view:

1: diag/rdbms/rcat/rcat
2: diag/rdbms/emrep/emrep
3: diag/rdbms/orcl/orcl
4: diag/rdbms/dummy/orcl
s a
Q: to quit
)h a
Please select option: 3
m
co eฺ
o ฺ
o uid
Output the results to file: /tmp/alert_27975_3086_orcl_2.ado
y a h
@ n t G
k de
acthe following
/* Scroll to bottom of the file to see
( f r z S t u */

LA e thcontrolis
ORA-00210: cannot open the A
O U specified
u s file
ORA-00202: control file:
C H '+FRA/ORCL/CONTROLFILE/control02.ctl'
e ttoo open file
ORA-17503: ksfdopn:2
2 T
0 ens Failed
% l ic
Ientryle'control02.ctl'
+FRA/ORCL/CONTROLFILE/control02.ctl
L
ORA-15173:
M E ab does not exist in directory

i e A fer
'CONTROLFILE'
a r a n s pga_aggregate_limit of 2048 MB
h Using
r default
n-t signalled during: ALTER DATABASE MOUNT...
Zac noORA-205
Checker run found 1 new persistent data failures

5. Close the gedit window by clicking the close window icon (x) and exit adrci.
Please select option: Q
adrci> exit
$

6. Check the Data Recovery Advisor for a solution. Preview the suggested solution before
executing it..
$ rman target "'/ as sysbackup'"
connected to target database: ORCL (not mounted)

RMAN> LIST FAILURE;

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 7
using target database control file instead of recovery catalog
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------------- -------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

509 CRITICAL OPEN 2013-06-25:09:52:48 Control file


+FRA/ORCL/CONTROLFILE/control02.ctl is missing

RMAN> ADVISE FAILURE;

List of Database Failures


=========================

s a
Failure ID Priority Status Time Detected Summary
)h a
---------- -------- --------- ------------------- ------- m
co eฺ
509 CRITICAL OPEN o ฺ
2013-06-25:09:52:48 Control file
o uid
+FRA/ORCL/CONTROLFILE/control02.ctl is missing
y a h
@ n t G
analyzing automatic repair options; zthis
k de some time
ac maytutake
( f r S
allocated channel: ORA_DISK_1
L A t h i s
channel ORA_DISK_1: SID=240Adeviceetype=DISK
U s
analyzing automatic repair
C t o u complete
HO eoptions
2 0T ens
Mandatory Manual
L l ic
I% leActions
ME erab
========================
A
r ie manual
no
n s factions available
c a
h -tra
a n
Z noOptional Manual Actions
=======================
no manual actions available

Automated Repair Options


========================
Option Repair Description
------ ------------------
1 Use a multiplexed copy to restore control file
+FRA/ORCL/CONTROLFILE/control02.ctl
Strategy: The repair includes complete media recovery with no
data loss
Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2352417243.hm
RMAN>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 8
RMAN> REPAIR FAILURE PREVIEW;
Strategy: The repair includes complete media recovery with no
data loss
Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2352417243.hm
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

contents of repair script:


# restore control file using multiplexed copy
restore controlfile from
'+DATA/ORCL/CONTROLFILE/current.265.818592057';
sql 'alter database mount';
RMAN>
7. Restore the control file. You can either execute the commands via the RMAN command
line, or use the REPAIR FAILURE command to perform the task for you.
s a
)h a
Note: Any existing copy of the control file can be used to restore the missing copy.
m
co eฺ
Enter y or yes when prompted to execute the repair and to open the database.
o ฺ
o uid
RMAN> REPAIR FAILURE;
y a h
@ n t G
Strategy: The repair includes complete k de
acmediaturecovery with no
f r z
A ( this S
data loss
L
UA use
Repair script:
O
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2352417243.hm
H e to
T C
contents of repair
% 2 0 script:
c e ns
# restore
E LI control
l e li file using multiplexed copy
A
restore
f ab
M econtrolfile
r from
i e
ar sql s
an'alter database mount';
'+DATA/ORCL/CONTROLFILE/current.265.818592057';

a c h - t r
Z non
Do you really want to execute the above repair (enter YES or
NO)? y
executing repair script

Starting restore at 2013-06-25:10:06:31


using channel ORA_DISK_1

channel ORA_DISK_1: copied control file copy


output file name=+DATA/ORCL/CONTROLFILE/current.265.818592057'
output file name=+FRA/ORCL/CONTROLFILE/control02.ctl
Finished restore at 2013-06-25:10:06:38

sql statement: alter database mount


released channel: ORA_DISK_1

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 9
repair failure complete

Do you want to open the database (enter YES or NO)? y


database opened
RMAN>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

8. Use the LIST FAILURE command to verify that the failure has been repaired.
RMAN> list failure;
no failures found that match specification

RMAN>
9. Clean up the practice environment by running the cleanup_12_02.sh script in another
terminal window. The output is in the /tmp/cleanup.log file.
$ ./cleanup_12_02.sh
s a
$ )h a
m
co backups,
o o ฺ
10. In preparation for the next practice, backup your orcl database, remove obsolete
eฺ
and ensure that no failures are listed. (The output is removed to not h
a
clutter i d
this activity
u
guide.) y t G
RMAN> BACKUP DATABASE PLUS ARCHIVELOG DELETE
a c k@ INPUT;
d e n
RMAN> delete noprompt obsolete; (frz S tu
RMAN> list failure;
A LA e this
RMAN> exit
H OU to us
$
0 T C se
I % 2 icen
E L ble l
A M era
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 10
Practice 12-3: Recovering from the Loss of all Control Files
Overview
In this practice, you create an issue by removing control files. After creating the issue, you must
restore the control files. The following tasks include steps for your learning purpose.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
A full backup of the database is available. Autobackup of the control file and SPFILE is
configured to the +FRA and +DATA disk groups.
Two terminal windows are open in the $LABS directory, pointing to the orcl instance. You are
acting as the oracle OS user.

Tasks
1. Set up for this practice by executing the setup_12_03.sh script from the $LABS directory.
In this script a new tablespace and user are created. The user creates a table ands a
)h a
populates it. A backup of the tablespace is performed and then the table is updated.
m
co eฺ
The output is redirected to /tmp/setup.log and can be viewed there also during the
execution of the script. o ฺ
o uid
y a h
$ ./setup_12_03.sh
@ n t G
$ k
ac tude
f r z S script from the $LABS
2. Cause a failure in the database by executing the (break_12_03.sh
L A h i s
directory. When prompted, enter oracleAas training tpassword for the grid OS user. The
O
output is in the /tmp/break.log file. U use
C H e to
$ ./break_12_03.sh
2 T
0<<< notnsdisplayed
% c e
LI ble li
Password: oracle
$ E
M theedatabase.
3. Attempt e A
to start f ra Notice the error messages. Exit from SQL*Plus.
a r i n s
a c h $ sqlplus
n - tra / as sysdba
Z noConnected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 534462464 bytes
Fixed Size 2290416 bytes
Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
ORA-00205: error in identifying control file, check alert log
for more info

SQL> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 11
4. View the alert log. Scroll to the most recent entries to see the errors from this practice.
$ adrci
adrci> set editor gedit
adrci> show alert
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Choose the home from which to view the alert log:

1: diag/rdbms/rcat/rcat
2: diag/rdbms/emrep/emrep
3: diag/rdbms/orcl/orcl
4: diag/rdbms/dummy/orcl
Q: to quit

s a
a
Please select option: 3 <<< Enter your orcl alert log number
)h
m
Output the results to file: /tmp/alert_14802_1398_orcl_1.ado
co eฺ
Please select option: o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

5. Exit from viewing the alert log. (Click the x icon to close the gedit window, enter Q, and
then exit.)

Please select option: Q
adrci> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 12
6. Use the LIST FAILURE and ADVISE FAILURE commands to determine the failures and
proposed solutions.
$ rman target "'/ as sysbackup'"
connected to target database: ORCL (not mounted)
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

RMAN> list failure;

using target database control file instead of recovery catalog


List of Database Failures
=========================

Failure ID Priority Status Time Detected Summary


s a
---------- -------- --------- ------------------- -------
)h a
1714 CRITICAL OPEN 2013-06-25:10:36:12 Control file
m
co eฺ
+DATA/ORCL/CONTROLFILE/current.265.818592057 is missing
o ฺ
o uid
1711 CRITICAL OPEN h
2013-06-25:10:36:12 Control file
y a
+FRA/ORCL/CONTROLFILE/control02.ctl is missing
@ n t G
RMAN> k
ac tude
( f r z S
L A h i s
RMAN> advise failure;
U A se t
C HO e to u
0 T ns
List of Database Failures
2
I% le lice
=========================
L
M E ab
e A r
IDfePriority
a r i
Failure
n s Status Time Detected Summary

a c h -tra
---------- -------- --------- ------------------- -------
Z no1714 n CRITICAL OPEN 2013-06-25:10:36:12 Control file
+DATA/ORCL/CONTROLFILE/current.265.818592057 is missing
1711 CRITICAL OPEN 2013-06-25:10:36:12 Control file
+FRA/ORCL/CONTROLFILE/control02.ctl is missing

analyzing automatic repair options; this may take some time


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=14 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions


========================
no manual actions available

Optional Manual Actions


=======================
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 13
1. If file +DATA/ORCL/CONTROLFILE/current.265.818592057 was
unintentionally renamed or moved, restore it
2. If file +FRA/ORCL/CONTROLFILE/control02.ctl was
unintentionally renamed or moved, restore it
3. If this is a standby database, restore the controlfile for a
standby database using RESTORE STANDBY CONTROLFILE FROM
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

AUTOBACKUP command
4. If this is a primary database and a standby database is
available, then perform a Data Guard failover initiated from the
standby

Automated Repair Options


========================
Option Repair Description
s a
------ ------------------
)h a
1 Restore a backup control file
m
co eฺ
Strategy: The repair includes complete media recovery with no
o ฺ
o uid
data loss
y a h
Repair script:
@ n t G
k
ac tude
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1662070021.hm
RMAN> ( f r z S
7. Review the commands generated by the A L A h i s
t PREVIEW command.
U s e
REPAIR FAILURE

HO e to u
RMAN> repair failure preview;
C
Strategy: The 2 0T includes
repair
e ns complete media recovery with no
data loss LI % li c
E l e
Repair
A Mscript:
f e r ab
h a rie ans
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1662070021.hm

a c n - tr
Z nocontents of repair script:
# restore control file
restore controlfile from autobackup;
sql 'alter database mount';
RMAN>
8. Use RMAN command line to restore the control files and mount the database.
Note: If you use the REPAIR FAILURE command at this point, then new failures are
created, so that the database must be recovered and you need to execute these RMAN
commands (again) to complete your database recovery:
LIST FAILURE;
ADVISE FAILURE;
REPAIR FAILURE PREVIEW;
REPAIR FAILURE;

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 14
Then continue with step 12.
If you are unsure, follow the steps exactly as described:
RMAN> restore controlfile from autobackup;

Starting restore at 2013-06-25:11:37:14


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

using channel ORA_DISK_1

recovery area destination: +FRA


database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: AUTOBACKUP
+FRA/ORCL/AUTOBACKUP/2013_06_25/s_819023635.294.819023637 found
in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID
was not set
s a
channel ORA_DISK_1: restoring control file from AUTOBACKUP
)h a
+FRA/ORCL/AUTOBACKUP/2013_06_25/s_819023635.294.819023637 m
co eฺ
channel ORA_DISK_1: control file restore from AUTOBACKUP o ฺ
o uid
complete
y a h
@ n t G
k
ac tude
output file name=+FRA/ORCL/CONTROLFILE/control02.ctl

f r z
output file name=+DATA/ORCL/CONTROLFILE/current.265.819027437
A ( this S
Finished restore at 2013-06-25:11:37:22
L
O UA use
RMAN> ALTER DATABASE H MOUNT; to
C
0 ense
T
2
I% le lic
Statement Lprocessed
MEchannel:
released
A e r ab ORA_DISK_1
ie ns
rRMAN> f
9. c h a a the database.
tropen
Attempt-to
a n
Z noRMAN> ALTER DATABASE OPEN;
RMAN-00571: ===============================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
RMAN-00571: ===============================================
RMAN-03002: failure of sql statement command at 06/25/2013
11:37:51
ORA-01589: must use RESETLOGS or NORESETLOGS option for database
open
RMAN>
Question: Why is RESETLOGS necessary?
Answer: RESETLOGS is required because the SCN in the restored control file does not
match the SCN recorded in the data files.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 15
10. Attempt to open the database with the RESETLOGS option.
RMAN> ALTER DATABASE OPEN RESETLOGS;

RMAN-00571: ================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

RMAN-00571: ===============================================
RMAN-03002: failure of sql statement command at 06/25/2013
11:40:07
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1:
'+DATA/ORCL/DATAFILE/system.261.818611365'
RMAN>
Question: Why did the database open still fail with the RESETLOGS option?
s a
)h a
Answer: The SCN in the control file is older than the SCN in the data files and the data files
have not been restored with the UNTIL cause. The database needs to be recovered so that
the control file can be synchronized with the data files. m
co eฺ
11. Recover the database. o ฺ
o uid
y a h
RMAN> recover database;
@ n t G
k
ac tude
( f r z S
Starting recover at 2013-06-25:11:40:59
L A h i s
t 2013-06-25:11:40:59
Starting implicit crosscheck
U A backup
s e at

H O to u
allocated channel: ORA_DISK_1
C
0T SID=14
channel ORA_DISK_1: sedevice type=DISK
32objects e n
Crosschecked%
lic
LI ble crosscheck
FinishedEimplicit backup at 2013-06-25:11:41:01
M
A fer a
a r i e n simplicit crosscheck copy at 2013-06-25:11:41:01
h r a
Starting
n-t channel ORA_DISK_1
Zac nousing
Crosschecked 1 objects
Finished implicit crosscheck copy at 2013-06-25:11:41:01

searching for all files in the recovery area


cataloging files...
cataloging done

List of Cataloged Files


=======================
File Name:
+FRA/ORCL/AUTOBACKUP/2013_06_25/s_819023635.294.819023637

using channel ORA_DISK_1

starting media recovery


Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 16
archived log for thread 1 with sequence 12 is already on disk as
file +DATA/ORCL/ONLINELOG/group_3.272.818957215
archived log file
name=+DATA/ORCL/ONLINELOG/group_3.272.818957215 thread=1
sequence=12
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

media recovery complete, elapsed time: 00:00:05


Finished recover at 2013-06-25:11:41:11
RMAN>
12. Open the database with RESETLOGS.
RMAN> ALTER DATABASE OPEN RESETLOGS;
Statement processed
RMAN>
s a
13. Optionally, list your new DBID.
h a
)FROM
RMAN> SELECT NAME, DBID, CURRENT_SCN, LOG_MODE, OPEN_MODE m
co eฺ
V$DATABASE;
o ฺ
o uid
y a h
DBID CURRENT_SCN LOG_MODE@ OPEN_MODE n t G
NAME
k e
ac tud------------------
--------- ---------- ----------- ------------
( f r z S
--
L A t h i s
ORCL 1346372794 A sARCHIVELOG
2377624
U e READ WRITE
RMAN>
C HO e to u
0T etonsverify that the failure has been repaired.
14. Use the LIST FAILURE command
2
L %
RMAN> list Ifailure;
e l ic
MERole: l
abPRIMARY
Database
A f e r
a ie failures
rno n s found that match specification
h r a
ac on-t
Z15.
RMAN>
Innanother terminal window, clean up the practice environment by using the
cleanup_12_03.sh script from the $LABS directory. The output is in the
/tmp/cleanup.log file.
$ ./cleanup_12_03.sh
$
16. In preparation for the next practice, backup your orcl database, remove obsolete backups,
and ensure that no failures are listed. (The output is removed to not clutter this activity
guide.) Then exit from RMAN.
RMAN> BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
RMAN> delete noprompt obsolete;
RMAN> list failure;
RMAN> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 17
Practice 12-4: Restoring the Password File
Overview
In this practice you recover from the loss of the database password file. The database password
is required for remote access to the database by SYSDBA privileged users.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
A full backup of the database is available.
Two terminal windows are open in the $LABS directory, pointing to the orcl instance. You are
acting as the oracle OS user.

Tasks
1. Cause a failure in the database by executing the break_12_04.sh script from the $LABS
directory. The output is redirected to /tmp/break.log and can be viewed there also
s a
during the execution of the script.
)h a
$ ./break_12_04.sh m
co eฺ
$ o ฺ
o uid
a h
y thet G
2. Attempt to connect to the database using a remote connection. Notice error messages.
$ sqlplus sys@orcl as sysdba @
ck ude n
z a
fr s St
(
Enter password: oracle_4U <<<Lnot
A e thi
A displayed
ERROR:
H OU to us
ORA-01017: invalid C e
0 T username/password;
n s logon denied

I%2 le lice
Enter user-name: (Control-c, then return)
L
ME connection
$
Note: The A remotefe r ab requires the use of a password file.
3. h a rieif theapassword
Check n s file exists. The name of the orcl database password file for Linux
r
-tsystems is $ORACLE_HOME/dbs/orapworcl.ora.
Zac and o n
Unix
n $ ls $ORACLE_HOME/dbs/orapw*
/u01/app/oracle/product/12.1.0/dbhome_1/dbs/orapwrcat
$
The orapworcl.ora should not be listed (because it was deleted by the
break_12_04.sh script).
Note: It is critically important to the security of your system that you protect your password
file and the environment variables that identify the location of the password file. Any user
with access to these could potentially compromise the security of the connection.
4. Optionally, view the description of the orapwd parameters. Execute orapwd in a terminal
window.
$ orapwd
Usage: orapwd file=<fname> entries=<users> force=<y/n> asm=<y/n>
dbuniquename=<dbname> format=<legacy/12> sysbackup=<y/n>
sysdg=<y/n> syskm=<y/n> delete=<y/n> input_file=<input-fname>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 18
Usage: orapwd describe file=<fname>

where
file - name of password file (required),
password - password for SYS will be prompted
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

if not specified at command line.


Ignored, if input_file is specified,
entries - maximum number of distinct DBA (optional),
force - whether to overwrite existing file (optional),
asm - indicates that the password to be stored in
Automatic Storage Management (ASM) disk group
is an ASM password. (optional).
dbuniquename - unique database name used to identify
s a
database
)h a
password files residing in ASM diskgroup
m
co eฺ
only.
o ฺ
o uid
y a h
Ignored when asm option is specified
(optional),
@ n t G
k
ac tude
format - use format=12 for new 12c features like SYSBACKUP,
f r z
A ( this S
SYSDG and SYSKM support, longer identifiers, etc.
L
If not specified, format=12 is default (optional),
UA use
delete - drops a password file. Must specify 'asm',
O
C H e to
'dbuniquename' or 'file'. If 'file' is specified,
2 T
0 ens
the file must be located on an ASM diskgroup
L I le lic
%
(optional),

A ME erab
sysbackup - create SYSBACKUP entry (optional and requires

a r ie nsf
the

a c h -tra 12 format). Ignored, if input_file is specified,


Z non sysdg - create SYSDG entry (optional and requires the 12
format), Ignored, if input_file is specified,
syskm - create SYSKM entry (optional and requires the 12
format), Ignored, if input_file is specified,
input_file - name of input password file, from where old
user
entries will be migrated (optional),
describe - describes the properties of specified password
file
(required).
There must be no spaces around the equal-to (=) character.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 19
5. Create a new password file by using the orapwd utility.
$ orapwd FILE=$ORACLE_HOME/dbs/orapworcl ENTRIES=15
Enter password for SYS: oracle_4U <<< Not displayed
$
Note: When you exceed the allocated number of password entries, you must create a new
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

password file. To avoid this necessity, allocate more entries than you think you will ever
need.
6. Test the remote SYSDBA login. Now it should be successful. Exit from SQL*Plus.
$ sqlplus sys@orcl as sysdba
Enter password: oracle_4U <<< not displayed
SQL>
7. Optionally, review the V$PWFILE_USERS view.
SQL> desc V$PWFILE_USERS
s a
Name Null? Type
)h a
----------------------------------------- -------- m
co eฺ
------------
- o ฺ
o VARCHAR2(30)
USERNAME y a h
G uid
SYSDBA
c k @ ent VARCHAR2(5)
d
SYSOPER
( frza s Stu VARCHAR2(5)
SYSASM
A LA e thi VARCHAR2(5)
SYSBACKUP
H OU to us VARCHAR2(5)
SYSDG
0 T C se VARCHAR2(5)
SYSKM
I % 2 icen VARCHAR2(5)
CON_ID
E L ble l NUMBER
A M era
r ie SELECT
n s f * FROM V$PWFILE_USERS;
c a SQL>
h -tra
a n
Z noUSERNAME SYSDB SYSOP SYSAS SYSBA SYSDG SYSKM
CON_ID
-------------------- ----- ----- ----- ----- ----- ----- -------
-
SYS TRUE TRUE FALSE FALSE FALSE FALSE
0
SQL>
8. Exit SQL*Plus.
SQL> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 20
Practice 12-5: Recovering a Tempfile
Overview
In this practice you examine the actions of the Oracle Database server when a tempfile is
missing.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
The temporary tablespace is named TEMP and located in +DATA/ORCL/DATAFILE.
Two terminal windows are open in the $LABS directory, pointing to the orcl instance. You are
acting as the oracle OS user.

Tasks
1. Set up for this practice by executing the setup_12_05.sh script from the $LABS directory.
In this script a new tablespace and user are created. The user creates a table, populates it
and performs a query with an ORDER BY clause. (Some of these activities use a tempfile.) s a
A backup of the tablespace is performed and then the table is updated. )h a
m
co eฺ
execution of the script. o ฺ
The output is redirected to /tmp/setup.log and can be viewed there also during the
o uid
y a h
$ ./setup_12_05.sh
@ n t G
$ k
ac tude
f r z
(break_12_05.shS script in the $LABS
2. Cause a failure in the database by executing the
L A h i s
tpassword for the grid OS user. The
directory. When prompted, enter oracleAas training e
U s
HO e to u
output is in the /tmp/break.log file.
C
$ ./break_12_05.sh
2 0 T ns
Password: oracleI% le<<<licnot e displayed
L
$
A ME erab
r e database
3. Start ithe
n s f instance. Exit from SQL*Plus.
c a tra / as sysdba
h $ sqlplus
a n -
Z noConnected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 534462464 bytes


Fixed Size 2290416 bytes
Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
Database mounted.
Database opened.

SQL> exit

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 21
4. View the end of the orcl alert log. The most recent entries show that the startup
processing includes the recreation of tempfiles, if needed.
Either use the adrci command line utility (as shown in earlier practices) or log in to EM
Cloud Control as the SYSMAN user with the oracle_4U password.
a. From the orcl database home page, navigate: Oracle Database > Logs > Alert Log
Content and click Switch to Text Alert Log Contents.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

b. Enter date and time values that include the time when you performed the startup
operation and then click Go.
c. You can either scroll through your selected portion of the alert log, or use your
browser's search functionality (Firefox: Ctrl+F, then enter a search word) to see the Re-
creating tempfile entry as shown in the screenshot.

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
ie and close
5. Logrout n s f all windows.
a tra
.ach -
Z no n

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 22
Practice 12-6: Creating Encrypted Backups
Overview
In this practice you create an encrypted backup that is protected against data breach if the
backup media is lost. In this example you will be using transparent encryption which depends on
an encryption wallet. If the encryption wallet is lost, the backup is not recoverable. To mitigate
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

the loss of a wallet or to allow the backup to be recovered on a different machine you can use
password encryption instead of transparent encryption, or use both so that either the wallet or
the password will allow the backup to be recovered.

Assumptions
Two terminal windows are open in the $LABS directory, pointing to the orcl instance. You are
acting as the oracle OS user.

Tasks
s a
1. Prepare the database for encryption.
)h a
m
co eฺ
a. Set the environment variables for your orcl database instance. If it does not exist,
create a directory for the Oracle wallet named o ฺ
o uid
$ORACLE_BASE/admin/orcl/wallet.
y a h
@ n t G
$ ls $ORACLE_BASE/admin/orcl/wallet k
ac tude
( f r z S
ls: cannot access /u01/app/oracle/admin/orcl/wallet: No such
file or directory
A LA e this
OU to us
$ mkdir -p $ORACLE_BASE/admin/orcl/wallet
$ H
C se
0 T
2 icen
b. Edit the $ORACLE_HOME/network/admin/sqlnet.ora file to add the following lines:
I % l
EL = able
ENCRYPTION_WALLET_LOCATION=
M
r i e A (METHOD
(SOURCE
s f er = FILE)
a c ha -tran (METHOD_DATA =
Z non (DIRECTORY = /u01/app/oracle/admin/orcl/wallet)))
$ gedit
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 23
2. Create a password-based keystore and back it up.
a. Connect to the orcl database instance as SYSDBA or as a user being granted the
SYSKM privilege.
$ sqlplus / as sysdba
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

b. Create a password-based keystore.


SQL> ADMINISTER KEY MANAGEMENT CREATE KEYSTORE
'/u01/app/oracle/admin/orcl/wallet' IDENTIFIED BY secret;
2
keystore altered.
SQL>
c. Confirm that the wallet exists.
SQL> ! ls -l /u01/app/oracle/admin/orcl/wallet
s a
total 4
)h a
-rw-r--r-- 1 oracle asmadmin 2408 Jun 27 05:21 ewallet.p12 m
co eฺ
SQL> o
o uidฺ
y a h
d. Open the keystore.
@ n t G
SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE
a k
c ude OPEN IDENTIFIED BY
secret; z
(fr is S t
A
keystore altered.
U AL se th
SQL>
H O to u
0 T C
e. Optionally, view information about
s e wallet in the data dictionary.
the
n
I%2 le lice STATUS, WALLET_TYPE FROM
SQL> SELECT WRL_PARAMETER,
L
ME erab
V$ENCRYPTION_WALLET;
A
WRL_PARAMETER
ie nsf
a r
h ----tra
----------------------------------------------------------------
a c
Z noSTATUS n WALLET_TYPE
------------------------------ --------------------
/u01/app/oracle/admin/orcl/wallet
OPEN_NO_MASTER_KEY PASSWORD
SQL>
f. Generate the master encryption key.
SQL> ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY secret WITH
BACKUP USING 'test';
keystore altered.
SQL>
g. Verify that the keystore has been backed up before the master key generation.
SQL> !ls -l /u01/app/oracle/admin/orcl/wallet
total 12
-rw-r--r-- 1 oracle asmadmin 2408 Jun 28 06:52
ewallet_2013062806521621_test.p12
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 24
-rw-r--r-- 1 oracle asmadmin 4112 Jun 28 06:52 ewallet.p12
SQL>
Notice that if you regenerate the master key, the file is growing. All previous master keys
are kept for data which could have used the previous master keys.
h. Generate another key and view the keystore file.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

SQL> ADMINISTER KEY MANAGEMENT SET KEY


IDENTIFIED BY secret WITH BACKUP;
keystore altered.

SQL> !ls -l /u01/app/oracle/admin/orcl/wallet


total 20
-rw-r--r-- 1 oracle asmadmin 2408 Jun 28 06:52
ewallet_2013062806521621_test.p12
s a
-rw-r--r-- 1 oracle asmadmin 4112 Jun 28 07:03
ewallet_2013062807031379.p12 )h a
m
co eฺ
-rw-r--r-- 1 oracle asmadmin 6312 Jun 28 07:03 ewallet.p12
o ฺ
o uid
SQL>
a h
i. Back up the keystore containing the current master key. @y t G
k n
c udeIDENTIFIED BY
SQL> ADMINISTER KEY MANAGEMENT BACKUP
f r z aKEYSTORE
t
( S
LA e this
secret;
keystore altered. A
H OU to us
0 T C se
SQL> !ls -l /u01/app/oracle/admin/orcl/wallet
I % 2 icen
total 28
E L 1 oracle
l e l asmadmin 2408 Jun 28 06:52
M erab
-rw-r--r--
A
a r ie nsf 1 oracle asmadmin 4112 Jun 28 07:03
ewallet_2013062806521621_test.p12

a c n - tra
h ewallet_2013062807031379.p12
-rw-r--r--
Z no-rw-r--r-- 1 oracle asmadmin 6312 Jun 28 07:08
ewallet_2013062807082628.p12
-rw-r--r-- 1 oracle asmadmin 6312 Jun 28 07:08 ewallet.p12
SQL>
Notice that both the current keystore and the backup files have the same size.
3. Using RMAN, create a transparent encrypted backup with a password. Use the
lab_12_06_02.rman script.
a. As always it is a good idea to review a script before executing it.
$ cat lab_12_06_02.rman
set encryption on for all tablespaces algorithm 'AES128';
run {
allocate channel enc_backup_disk1 type disk format
'/u01/backup/orcl/%U';
backup as BACKUPSET tag 'TRANSPARENT' database;

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 25
backup as BACKUPSET tag 'TRANSPARENT' archivelog all not backed
up;
release channel enc_backup_disk1;
}
$
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

b. Execute the lab_12_06_02.rman script.


$ rman target "'/ as sysbackup'" @lab_12_06_02.rman
Recovery Manager: Release 12.1.0.1.0 - Production on Fri Jun 28
07:12:21 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All
rights reserved.

connected to target database: ORCL (DBID=1346372794)


s a
RMAN> set encryption on for all tablespaces algorithm 'AES128'; )h a
m
co eฺ
2> run {
o
o uidฺ
3> allocate channel enc_backup_disk1 type disk h format
y a G
'/u01/backup/orcl/%U';
k @ n t
4> backup as BACKUPSET tag 'TRANSPARENT'
r z t u de
ac database;
( f
5> backup as BACKUPSET tag 'TRANSPARENT'
s S
archivelog all not
A i
backed up;
U AL se th
HO e to u
6> release channel enc_backup_disk1;
7> } C
0T ens
8> 2 ic encryption
I% le lSET
executing Lcommand:
E adatabase
Mtarget b
A
using
e f e r control file instead of recovery catalog
i
ar tran s
c h
n-
Za noallocated channel: enc_backup_disk1
channel enc_backup_disk1: SID=275 device type=DISK

Starting backup at 2013-06-28:07:12:23


channel enc_backup_disk1: starting full datafile backup set
channel enc_backup_disk1: specifying datafile(s) in backup set
input datafile file number=00003
name=+DATA/ORCL/DATAFILE/sysaux.270.818591867
channel enc_backup_disk1: starting piece 1 at 2013-06-
28:07:12:24
channel enc_backup_disk1: finished piece 1 at 2013-06-
28:07:12:59
piece handle=/u01/backup/orcl/29oda52o_1_1 tag=TRANSPARENT
comment=NONE
channel enc_backup_disk1: backup set complete, elapsed time:
00:00:35
channel enc_backup_disk1: starting full datafile backup set
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 26
channel enc_backup_disk1: specifying datafile(s) in backup set
input datafile file number=00001
name=+DATA/ORCL/DATAFILE/system.261.818611365
channel enc_backup_disk1: starting piece 1 at 2013-06-
28:07:12:59
channel enc_backup_disk1: finished piece 1 at 2013-06-
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

28:07:13:34
piece handle=/u01/backup/orcl/2aoda53r_1_1 tag=TRANSPARENT
comment=NONE
channel enc_backup_disk1: backup set complete, elapsed time:
00:00:35
channel enc_backup_disk1: starting full datafile backup set
channel enc_backup_disk1: specifying datafile(s) in backup set
input datafile file number=00005
s a
name=/u01/backup/orcl/bartbs.dbf
)h a
input datafile file number=00002
m
co eฺ
name=+DATA/ORCL/DATAFILE/example.264.818592141
o ฺ
o uid
input datafile file number=00006
y a h
name=+DATA/ORCL/DATAFILE/users.268.818592007
@ n t G
input datafile file number=00004 k
ac tude
f r z
A ( this S
name=+DATA/ORCL/DATAFILE/undotbs1.267.818592009
L
channel enc_backup_disk1: starting piece 1 at 2013-06-
28:07:13:35
O UA use
C H e to
channel enc_backup_disk1: finished piece 1 at 2013-06-
28:07:13:50
2 T
0 ens
I le lic
%
piece handle=/u01/backup/orcl/2boda54u_1_1 tag=TRANSPARENT
L
ME erab
comment=NONE
A
a r ie nsf
channel enc_backup_disk1: backup set complete, elapsed time:

a c h -tra00:00:15
Z non Finished backup at 2013-06-28:07:13:50

Starting backup at 2013-06-28:07:13:52


current log archived
channel enc_backup_disk1: starting archived log backup set
channel enc_backup_disk1: specifying archived log(s) in backup
set
input archived log thread=1 sequence=3 RECID=74 STAMP=819034291
input archived log thread=1 sequence=4 RECID=75 STAMP=819064908
input archived log thread=1 sequence=5 RECID=76 STAMP=819065052
input archived log thread=1 sequence=6 RECID=77 STAMP=819104452
input archived log thread=1 sequence=7 RECID=78 STAMP=819151250
input archived log thread=1 sequence=8 RECID=79 STAMP=819151452
input archived log thread=1 sequence=9 RECID=80 STAMP=819180036
input archived log thread=1 sequence=10 RECID=81 STAMP=819226810
input archived log thread=1 sequence=11 RECID=82 STAMP=819237809
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 27
input archived log thread=1 sequence=12 RECID=83 STAMP=819248458
input archived log thread=1 sequence=13 RECID=84 STAMP=819270835
channel enc_backup_disk1: starting piece 1 at 2013-06-
28:07:13:56
channel enc_backup_disk1: finished piece 1 at 2013-06-
28:07:14:21
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

piece handle=/u01/backup/orcl/2coda55k_1_1 tag=TRANSPARENT


comment=NONE
channel enc_backup_disk1: backup set complete, elapsed time:
00:00:25
Finished backup at 2013-06-28:07:14:21

Starting Control File and SPFILE Autobackup at 2013-06-


28:07:14:22
s a
piece
)h a
handle=+FRA/ORCL/AUTOBACKUP/2013_06_28/s_819270862.289.819270865
m
co eฺ
comment=NONE
o ฺ
o uid
Finished Control File and SPFILE Autobackup at 2013-06-
y a h
28:07:14:29
@ n t G
k
ac tude
f r z
A ( this S
released channel: enc_backup_disk1
L
Recovery Manager complete. O UA use
C H e to
$
2 T ns
0 wereeencrypted.
4. Verify that the backup
L % pieces
I le li c Use the lab_12_06_03.sql script.

M E ab
$ cat lab_12_06_03.sql

r i
--e A
s f
DISCLAIMER: er
c ha -- -This
t r anscript is provided for educational purposes only. It is
a
Z no--n NOT supported by Oracle World Wide Technical Support.
-- The script has been tested and appears to work as intended.
-- You should always run new scripts on a test instance
initially.

/* display the backup pieces and the encryption status of each


*/
/* Where the Tag is 'TRANSPARENT' */
SET PAGES 99
COL_BS_REC FORMAT 99999
COL BP_REC FORMAT 99999
COL ENCRYPTED FORMAT A7
COL TAG FORMAT A12
COL MEDIA_HANDLE FORMAT a40

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 28
SELECT s.recid as BS_REC, P.RECID as BP_REC, P.ENCRYPTED, P.TAG,
p.HANDLE as MEDIA_HANDLE
from v$BACKUP_PIECE P, V$BACKUP_SET S
WHERE P.SET_STAMP=S.SET_STAMP
and P.SET_COUNT = S.SET_COUNT
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

and P.TAG='TRANSPARENT'
/
exit
$

$ sqlplus / as sysdba @lab_12_06_03.sql

BS_REC BP_REC ENCRYPT TAG MEDIA_HANDLE


s a
)h a
------ ------ ------- ------------ ----------------------------
66 66 YES TRANSPARENT m
co eฺ
/u01/backup/orcl/29oda52o_1_1
o ฺ
o uid
67 67 YES TRANSPARENT
y a h
/u01/backup/orcl/2aoda53r_1_1
@ n t G
68 68 YES TRANSPARENTk
ac tude
f r z
A ( this S
/u01/backup/orcl/2boda54u_1_1
L
UA use
69 69 YES TRANSPARENT
O
/u01/backup/orcl/2coda55k_1_1
H e to
$
T C
0 ens
2
I le lic
%
L
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 29
Practice 12-7: Recovering by Using an Encrypted Backup
Overview
In this practice you will recover a lost data file by using an encrypted backup.

Assumptions
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Practice 12-6 has been completed. An encryption wallet exists and a full database backup using
transparent encryption has been created.
Two terminal windows are open in the $LABS directory, pointing to the orcl instance. You are
acting as the oracle OS user.

Tasks
1. Set up for this practice by executing the setup_12_07.sh script from the $LABS directory.
In this script a new tablespace and user are created. The user creates a table and
populates it. A backup of the tablespace is performed and then the table is updated. Thes a
output is in the /tmp/setup.log file. )h a
m
co eฺ
$ ./setup_12_07.sh
o ฺ
o uid
$
a h
y scriptt G
2. Cause a failure in the database by executing the break_12_07.sh
c k @ e n from the $LABS
fordthe grid OS user. The
frza s Stu
directory. When prompted, enter oracle as training password
output is in the /tmp/break.log file. (
A LA e thi
OU
$ ./break_12_07.sh
Password: oracle <<< H not
t o
displayedus
The Oracle base 0 T Cbeen schanged
e
2 has
e n from /u01/app/oracle to
/u01/app/grid
L I% le lic
$
M E ab
3. Attempt e A f
to start the r
edatabase. Notice the error messages.
a r i n s
a c h $ sqlplus
n - tra / as sysdba
Z noConnected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 534462464 bytes
Fixed Size 2290416 bytes
Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 3 - see DBWR trace
file
ORA-01110: data file 3:
'+DATA/ORCL/DATAFILE/sysaux.268.811233943'
SQL>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 30
4. In another terminal window, use the LIST FAILURE and ADVISE FAILURE commands to
diagnose the problem.
$ rman target "'/ as sysbackup'"

RMAN> LIST FAILURE;


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

using target database control file instead of recovery catalog


Database Role: PRIMARY

List of Database Failures


=========================

Failure ID Priority Status Time Detected Summary


---------- -------- --------- ------------------- -------
s a
8
non-system
HIGH OPEN 2013-06-28:07:26:23 One or more
datafiles are missing )h a
m
co eฺ
o ฺ
o uid
RMAN> ADVISE FAILURE;
y a h
@ n t G
Database Role: PRIMARY k
ac tude
( f r z S
List of Database Failures A L A t h i s
U s e
=========================
C HO e to u
2 0T Statuse ns Time Detected
I %
Failure ID Priority
L l i c Summary
E --------
----------
M a b le --------- ------------------- -------
8e A f r
eHIGH
r i s OPEN 2013-06-28:07:26:23 One or more

a c ha -tran
non-system datafiles are missing
n
Z noanalyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=250 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions


========================
no manual actions available

Optional Manual Actions


=======================
1. If file +DATA/ORCL/DATAFILE/sysaux.270.818591867 was
unintentionally renamed or moved, restore it

Automated Repair Options


Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 31
========================
Option Repair Description
------ ------------------
1 Restore and recover datafile 3
Strategy: The repair includes complete media recovery with no
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

data loss
Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1391499873.hm
RMAN>
5. Review the repair commands with the REPAIR FAILURE PREVIEW command.
RMAN> repair failure preview;
Strategy: The repair includes complete media recovery with no
data loss
s a
Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1391499873.hm )h a
m
co eฺ
o ฺ
o uid
contents of repair script:
y a h
# restore and recover datafile
@ n t G
restore ( datafile 3 ); k
ac tude
f r z S
A3( online';
recover datafile 3;
L h i s
sql 'alter database datafile
U A se t
RMAN>
H O to u
C
0T andeexpect
6. Optionally, execute the repair se an error.
2 n
RMAN> REPAIR
L I%FAILURE;
e l ic
M E ab l
r i e A
Strategy:
s f er repair includes complete media recovery with no
The
c ha data- t r an
loss
a
Z noRepairn script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1391499873.hm

contents of repair script:


# restore and recover datafile
restore ( datafile 3 );
recover datafile 3;
sql 'alter database datafile 3 online';

Do you really want to execute the above repair (enter YES or


NO)? y
executing repair script

Starting restore at 2013-06-28:07:32:25


using channel ORA_DISK_1

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 32
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from
backup set
channel ORA_DISK_1: restoring datafile 00003 to
+DATA/ORCL/DATAFILE/sysaux.270.818591867
channel ORA_DISK_1: reading from backup piece
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

/u01/backup/orcl/29oda52o_1_1
RMAN-00571: ===============================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
RMAN-00571: ===============================================
RMAN-03002: failure of repair command at 06/28/2013 07:32:29
RMAN-03015: error occurred in stored script Repair Script
ORA-19870: error while restoring backup piece
/u01/backup/orcl/29oda52o_1_1
s a
ORA-19913: unable to decrypt backup
)h a
ORA-28365: wallet is not open m
co eฺ
RMAN> o ฺ
o uid
7. Because the database was restarted and the encryption wallet isynot ahconfigured
Gcan begin.
to be an
@ n t
Logged in to SQL*Plus as SYSDBA or SYSKM, openrz a ck uand
auto-login wallet, the encryption wallet must be opened before the recovery
dethen exit.
( f the t
keystore
S OPEN IDENTIFIED BY
SQL> ADMINISTER KEY MANAGEMENT A
L h i s
A se t
SET KEYSTORE
secret; U
keystore altered.
C HO e to u
2 0T ens
SQL> EXIT I%
L e l ic
$ ME erab l
A f repair the failure and open the database. Notice that one of the
ieRMANnsession,
r
8. In your
a s
a c n raencrypted backup was used to restore the tablespace.
hpieces of-tthe
Z noRMAN> REPAIR FAILURE;
Strategy: The repair includes complete media recovery with no
data loss
Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1391499873.hm

contents of repair script:


# restore and recover datafile
restore ( datafile 3 );
recover datafile 3;
sql 'alter database datafile 3 online';

Do you really want to execute the above repair (enter YES or


NO)? y
executing repair script
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 33
Starting restore at 2013-06-28:07:38:55
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

channel ORA_DISK_1: specifying datafile(s) to restore from


backup set
channel ORA_DISK_1: restoring datafile 00003 to
+DATA/ORCL/DATAFILE/sysaux.270.818591867
channel ORA_DISK_1: reading from backup piece
/u01/backup/orcl/29oda52o_1_1
channel ORA_DISK_1: piece handle=/u01/backup/orcl/29oda52o_1_1
tag=TRANSPARENT
channel ORA_DISK_1: restored backup piece 1
s a
channel ORA_DISK_1: restore complete, elapsed time: 00:01:16
)h a
Finished restore at 2013-06-28:07:40:12 m
co eฺ
o ฺ
o uid
y a h
Starting recover at 2013-06-28:07:40:12
@ n t G
using channel ORA_DISK_1 k
ac tude
f r z
starting media recovery L A ( this S
media recovery complete, U A stime:
e 00:00:02
O
H e to u
elapsed

T C
2
Finished recover
% c e ns
0at 2013-06-28:07:40:16
E LI ble li
A M era alter database datafile 3 online
sql statement:
r s f
ie nfailure
h a repair
t r a complete

Zac noDon-you want to open the database (enter YES or NO)? yes
database opened
RMAN>
9. Use the LIST FAILURE command to verify that the failure has been repaired. Then exit
RMAN.
RMAN> list failure;
Database Role: PRIMARY
no failures found that match specification

RMAN> exit
Recovery Manager complete.
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 34
Practice 12-8: Recovering a Lost Encryption Wallet
Overview
In this practice you will recover a lost encryption wallet.
Note: If you lose the wallet and do not have a backup of it, you will have to recover the
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

database to a point in time before the wallet was used.

Assumptions
Practices 12-6 and 12-7 have been completed.
Two terminal windows are open in the $LABS directory, pointing to the orcl instance. You are
acting as the oracle OS user.

Tasks
1. Copy the keystore (or encryption wallet), which is located at
s a
$ORACLE_BASE/admin/orcl/wallet/ewallet.p12, to the /u01/backup/orcl
)h a
directory. m
$ cp $ORACLE_BASE/admin/orcl/wallet/ewallet.p12 o ฺ co eฺ
/u01/backup/orcl/ewallet.p12
a h o uid
@ y t G
$
k n
$ ls /u01/backup/orcl/ewal*
f r z ac tude
/u01/backup/orcl/ewallet.p12
A ( i s S
L
A se t h
$
U
O tofotheu wallet.
C Hbackup
Note: Continue only if you see the
e
0T en
2. Remove the keystore by executing
2 thesbreak_12_08.sh script. When prompted, enter
% c
oracle as trainingI passwordlifor the grid OS user. The output is in the
/tmp/break.log
M EL file.able
A fer
$ie./break_12_08.sh
a r a n s
a c h - t r
Password: oracle <<< not displayed
n
Z noThe Oracle base has been changed from /u01/app/oracle to
/u01/app/grid
$
3. Attempt to start the database by using SQL*Plus.
$ sqlplus / as sysdba

SQL> startup
Total System Global Area 534462464 bytes
Fixed Size 2290416 bytes
Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 3 - see DBWR trace
file

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 35
ORA-01110: data file 3:
'+DATA/ORCL/DATAFILE/sysaux.270.819272337'
SQL>
4. This is exactly the same message you received in the previous practice where you
recovered from a missing SYSAUX tablespace. Attempt to open the keystore.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY


secret;
ERROR at line 1:
ORA-28367: wallet does not exist

SQL>
5. Restore the wallet.
SQL> ! cp /u01/backup/orcl/ewallet.p12
s a
$ORACLE_BASE/admin/orcl/wallet/ewallet.p12
)h a
m
co eฺ
SQL> !ls $ORACLE_BASE/admin/orcl/wallet
o ฺ
o uid
ewallet.p12
y a h
SQL> @ n t G
k
c usession
aSQL*Plus de to execute an OS
Note: The exclamation mark (!) temporarily leaves the
( f r z S t
command.
L A h i s
6. Open the keystore. Then exit from SQL*Plus.
U A se t
SQL> ADMINISTER KEY MANAGEMENTH O to uSET KEYSTORE OPEN IDENTIFIED BY
secret;
0 C
T nse
2
I% le lice
keystore altered.
L
A ME erab
r ie exit
SQL>
n s f
c a
h -tra
SQL>
a
Z7. Use n Data Recovery Adviser RMAN commands to recover and open the database. Then
othe
n
confirm that there are no failures and exit RMAN.
$ rman target "'/ as sysbackup'"

RMAN> list failure;

using target database control file instead of recovery catalog


Database Role: PRIMARY

List of Database Failures


=========================

Failure ID Priority Status Time Detected Summary


---------- -------- --------- ------------------- -------
8 HIGH OPEN 2013-06-28:08:13:18 One or more
non-system datafiles are missing
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 36
RMAN> advise failure;

Database Role: PRIMARY


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

List of Database Failures


=========================

Failure ID Priority Status Time Detected Summary


---------- -------- --------- ------------------- -------
8 HIGH OPEN 2013-06-28:08:13:18 One or more
non-system datafiles are missing

s a
analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1 )h a
m
co eฺ
channel ORA_DISK_1: SID=14 device type=DISK
o ฺ
o uid
analyzing automatic repair options complete
y a h
@ n t G
k
ac tude
Mandatory Manual Actions
( f r z S
========================
L A t h i s
no manual actions availableA e
U s
C HO e to u
0 T ns
Optional Manual Actions
2
I% le lice
=======================
L
A ME e+DATA/ORCL/DATAFILE/sysaux.270.819272337
1. If file
r a b renamed or moved, restore it was

a r ie nsf
unintentionally

a c h -tra
n
Z noAutomated Repair Options
========================
Option Repair Description
------ ------------------
1 Restore and recover datafile 3
Strategy: The repair includes complete media recovery with no
data loss
Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1030327383.hm

RMAN> repair failure;

Strategy: The repair includes complete media recovery with no


data loss
Repair script:
/u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1030327383.hm

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 37
contents of repair script:
# restore and recover datafile
restore ( datafile 3 );
recover datafile 3;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

sql 'alter database datafile 3 online';

Do you really want to execute the above repair (enter YES or


NO)? yes
executing repair script

Starting restore at 2013-06-28:08:20:44


using channel ORA_DISK_1
s a
channel ORA_DISK_1: starting datafile backup set restore ) h
a
c m
ofrom
channel ORA_DISK_1: specifying datafile(s) to restore
o ฺ
o ideฺ
backup set
a h u
channel ORA_DISK_1: restoring datafile 00003yto t G
+DATA/ORCL/DATAFILE/sysaux.270.819272337
a c k@ den
frz spiece
channel ORA_DISK_1: reading from (backup S tu
/u01/backup/orcl/29oda52o_1_1LA
A e t hi
channel ORA_DISK_1: pieceUhandle=/u01/backup/orcl/29oda52o_1_1
tag=TRANSPARENT H O to us
0 T Crestored
se backup piece 1
2
channel ORA_DISK_1:
e n
L I% le licrestore complete, elapsed time: 00:00:55
channel ORA_DISK_1:
MErestore
Finished
A e r ab at 2013-06-28:08:21:41
rie ans f
c h a tr recover at 2013-06-28:08:21:41
a n -
Starting
Z nousing channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:10

Finished recover at 2013-06-28:08:21:52

sql statement: alter database datafile 3 online


repair failure complete

Do you want to open the database (enter YES or NO)? y


database opened

RMAN> list failure;

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 38
Database Role: PRIMARY

no failures found that match specification

RMAN> exit
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

$
8. Clean up the practice environment by executing the cleanup_12_08.sh script. This script
removes the encrypted backups and disables encrypted backups. The output is in the
/tmp/cleanup.log file.
$ ./cleanup_12_08.sh
$

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 39
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 12: Performing Recovery II


Chapter 12 - Page 40
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @Lesson n t G13:
k
ac Oraclede Secure
RMAN f r z
and t u
A ( this S
Backup
L
O UA use
C H e Chapter
to 13
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 1
Practices for Lesson 13: Overview
Practices Overview
In these practices, you will you install and use Oracle Secure Backup.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 2
Practice 13-1: Installing Oracle Secure Backup
Overview
In this practice you install Oracle Secure Backup from a staging area.

Assumptions
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

You have an orcl database instance up and running and you performed the RMAN
configuration in earlier practices,
Two terminal windows are open in the $LABS directory, pointing to the orcl instance. You are
acting as the root OS user.
The Oracle Secure Backup software is staged and unzipped in the /stage/software
directory.

Tasks
s a
1. Log in as the root user and confirm that the /usr/local/oracle/backup directory
)h a
exists. This is the Oracle Secure Backup home directory and it is recommended to start the
m
co eฺ
installation from that directory. (If you were to choose another directory, the OSB product
o ฺ
o uid
documentation, as well as all related training files would not be synchronized and not work
y a h
as they are.)
@ n t G
$ su - root k
ac tude
Password: oracle <<< not displayed ( f r z S
# cd /usr/local/oracle/backupLA h i s
U A se t
# u
HO e toenvironment:
2. To install the OSB software TinCyour training
2 0 ens
I le lic
%
1. Execute /stage/<osb_installmedia>/setup
L
in the directory.
2. If asked,
M Eacceptabthe default to not edit the obparameters file.
A
3. eAccept thefe r to install now.
default
r i s
c ha4. Install
- t r anas an administrative server, media server and client [a]
a
Z no5.nSet the password for the encryption key store to oracle_4U.
6. Set the password for the admin user to oracle_4U.
7. Do not enter an e-mail address for admin user, just press the enter key.
8. Accept the default to not connect to tape libraries.
9. Accept the default to not connect to tape drives.
10. Exit the root OS user account.
# /stage/software/osb-10.4.0.2.0_linux.x64_cdrom120606/setup

Welcome to Oracle's setup program for Oracle Secure Backup.


This
program loads Oracle Secure Backup software from the CD-ROM to a
filesystem directory of your choosing.

This CD-ROM contains Oracle Secure Backup version


10.4.0.2.0_LINUX64.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 3
Please wait a moment while I learn about this host... done.

- - - - - - - - - - - - - - - - - - - - - -
-
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

1. linux86_64
administrative server, media server, client

- - - - - - - - - - - - - - - - - - - - - -
-
Loading Oracle Secure Backup installation tools... done.
Loading linux86_64 administrative server, media server,
client... done.

s a
- - - - - - - - - - - - - - - - - - - - h- -
) a
-
o m
Loading of Oracle Secure Backup software from CD-ROM
o o ฺcis eฺ
complete.
y ah Guid
You may unmount and remove the CD-ROM. k@
e n t
c d
( frza s Stu
A thi Backup installation
LA eSecure
OU to us
Would you like to continue Oracle
with H
C Oracle
'installob' now?0T(The
2 e n se Secure Backup Installation Guide
contains complete
L ic
I% le information
l about installob.)
ME era'yes'
Please answer
A b or 'no' [yes]:
a r ie nsf
a c h - --tra- - - - - - - - - - - - - - - - - - - -
Z no-n
Welcome to installob, Oracle Secure Backup's installation
program.

For most questions, a default answer appears enclosed in square


brackets.
Press Enter to select this answer.

Please wait a few seconds while I learn about this machine...


done.

Have you already reviewed and customized install/obparameters


for your
Oracle Secure Backup installation [yes]?

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 4
- - - - - - - - - - - - - - - - - - - - -
-

Oracle Secure Backup is not yet installed on this machine.


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Oracle Secure Backup's Web server has been loaded, but is not
yet configured.

Choose from one of the following options. The option you choose
defines
the software components to be installed.

Configuration of this host is required after installation


completes.
s a
)h a
You can install the software on this host in one of them
following ways: o ฺ co eฺ
(a) administrative server, media server and a h o
clientuid
@ y t G
k n
(b) media server and client
f r z ac tude
L A ( this S
(c) client
O UA use
C H e to
2 T
0 ens
If you are Inot surelic
%
Oracle E
L ble which option to choose, please refer to the
A MBackup
e raInstallation Guide. (a,b or c) a
i e
Secure
s f
c h ar tran
n-
Za noBeginning the installation. This will take just a minute and
will produce
several lines of informational output.

Installing Oracle Secure Backup on edrsr39p1 (Linux version


2.6.39-200.24.1.el6uek.x86_64)

You must now enter a password for the Oracle Secure Backup
encryption
key store. Oracle suggests you choose a password of at least 8
characters in length, containing a mixture of alphabetic and
numeric
characters.

Please enter the key store password: oracle_4U <<<not displayed


Re-type password for verification: oracle_4U <<<not displayed

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 5
You must now enter a password for the Oracle Secure Backup
'admin' user.
Oracle suggests you choose a password of at least 8 characters
in length,
containing a mixture of alphabetic and numeric characters.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Please enter the admin password: oracle_4U <<<not displayed


Re-type password for verification: oracle_4U <<<not displayed

You should now enter an email address for the Oracle Secure
Backup 'admin'
user. Oracle Secure Backup uses this email address to send job
summary
s a
reports and to notify the user when a job requires input. If you
)h a
leave this m
co eฺ
o
blank, you can set it later using the obtool's 'chuser' command.ฺ
o uid
a h
y enter
@
Do not n t G an e-mail
Please enter the admin email address: <<< k de
acentertukey.
address for admin user, just press the
( f r z S
L A t h i s
generating links for admin
U A installation
s e with Web server
HO e to u
updating /etc/ld.so.conf
C
2 0T Secure
checking Oracle
e n s Backup's configuration file
L I%
(/etc/obconfig)
e l ic
M E ab
setting l
Oracle Secure Backup directory to

i e A fer
/usr/local/oracle/backup in /etc/obconfig
a s
ar/etc/obconfig
n local database directory to /usr/etc/ob in
setting
c h t r
Za non- setting temp directory to /usr/tmp in /etc/obconfig
setting administrative directory to
/usr/local/oracle/backup/admin in /etc/obconfig
protecting the Oracle Secure Backup directory
creating /etc/rc.d/init.d/observiced
activating observiced via chkconfig
initializing the administrative domain

****************************** N O T E
******************************
On Linux systems Oracle recommends that you answer no to the
next two
questions. The preferred mode of operation on Linux systems is
to use
the /dev/sg devices for attach points as described in the
'ReadMe'
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 6
and in the 'Installation and Configuration Guide'.

Is edRSr39p1 connected to any tape libraries that you'd like to


use with
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Oracle Secure Backup [no]?

Is edRSr39p1 connected to any tape drives that you'd like to use


with
Oracle Secure Backup [no]?

Installation summary:

Installation Host OS s a Driver OS Move Reboot


Mode Name Name )h a Installed? Required?
Required? m
co eฺ
o ฺ
o uid
y a h
admin edRSr39p1 Linux no
@
no
n t G no
z a ck ude
t
r yourSuse.
Oracle Secure Backup is now ready(ffor
# exit
A LA e this
logout
H OU to us
$
0 T C se
I % 2 icen
E L ble l
A M era
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 7
Practice 13-2: Configuring Oracle Secure Backup
Overview
In this practice, you configure Oracle Secure Backup and RMAN and then initiate a backup to
tape to test your configuration.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
Two terminal windows are open in the $LABS directory, pointing to the orcl instance. You are
acting as the oracle OS user.
You completed the previous practice 13-1 and installed the software using the directories and
passwords as indicated.

Tasks
1. Execute the setup_13_osb.sh script (which calls the osb_in.sh script that updates the
osb_out.sh script with your hostname and then executes the osb_out.sh script). s a
)h a
The scripts create two virtual test libraries, some virtual test drives, inserts volumes, and
create a preauthorized oracle OSB user.
m
co eฺ
o ฺ
o uid
y a h
THESE VIRTUAL TEST DEVICES USED IN THIS PRACTICE ARE FOR TRAINING
PURPOSES ONLY. THEY ARE NOT SUPPORTED FOR PRODUCTION USE.
@ n t G
The output is in the /tmp/setup.log file. k
ac tude
Optionally, review the setup_13_osb.sh file. ( f r z S
L A h i s
$ cat setup_13_osb.sh
U A se t
#!/bin/bash
C HO e to u
# -- DISCLAIMER:T
# -- This Iscript % e ns for educational purposes only. It
20 isicprovided
is E L ble l
A MNOT supported
e ra
r i e
# --
s f by Oracle World Wide Technical Support.
n script has been tested and appears to work as
a c ha #intended.
-
--aThe
t r
Z no#n -- You should always run new scripts on a test instance
initially.
#
# Run as oracle OS user
. $LABS/set_db.sh > /tmp/setup.log

if [ `whoami` != "oracle" ]; then


echo "You are supposed to be logged on as oracle when running
this script."
exit
fi
x=`hostname --short`
echo $x >> /tmp/setup.log
sed 's/edrsr04p1/'$x'/' osb_in.sh > osb_out.sh

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 8
cat $LABS/osb_out.sh >> /tmp/setup.log
. $LABS/osb_out.sh

ls /u01 >> /tmp/setup.log


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

obtool --user admin --password oracle_4U mkuser --class oracle -


-password oracle_4U --unixname oracle --unixgroup dba --ndmpuser
no --preauth *:*:*+rman+cmdline oracle
echo "Created preauthorized OSB user oracle with password
oracle_4U" >> /tmp/setup.log

echo "OSB configuration script completed." >> /tmp/setup.log

$ ./setup_13_osb.sh
s a
$
)h a
2. With the obtool command line, review the elements that you just created. co m
Note: OSB commands are case-sensitive like Linux. h o oฺ ideฺ
y u you do
aoracleGuser,
a. Log in to obtool as the admin OSB user. As preauthorized
k@ den t
not need to enter the oracle_4U password. a c
$ obtool ( frz s Stu
ob> A LA e thi
U withusthe lsmf --long command.
Ofamily
b. View the RMAN-DEFAULT media
C H e to
ob> lsmf --long 0
2 T ns
% c e
LI ble li
OSB-CATALOG-MF:
E
A M window:
Write
e r a 7 days
rie Keep n f
svolume set: 14 days
c h a t r a
a n - Appendable:
Z no Volume ID used:
yes
unique to this media family
Comment: OSB catalog backup media family
UUID: c873c726-c134-1030-bc35-002564b9985a
RMAN-DEFAULT:
Keep volume set: content manages reuse
Appendable: yes
Volume ID used: unique to this media family
Comment: Default RMAN backup media family
UUID: c79ec486-c134-1030-bc35-002564b9985a
ob>
c. View your currently configured devices with the lsdev command.
ob> lsdev
library vlib in service
drive 1 vdte1 in service
drive 2 vdte2 in service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 9
drive 3 vdte3 in service
drive 4 vdte4 in service
library vlib2 in service
drive 1 vdrive1 in service
drive 2 vdrive2 in service
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

ob>
d. List the volumes inserted into the vlib2 library with the lsvol command.
ob> lsvol -L vlib2
Inventory of library vlib2:
in 1: unlabeled, barcode
37f7a2f6c136103a016002564b9985a
in 2: unlabeled, barcode
3806a3a0c136103a016002564b9985a
s a
in 3: unlabeled,
38155878c136103a016002564b9985a )h a barcode
m
co eฺ
in 4: unlabeled,
barcode
o ฺ
o uid
38240eccc136103a016002564b9985a
barcode y a h
in 5: unlabeled,
@ n t G
383295f0c136103a016002564b9985a k
ac tude
f r z
A ( this S
in 6: unlabeled,
barcode
L
38413948c136103a016002564b9985a
in 7:
O UA use barcode
unlabeled,
H e to
3850299ec136103a016002564b9985a
C
in
2
8: T
0 ens unlabeled,
barcode
%
LI ble li c
385ed034c136103a016002564b9985a
E
M era
in 9: unlabeled,
barcode
A
ie nsf
386d898ac136103a016002564b9985a
a r
h -tra in 10: unlabeled,
barcode
a c
Z non 387c6d2ec136103a016002564b9985a
in 11: unlabeled,
barcode
388b1892c136103a016002564b9985a
in 12: unlabeled, barcode
3899e70ac136103a016002564b9985a
in 13: unlabeled, barcode
38a8d454c136103a016002564b9985a
in 14: unlabeled, barcode
38b7cf04c136103a016002564b9985a
ob>
e. Exit the obtool utility.
ob> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 10
3. In the web tool, optionally explore the elements that you created and then configure a
database backup storage selector. (Step 5 following is mandatory.)
Note: You could have created this object also with the obtool utility. The practice does it
in the graphic tool for learning purposes. The equivalent is true for the objects that you
created in the previous step with obtool scripts: you could have created them also in the
web tool.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

a. Log into the web tool. The URL is: https://<hostname>.


b. The first time you log in to the web tool you need to confirm the security exception.
(Firefox: I Understand the Risks > Add Exception > Confirm Security Exception)
c. Enter admin as User Name and oracle_4U as Password, then click Login.

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
On r ie OSBnhome
your s f page, you can see jobs and their status from within the last 24 hours.
c a
hThe lower a of the page displays existing devices.
trpart
a n -
Z d.noClick Preferences and select the "Extended command output" to be On.

e. Click Apply, and then click Home.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 11
f. Scroll to the bottom of the page.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

You see a new area which displays recent obtool commands and their status.
s a
4. a
Optionally, review the elements that were created for you. Click Configure and then click
)h
on any element that interests you.
m
co eฺ
o
o uidฺ
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 page,enreviews
a. On the Configure:
L % Hosts c
i reviewing
I youlefinished
l the roles that you chose during the software

M E ab
installation. When hosts, click Configure (either the tabbed page

i e A fer
or the breadcrumb) to return to the Configure overview page.
ar tran s
c h
Za non-

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 12
b. On the Configure: Devices page, review your library and tape drives that were created
with obtool scripts. Optionally, select a device and ping it. Then return to the
Configure overview page.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o
o uidฺ
y a h
@ n t G
k
c ude media family that
aRMAN-DEFAULT
c. On the Configure: Media Families page, review
( f r z
the
S t
L A this
was created during the software installation. Return to the Configure overview page.

O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
d.arOn n s f Users page, select the oracle user and click Edit.
ie the Configure:
a c h -tra
Z non

You see the page where the oracle OS user is mapped to the oracle OSB user.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 13
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

e. Click Preauthorized Access.

s a
)h a
m
co eฺ
o
o uidฺ
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c n trathe oracle user is preauthorized for both command line (cmdline) and
hYou see-that
Z no rman operations.
f. When you finished reviewing the oracle OSB user, click Configure in the top-left.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 14
5. Navigate to Configure > Database Backup Storage Selectors, click Add and configure a
database backup storage selector as shown in the screenshot.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
c hNote: You
- a click the host name for the Apply to work.
trmuch
a n
Z a.noClick Apply. (You should see a success message.)
b. Scroll to the bottom of the page and review the obtool command.

c. Return to the OSB Home page, but do not exit the web tool.
6. Switch to a terminal window. Log in to the RMAN client in the SYSBACKUP role and
configure a channel for backing up to tape. Either enter the command on one line or use
run { ...} to configure your channel.
$ rman target "'/ as sysbackup'"

RMAN> CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS


'ENV=(OB_DEVICE=vdrive1)';
2>
using target database control file instead of recovery catalog
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 15
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS
'ENV=(OB_DEVICE=vdrive1)';
new RMAN configuration parameters are successfully stored
RMAN>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

7. Optionally, review all parameters and note the ones about SBT_TAPE that were created as
part of your channel configuration.
RMAN> show all;
RMAN configuration parameters for database with db_unique_name
ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
s a
CONFIGURE CONTROLFILE AUTOBACKUP ON;
)h a
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
m
co eฺ
'%F'; # default
o ฺ
o uid
y a h
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE
TO '%F'; # default
@ n t G
k
ac tude
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO
f r z
A ( this S
BACKUPSET; # default
L
CONFIGURE DEVICE TYPE SBT_TAPE PARALLELISM 1 BACKUP TYPE TO
BACKUPSET; # default
O UA use
H e to
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
C
default
2 T
0 ens
I le lic
%
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1;
L
ME erab
# default
A
a r ie nsf
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #

a c h -tra
default

Z non CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO


1; # default
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS
'ENV=(OB_DEVICE=vdrive1)';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT'
OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/u01/app/oracle/product/12.1.0/dbhome_1/dbs/snapcf_orcl.f'; #
default
RMAN>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 16
8. In RMAN, perform a backup to the device type tape of the USERS tablespace.
RMAN> backup device type SBT_TAPE tablespace users;
Starting backup at 2013-06-27:09:40:01
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=276 device type=SBT_TAPE
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

channel ORA_SBT_TAPE_1: Oracle Secure Backup


channel ORA_SBT_TAPE_1: starting full datafile backup set
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
input datafile file number=00006
name=+DATA/ORCL/DATAFILE/users.268.818592007
channel ORA_SBT_TAPE_1: starting piece 1 at 2013-06-27:09:40:02
channel ORA_SBT_TAPE_1: finished piece 1 at 2013-06-27:09:40:27
piece handle=27od7pbi_1_1 tag=TAG20130627T094001 comment=API
Version 2.0,MMS Version 10.4.0.2 s a
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: )h a
00:00:25 m
co eฺ
o ฺ
o uid
Finished backup at 2013-06-27:09:40:27
y a h
@ n t G
Starting Control File and SPFILE Autobackup k
ac tude
at 2013-06-
f r z
is S
A ( thcomment=API
27:09:40:27

2.0,MMS Version 10.4.0.2 UA


L
piece handle=c-1346372794-20130627-00
e
Version

O to usAutobackup at 2013-06-
Finished Control FileHand SPFILE
0 T C se
27:09:41:02
I % 2 icen
RMAN>
E L ble l
9. Review yourM a in RMAN, then exit.
tape backups
A f e r
a ie list
rRMAN> n s backup device type SBT_TAPE;
h r a
Zac noListn-t of Backup Sets
===================

BS Key Type LV Size Device Type Elapsed Time Completion


Time
------- ---- -- ---------- ----------- ------------ ------------
-
64 Full 1.63M SBT_TAPE 00:00:24 2013-06-
27:09:40:26
BP Key: 64 Status: AVAILABLE Compressed: NO Tag:
TAG20130627T094001
Handle: 27od7pbi_1_1 Media: RMAN-DEFAULT-000001
List of Datafiles in backup set 64
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 17
6 Full 2521406 2013-06-27:09:40:02
+DATA/ORCL/DATAFILE/users.268.818592007

BS Key Type LV Size Device Type Elapsed Time Completion


Time
------- ---- -- ---------- ----------- ------------ ------------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

-
65 Full 9.81M SBT_TAPE 00:00:25 2013-06-
27:09:40:52
BP Key: 65 Status: AVAILABLE Compressed: NO Tag:
TAG20130627T094027
Handle: c-1346372794-20130627-00 Media: RMAN-DEFAULT-
000001
SPFILE Included: Modification time: 2013-06-26:23:02:22
SPFILE db_unique_name: ORCL
s a
Control File Included: Ckp SCN: 2521419 Ckp time: 2013-
)h a
06-27:09:40:27 m
co eฺ
o
o uid ฺ
RMAN>
y a h
RMAN> exit @ n t G
k
ac tude
$
f r z
( are stored Son volume 000001; the first
Note: The device type is SBT_TAPE, the backups
L A h i s
tand the control file.
backup contains the data file, the secondA
the SPFILEe
U s
u then click Show completed jobs.
O page,toand
10. Return to the web tool and refresh
C Hthe
2 0T ense
L I% le lic
A ME erab
ie view
11. Optionally,
r n s f jobs in the obtool with the lsj command.
the
c a
h $ obtooltra
a n -
Z noob> lsj -A
Job ID Sched time Contents
State
---------------- ----------- ------------------------------
oracle/1 none database orcl (dbid=1346372794)
completed successfully at 2013/06/27.09:40
oracle/1.1 none datafile backup
completed successfully at 2013/06/27.09:40
oracle/2 none database orcl (dbid=1346372794)
completed successfully at 2013/06/27.09:40
oracle/2.1 none controlfile autobackup
completed successfully at 2013/06/27.09:40
ob>
The output should show the successful completion for a datafile backup and
controlfile autobackup.
12. Exit all windows and tools.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 13: RMAN and Oracle Secure Backup


Chapter 13 - Page 18
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @Lesson n t G14:
k
ac tude
Using f r z
Flashback
A ( this S
Technologies
L
O UA use
C H e Chapter
to 14
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 1
Practices for Lesson 14: Overview
Practices Overview
In these practices, you will configure your database for use of flashback technologies. You will
then use flashback technologies to restore a dropped table and reverse the actions of a
transaction.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 2
Practice 14-1: Preparing to use Flashback Technologies
Overview
In this practice you will configure the database to use the flashback transaction and flashback
table features.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
In the $LABS directory, you have two terminal windows open, pointing to the orcl instance.
You are acting as the oracle OS user.

Tasks
1. Determine how far the undo data will allow you to flash back transactions in the current
database. The V$UNDOSTAT view contains up to 4 days of statistics, over each 10 minute
s a
interval. The first row contains the current (partial) time period statistics. (Your value may be
different.) )h a
m
co eฺ
$ sqlplus / as sysdba
o
o uidฺ
a h
y where
SQL> select tuned_undoretention from v$undostat
@ n t G rownum =
1; k
ac tude
f r z
L A ( this S
UA use
TUNED_UNDORETENTION
------------------- O
H e to
1637C
2 T
0 ens
SQL>
L %
I thelvalue
e l ic
Question: What
M E ab
does of TUNED_UNDORETENTION time represent?
Answer:
r i e s f er of seconds the data is being retained in the database at any given
AThe number
n is not guaranteed by default. If the system needs more space, the
a Undotraretention
htime.
a c -
Oraclendatabase can overwrite unexpired undo with more recently generated undo data
Z2. Setnothe UNDO_RETENTION parameter and RETENTION GUARANTEE clause on the undo
tablespace to guarantee retention for 24 hours. Change the properties of the tablespace so
you will not run out of space in the tablespace.
a. Change the UNDO_RETENTION parameter to 14400 seconds (4 hours).
Note: Increasing the value of UNDO_RETENTION to more than a few days can cause
unreasonable growth of the undo tablespace.
SQL> ALTER SYSTEM SET UNDO_RETENTION = 14400 SCOPE=BOTH;
System altered.
SQL>
b. Find the name of the undo tablespace.
SQL> SHOW PARAMETER UNDO

NAME TYPE VALUE


----------------------------------- ----------- -------------
temp_undo_enabled boolean FALSE
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 3
undo_management string AUTO
undo_retention integer 14400
undo_tablespace string UNDOTBS1
SQL>
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

c. Change the RETENTION GUARANTEE value of the undo tablespace.


SQL> ALTER TABLESPACE UNDOTBS1 RETENTION GUARANTEE;
Tablespace altered.
SQL>
d. Find the names of the data files associated with the UNDOTBS1 tablespace. Note your
own FILE_ID value_____________.
SQL> select file_name, file_id from dba_data_files where
tablespace_name = 'UNDOTBS1';
s a
)h a
FILE_NAME m
co eฺ
---------------------------------------------------------------- o ฺ
o uid
y a h
-
@ n t G
FILE_ID k
ac tude
----------
f r z
L A ( this S
+DATA/ORCL/DATAFILE/undotbs1.267.818592009
4
O UA use
SQL>
C H e to
T
0 endata
e. Configure the undo2tablespace s file to automatically extend if more space is
%
LI unexpired
needed to keep c
liundo and active undo records. Use your own FILE_ID
value. ME l e
A f e r ab
a ie ALTER
rSQL> n s DATABASE DATAFILE 4 AUTOEXTEND ON MAXSIZE UNLIMITED;
h r a
n-t
Zac noSQL>
Database altered.

Question: What happens if undo retention is guaranteed and no more space is available
for active undo records (either because the undo tablespace has filled, reached the
maximum size, or there is no more space left on the storage device (disk))?
Answer: Transactions fail due to lack of space in the undo tablespace.
3. View the value of the RECYCLEBIN parameter, then exit SQL*Plus.
Note: ON is the default value.
SQL> show parameter recyclebin
NAME TYPE VALUE
------------------------------------ ----------- ------------
recyclebin string on
SQL> exit

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 4
4. Optionally, view your modified settings in EM Express.
a. Logged in as the SYS user with the oracle_4U password and SYSDBA privileges,
navigate from the orcl database home page: Configuration > Initialization
Parameters.
b. On the Current tabbed page enter UNDO.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
Note: You see the same values as in step 2b. If you wanted to change an ฺinitialization
h
parameter, you can select the parameter, click Set and enter the desired o
o values.
i d- At this
point, you do not want to change any values, so cancel out of it. y a G u
k @ n t
f r z ac tude
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

c. When you enter recyclebin, you see the same value as shown in step 3.
d. To view the current values of the UNDOTBS1 tablespace, navigate: Storage >
Tablespaces.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 5
Note: You see that the tablespace is unlimited, as configured in step 2e. Your numeric
values may be different.
e. Return to the Database Home page by clicking ORCL (12.1.0.1..0).
5. Optionally, view your modified settings in Cloud Control.
a. Logged in as the SYSMAN user with the oracle_4U, navigate from the orcl database
home page: Administration > Initialization Parameters > Current (tabbed page).
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Enter UNDO as Name and click Go. - You see the same values as in step 2b and 4b.
b. When you enter recyclebin and click Go, you see the same value as shown in step
3 and 4c.
c. Navigate to Administration > Storage > Automatic Undo Management and explore
the General and System Activity pages including their graphs.

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 6
d. Find the graph (on the System Activity page)that shows the Maximum Possible Query
or Flashback Duration.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
H e to
e. Return to the orcl home page.
C
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 7
Practice 14-2: Restoring a Dropped Table
Overview
In this practice you will recover a table that has been dropped.

Assumptions
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

The RECYCLEBIN parameter is set to ON (which you confirmed in the previous practice).
In the $LABS directory, you have two terminal windows open, pointing to the orcl instance.
You are acting as the oracle OS user.

Tasks
1. Execute the setup_14_02.sh script to create the practice environment. The output is in
the /tmp/setup.log file.
$ ./setup_14_02.sh
s a
$
)h a
2. Execute the break_14_02.sh script to simulate work done by a developer. m
coThe output is
in the /tmp/break.log file. o ฺ
o uide ฺ
y a h
$ ./break_14_02.sh
@ n t G
$ k
ac tude
3. A developer (with the BAR Oracle user account) ( f r z
comes tosyou S and asks you to restore a
L A
table that was dropped. He explains thereAwere several h i
t iterations of this table but the one
he needs was named BAR102 in the O U
BAR u
schema. s e
It should have 12 columns, one of which
was named LOCATION_ID. There H
C se is t o
currently a BAR102 table in the BAR schema.
0 T
I % l c en
2 toiBAR102A.
Restore the requested table
a. Attempt to use
bin. M
EL theaSHOW
b le RECYCLEBIN command to view the contents of the recycle
A fer
r$iesqlplusn s / as sysdba
h a r a
Zac noSQL> n -t show recyclebin
SQL>
Note: There is no output. The SHOW RECYCLEBIN command shows only those objects that
belong to the current user. Because you are the DBA and do not know the password for
the BAR user, the SHOW RECYCLEBIN command does not show the dropped tables you are
interested in restoring.
b. Examine the objects in the dba_recyclebin. Optionally, change the SQL*Plus page
size to 99 lines.
SQL> set pages 99
SQL> select original_name, object_name, droptime
from dba_recyclebin
where owner ='BAR';
2 3
ORIGINAL_NAME
----------------------------------------------------------------
-
OBJECT_NAME
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 8
----------------------------------------------------------------
-
DROPTIME
-------------------
BAR102
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

BIN$4Dj16SAXGvrgQ4sjuYtecg==$0
2013-06-28:14:47:40

BAR102
BIN$4Dj16SASGvrgQ4sjuYtecg==$0
2013-06-28:14:47:40

BAR101
s a
BIN$4Dj16SAcGvrgQ4sjuYtecg==$0
2013-06-28:14:47:40 )h a
m
co eฺ
SQL>
o ฺ
oin time.uiWith
a h
Note: Above you see the same object dropped twice at different points d the
y t G
@want etonrestore.
timestamp, you determine which version of the table you really
c k Yourdobject names will be
frza s Stu
c. Determine which object contains the column of interest.
different. Use your own values. ( i quotes because it may
A be inthdouble
A
Note: The object name from the recycle binLmust e
contain special characters.
H OU to us
SQL> select location_id
0 T C se
% 2 icen
from BAR."BIN$4Dj16SASGvrgQ4sjuYtecg==$0"
I
E
where rownum L = b1;le l
2 AM3 selecte ra location_id
i e s f
c h ar tran*
Za noERRORn- at line 1:
ORA-00904: "LOCATION_ID": invalid identifier

SQL> select location_id


from BAR."BIN$4Dj16SAXGvrgQ4sjuYtecg==$0"
where rownum = 1;
2 3
LOCATION_ID
-----------

SQL>
d. Restore the object that has the correct columns.
SQL> FLASHBACK TABLE BAR."BIN$4Dj16SAXGvrgQ4sjuYtecg==$0" TO
BEFORE DROP RENAME TO BAR102A;

Flashback complete.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 9
SQL>
4. Confirm that the BAR.BAR102A table has been restored by selecting the first row. (It does
not matter which row appears, just that there is one row.) Then exit.
SQL> select * from BAR.BAR102A where rownum = 1;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

EMPLOYEE_ID FIRST_NAME LAST_NAME


----------- -------------------- -------------------------
EMAIL PHONE_NUMBER HIRE_DATE JOB_ID
------------------------- -------------------- -----------------
-
SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID LOCATION_ID
---------- -------------- ---------- ------------- -----------
100 Steven King
s a
SKING
AD_PRES
515.123.4567 2003-06-17:00:00:00
)h a
m
co eฺ
24001 90
o ฺ
o uid
y a h
SQL> exit @ n t G
k
ac tude
$
( f r z S
5. Clean up this practice environment by using the
L t h i s
A cleanup_14_02.sh script.
U A se command to remove all objects from
Note: This script uses the PURGE DBA_RECYCLEBIN
the recycle bin. The output is in the O t o u
H /tmp/cleanup.log file.
T
0 ensC e
2
$ ./cleanup_14_02.sh
I le lic
%
$ L
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 10
Practice 14-3: Using Flashback Table
Overview
In this practice you will use flashback table to reverse a rogue transaction.

Assumptions
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Practice 14-1 has been completed.


In the $LABS directory, you have two terminal windows open, pointing to the orcl instance.
You are acting as the oracle OS user.

Tasks
1. Execute the setup_14_03.sh script to create the user and tables used in this practice.
The tables have a foreign-key relationship. The output is in the /tmp/setup.log file.
$ ./setup_14_03.sh
s a
$
) h a
2. Determine the current time to the nearest second. Record this as T1 m
co eฺ
____________________ o
o uidฺ
a h
y been
Note: The format of SYSDATE is not the default format. The format
@
has
n t G"Setting
altered by the
NLS_DATE_FORMAT environment variable that was set in the
a c k de
Practice titled the
Date and Time Format for RMAN."
( f rz Stu
$ sqlplus / as sysdba
A LA e this
H OU t o us
SQL> select sysdate from
0 T C se dual;
2 icen
SYSDATE LI% l
E
M erab l e
A
-------------------
ie nsf
a r2013-06-28:15:00:21
a c h SQL>
n - tra
Z3. Innanother
o terminal window, execute the break_14_03.sh script. This simulates a rogue
transaction that scrambles the data in the BARCOPY and BARDEPT tables. There is a foreign
key constraint between BARCOPY and BARDEPT. The output is in the /tmp/break.log
file.
$ ./break_14_03.sh
$
4. The HR representative reports that an employee has incorrectly changed the names of the
departments, and scrambled which employees are assigned to which departments. The
tables were correct at time T1 and no authorized changes have been made since that time.
The tables involved are BAR.BARCOPY and BAR.DEPT. Restore the tables to the state
they were at T1. You must use your own T1 values.
Because there is a foreign key relationship, both tables must be restored. (Continue in your
SQL*Plus session.)
SQL> ALTER TABLE BAR.BARDEPT ENABLE ROW MOVEMENT;
Table altered.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 11
SQL> ALTER TABLE BAR.BARCOPY ENABLE ROW MOVEMENT;
Table altered.

SQL> FLASHBACK TABLE BAR.BARDEPT TO TIMESTAMP


TO_TIMESTAMP('2013-06-28:15:00:21','YYYY-MM-DD:HH24:MI:SS');
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Flashback complete.

SQL> FLASHBACK TABLE BAR.BARCOPY TO TIMESTAMP


TO_TIMESTAMP('2013-06-28:15:00:21','YYYY-MM-DD:HH24:MI:SS');

Flashback complete.

SQL> s a
)h a
5. Check that you have correctly restored the tables. The results of following query should
match yours, although the row order may be different. Then exit SQL*Plus. co m
SQL> @check_14_03.sql h o oฺ ideฺ
y a G u
k@ deCOUNT(*)n t
a c
frz s Stu----------
DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------(
100 Finance A LA e thi 24
50 Shipping O
U u s
C H t o 180

2 0 T Relations
70 Public
e n se 4

L %Executive
I90 e l ic 12

M E ab 30 l
Purchasing 24

i e A fe10r Administration 4
r s
a c ha -tran 110 Accounting 8
Z non 40 Human Resources 4
20 Marketing 8
60 IT 20
80 Sales 136

11 rows selected.

SQL> exit

6. Clean up the practice environment by running the cleanup_14_03.sh script.


$ ./cleanup_14_03.sh
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 12
7. In preparation for the next practice, backup your orcl database, remove obsolete backups,
and ensure that no failures are listed. (The output is removed to not clutter this activity
guide.) Then exit from RMAN.
$ rman target "'/ as sysbackup'"
RMAN> BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

RMAN> delete noprompt obsolete;


RMAN> list failure;
RMAN> exit
$

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 13
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 14: Using Flashback Technologies


Chapter 14 - Page 14
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lesson n t G15:
k
ac Database de
Flashback
( f r z S t u
L A h i s
U AChapterse15 t
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Flashback Database


Chapter 15 - Page 1
Practices for Lesson 15: Overview
Practices Overview
In these practices, you will enable flashback logging and perform flashback database.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Flashback Database


Chapter 15 - Page 2
Practice 15-1: Enabling Flashback Logging
Overview
In this practice you will enable flashback logging.

Assumptions
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

In the $LABS directory, you have two terminal windows open, pointing to the orcl instance.
You are acting as the oracle OS user.

Tasks
1. Log in to SQL*Plus and determine whether flashback logging is enabled.
$ sqlplus / as sysdba
SQL> SELECT flashback_on FROM v$database;

s a
FLASHBACK_ON
)h a
------------------ m
co eฺ
NO o ฺ
o uid
y a h
SQL>
@ n t G
2. Create a guaranteed restore point and check your current k de status.
acFLASHBACK_ON
f r z
( usage.
Note that guaranteed restore points affect your space S t u
L A h i s
t FLASHBACK DATABASE;
SQL> CREATE RESTORE POINT rp1
U A GUARANTEE
s e
Restore point created. O
C H e to u
2 0T ensFROM V$DATABASE;
SQL> SELECT %
L I le lic
FLASHBACK_ON

A ME erab
a r ie nsf
FLASHBACK_ON

a c h -tra
------------------
Z noRESTOREn POINT ONLY
SQL>
3. Enable flashback logging with one tool of your choice.
SQL> ALTER DATABASE FLASHBACK ON;
Database altered.
SQL>
Question: Which other tool could you have used to enable flashback logging for the
database?
Possible Answer: Cloud Control
Question: What are the navigational steps for your tool of choice?
Possible answer: Cloud Control: Availability > Backup & Recovery > Recovery Settings >
Availability > Backup & Recovery > Recovery Settings.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Flashback Database


Chapter 15 - Page 3
4. Verify that flashback logging has been enabled.
SQL> SELECT FLASHBACK_ON FROM V$DATABASE;

FLASHBACK_ON
------------------
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

YES
SQL>

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Flashback Database


Chapter 15 - Page 4
Practice 15-2: Performing Flashback Database
Overview
In this practice you will flash back your database after some incorrect updates to the database.
This practice is for learning purposes. If you had a scenario similar to this in a production
environment, you would probably choose a different solution, that is, to limit your flashback to
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

the affected objects, rather than choose a flashback of the entire database.

Assumptions
You have completed practice 15-1.
In the $LABS directory, you have two terminal windows open, pointing to the orcl instance.
You are acting as the oracle OS user.

Tasks
1. s
There are several ways how you can perform a flashback database operation, for example a
)h a
with a guaranteed restore point, SCN, time value, threads, and so on. This example uses
the SCN, but you could also use your just created RP1 restore point. m
co eฺ
o ฺ
o uid
Determine your current SCN. It is _______________. You will need to use it in a later
practice step. y a h
@ n t G
SQL> SELECT current_scn FROM v$database; k
ac tude
f r z
CURRENT_SCN L A ( this S
-----------
O UA use
2687945 C H e to
SQL> 2 T
0 ens
2. View HR data.E You
%
LIwill use
l e lic
this information for comparison during this practice.
A
a. Determine
M theesum
f r abof the SALARY column in the HR.EMPLOYEES table.
a ie SELECT
rSQL> n s sum(salary) FROM hr.employees;
h r a
n-t
Zac noSUM(SALARY)
-----------
691416
SQL>
b. Determine the total number of employees in department 90.
SQL> SELECT count(*) FROM hr.employees where department_id=90;
COUNT(*)
----------
3
SQL>
3. Execute the lab_15_02_03.sql script to update in the HR schema. It creates issues from
which this practice "recovers" by flashing back the database.
SQL> @lab_15_02_03.sql
SQL> update hr.employees
2 set department_id = 90

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Flashback Database


Chapter 15 - Page 5
3 where job_id = 'IT_PROG'
4 /

5 rows updated.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

SQL> update hr.employees e


2 set salary = least(e.salary,
3 (select (min_salary + max_salary)/2 * 1.10
4 from hr.jobs j
5 where j.job_id = e.job_id))
6 where job_id not like 'AD_%'
7 /

s a
103 rows updated.
)h a
SQL> m
co eฺ
4. Commit your data and determine the current SCN. o ฺ
o uid
y a h
SQL> COMMIT;
@ n t G
Commit complete. k
ac tude
f r z
A ( this S
SQL> SELECT current_scn FROM v$database;
L
CURRENT_SCN
O UA use
----------- C H e to
2688058 2 T
0 ens
L I le lic
%
MEin the
SQL>
5. Query theAdata
f e r aHRbschema again and compare the results to the values you received
ina
h riequeries
the
a ninsstep 2.
r
n-t the sum of the SALARY column in the HR.EMPLOYEES table.
Zac a.noDetermine
SQL> SELECT sum(salary) FROM hr.employees;

SUM(SALARY)
-----------
679092.4
SQL>
b. Determine the total number of employees in department 90.
SQL> SELECT count(*) FROM hr.employees where department_id=90;
COUNT(*)
----------
8
SQL>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Flashback Database


Chapter 15 - Page 6
6. You need to restore the database so that the data is as it was when you started this
practice. For training purposes, use Flashback Database for this operation.
Question: In which state must the database be for a flashback database operation?
Possible Answer: The database must be mounted.
a. Shut down the database instance and start it in MOUNT mode.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

SQL> shutdown immediate


Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

s a
Total System Global Area 534462464 a
bytes
)h
Fixed Size 2290416
mbytes
co eฺ
Variable Size 276827408
o ฺ
o uid
bytes
Database Buffers 247463936
y a h bytes
@ n t G
Redo Buffers
k
7880704
ac tude
bytes
Database mounted.
f r z
SQL> exit
L A ( this S
$
O UA use
b. Log in to RMAN and use theH to DATABASE command to flash back the
database to the SCN0 T C FLASHBACK
e
you notedninsstep 1. Exit RMAN.
2 e
I "'/le aslicsysbackup'"
%
$ rman target
E L nocatalog

A M erab
r ie flashback
RMAN>
n s f database to scn=2687945; (Enter your SCN number)
h a r a
n-t
Zac noallocated
Starting flashback at 2013-06-28:15:26:14
channel: ORA_DISK_1
channel ORA_DISK_1: SID=240 device type=DISK
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=17 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Secure Backup

starting media recovery


media recovery complete, elapsed time: 00:00:15

Finished flashback at 2013-06-28:15:26:34


RMAN> exit

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Flashback Database


Chapter 15 - Page 7
c. Verify that the database was flashed back correctly by querying the HR.EMPLOYEES
table again. The values should match the values you obtained in the queries in step 2.
$ sqlplus / as sysdba

SQL> alter database open read only;


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Database altered.

SQL> SELECT sum(salary) FROM hr.employees;


SUM(SALARY)
-----------
691416

SQL> SELECT count(*) FROM hr.employees where department_id=90;

s a
COUNT(*)
)h a
---------- m
co eฺ
3
o
o uidฺ
SQL> a h
yopen thet database
d. After you verified that you flashed back to the desired k @
state, n G for
a c d e
read/write operations.
( frz s Stu
SQL> shutdown immediate
A LA e thi
Database closed.
Database dismounted. HO
U us
T C down. e to
ORACLE instance 0
% 2 shut
c e ns
E LI mount l e li
ab started.
SQL> startup
A Minstance
e r
rie ans
ORACLE f
c h a tr System Global Area 534462464 bytes
a n -
Z noFixed Size
Total
2290416 bytes
Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
Database mounted.

SQL> alter database open resetlogs;


Database altered.

SQL>
7. Disable flashback logging.
SQL> ALTER DATABASE FLASHBACK OFF;
Database altered.

SQL>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Flashback Database


Chapter 15 - Page 8
8. Drop the RP1 guaranteed restore point. Then exit SQL*Plus.
SQL> DROP RESTORE POINT rp1;
Restore point dropped.

SQL> exit
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Flashback Database


Chapter 15 - Page 9
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 15: Flashback Database


Chapter 15 - Page 10
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lessonn t G16:
k
ac tData de
Transporting
( f r z S u
L A h i s
U AChapterse16 t
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Transporting Data


Chapter 16 - Page 1
Practices for Lesson 16: Overview
Practices Overview
In these practices, you will transport a tablespace. You will also perform the steps that it takes to
transport a tablespace from one platform to another (although in the training environment each
student has access to one host, not several).
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Transporting Data


Chapter 16 - Page 2
Practice 16-1: Transporting a Tablespace
Overview
In this practice you will transfer a tablespace with all the steps that it would take to transfer it
across different platforms (although in your training environment you are using only one host on
one platform).
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
Two terminal windows is open in the $LABS directory. ORCL is your source database, RCAT your
destination database. The practice indicates when it is necessary to switch environment
variables.

Tasks
1. Set up for this practice by executing the setup_16_01.sh script from the $LABS directory.
In this script:
s a
• A new tablespace and user are created. )h a
• The user creates a table and populates it. m
co eฺ
o ฺ
o uid
• The output is in the /tmp/setup.log file.
y a h
$ . oraenv @ n t G
k
ac tude
ORACLE_SID = [oracle] ? orcl
( f r z S
A
The Oracle base has been set to /u01/app/oracle
L h i s
$ ./setup_16_01.sh
U A se t
$
C HO e to u
2. Start a SQL*Plus session0 onTyour ORCL
ns source database and verify the prerequisites for
% 2
I le li
transporting a tablespace c
across e
platforms.
E LSYS b and Verify that the source database is in read-write mode.
a. Log in as
A M erauser
the
r$iesqlplus
n s f/ as sysdba
c a
h -tra
a
Z noSQL> n SELECT NAME, LOG_MODE, OPEN_MODE, CURRENT_SCN FROM
V$DATABASE;

NAME LOG_MODE OPEN_MODE CURRENT_SCN


--------- ------------ -------------------- -----------
ORCL ARCHIVELOG READ WRITE 2690117
SQL>
b. For performing cross-platform tablespace transport, you must know the exact name of
the destination platform to which you are transporting data.
SQL> col platform_name format a30

SQL> SELECT PLATFORM_ID, PLATFORM_NAME, ENDIAN_FORMAT


FROM V$TRANSPORTABLE_PLATFORM
WHERE UPPER(PLATFORM_NAME) LIKE '%LINUX%';

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Transporting Data


Chapter 16 - Page 3
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- ------------------------------ --------------
10 Linux IA (32-bit) Little
11 Linux IA (64-bit) Little
9 IBM zSeries Based Linux Big
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

13 Linux x86 64-bit Little


18 IBM Power Based Linux Big
SQL>
c. Make the BARTBS tablespace read-only. This is required for the export of the
tablespace meta data and then exit.
SQL> ALTER TABLESPACE bartbs READ ONLY;
Tablespace altered.

s a
SQL> exit
)h a
$ m
co instance.
3. Start an RMAN session and connect to your ORCL source database asothe o ฺtarget eฺ
a h u i d
$ . oraenv y t G
ORACLE_SID = [orcl] ?
a c k@ den
The Oracle base remains unchanged(fwith rz value S tu/u01/app/oracle
$ rman target "'/ as sysbackup'"
A LA e this
RMAN>
H OU to us
4. Back up the source tablespace
0 T Cusing stheeBACKUP command with TO PLATFORM clause.
Use the DATAPUMP clause
I % l i c en that an export dump file for the tablespaces must be
2 to indicate
created for theE L blemetadata.
tablespace
M
A BACKUP e raTO PLATFORM 'Linux x86 64-bit' FORMAT
RMAN>
i e s f
c h ar'/u01/backup/test.bck'
t r a n bartbs; DATAPUMP FORMAT '/u01/backup/test.dmp'

Za non-
TABLESPACE

Starting backup at 2013-06-28:15:58:05


using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK
Running TRANSPORT_SET_CHECK on specified tablespaces
TRANSPORT_SET_CHECK completed successfully

Performing export of metadata for specified tablespaces...


EXPDP> Starting "SYSBACKUP"."TRANSPORT_EXP_ORCL_FbAv":
EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
EXPDP> Processing object type
TRANSPORTABLE_EXPORT/TABLE_STATISTICS
EXPDP> Processing object type
TRANSPORTABLE_EXPORT/STATISTICS/MARKER
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Transporting Data


Chapter 16 - Page 4
EXPDP> Processing object type
TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
EXPDP> Master table "SYSBACKUP"."TRANSPORT_EXP_ORCL_FbAv"
successfully loaded/unloaded
EXPDP>
****************************************************************
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

***
EXPDP> Dump file set for SYSBACKUP.TRANSPORT_EXP_ORCL_FbAv
is:
EXPDP>
/u01/app/oracle/product/12.1.0/dbhome_1/dbs/backup_tts_ORCL_3865
3.dmp
EXPDP>
****************************************************************
***
s a
EXPDP> Datafiles required for transportable tablespace
)h a
BARTBS: m
co eฺ
EXPDP> /u01/backup/orcl/bartbs.dbf o ฺ
o uid
y a h
EXPDP> Job "SYSBACKUP"."TRANSPORT_EXP_ORCL_FbAv" successfully
@
completed at Fri Jun 28 15:59:39 2013 elapsed 0 00:01:19
n t G
k
ac tude
Export completed
( f r z S
L A t h i s
channel ORA_DISK_1: starting
U A fullsedatafile backup set
channel ORA_DISK_1: specifyingO
H e to u
datafile(s) in backup set
C
0T number=00005
input datafile file
% 2 c e ns
LI ble li starting piece 1 at 2013-06-28:15:59:44
name=/u01/backup/orcl/bartbs.dbf
channel E ORA_DISK_1:
A M ORA_DISK_1:
e ra
r i e
channel
n s f finished piece 1 at 2013-06-28:15:59:45

a c ha piece
- t r ahandle=/u01/backup/test.bck tag=TAG20130628T155806
n
Z nochannel
comment=NONE
ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
input Data Pump dump
file=/u01/app/oracle/product/12.1.0/dbhome_1/dbs/backup_tts_ORCL
_38653.dmp
channel ORA_DISK_1: starting piece 1 at 2013-06-28:15:59:46
channel ORA_DISK_1: finished piece 1 at 2013-06-28:15:59:47
piece handle=/u01/backup/test.dmp tag=TAG20130628T155806
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2013-06-28:15:59:47

RMAN>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Transporting Data


Chapter 16 - Page 5
5. Allow read-write operations on the BARTBS tablespace. Then exit RMAN.
RMAN> alter tablespace bartbs READ WRITE;
Statement processed

RMAN> exit
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

$
Note: Normally, after you disconnected from the source database, you move the backup
sets and the Data Pump export dump file to the destination host with operating system
utilities. In this training example, you do not need to do it because you have one host
available.
6. As the SYS user, connect to the RCAT destination host as the target. (You log in as SYS,
not as SYSBACKUP because you will create the BAR user in the destination database).
$ . oraenv
ORACLE_SID = [orcl] ? rcat s a
The Oracle base remains unchanged with value /u01/app/oracle )h a
$ rman target / m
co eฺ
o ฺ
o uid
y a h
connected to target database: RCAT (DBID=590740692)
@ n t G
RMAN> k
ac tude
f r z
A this Smode.
7. Ensure that the destination database is opened in( read-write
L
RMAN> SELECT NAME, LOG_MODE,
V$DATABASE; O UA OPEN_MODE,
u se CURRENT_SCN FROM

C H e to
2 T ns file instead of recovery catalog
0 econtrol
using target % database
I le li
LLOG_MODE c
NAME E b
M ------------
a OPEN_MODE CURRENT_SCN
A e r
a r ie nsfARCHIVELOG
--------- -------------------- -----------

a c h -tra
RCAT READ WRITE 2421859
Z non
RMAN>
8. Create the BAR user and grant the CREATE SESSION privilege.
RMAN> CREATE USER BAR IDENTIFIED BY oracle_4U;
Statement processed

RMAN> GRANT CREATE SESSION TO BAR;


Statement processed

RMAN>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Transporting Data


Chapter 16 - Page 6
9. Use the RESTORE command with the FOREIGN TABLESPACE clause. The FORMAT clause
specifies the file destination. Use the DUMP FILE FROM BACKUPSET clause to restore the
metadata from the dump file which is required to plug the tablespace into the destination
database.
RMAN> RESTORE FOREIGN TABLESPACE bartbs FORMAT
'/u01/backup/rcat/bartbs.dbf' FROM BACKUPSET
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

'/u01/backup/test.bck' DUMP FILE FROM BACKUPSET


'/u01/backup/test.dmp';

Starting restore at 2013-06-28:16:09:04


allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=39 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore


channel ORA_DISK_1: specifying datafile(s) to restore from s a
backup set )h a
m
co eฺ
channel ORA_DISK_1: restoring all files in foreign tablespace
BARTBS o ฺ
o uid
y a h
channel ORA_DISK_1: reading from backup piece
@ n t G
/u01/backup/test.bck k
ac tude
f r z
channel ORA_DISK_1: restoring foreign file 5 to
A ( this S
/u01/backup/rcat/bartbs.dbf
L
UA use
channel ORA_DISK_1: foreign piece handle=/u01/backup/test.bck
O
H e to
channel ORA_DISK_1: restored backup piece 1
C
T
0 ens
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
2
L I le lic
%
channel ORA_DISK_1: starting datafile backup set restore
ME erab
channel ORA_DISK_1: specifying datafile(s) to restore from
A
a r ie nsf
backup set

a c h -trachannel ORA_DISK_1: restoring Data Pump dump file to


Z non /u01/app/oracle/product/12.1.0/dbhome_1/dbs/backup_tts_RCAT_4323
4.dmp
channel ORA_DISK_1: reading from backup piece
/u01/backup/test.dmp
channel ORA_DISK_1: foreign piece handle=/u01/backup/test.dmp
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02

Performing import of metadata...


IMPDP> Master table "SYS"."TSPITR_IMP_RCAT_xpim" successfully
loaded/unloaded
IMPDP> Starting "SYS"."TSPITR_IMP_RCAT_xpim":
IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
IMPDP> Processing object type
TRANSPORTABLE_EXPORT/TABLE_STATISTICS

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Transporting Data


Chapter 16 - Page 7
IMPDP> Processing object type
TRANSPORTABLE_EXPORT/STATISTICS/MARKER
IMPDP> Processing object type
TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
IMPDP> Job "SYS"."TSPITR_IMP_RCAT_xpim" successfully
completed at Fri Jun 28 16:09:19 2013 elapsed 0 00:00:07
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Import completed

Finished restore at 2013-06-28:16:09:21


RMAN>
10. Confirm that the tablespace exists in your destination database. Then exit
RMAN> select tablespace_name, status from dba_tablespaces;

TABLESPACE_NAME a
STATUS
s
------------------------------ )h a
---------
SYSTEM m
co eฺONLINE
SYSAUX o ฺ
o uid ONLINE
y a h
UNDOTBS1
@ n t G ONLINE
TEMP k
ac tude ONLINE
f r z
USERS
EXAMPLE L A ( this S ONLINE
ONLINE
RCATBS O UA use ONLINE
C H e to
BARTBS
2 T
0 ens READ ONLY

L I le lic
%
ME erab
8 rows selected
A
r ie exit
n s f
c a
h -tra
RMAN>
a
Z no$n
11. Clean up the practice environment by executing the cleanup_16_01.sh script. This script
removes the original and the transported tablespace, as well as the backup and dump files.
The output is in the /tmp/cleanup.log file.
$ ./cleanup_16_01.sh
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 16: Transporting Data


Chapter 16 - Page 8
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @Lesson n t G17:
k de
ac Point-in-Time
Performing
f r z t u
A ( this S
Recovery
L
O UA use
C H e Chapter
to 17
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 1
Practices for Lesson 17: Overview
Practices Overview
In these practices, you will recover a table from a backup set (without affecting other objects in
the tablespace or schema.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 2
Practice 17-1: Recovering a Table from a Backup
Overview
In this practice you will recover a table from a backup set (without affecting other objects in the
tablespace or schema). The tasks include:
• Setup your test environment and confirm the configuration which typically is a one-time
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

task.
• In RMAN, perform a level 0 backup plus archive logs and delete obsolete backups.
• In SQL*Plus, create and populate a new TEST_TABLE. Note the SCN after commit.
• In RMAN, perform backup level 1.
• In SQL*Plus, create the need to recover a table by purging TEST_TABLE.
• In RMAN, recover your test table to the SCN.
• In SQL*Plus, confirm the success of the recovery.
s a
• Cleanup your practice environment.
)h a
m
co eฺ
o ฺ
o uid
Assumptions
a h
y database
Two terminal windows is open in the $LABS directory pointing to @ the orcl n t G instance.
You start as the oracle OS user.
k
ac tude
f r z
Tasks L A ( this S
A se
Usetup_17_01.sh
1. Set up for this practice by executingO
H the
t o u script from the $LABS directory.
In this script:
0 T C se
• A new tablespace and
I % 2 icare
user
l encreated.
• EL aa btable
The user creates
M le and populates it.

r
The A
i e output is in
s f erthe /tmp/setup.log file.
c - t an
ha $ ./setup_17_01.sh
r
a
Z no$n
2. Start a SQL*Plus session and verify your test configuration.
a. Log in as the SYS user.
$ sqlplus / as sysdba
SQL>
b. Confirm that the database is in archive log mode.
SQL> SELECT NAME, LOG_MODE, OPEN_MODE FROM V$DATABASE;
NAME LOG_MODE OPEN_MODE
--------- ------------ --------------------
ORCL ARCHIVELOG READ WRITE
SQL>
c. Confirm that compatibility is set to 12.0 or higher.
SQL> show parameters compatible
NAME TYPE VALUE
-------------------------------- ----------- ------------------
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 3
compatible string 12.1.0.0.0
noncdb_compatible boolean FALSE
SQL>
d. Confirm your backup location and size.
SQL> show parameters recovery_f
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

NAME TYPE VALUE


------------------------------- ----------- ------------------
db_recovery_file_dest string +FRA
db_recovery_file_dest_size big integer 4800M
SQL>
e. Confirm that the setup by executing the lab_17_02.sql script from the $LABS
directory. The BAR user should own the BARCOPY table.
SQL> @lab_17_02.sql
s a
SQL> COL TABLE_NAME FORMAT A30
)h a
SQL> COL TABLESPACE_NAME FORMAT A15 m
co eฺ
o ฺ
o uid
SQL> COL OWNER FORMAT A10
y a h
SQL>
@ n t G
SQL> SELECT TABLE_NAME, TABLESPACE_NAME, k
ac tude
STATUS
f r z
A ( this S
2 FROM DBA_TABLES
L
UA use
3 WHERE OWNER = 'BAR';
O
H e to TABLESPACE_NAME STATUS
TABLE_NAME
T C
0 ens
% 2
------------------------------
I i c --------------- --------
BARCOPY E L le l BARTBS VALID
SQL>AM a b
r i e s f er
3. h
c Ina an window, start an RMAN session and connect to your ORCL database as
anotherrterminal
- t
a
Z nonthe target instance.
Note: The easiest way to send RMAN output both to a log file and to standard output is to
use the Linux tee command or its equivalent. There is no need to do this, if your standard
ouput allows you to scroll as much as you wish.
The output of the BACKUP command is removed to not clutter this activity guide. You can
view the output in the /home/oracle/rman_17.log file.
$ rman target "'/ as sysbackup'"| tee /home/oracle/rman_17.log
RMAN>
4. Confirm or configure autobackup of control file and perform a level 0 backup. (The output of
the BACKUP command is removed to not clutter this activity guide.)
RMAN> show CONTROLFILE AUTOBACKUP;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name
ORCL are:
CONFIGURE CONTROLFILE AUTOBACKUP ON;

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 4
RMAN> backup incremental level 0 database plus archivelog;
RMAN>
5. In SQL*Plus, create and populate a new BAR.TEST_TABLE. Note the SCN after commit.
SQL> @lab_17_05.sql
SQL> -- DISCLAIMER:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

SQL> -- This script is provided for educational purposes only.


It is
SQL> -- NOT supported by Oracle World Wide Technical Support.
SQL> -- The script has been tested and appears to work as
intended.
SQL> -- You should always run new scripts on a test instance
initially
SQL> -- Create an additional test table
s a
SQL> -- First drop it, so that this script can be executed
repeatedly. )h a
m
co eฺ
SQL>
o ฺ
o uid
SQL> set echo on
y a h
SQL> DROP TABLE BAR.test_table;
@ n t G
DROP TABLE BAR.test_table k
ac tude
f r z
A ( this S
*
L
UA use
ERROR at line 1:
O
ORA-00942: table or view does not exist
H e to
T C
% 2 c e ns
0 BAR.test_table
I le li
SQL> CREATE TABLE
Lnumber(8),
2 (NUM E ab
M varchar2(25),
3 ANAME
f e r
h a rie4 NOW a n s date
t r
Zac non5- )
6 /
Table created.

SQL> INSERT INTO BAR.test_table VALUES (1,'First test


row',sysdate);
1 row created.

SQL> INSERT INTO BAR.test_table VALUES (2,'Second test


row',sysdate);
1 row created.

SQL> INSERT INTO BAR.test_table VALUES (3,'Third test


row',NULL);
1 row created.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 5
SQL> commit;
Commit complete.

SQL> ALTER SYSTEM SWITCH logfile;


System altered.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

SQL> ALTER SYSTEM checkpoint;


System altered.

SQL>
SQL> -- **** Note the SCN!
SQL> SELECT NAME, CURRENT_SCN FROM V$DATABASE;

s a
NAME CURRENT_SCN
)h a
--------- ----------- m
co eฺ
ORCL 2695890
o
o uidฺ
SQL>
y a h
@ n t G
Note your own SCN. You will use it for recovery! ________ k
c your
astarted deRMAN session with
6. In your RMAN session, perform a backup level 1. Ifryou
f z t u
the tee command, then your output is redirected
L is S
A (to theth/home/oracle/rman_17.log
file. (The output of the BACKUP commandA e to not clutter this activity guide.)
O U is removed
u s
RMAN> backup incremental
C H level
e to 1 database plus archivelog;
RMAN>
2 T
0 ens
7. In SQL*Plus, create L %
I the need
e l
toicrecover a table by purging it. Optionally, view your SCN
before and M Ethe DROP
after l
ab TABLE command.
A f e r
a ie SELECT
rSQL> n s NAME, CURRENT_SCN FROM V$DATABASE;
h r a
n-t
Zac no---------
NAME CURRENT_SCN
-----------
ORCL 2696503

SQL> drop table BAR.test_table purge;


Table dropped.
SQL> SELECT NAME, CURRENT_SCN FROM V$DATABASE;
NAME CURRENT_SCN
--------- -----------
ORCL 2696537
SQL>
Note: Assume that you do not have this table duplicated or in flashback logs or anywhere
else, so there is a need to recover it from your backups.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 6
8. Optionally, view the current tables that the BAR user owns. The TEST_TABLE should not
be displayed.
SQL> SELECT table_name FROM dba_tables WHERE owner = 'BAR';

TABLE_NAME
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

------------------------------
BARCOPY

SQL>
9. In RMAN, recover your test table to YOUR SCN. Provide the following input with the
RECOVER command:
• Names of tables or table partitions to be recovered
• SCN (or Point in time) to which the tables or table partitions need to be recovered
s a
• Whether the recovered tables or table partitions must be imported into the target
)h a
database (default is Yes.)
m
co eฺ
• Auxiliary destination '/u01/backup/test'. o ฺ
othen execute
h
First, confirm that the directory of the auxiliary destination is emptyaand
y G uid your
RECOVER command.
c k @ ent
RMAN> HOST "ls /u01/backup/test/*";rza
( f S tud
ls: cannot access /u01/backup/test/*:
L A thNo is such file or directory
host command complete
O UA use
C H e to
RMAN-00571: ===============================================
2 T
0 ens ERROR MESSAGE STACK FOLLOWS
RMAN-00569: ===============
RMAN-00571: L %
e l ic
I ===============================================
ME ererror
RMAN-06135: l
b executing host command: Additional
a512
A f
h a rie ans
information:

a c -
Note: This
n trpositive error prior to the RECOVER command confirms that the auxiliary
Z destination
no is empty.
RMAN> RECOVER TABLE BAR.TEST_TABLE UNTIL SCN 2695890 <<Your SCN
2> AUXILIARY DESTINATION '/u01/backup/test';

Starting recover at 2013-06-28:17:19:09


using channel ORA_DISK_1
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=47 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Secure Backup
RMAN-05026: WARNING: presuming following set of tablespaces
applies to specified Point-in-Time

List of tablespaces expected to have UNDO segments


Tablespace SYSTEM
Tablespace UNDOTBS1

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 7
Creating automatic instance, with SID='ukoA'

initialization parameters used for automatic instance:


db_name=ORCL
db_unique_name=ukoA_pitr_ORCL
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

compatible=12.1.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
diagnostic_dest=/u01/app/oracle
db_create_file_dest=/u01/backup/test
log_archive_dest_1='location=/u01/backup/test'
s a
#No auxiliary parameter file used
)h a
m
co eฺ
o ฺ
o uid
starting up automatic instance ORCL
y a h
@ n t G
k
ac tude
Oracle instance started
f r z
L A ( this S
Total System Global Area UA1068937216
O u se bytes
C H e to
Fixed Size
2 T
0 ens 2296576 bytes
L
Variable Size %
I le li c 281019648 bytes
Database E
M Buffers ab 780140544 bytes
A f e r
a r ie ns
Redo Buffers 5480448 bytes

a c n - tra instance created


h Automatic
Z no
contents of Memory Script:
{
# set requested point in time
set until scn 2695890;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
}
executing Memory Script

executing command: SET until clause

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 8
Starting restore at 2013-06-28:17:20:12
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=75 device type=DISK
allocated channel: ORA_AUX_SBT_TAPE_1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

channel ORA_AUX_SBT_TAPE_1: SID=82 device type=SBT_TAPE


channel ORA_AUX_SBT_TAPE_1: Oracle Secure Backup

channel ORA_AUX_DISK_1: starting datafile backup set restore


channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece
+FRA/ORCL/AUTOBACKUP/2013_06_28/s_819306681.288.819306683
channel ORA_AUX_DISK_1: piece
handle=+FRA/ORCL/AUTOBACKUP/2013_06_28/s_819306681.288.819306683 s a
tag=TAG20130628T171121
)h a
channel ORA_AUX_DISK_1: restored backup piece 1 m
co eฺ
o ฺ
o uid
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
y a h
output file
@ n t G
k
ac tude
name=/u01/backup/test/ORCL/controlfile/o1_mf_8wvkgn5h_.ctl
f r z
A ( this S
Finished restore at 2013-06-28:17:20:21
L
UA mount
sql statement: alter database
O u se clone database
C H e to
T
0 system
sql statement:2alter ns archive log current
% c e
E LI ble li
A
contentsM oferMemory
a Script:
r{ie ans f
c h a tr requested point in time
a n -
# set
Z noset until scn 2695890;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 3 to new;
set newname for clone tempfile 1 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary
set
restore clone datafile 1, 4, 3;
switch clone datafile all;
}
executing Memory Script

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 9
executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to
/u01/backup/test/ORCL/datafile/o1_mf_temp_%u_.tmp in control
file
s a
Starting restore at 2013-06-28:17:20:28 )h a
m
co eฺ
using channel ORA_AUX_DISK_1
o ฺ
o uid
using channel ORA_AUX_SBT_TAPE_1
y a h
@ n t G
k
ac tude
f r z
channel ORA_AUX_DISK_1: starting (datafile S
L A t h i s backup set restore

U A sedatafile(s)
channel ORA_AUX_DISK_1: specifying to restore from
backup set
HOrestoring
t o u
T
channel ORA_AUX_DISK_1:
0 C s e datafile 00003 to
n
I%2 le lice reading from backup piece
/u01/backup/test/ORCL/datafile/o1_mf_sysaux_%u_.dbf
L
channel ORA_AUX_DISK_1:
E ab
M er
+FRA/ORCL/BACKUPSET/2013_06_28/nnndn0_tag20130628t170851_0.301.8
A
r i e
19306533
s f
c ha channel
- t r anORA_AUX_DISK_1: piece
a n
Z nohandle=+FRA/ORCL/BACKUPSET/2013_06_28/nnndn0_tag20130628t170851_
0.301.819306533 tag=TAG20130628T170851
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from
backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to
/u01/backup/test/ORCL/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece
+FRA/ORCL/BACKUPSET/2013_06_28/nnndn0_tag20130628t170851_0.302.8
19306597
channel ORA_AUX_DISK_1: piece
handle=+FRA/ORCL/BACKUPSET/2013_06_28/nnndn0_tag20130628t170851_
0.302.819306597 tag=TAG20130628T170851
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 10
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from
backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to
/u01/backup/test/ORCL/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

+FRA/ORCL/BACKUPSET/2013_06_28/nnndn0_tag20130628t170851_0.300.8
19306653
channel ORA_AUX_DISK_1: piece
handle=+FRA/ORCL/BACKUPSET/2013_06_28/nnndn0_tag20130628t170851_
0.300.819306653 tag=TAG20130628T170851
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 2013-06-28:17:21:42
s a
)h a
datafile 1 switched to datafile copy
input datafile copy RECID=15 STAMP=819307303 file ฺco
m
h o o ideฺ
name=/u01/backup/test/ORCL/datafile/o1_mf_system_8wvkj0r0_.dbf
y a G u
datafile 4 switched to datafile copy
k@ file
e n t
input datafile copy RECID=16 STAMP=819307303 a c d
( frz s Stu
name=/u01/backup/test/ORCL/datafile/o1_mf_undotbs1_8wvkk3tw_.dbf
datafile 3 switched to datafile
A LAcopye thi
input datafile copy RECID=17 O U STAMP=819307303
us file
H
C se t o
name=/u01/backup/test/ORCL/datafile/o1_mf_sysaux_8wvkgxph_.dbf
0 T
2 icen
I %
L Memory lScript:
contents of
E l e
{ AM
f e r ab
h a r#iesetarequested
n s point in time
r
-tuntil scn 2695890;
Zac noset n
# online the datafiles restored or switched
sql clone "alter database datafile 1 online";
sql clone "alter database datafile 4 online";
sql clone "alter database datafile 3 online";
# recover and open database read only
recover clone database tablespace "SYSTEM", "UNDOTBS1",
"SYSAUX";
sql clone 'alter database open read only';
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile 1 online


sql statement: alter database datafile 4 online

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 11
sql statement: alter database datafile 3 online

Starting recover at 2013-06-28:17:21:43


using channel ORA_AUX_DISK_1
using channel ORA_AUX_SBT_TAPE_1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

starting media recovery

archived log for thread 1 with sequence 4 is already on disk as


file
+FRA/ORCL/ARCHIVELOG/2013_06_28/thread_1_seq_4.281.819306679
archived log for thread 1 with sequence 5 is already on disk as
file
+FRA/ORCL/ARCHIVELOG/2013_06_28/thread_1_seq_5.293.819306703
s a
)h
archived log for thread 1 with sequence 6 is already on disk asa
file m
co eฺ
o ฺ
+FRA/ORCL/ARCHIVELOG/2013_06_28/thread_1_seq_6.287.819306805
o uid
archived log file
y a h
@ t G
name=+FRA/ORCL/ARCHIVELOG/2013_06_28/thread_1_seq_4.281.81930667
n
9 thread=1 sequence=4 k
ac tude
f r z
A ( this S
archived log file
L
name=+FRA/ORCL/ARCHIVELOG/2013_06_28/thread_1_seq_5.293.81930670
3 thread=1 sequence=5
O UA use
archived log file
C H e to
T
0 ens
name=+FRA/ORCL/ARCHIVELOG/2013_06_28/thread_1_seq_6.287.81930680
2
I le lic
%
5 thread=1 sequence=6
L
ME erab
media recovery complete, elapsed time: 00:00:01
A
a r ie nsf
Finished recover at 2013-06-28:17:21:48

a c h -tra
Z nosql n statement: alter database open read only
contents of Memory Script:
{
sql clone "create spfile from memory";
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set control_files =
''/u01/backup/test/ORCL/controlfile/o1_mf_8wvkgn5h_.ctl''
comment=
''RMAN set'' scope=spfile";
shutdown clone immediate;
startup clone nomount;
# mount database
sql clone 'alter database mount clone database';
}
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 12
executing Memory Script

sql statement: create spfile from memory

database closed
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)


Oracle instance started

Total System Global Area 1068937216 bytes

s a
Fixed Size 2296576
)h a bytes
Variable Size m
285213952
co eฺ
bytes
Database Buffers o ฺ
775946240
o uid
bytes
Redo Buffers
y a h 5480448 bytes
@ n t G
k
ac tude=
( f r z
sql statement: alter system set control_files
S
A i s
''/u01/backup/test/ORCL/controlfile/o1_mf_8wvkgn5h_.ctl''
L h
A se t
comment= ''RMAN set'' scope=spfile
U
H O to u
Oracle instance shut C
0T ense down
2
I%auxiliaryic database (not started)
L
E ab
connected to l e l
A Minstance
er started
r i e
Oracle
s f
a c ha -tran
Z noTotal n System Global Area 1068937216 bytes
Fixed Size 2296576 bytes
Variable Size 285213952 bytes
Database Buffers 775946240 bytes
Redo Buffers 5480448 bytes

sql statement: alter database mount clone database

contents of Memory Script:


{
# set requested point in time
set until scn 2695890;
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile 5 to new;

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 13
# restore the tablespaces in the recovery set and the auxiliary
set
restore clone datafile 5;
switch clone datafile all;
}
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

Starting restore at 2013-06-28:17:22:32


allocated channel: ORA_AUX_DISK_1
s a
channel ORA_AUX_DISK_1: SID=15 device type=DISK
allocated channel: ORA_AUX_SBT_TAPE_1 )h a
m
co eฺ
channel ORA_AUX_SBT_TAPE_1: SID=86 device type=SBT_TAPE
o ฺ
o uid
channel ORA_AUX_SBT_TAPE_1: Oracle Secure Backup
y a h
@ n t G
k
ac backup de set restore
channel ORA_AUX_DISK_1: starting datafile
f r z
( datafile(s) t u
S to restore from
channel ORA_AUX_DISK_1: specifying
L A t h i s
UA usedatafile 00005 to
backup set
channel ORA_AUX_DISK_1:Orestoring
C H e to
2 T
/u01/backup/test/UKOA_PITR_ORCL/datafile/o1_mf_bartbs_%u_.dbf
s
0 enreading
channel ORA_AUX_DISK_1:
I % l i c from backup piece
EL able
+FRA/ORCL/BACKUPSET/2013_06_28/nnndn0_tag20130628t170851_0.300.8
M er
19306653
i e A ORA_AUX_DISK_1:
f
a rchannel
a n s piece
h r
n-t
Zac no0.300.819306653
handle=+FRA/ORCL/BACKUPSET/2013_06_28/nnndn0_tag20130628t170851_
tag=TAG20130628T170851
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2013-06-28:17:22:35

datafile 5 switched to datafile copy


input datafile copy RECID=19 STAMP=819307355 file
name=/u01/backup/test/UKOA_PITR_ORCL/datafile/o1_mf_bartbs_8wvkl
td3_.dbf

contents of Memory Script:


{
# set requested point in time
set until scn 2695890;
# online the datafiles restored or switched
sql clone "alter database datafile 5 online";
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 14
# recover and open resetlogs
recover clone database tablespace "BARTBS", "SYSTEM",
"UNDOTBS1", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

executing Memory Script

executing command: SET until clause

sql statement: alter database datafile 5 online

Starting recover at 2013-06-28:17:22:35


using channel ORA_AUX_DISK_1
s a
using channel ORA_AUX_SBT_TAPE_1
)h a
m
co eฺ
starting media recovery
o ฺ
o uid
a h
archived log for thread 1 with sequence 4@ isyalready
t Gon disk as
k n
file
f r z ac tude
(
Asequence i s S
+FRA/ORCL/ARCHIVELOG/2013_06_28/thread_1_seq_4.281.819306679
archived log for thread 1 with L
A se t h 5 is already on disk as
U
HO e to u
file
+FRA/ORCL/ARCHIVELOG/2013_06_28/thread_1_seq_5.293.819306703
archived log for0thread
C
T n1s with sequence 6 is already on disk as
I % 2 i ce
file
L
E able l
+FRA/ORCL/ARCHIVELOG/2013_06_28/thread_1_seq_6.287.819306805
A logM er file
r i e
archived
s f
c ha 9 thread=1
- t r an sequence=4
name=+FRA/ORCL/ARCHIVELOG/2013_06_28/thread_1_seq_4.281.81930667
a n
Z noarchived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_28/thread_1_seq_5.293.81930670
3 thread=1 sequence=5
archived log file
name=+FRA/ORCL/ARCHIVELOG/2013_06_28/thread_1_seq_6.287.81930680
5 thread=1 sequence=6
media recovery complete, elapsed time: 00:00:01
Finished recover at 2013-06-28:17:22:39

database opened

contents of Memory Script:


{
# create directory for datapump import
sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/u01/backup/test''";
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 15
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/u01/backup/test''";
}
executing Memory Script
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR


as ''/u01/backup/test''

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR


as ''/u01/backup/test''

Performing export of tables...


EXPDP> Starting "SYS"."TSPITR_EXP_ukoA_Cmxe": s a
EXPDP> Estimate in progress using BLOCKS method... )h a
m
co eฺ
o ฺ
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
o uid
y a h
EXPDP> Total estimation using BLOCKS method: 64 KB

@ t G
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
n
EXPDP> Processing object type k
ac tude
f r z
A ( this S
TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
L
EXPDP> Processing object type
UA use
TABLE_EXPORT/TABLE/STATISTICS/MARKER
O
C H e to
EXPDP> ORA-39127: unexpected error from call to export_string
2 T
0 ens
:=SYS.DBMS_TRANSFORM_EXIMP.INSTANCE_INFO_EXP('AQ$_ORDERS_QUEUETA
I le lic
%
BLE_S','IX',1,1,'12.01.00.00.00',newblock)
L
ME erab
ORA-00376: file 2 cannot be read at this time
A
a r ie nsf
ORA-01110: data file 2:

a c h -tra'+DATA/ORCL/DATAFILE/example.264.818592141'
Z non ORA-06512: at "SYS.DBMS_TRANSFORM_EXIMP", line 197
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_METADATA", line 9901
ORA-39127: unexpected error from call to export_string
:=SYS.DBMS_TRANSFORM_EXIMP.INSTANCE_INFO_EXP('AQ$_STREAMS_QUEUE_
TABLE_S','IX',1,1,'12.01.00.00.00',newblock)
ORA-00376: file 2 cannot be read at this time
ORA-01110: data file 2:
'+DATA/ORCL/DATAFILE/example.264.818592141'
ORA-06512: at "SYS.DBMS_TRANSFORM_EXIMP", line 197
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_METADATA", line 9901
EXPDP> . . exported "BAR"."TEST_TABLE"
5.992 KB 3 rows
EXPDP> Master table "SYS"."TSPITR_EXP_ukoA_Cmxe" successfully
loaded/unloaded

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 16
EXPDP>
****************************************************************
**************
EXPDP> Dump file set for SYS.TSPITR_EXP_ukoA_Cmxe is:
EXPDP> /u01/backup/test/tspitr_ukoA_77184.dmp
EXPDP> Job "SYS"."TSPITR_EXP_ukoA_Cmxe" completed with 2
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

error(s) at Fri Jun 28 17:23:17 2013 elapsed 0 00:00:22


Export completed

contents of Memory Script:


{
# shutdown clone before import
shutdown clone abort
}
s a
executing Memory Script
)h a
m
co eฺ
Oracle instance shut down o ฺ
o uid
y a h
@ n t G
Performing import of tables... k
ac tude
( f r z S
IMPDP> Master table "SYSBACKUP"."TSPITR_IMP_ukoA_uAna"
successfully loaded/unloaded LA h i s
U A se t
H O o u TABLE_EXPORT/TABLE/TABLE
IMPDP> Starting "SYSBACKUP"."TSPITR_IMP_ukoA_uAna":
object ttype
IMPDP> Processing C
0T object se type TABLE_EXPORT/TABLE/TABLE_DATA
2
IMPDP> Processing
e n
IMPDP> L.I%
e l
. imported ic "BAR"."TEST_TABLE"
5.992 M KBE l
ab3 rows
A f e r
a ie IMPDP> s Processing object type
rTABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
n
h t r a
Zac non-IMPDP> Processing object type
TABLE_EXPORT/TABLE/STATISTICS/MARKER
IMPDP> Job "SYSBACKUP"."TSPITR_IMP_ukoA_uAna" successfully
completed at Fri Jun 28 17:23:29 2013 elapsed 0 00:00:05
Import completed

Removing automatic instance


Automatic instance removed
auxiliary instance file
/u01/backup/test/ORCL/datafile/o1_mf_temp_8wvkkdg5_.tmp deleted
auxiliary instance file
/u01/backup/test/UKOA_PITR_ORCL/onlinelog/o1_mf_3_8wvkm25y_.log
deleted
auxiliary instance file
/u01/backup/test/UKOA_PITR_ORCL/onlinelog/o1_mf_2_8wvkm0v3_.log
deleted

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 17
auxiliary instance file
/u01/backup/test/UKOA_PITR_ORCL/onlinelog/o1_mf_1_8wvklzto_.log
deleted
auxiliary instance file
/u01/backup/test/UKOA_PITR_ORCL/datafile/o1_mf_bartbs_8wvkltd3_.
dbf deleted
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

auxiliary instance file


/u01/backup/test/ORCL/datafile/o1_mf_sysaux_8wvkgxph_.dbf
deleted
auxiliary instance file
/u01/backup/test/ORCL/datafile/o1_mf_undotbs1_8wvkk3tw_.dbf
deleted
auxiliary instance file
/u01/backup/test/ORCL/datafile/o1_mf_system_8wvkj0r0_.dbf
deleted
s a
auxiliary instance file
)h a
/u01/backup/test/ORCL/controlfile/o1_mf_8wvkgn5h_.ctl deleted
m
co eฺ
auxiliary instance file tspitr_ukoA_77184.dmp deleted
o ฺ
o uid
Finished recover at 2013-06-28:17:23:32
y a h
@ n t G
RMAN>
k dethe specified table. It
aofcrecovering
Note: RMAN uses your input to automate the process
( f r z S t u
performs the following tasks:
L A t h i s
a. RMAN determines the backup basedA e
on your specification, that is YOUR SCN.
O U u s
CH
b. RMAN creates an auxiliary instance.
T e to up to the specified point in time, into this
c. RMAN recovers your0
auxiliary instance.% 2 tables
c e ns
or table partitions,

d. RMAN creates E LIa Data l e li export dump file that contains the recovered objects.
Pump
A M r b
arecovered
e. RMAN
r i e s f
importsethe objects into the target database.
hf. a RMAN t r n the auxiliary instance.
aremoves
a c
Z10. Delete -
nobsolete archive logs and then exit RMAN. The output is removed to avoid clutter.
noRMAN> delete noprompt obsolete;
RMAN> exit
$
11. In SQL*Plus, query all rows of the test table to confirm the success of the recovery. Then
exit.
SQL> SELECT * FROM BAR.TEST_TABLE;

NUM NAME NOW


---------- ------------------------- -------------------
1 First test row 2013-06-28:17:11:41
2 Second test row 2013-06-28:17:11:42
3 Third test row
SQL> exit
$
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 18
12. Clean up the practice environment by executing the cleanup_17_01.sh script. This script
removes the original and the transported tablespace, as well as the backup and dump files.
The output is in the /tmp/cleanup.log file.
$ ./cleanup_17_01.sh
$
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 19
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 17: Performing Point-in-Time Recovery


Chapter 17 - Page 20
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lessonn t G18:
k de
ac atDatabase
Duplicating
( f r z S u
L A h i s
U AChapterse18 t
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 1
Practices for Lesson 18: Overview
Practices Overview
In these practices, you will prepare and then duplicate a database.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 2
Practice 18-1: Duplicating a Database
Overview
In this practice you learn how to duplicate an active database in ASM to another disk group in
ASM. ORCL is the active database that will be duplicated or cloned as DBTEST. The tasks
include:
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

• Use ASMCA to confirm sufficient disk space for the duplicated database.
• Prepare the destination for the future DBTEST database with Oracle Net connectivity,
password file, and a minimal initdbtest.ora file.
• Confirm source database configuration settings.
• Duplicate the ORCL database by using RMAN.
• Test access to the cloned database.

Assumptions s a
)h a
Two terminal windows is open in the $LABS directory pointing to the orcl database instance.
Work as the oracle OS user unless the task indicates the grid OS user. m
co eฺ
o ฺ
o uid
y a h
@ n t G
Tasks k
c ude
aoracle
r
1. In a terminal window, log in as the grid OS user fwith
( z S t as training password and
point your environment variables to the +ASM A
A L instance.
e t his
$ su - grid
O U us
Password: oracle <<< C H e to
not displayed
$ . oraenv 2 T
0 ens
%
ORACLE_SIDLI= [grid] e l ic? +ASM
ME ebase l
ab has been changed from /u01/app/oracle to
The AOracle
f r
a ie ns
r/u01/app/grid
c h $ -tra
a
Z2. Use n asmca utility to create the DISK2 disk group for your duplicate database.
nothe
a. Enter asmca to start the utility which opens in a separate window.
$ asmca

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 3
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
c ude
aclick
b. Click Create and enter Disk Group Name: DISK2,
( f r z S t
Redundancy: External
A thentclick i s
A se h
(None), and select two available disks,Land OK.
U
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 4
c. Disk Group: Creation progress window may appear, followed by a success message.
Click OK.
d. Your new disk group is displayed on the Disk Groups tabbed page.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
e. rClick s f then Yes to confirm your exit.
ie Exit,nand
c a
h -tra
a
non as oracle OS user pointing to the orcl instance. Prepare Oracle Net
Z3. Continue
connectivity with the netca utility. Add a dbtest entry to the tnsnames.ora file.
$ netca
a. On the Oracle Net Configuration Assistant: Welcome page, select Local Net Service
Name configuration and click Next.
b. Confirm that Add is selected and click Next.
c. Enter dbtest as Service Name and click Next.
d. Select TCP as protocol and click Next.
e. Enter your host and domain name (for example, edRSr39p1.us.oracle.com) in the
Host name field. If you are unsure about the format, execute the command in the next
step to view currently active examples.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 5
f. Confirm that Use the standard port number of 1521 is selected and click Next.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
g. Select No, do not test, becauseO UAdbtest
your u seinstance does not yet exist, and click
Next. C H e to
h. Confirm dbtest as2Net
T
0 Service nsName and click Next.
% c e
li Would you like to configure another net service name
I question:
i. Answer No EtoLthe l e
MNext.erab
and click
A
ie should
j. rYou n s f the message: Net service name Configuration Complete! Click
see
c a
h Next. tra
a n -
Z k.noClick Finish.
$ netca

Oracle Net Services Configuration:


Default local naming configuration complete.
Created net service name: dbtest
Oracle Net Services configuration successful. The exit code is 0
$
4. Pointing to the ORCL instance, view the DBTEST entry in the
$ORACLE_HOME/network/admin/tnsnames.ora file.
$ cat $ORACLE_HOME/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.o
ra
# Generated by Oracle configuration tools.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 6
$ cat $ORACLE_HOME/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.o
ra
# Generated by Oracle configuration tools.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

RCAT =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edRSr39p1.us.oracle.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rcat)
s a
)
)h a
) m
co eฺ
o ฺ
o uid
y a h
DBTEST =
@ n t G
(DESCRIPTION = k
ac tude
f r z
A ( thi=s S
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = LTCP)(HOST
UA =u1521))
edRSr39p1.us.oracle.com)(PORT
O se
) C H e to
2
(CONNECT_DATA
T
0 = ens
L I le lic= dbtest)
%
(SERVICE_NAME
)M
E ab
r i e A
s f er
ha -tran
)
a c
Z noORCL n =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edRSr39p1.us.oracle.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
$
5. Comparing the DBTEST entry with the ORCL configuration, your notice that (SERVER =
DEDICATED) is missing.
a. Update the tnsnames.ora file with the gedit or vi editor so that the ORCL and
DBTEST configurations follow the same pattern.
$ gedit $ORACLE_HOME/network/admin/tnsnames.ora

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 7
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L
b. After you finished % l icconfirm that the entry is now:
I yourleedit,
... AM
E ab
r i e s f er
c
DBTEST
- t r an
ha (DESCRIPTION=
a
Z non (ADDRESS_LIST =
=
(ADDRESS = (PROTOCOL = TCP)(HOST =
edRSr39p1.us.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dbtest)
)
)
6. Copy the file into the equivalent grid home directory,
/u01/app/grid/product/12.1.0/grid/network/admin in this example.
$ cp
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.o
ra /u01/app/grid/product/12.1.0/grid/network/admin/tnsnames.ora
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 8
7. Create a password file for the future DBTEST database to allow OS authentication.
a. As oracle OS user, point the environment variables to the dbtest instance.
$ . oraenv
ORACLE_SID = [orcl] ? dbtest
ORACLE_HOME = [/home/oracle] ?
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

/u01/app/oracle/product/12.1.0/dbhome_1/
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1/ is
/u01/app/oracle
$
b. Create the $ORACLE_HOME/dbs/orapwdbtestfile with the orapwd utility.
$ orapwd file=$ORACLE_HOME/dbs/orapwdbtest entries=15
password=oracle_4U
$ s a
)h a
c. Optionally, confirm that the file exists.
m
co eฺ
$ ls $ORACLE_HOME/dbs/*ora*
o ฺ
o uid
/u01/app/oracle/product/12.1.0/dbhome_1//dbs/init.ora
y a h
@ n t G
k
/u01/app/oracle/product/12.1.0/dbhome_1//dbs/orapwdbtest
ac tude
r z
/u01/app/oracle/product/12.1.0/dbhome_1//dbs/orapworcl
f
A ( this S
/u01/app/oracle/product/12.1.0/dbhome_1//dbs/orapwrcat
L
UA use
/u01/app/oracle/product/12.1.0/dbhome_1//dbs/pfileorcl.ora
O
H e to
/u01/app/oracle/product/12.1.0/dbhome_1//dbs/spfileorcl.ora
C
2 T
0 ens
/u01/app/oracle/product/12.1.0/dbhome_1//dbs/spfilercat.ora

L I le lic
%
/u01/app/oracle/product/12.1.0/dbhome_1//dbs/spfileukoA.ora
$
A ME erab
r
8. In the
n f create a minimal initdbtest.ora file with the following entries:
iesame directory,
s
c a tra
h db_name=dbtest
a n -
Z noremote_login_passwordfile=exclusive
Then confirm your content with the cat command.
$ vi $ORACLE_HOME/dbs/initdbtest.ora

$ cat $ORACLE_HOME/dbs/initdbtest.ora
db_name=dbtest
remote_login_passwordfile=exclusive
$
9. Point environment variables to the dbtest instance (as shown in step 7 a). Log in to
SQL*Plus as SYSDBA, start the dbtest instance in NOMOUNT mode with the
initdbtest.ora file. Then exit.
$ . oraenv
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 9
ORACLE_SID = [dbtest] ?
ORACLE_HOME = [/home/oracle] ?
/u01/app/oracle/product/12.1.0/dbhome_1
The Oracle base for
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is
/u01/app/oracle
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

$
$ sqlplus / as sysdba
SQL>
SQL> startup NOMOUNT
pfile='/u01/app/oracle/product/12.1.0/dbhome_1/dbs/initdbtest.or
a'
ORACLE instance started.

s a
Total System Global Area 229683200 bytes
)h a
Fixed Size 2286176 bytes m
co eฺ
Fixed Size 2286800 bytes o
o uidฺ
Variable Size 171969328 bytes
y a h
@ n t G
Redo Buffers 5095424 bytes k
ac tude
SQL> exit
f r z
$
L A ( this S
UA ussettings
10. Confirm the ORCL source database configuration
O e in SQL*Plus.
C
a. With your environment variables H pointed
e toto orcl, you logged in to SQL*Plus as
SYSBDA. Confirm that2 T ns
0compatibility is set to 12.0 or higher to take advantage of
I
the features new % l
to Oracle i c e
Database 12c.
M ELparameters
a b le compatible
i e A fer
SQL> show

a rNAME
a n s TYPE VALUE
h r
Zac no--- n-t
------------------------------------ ----------- ---------------

compatible string 12.1.0.0.0


noncdb_compatible boolean FALSE
SQL>
b. Confirm your backup location and size. If the FRA is smaller, enlarge it with
ALTER SYSTEM SET db_recovery_file_dest_size = 10G SCOPE=BOTH;
SQL> show parameters recovery_f
NAME TYPE VALUE
------------------------------------ ----------- ---------------
---
db_recovery_file_dest string +FRA
db_recovery_file_dest_size big integer 10G
SQL>
c. Confirm that the database is in archive log mode. Then exit.
SQL> SELECT NAME, LOG_MODE, OPEN_MODE FROM V$DATABASE;
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 10
NAME LOG_MODE OPEN_MODE
--------- ------------ --------------------
ORCL ARCHIVELOG READ WRITE
SQL> exit
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

$
Note: If your values differ, discuss with your instructors which steps you may need to take
to prepare the database that you wish to duplicate.
11. In your cloning session set the $TNS_ADMIN environment variable as oracle OS user,
because the server processes will try to resolve the AUXILIARY service name by using
$TNS_ADMIN/tnsnames.ora.
$ export
TNS_ADMIN=/u01/app/grid/product/12.1.0/grid/network/admin
$ echo $TNS_ADMIN s a
/u01/app/grid/product/12.1.0/grid/network/admin )h a
m
co eฺ
$
o ฺ
12. Use RMAN to duplicate the ORCL database as DBTEST database.aho uid
Note that for the target and catalog, the service names @ y
are used, n
but
G
t NOT for the
c k e
d pointing to the dbtest
frza s Stu
auxiliary connection. So you must set the environment variables
instance. (
A LA e thi
OU to us
$ . oraenv
ORACLE_SID = [orcl] ?Hdbtest
0 T C se ?
I % 2 icen
ORACLE_HOME = [/home/oracle]
/u01/app/oracle/product/12.1.0/dbhome_1
The Oracle E L baseblfor
e l
A M era
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is
i e s f
c h ar$ echot r an$ORACLE_SID
/u01/app/oracle
a
Z nodbtest n -
$
$ rman target sys/oracle_4U@orcl auxiliary sys/oracle_4U catalog
rcatowner/oracle_4U@rcat

Recovery Manager: Release 12.1.0.1.0 - Production on Wed Apr 24


12:17:30 2013

Copyright (c) 1982, 2013, Oracle and/or its affiliates. All


rights reserved.

connected to target database: ORCL (DBID=1341256546)


connected to recovery catalog database
connected to auxiliary database: DBTEST (not mounted)

RMAN>
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 11
Note: It is recommended that you DO NOT enter a password on the command line. We
used this approach only to avoid ambiguity (and allow you to copy-and-paste it).
13. Duplicate the ORCL database as DBTEST database from the +DATA disk group to the
+DISK2 disk group with the following command:
DUPLICATE TARGET DATABASE TO dbtest FROM ACTIVE DATABASE
SPFILE PARAMETER_VALUE_CONVERT
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

'+DATA','+DISK2','ORCL','DBTEST'
SET DB_RECOVERY_FILE_DEST_SIZE='10G';
RMAN> DUPLICATE TARGET DATABASE TO dbtest FROM ACTIVE DATABASE
SPFILE PARAMETER_VALUE_CONVERT
'+DATA','+DISK2','ORCL','DBTEST'
SET DB_RECOVERY_FILE_DEST_SIZE='10G';
2> 3>
Starting Duplicate Db at 2013-06-29:09:10:25 s a
new incarnation of database registered in recovery catalog )h a
m
co eฺ
starting full resync of recovery catalog
o ฺ
o uid
full resync complete
y a h
allocated channel: ORA_AUX_DISK_1
@ n t G
k
ac tude
channel ORA_AUX_DISK_1: SID=12 device type=DISK
f r z
A ( this S
current log archived
L
contents of Memory Script: O UA use
C H e to
{
2 T ns
0from eservice
L I %
restore clone
l i c 'orcl' spfile to
E able
'/u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfiledbtest.ora';
M
r i e A clone
sql
s f er "alter system set spfile=
a c ha "; -tran
''/u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfiledbtest.ora''

Z no}n
executing Memory Script

Starting restore at 2013-06-29:09:10:35


using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore


channel ORA_AUX_DISK_1: using network backup set from service
orcl
channel ORA_AUX_DISK_1: restoring SPFILE
output file
name=/u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfiledbtest.or
a
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2013-06-29:09:10:37

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 12
sql statement: alter system set spfile=
''/u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfiledbtest.ora''

contents of Memory Script:


{
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

sql clone "alter system set db_name =


''DBTEST'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set control_files =
''+FRA/DBTEST/CONTROLFILE/control02.ctl'',
''+DISK2/DBTEST/CONTROLFILE/current.265.819027437'' comment=
'''' scope=spfile";
sql clone "alter system set DB_RECOVERY_FILE_DEST_SIZE =
10G comment= s a
'''' scope=spfile"; )h a
m
co eฺ
shutdown clone immediate;
o ฺ
o uid
startup clone nomount;
y a h
}
@ n t G
executing Memory Script k
ac tude
( f r z S
L A
sql statement: alter systemAset db_name h i s
t = ''DBTEST'' comment=
U s e
HO e to u
''duplicate'' scope=spfile
C
0T system
sql statement:2alter
% c e ns set control_files =
L I le li
''+FRA/DBTEST/CONTROLFILE/control02.ctl'',
E
M erab
''+DISK2/DBTEST/CONTROLFILE/current.265.819027437'' comment=
A f
h a rie ans
'''' scope=spfile

a c n - tr
Z no statement: alter system set DB_RECOVERY_FILE_DEST_SIZE =
sql
10G comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)


Oracle instance started

Total System Global Area 534462464 bytes

Fixed Size 2290416 bytes


Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes

contents of Memory Script:


Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 13
{
sql clone "alter system set control_files =
''+FRA/DBTEST/CONTROLFILE/control02.ctl'',
''+DISK2/DBTEST/CONTROLFILE/current.256.819364259'' comment=
''Set by RMAN'' scope=spfile";
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

sql clone "alter system set db_name =


''ORCL'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''DBTEST'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
s a
restore clone from service 'orcl' primary controlfile;
alter clone database mount; )h a
m
co eฺ
}
o ฺ
o uid
executing Memory Script
y a h
@ n t G
k
ac tude=
f r z
sql statement: alter system set control_files

L A ( this S
''+FRA/DBTEST/CONTROLFILE/control02.ctl'',
''+DISK2/DBTEST/CONTROLFILE/current.256.819364259'' comment=
U A se
HO e to u
''Set by RMAN'' scope=spfile
C
0T system
sql statement:2alter
% c e ns set db_name = ''ORCL'' comment=
E L ble i
''Modified Iby RMAN lduplicate'' scope=spfile

A M era
r ie statement:
sql
n s f alter system set db_unique_name = ''DBTEST''
c h a t
comment=r a ''Modified by RMAN duplicate'' scope=spfile
a
Z no n -
Oracle instance shut down

Oracle instance started

Total System Global Area 534462464 bytes

Fixed Size 2290416 bytes


Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes

Starting restore at 2013-06-29:09:11:23


allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=13 device type=DISK

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 14
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service
orcl
channel ORA_AUX_DISK_1: restoring control file
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07


output file name=+FRA/DBTEST/CONTROLFILE/control02.ctl
output file name=+DISK2/DBTEST/CONTROLFILE/current.256.819364259
Finished restore at 2013-06-29:09:11:32

database mounted

contents of Memory Script:


s a
{
set newname for clone datafile 1 to new; )h a
m
co eฺ
set newname for clone datafile 2 to new;
o ฺ
o uid
set newname for clone datafile 3 to new;
y a h
@
set newname for clone datafile 4 to new;
n t G
k
ac tude
f r z
set newname for clone datafile 6 to new;
restore
L A ( this S
from service 'orcl'
O UA use
clone database
;
C H e to
T
0 ens
sql 'alter system archive log current';
2
}
L I le lic
%
ME erab
executing Memory Script
A
a r e nsf
iexecuting
a c h -tra command: SET NEWNAME
Z non
executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 2013-06-29:09:11:41


using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service
orcl
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from
backup set
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 15
channel ORA_AUX_DISK_1: restoring datafile 00001 to +DATA
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service
orcl
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from


backup set
channel ORA_AUX_DISK_1: restoring datafile 00002 to +DATA
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service
orcl
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from
backup set
s a
)h
channel ORA_AUX_DISK_1: restoring datafile 00003 to +DATA a
m
co eฺ
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05
o ฺ
o uid
channel ORA_AUX_DISK_1: starting datafile backup set restore
y a h
@ n t G
channel ORA_AUX_DISK_1: using network backup set from service
orcl k
ac tude
r z
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from
f
backup set
L A ( this S
UA use
channel ORA_AUX_DISK_1: restoring datafile 00004 to +DATA
O
H e to
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
C
T
0 ens
channel ORA_AUX_DISK_1: starting datafile backup set restore
2
I le lic
%
channel ORA_AUX_DISK_1: using network backup set from service
L
ME erab
orcl
A
a r ie nsf
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from

a c h -trabackup set
Z non channel ORA_AUX_DISK_1: restoring datafile 00006 to +DATA
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2013-06-29:09:14:23

sql statement: alter system archive log current


current log archived

contents of Memory Script:


{
restore clone force from service 'orcl'
archivelog from scn 2751227;
switch clone datafile all;
}
executing Memory Script

Starting restore at 2013-06-29:09:14:27


Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 16
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting archived log restore to default


destination
channel ORA_AUX_DISK_1: using network backup set from service
orcl
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

channel ORA_AUX_DISK_1: restoring archived log


archived log thread=1 sequence=14
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting archived log restore to default
destination
channel ORA_AUX_DISK_1: using network backup set from service
orcl
channel ORA_AUX_DISK_1: restoring archived log
s a
archived log thread=1 sequence=15
)h a
m
co eฺ
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 2013-06-29:09:14:34 o ฺ
o uid
y a h
datafile 1 switched to datafile copy
@ n t G
k
ac tude
input datafile copy RECID=17 STAMP=819364475 file
r z
name=+DATA/DBTEST/DATAFILE/system.266.819364303
f
A ( this S
datafile 2 switched to datafile copy
L
UA use
input datafile copy RECID=18 STAMP=819364475 file
O
H e to
name=+DATA/DBTEST/DATAFILE/example.256.819364357
C
T
0 ens
datafile 3 switched to datafile copy
2
I le lic
%
input datafile copy RECID=19 STAMP=819364475 file
L
ME erab
name=+DATA/DBTEST/DATAFILE/sysaux.257.819364383
A
a r ie nsf
datafile 4 switched to datafile copy

a c h -trainput datafile copy RECID=20 STAMP=819364476 file


Z non name=+DATA/DBTEST/DATAFILE/undotbs1.258.819364449
datafile 6 switched to datafile copy
input datafile copy RECID=21 STAMP=819364476 file
name=+DATA/DBTEST/DATAFILE/users.263.819364463

contents of Memory Script:


{
set until scn 2751502;
recover
clone database
delete archivelog
;
}
executing Memory Script

executing command: SET until clause


Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 17
Starting recover at 2013-06-29:09:14:37
using channel ORA_AUX_DISK_1

starting media recovery


Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

archived log for thread 1 with sequence 14 is already on disk as


file
+FRA/DBTEST/ARCHIVELOG/2013_06_29/thread_1_seq_14.284.819364469
archived log for thread 1 with sequence 15 is already on disk as
file
+FRA/DBTEST/ARCHIVELOG/2013_06_29/thread_1_seq_15.283.819364473
archived log file
name=+FRA/DBTEST/ARCHIVELOG/2013_06_29/thread_1_seq_14.284.81936
s a
4469 thread=1 sequence=14
)h a
archived log file
m
co eฺ
4473 thread=1 sequence=15 o ฺ
name=+FRA/DBTEST/ARCHIVELOG/2013_06_29/thread_1_seq_15.283.81936
o uid
y a h
media recovery complete, elapsed time: 00:00:02
@ n t G
Finished recover at 2013-06-29:09:14:43 k
ac tude
f r z
A ( this S
Oracle instance started
L
Total System Global Area O UA 534462464
u se bytes
C H e to
2 T
0 ens
LI ble lic
Fixed Size 2290416 bytes
VariableESize
% 276827408 bytes
A M Buffers
Database
e ra 247463936 bytes
i e s f
c h arRedotrBuffers
a n 7880704 bytes
n-
Za nocontents of Memory Script:
{
sql clone "alter system set db_name =
''DBTEST'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
}
executing Memory Script

sql statement: alter system set db_name = ''DBTEST'' comment=


''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset db_unique_name scope=spfile


Oracle instance started

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 18
Total System Global Area 534462464 bytes

Fixed Size 2290416 bytes


Variable Size 276827408 bytes
Database Buffers 247463936 bytes
Redo Buffers 7880704 bytes
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DBTEST"


RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
s a
GROUP 1 SIZE 50 M ,
)h a
GROUP 2 SIZE 50 M ,
m
co eฺ
GROUP 3 SIZE 50 M
o ฺ
o uid
DATAFILE
y a h
'+DATA/DBTEST/DATAFILE/system.266.819364303'
@ n t G
CHARACTER SET AL32UTF8 k
ac tude
f r z
L A ( this S
UA use
contents of Memory Script:
{ O
H tempfile
to
set newname for C
0 T clone
s e
n all;
1 to new;
switch clone
I % 2 tempfile
i c e
catalogL clone e l
E abl datafilecopy
M
A fer
"+DATA/DBTEST/DATAFILE/example.256.819364357",

a r i e s
"+DATA/DBTEST/DATAFILE/sysaux.257.819364383",
n
h -t r a
Zac non"+DATA/DBTEST/DATAFILE/users.263.819364463";
"+DATA/DBTEST/DATAFILE/undotbs1.258.819364449",

switch clone datafile all;


}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to +DATA in control file

cataloged datafile copy


datafile copy file
name=+DATA/DBTEST/DATAFILE/example.256.819364357 RECID=1
STAMP=819364518
cataloged datafile copy
datafile copy file
name=+DATA/DBTEST/DATAFILE/sysaux.257.819364383 RECID=2
STAMP=819364518
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 19
cataloged datafile copy
datafile copy file
name=+DATA/DBTEST/DATAFILE/undotbs1.258.819364449 RECID=3
STAMP=819364519
cataloged datafile copy
datafile copy file
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

name=+DATA/DBTEST/DATAFILE/users.263.819364463 RECID=4
STAMP=819364519

datafile 2 switched to datafile copy


input datafile copy RECID=1 STAMP=819364518 file
name=+DATA/DBTEST/DATAFILE/example.256.819364357
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=819364518 file
name=+DATA/DBTEST/DATAFILE/sysaux.257.819364383
s a
datafile 4 switched to datafile copy
)h a
input datafile copy RECID=3 STAMP=819364519 file m
co eฺ
name=+DATA/DBTEST/DATAFILE/undotbs1.258.819364449
o ฺ
o uid
datafile 6 switched to datafile copy
y a h
@
input datafile copy RECID=4 STAMP=819364519 file
n t G
k
ac tude
name=+DATA/DBTEST/DATAFILE/users.263.819364463
f r z
L A ( this S
UA use
contents of Memory Script:
{ O
H opentoresetlogs;
T C
Alter clone database
0 ens e
}
% 2
I leScript ic
executing LMemory l
A MEopened
database
e r ab
f
ie nsDuplicate Db at 2013-06-29:09:16:19
rFinished
c h a tra
a
Z noRMAN> n -
14. Optionally, review the output. Find the major steps that RMAN performs for you. Then exit
RMAN.
An incomplete example:
• Registering the new database in the recovery catalog
• Cloning the SPFILE.
• Cloning the control file to the DISK2 disk group
• Cloning the data files
• Switching to the data files copies
• Performing media recovery
• Open DBTEST in RESETLOGS mode
RMAN> exit
$

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 20
15. Confirm the availability and accessibility of your newly created dbtest database.
$ . oraenv
ORACLE_SID = [oracle] ? dbtest
ORACLE_HOME = [/home/oracle] ?
/u01/app/oracle/product/12.1.0/dbhome_1
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

The Oracle base for


ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is
/u01/app/oracle

$ sqlplus / as sysdba

SQL> select dbid, name, created, open_mode from v$database;

DBID NAME CREATED OPEN_MODE


s a
)h
---------- --------- ------------------- --------------------a
1212227365 DBTEST 2013-06-29:09:15:17 READ WRITE m
co eฺ
o ฺ
o uid
y a h
SQL> exit
@ n t G
$ k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 21
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 18: Duplicating a Database


Chapter 18 - Page 22
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lessonn t G19:
k
ac tude
RMAN ( f r z
Troubleshooting
S and
A LA e this
Tuning
H OU Chapter
t o us19
0 T C se
I % 2 icen
E L ble l
A M era
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 19: RMAN Troubleshooting and Tuning


Chapter 19 - Page 1
Practices for Lesson 19: Overview
Practices Overview
In these practices, you will prepare your environment for the workshop
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 19: RMAN Troubleshooting and Tuning


Chapter 19 - Page 2
Practice 19-1: Resetting Your Training Databases
Overview
This lesson does not have a tuning hands-on practice. Instead, it is used to reset your training
environment for the backup and recovery workshop. The RESET_BAR.sh script takes down
your current ORCL and RCAT databases and recreates them. The script does not touch the other
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

databases and Cloud Control.


1. Close all sessions and windows that may be open from previous tasks.
$ exit
2. Log in as root OS user.
$ su - root
Password: oracle <<< not displayed
#
s a
3. a
Skip this step when you are resetting your course environment for first time. The command
)h
deletes the BAR.rebuild file that flags the completion of the reset. m
co eฺ
# rm -f /stage/MBS/logs/BAR.rebuild o ฺ
o uid
# rm -f /stage/MBS/targets/D78850GC10.reset1 ah
@ y t G
k n
ac tude
#
f r z
A ( this S
4. Navigate to the /stage/MBS/scripts directory.
L
UA use
# cd /stage/MBS/scripts
# O
H e to(The scripts may take one or more hours to
T
0 ensC
5. Start the rebuild of your training databases.
complete.) 2
I le lic
%
L
MEDBerteardown
# ./RESET_BAR.sh
A ab
r i e
starting
s f log file: /stage/MBS/logs/BARreset1.log

c ha starting
- t r an DB rebuild log file: /stage/MBS/logs/BAR.rebuild
a n
Z nofinished rebuild: Check logfiles in /stage/MBS/logs
#

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 19: RMAN Troubleshooting and Tuning


Chapter 19 - Page 3
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 19: RMAN Troubleshooting and Tuning


Chapter 19 - Page 4
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
Practices for @ Lessonn t G20:
k
ac tude
Workshop
( f r z S
L A h i s
U AChapterse20 t
C HO e to u
2 0T ens
L I% le lic
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 20: Workshop


Chapter 20 - Page 1
Practices for Lesson 20: Overview
Practices Overview
In these practices, you will protect the ORCL database with backups. Then known and unknown
issues will be introduced (either by you or your instructor). Your task is to recover the database
with no or minimal data loss.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 20: Workshop


Chapter 20 - Page 2
Practice 20-1: Preparing for Backup and Recovery Workshop
Overview
In this practice you have a chance to apply all that you learned. Your tasks are to secure the
availability of your database by appropriate backup and recovery strategies. Then your
configuration will be tested: Known and unknown issues will be introduced (either by you or your
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

instructor) so that you have the opportunity to recover with no or minimal data loss in a real-life
scenario.

Assumptions
You are familiar with Oracle backup and recovery. You completed practice 19, so that the ORCL
and RCAT databases are in the default configuration, as it was at the beginning of the course.

Tasks
1. Configure the recovery settings. Use Enterprise Manager or commands as shown in the
s a
)h a
practices to configure the settings you wish to use to protect your database. Assume that
m
this is a production database, and the business requirement is minimum loss of data.
co eฺ
Complete recovery is desired if at possible. Consider the following:
o ฺ
o uid
− ARCHIVELOG mode (practice 3.1)
y a h
@ n t G
− Archive log file destination (practice 3.1) k
ac tude
− Fast recovery area f r z
− Default backup location L A ( this S
− Backupsets or image copies U
A se
C
− Incremental or full backups H e to u
O
0T (suggested
− Backup retention2policy e ns redundancy of 2 for these exercises) (practice
3.3) %
LI ble li c
E
M anderlocation
a of control files (practice 3.4)
i e A
− Number
f
ar− Number a s
n and location of redo log files
c h - t r
Za no−nLocation of parameter and password files (practice 12)
− Tablespaces and location of the data files
− Backup strategy for the control file (practice 3.3, 7.1)
− Loss of ASM disks (practice 7.2)
− Use of a recovery catalog (practice 4)
2. Record the DBID of the orcl database: _______________________
3. Check the capacity of the +FRA diskgroup regularly. If it gets too full, archive logging will
stall and the database will stop.
Note: Your instructor will advise you if you should set the DB_RECOVERY_FILE_DEST
parameter to /u01/backup/orcl for more disk space.
4. After your database is fully configured for your backup and recovery strategy, perform two
backups of your choice.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 20: Workshop


Chapter 20 - Page 3
Practice 20-2: Experience the Real-Life Workshop
Overview
In this workshop, the instructor will present a random scenario. Your tasks are to diagnose the
problem and perform a complete recovery on the database, if possible.
When a complete recovery is not possible, recover to as recent a point in time as you can.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Assumptions
Practices 19 and 20-1 have been completed.

Tasks
1. The first step in every scenario is to log in to the database and attempt to start it.
2. Diagnose the problem by reviewing the error messages, alert log, or other indicators.
3. Decide on a recovery plan, and implement it. a
4. as
IMPORTANT: If you perform an incomplete recovery, you must perform a new backup to
protect your database. m )h
5. ฺ co eฺ
When you are satisfied that the database has been recovered and protected ask the
o
instructor to assign another scenario.
a h o uid
@ y t G
k n
f r z ac tude
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 20: Workshop


Chapter 20 - Page 4
Practice 20-3: Your Scenarios
Overview
In this practice you are presented with a database that is not functioning. You must determine
the cause of failure and the resources available to repair the database. Then repair the
database, recovering as much data as possible.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

In each of the scenarios, a new tablespace with a new schema is created. Sometimes it has
been backed up. A check of the alert log will show tablespaces created since the last backup. A
new schema has been created in the USERS tablespace.
If the instructor initiates the crash scenarios (which is the recommended method), then the
instructor will ftp to your training environment and locally initiate one of the scenarios.
Use the following commands only if you work without an instructor and want to introduce your
own "crash scenario". (Replace nn with the scenario number.)
$ cd $WORKS
s a
$ ./wksh_20_nn.sh
)h a
Password: oracle <<< not displayed m
co eฺ
$ o
o uidฺ
y a h
@ n t G
After most recoveries it is highly recommended to take a new full k database
ac tude
backup.
f r z
Assumptions
L A ( this S
The recovery strategy you put in place may have
been taken out of ARCHIVELOG mode,O
UA beensecompromised. The database may have
the type ofubackups used may have changed, or
C H be tlost.
safe may e
o
particular files you expected to be
2 T
0 ens
Warmup Scenarios: L I le lic
%
E lossaofba redo log file (inactive).
Mthe
1. Recover A
r
from
ie redo s f erfile has been lost. A complete recovery is possible.
c
Anainactive
ha. Start-tthe
r andatabase instance. Normal operation of the instance is not affected as long
log
a
Z noasnat least one group member is still functioning.
b. It's important to review the end of the alert_orcl.log to see the error. A redo log
file is missing.
c. Determine which redo log file group is missing.
d. Determine the status of the redo log group: CURRENT, ACTIVE, or INACTIVE from
V$LOG.
e. You can restore the missing log file by dropping the lost redo log member and adding a
new member.
f. If the group with the missing log file has been archived, you can clear the log group to
re-create the missing file ALTER DATABASE CLEAR [UNARCHIVED] LOGFILE
GROUP <number> command.
g. Perform a full backup.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 20: Workshop


Chapter 20 - Page 5
2. Recover from the loss of a redo log file (current). You can use either the RMAN client or
Cloud Control for these tasks.
An active or current redo log file has been lost. A complete recovery may not be possible.
a. Start the database instance. Normal operation of the instance is not affected as long
as at least one group member is still functioning.
b. It's important to review the end of the alert_orcl.log to see the error. A redo log
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

file is missing.
c. Determine which redo log file group is missing.
d. Determine the status of the redo log group (CURRENT, ACTIVE, or INACTIVE) from
V$LOG. Record the sequence number and starting SCN of the missing group.
Note: If the V$LOG view is not available, shut down the database and use the
STARTUP MOUNT command.
e. You can restore the missing log file by dropping the lost redo log member and adding a
new member.
s a
f.
)h a
If the group with the missing log file has been archived, you can clear the log group to
re-create the missing file ALTER DATABASE CLEAR [UNARCHIVED] LOGFILE m
co eฺ
GROUP <number> command.
o ฺ
o uid
g. a h
Start RMAN and list failures. If the database cannot be made consistent, then an
y
@ t
incomplete recovery is required. You can perform it with the REPAIR FAILURE
n G
command. Notice the UNTIL SCN clause.
k
ac tude
f r z
h.
A ( this S
Perform a full backup. (This is required especially after an incomplete recovery.)
L
A
3. Loss of a keystore with loss of a H OU to use
tablespace.
T
This scenario does an encrypted
0 C backup. e The tablespace is lost and keystore is lost. A
swallet)
backup of the keystore% 2
(or c e
encryption n is in /u01/backup/orcl/ewallet.p12.
L I e l i
M E abis l"secret".
The keystore password The keystore was created in the default location in

i e A fer
the $ORACLE_BASE/admin/orcl/wallet/ewallet.p12 directory.
a.arDetermine
a s
nthe failure. (Loss of a data file will be the first error.)
c h t r
n- the data file. (The restore will fail with an error on encrypted backup.)
Za b.noRestore
c. Attempt to open the keystore as SYSDBA.
ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY
secret;
This fails with ORA-28367: wallet does not exist
d. Restore the keystore to the default location and then open the keystore.
e. Use LIST FAILURE, …, REPAIR FAILURE.
f. Open the database.
g. Revert to unencrypted backups. Execute the cleanup_20_03.sh script (which takes
a new level 0 backup).

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 20: Workshop


Chapter 20 - Page 6
4. Restore a lost ASM disk group, with external redundancy.
Note: This scenario uses the ASMCMD md_backup command to create a backup of the
metadata for the DATA disk group at /u01/backup/oracle/dgbackupDATA, then drops
the DATA disk group.
a. Start the database. This error message is included in the error stack: ORA-15001:
diskgroup "DATA" does not exist or is not mounted
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

b. As grid OS user with the environment variables pointing to +ASM, use ASMCMD to
view the ASM disk groups by using the lsdg command.
$ asmcmd lsdg
c. Restore the DATA disk group with the md_restore command.
Note: This command restores the disk group to the original disks. This does not work if
the disks do not exist. The directory structure is also restored.
$ asmcmd md_restore --full -G data /u01/backup/orcl/dgbackupDATA
s a
Current Diskgroup metadata being restored: DATA
)h a
Diskgroup DATA created!
m
co eฺ
System template BACKUPSET modified!
o ฺ
o uid
System template FLASHFILE modified!
y a h
@
System template CHANGETRACKING modified!
n t G
k
ac tude
f r z
System template TEMPFILE modified!
A ( this S
System template ONLINELOG modified!
L
UA use
System template FLASHBACK modified!
O
H e to
System template CONTROLFILE modified!
C
T
0 ens
System template ASMPARAMETERFILE modified!
2
I le lic
%
System template DATAGUARDCONFIG modified!
L
ME erab
System template DATAFILE modified!
A
a r ie nsf
System template OCRFILE modified!

a c h -tra System template XTRANSPORT modified!


Z non System template PARAMETERFILE modified!
System template DUMPSET modified!
System template ARCHIVELOG modified!
System template AUTOBACKUP modified!
Directory +DATA/DB_UNKNOWN re-created!
Directory +DATA/ORCL re-created!
Directory +DATA/ASM re-created!
Directory +DATA/ORCL/ONLINELOG re-created!
Directory +DATA/ORCL/TEMPFILE re-created!
Directory +DATA/ORCL/CONTROLFILE re-created!
Directory +DATA/ORCL/DATAFILE re-created!
Directory +DATA/DB_UNKNOWN/PARAMETERFILE re-created!
Directory +DATA/ASM/ASMPARAMETERFILE re-created!

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 20: Workshop


Chapter 20 - Page 7
d. Because the data was not restored to the DATA disk group and only the structure was
restored, you must restore the SPFILE, control files, and all the data files. Start by
restoring the SPFILE.
Note: The autobackup recovery area depends on your own configuration.
e. Continue by restoring the control files. Depending on whether or not you placed a copy
of the control file on disk group FRA, you can restore from a single control file loss or all
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

control file loss. The REPAIR FAILURE PREVIEW command will provide additional
information.
f. Restore the data files.
g. Once the control file is restored and the database mounted, determine which redo log
groups should be cleared. Hint: ADVISE FAILURE will show which files are missing.
h. If there are multiplexed copies of the redo log files skip to Step i. There may one or
more redo log groups that were not archived or multiplexed. Proceed with an
incomplete recovery.
s a
− In SQL*Plus, clear the unarchived log file.
)h a
− In RMAN, restore the data file. m
− Recover the database. o ฺ co eฺ
a h o uid
− Open the database. (If the database was consistent when the ASM disk group was
@ y t G
lost, reset logs will not be necessary.)
k n
i. Recover the database.
f r z ac tude
j. A ( this S
If the multiplexed copies of the redo logs exist, then drop the missing redo log file
L
O UA use
members and add new log file members on the DATA disk group. Find the names of
the missing and existing files, DROP and ADD with the commands shown replacing the
C H e to
2 T
file names with names from your listings.
0 ens
WARNING: Be sure to drop the missing redo logs and not the existing logs.
L I le lic
%
A ME erab
Note: One of the groups will give an error that it is the current log file. Skip that one and
do all the others with your own group names, then use the ALTER SYSTEM SWITCH
a r ie nsf
LOGFILE command. Afterward DROP and ADD from the remaining log file group.
a c h $ sqlplus
n - tra / as sysdba
Z noSQL> ALTER DATABASE OPEN;
SQL> select group#, status, member from v$logfile;
SQL> ALTER DATABASE DROP LOGFILE MEMBER '
+DATA/orcl/onlinelog/group_n.nnn.nnnnnnnnn';
SQL> ALTER DATABASE ADD LOGFILE MEMBER '+DATA' TO GROUP n;

5. Recover a lost read-only tablespace.


Recovery of a lost read-only tablespace is the same as any other tablespace as long as the
control file correctly identifies the state of the tablespace. A complete recovery is possible, if
archive logs can be applied.

6. Recover a tablespace without a backup (in ARCHIVELOG mode).


Recovery of a tablespace without a backup is the same as any other tablespace as long as
the control file is current, that it has a record of the tablespace existence, and the archive
log files exist to recover to the current point-in-time.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 20: Workshop


Chapter 20 - Page 8
7. Recover a tablespace in NOARCHIVELOG mode.
Note: The database is in NOARCHIVELOG mode. A tablespace has been lost. A complete
recovery is not possible unless all the changes since the last backup are contained in the
online redo logs.
a. Diagnose the failure.
b. Determine the restores that are available.
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

Hint: Check the backups that are available by using the LIST BACKUP command.
There are two possible recovery paths: 1) Drop the missing tablespace or 2) Recover the
entire database to the time of the last backup. With option 1, you lose everything in the
single tablespace, and it must be re-entered by some other means. With option 2, you will
lose everything entered since the last backup. This is the option presented with the ADVISE
FAILURE command.
Option 1: Issue the following commands.
Note: The BARTBS tablespace has been lost. If the data is important it must be
s a
reconstructed by some other means. In this solution the database does not get a new
incarnation. )h a
m
co eฺ
$ sqlplus / as sysdba
o ฺ
SQL> ALTER DATABASE DATAFILE OFFLINE FOR DROP; ho id
y a G u
SQL> ALTER DATABASE OPEN;
c k @ ent
SQL> DROP TABLESPACE BARTBS INCLUDINGaCONTENTS d AND DATAFILES;
( frz s Stu
LA e thi
SQL> EXIT;
A
Option 2: Issue the following commands.
H OU to us
$ rman target /
0 T C se
RMAN> list failure;
I % 2 icen
RMAN> advise
E L ble lfailure;
RMAN> M repair a
A f e r failure;

a ie exit
rRMAN> n s
h r a
-trecovering the database execute the cleanup_20_07.sh script from the
Zac c.noAfter
n
/home/oracle/workshops directory.

8. Recover the control file using the control file trace file.
The scenario creates a control file trace at /u01/backup/orcl/control.trc. The
controlfile autobackup is not available.
a. Start the database instance by using SQL*Plus and determine the failure.
b. Determine that all the control files are missing by viewing the alert_orcl.log file.
c. Use amscmd ls +DATA/ORCL/* to determine that all the other files are present.
d. Find the control file trace file and make a copy to control.sql. Edit the
control.sql file.
e. Make sure all the data files are listed including the data file for the BARTBS tablespace.
f. Because all the redo logs are still in place, use the Set #1 the NORESETLOGS case.
Note: The control files will be created in the locations specified in the initialization
parameter file.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 20: Workshop


Chapter 20 - Page 9
g. Confirm that the files named in the various statements exist. Use asmcmd ls or the
ls OS command to check.
h. Delete or comment out all the commands for Set #2. RESETLOGS case.
i. Confirm that the database is shut down.
$ cd /backup/orcl
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

$ sqlplus / as sysdba
SQL> shutdown
j. Execute the control.sql file.
SQL> @control.sql
k. If the script fails, check the file existence again and correct the script. HINT: The online
log files may be in the ASM diskgroups.
l. Check that the database is in ARCHIVELOG mode.
SQL> archive log list
s a
a
) h the
m. At this point, check the incarnation table and the backups that are recorded. Check
m
co eฺ
controlfile autobackup configuration. Check that all the tablespaces are correctly
configured. o ฺ
o uid
y a h
$ rman target /
@ n t G
RMAN> list incarnation; k
ac tude
f r z
A ( this S
RMAN> list backup summary;
L
UA use
RMAN> show controlfile autobackup;
RMAN> report schema; O
H e to
T C
using target database
% 2 c ns for file
0 econtrol instead of recovery catalog

L I le li
Report of database schema database with db_unique_name ORCL

A ME erab
rList f
ie ofnPermanent
s Datafiles
c a tra
h ===========================
a n -
Z noFile Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ---------------------
-
1 800 SYSTEM ***
+DATA/orcl/datafile/system01.dbf
2 800 SYSAUX ***
+DATA/orcl/datafile/sysaux01.dbf
3 165 UNDOTBS1 ***
+DATA/orcl/datafile/undotbs01.dbf
4 5 USERS ***
+DATA/orcl/datafile/users01.dbf
5 357 EXAMPLE ***
+DATA/orcl/datafile/example01.dbf
6 10 BARTBS ***
/u01/app/oracle/oradata/orcl/BARtbs01.dbf

List of Temporary Files


Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 20: Workshop


Chapter 20 - Page 10
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- -----------------
-
1 20 TEMP 32767
+DATA/orcl/tempfile/temp.265.743260495
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

n. After this practice execute /home/oracle/workshop/cleanup_20_08.sh. This


script includes a new backup.

Scenarios:
For the following scenarios, diagnose the failure and perform the recovery. There are minimal
hints.
9. Loss of tablespace and current redo log file group
This scenario will require an incomplete recovery followed by a new backup. s a
)h a
c m
o ฺthe
10. Recover from the loss of all control files and a tablespace. This will requireฺrestoring
control file from a backup set.
h o
o uide
a
y backups
This scenario requires that there is a backup of the control file. Either G must be
k @ e n t
done INCLUDING CONTROLFILE or with the CONTROLFILE
z a c it requires
d
AUTOBACKUP
u
ON. It is
possible to restore using a control file backup to trace,
( but t
fr sIn allScases a complete
that you know the
L A
location of the data files belonging to the lost tablespace.
t h i recovery
is possible.
O UA use
C H e to
2 0
11. Loss of all control files, and Ta s dropped and re-created since the last backup.
tablespace
n
Hint: The creation of%
I the tablespace
l e
ic is visible in the alert log.
L l e
A ME erwith ab backups that have not been cataloged. Recover using an
12. Loss of a f
tablespace
rie abackup n s set.
h a
uncataloged
r
Zac The o n -t creates a copy of backup files in the /u01/backup/alt directory.
setup
n
Hint: Catalog the existing backup files, then recover using the REPAIR FAILURE
command.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 20: Workshop


Chapter 20 - Page 11
Unauthorized reproduction or distribution prohibitedฺ Copyright© 2016, Oracle and/or its affiliatesฺ

s a
)h a
m
co eฺ
o ฺ
o uid
y a h
@ n t G
k
ac tude
f r z
L A ( this S
O UA use
C H e to
2 T
0 ens
L I le lic
%
A ME erab
a r ie nsf
a c h -tra
Z non

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Practices for Lesson 20: Workshop


Chapter 20 - Page 12

You might also like