0% found this document useful (0 votes)
145 views127 pages

Oracle Database 12c Administration Workshop

The document provides an overview of an Oracle Database 12c administration workshop including the course content, requirements, objectives and exploring the Oracle database architecture such as the database instance configurations, connecting to the database instance, and Oracle database memory structures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
145 views127 pages

Oracle Database 12c Administration Workshop

The document provides an overview of an Oracle Database 12c administration workshop including the course content, requirements, objectives and exploring the Oracle database architecture such as the database instance configurations, connecting to the database instance, and Oracle database memory structures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 127

Oracle Database 12c:

Administration Workshop

Done by
Course Content
• Introduction
• Exploring Oracle Database Architecture
• Create Oracle Database
• Configuring the Oracle Network Environment
• Managing the Database Instance
• Managing User Security
• Managing Database Storage Structures
• Implementing Oracle Database Auditing
• Backup and Recovery: Concepts & Configuration
• Performing Database Backups & Recovery
• Improving Your Backups
• Moving Data
Requirements

The following prerequisite is required prior attending this


Oracle classes:
• You should have a knowledge of Oracle SQL
• 60 GB free space to install oracle and doing backup exercises.
• Minimum 8 GB RAM
• VMware Workstation 15.1.0 or later
Introduction
• The course provides a knowledge about the architecture of Oracle
Database and oracle database tools . The students will learn about
Oracle Database objects and maintenance of Database.
• The Oracle Administration includes the creation and managing the
databases. There will be practical exercises given to the participants
as well.
• By undergoing this training course the candidates will learn managing
database instance, redo and undo logs. The Participants will learn to
perform and manage backup of database. The management of control
file, redo and undo logs, auditing, database instances are also covered
in this training course.

Oracle Database 12c: Administration Workshop


Introduction -1
Course Objectives
• After completing this course, you should be able to:
• Describe Oracle Database architecture
• Configure the database to support your applications
• Manage database security and implement auditing
• Implement basic backup and recovery procedures
• Move data between databases and files
• Employ basic monitoring procedures and manage performance

Oracle Database 12c: Administration Workshop


Introduction -2
Exploring Oracle Database Architecture
Oracle Database Server Architecture
• There are three major structures in
Instance Oracle Database server
architecture: memory structures,
Memory Structures process structures, and storage
(System Global Area) structures. A basic Oracle
database system consists of an
Server
Process Structures Oracle database and a database
instance.
• The instance consists of memory
structures and background
Database (Storage Structures)
processes associated with that
instance.

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 1
Oracle Database Instance Configurations

• Each database instance is associated


Clustered System with one and only one database. If there
Nonclustered System
are multiple databases on the same
server, then there is a separate and
I1
I1 I2 I3
distinct database instance for each
I2 database. A database instance cannot
be shared. A Real Applications Cluster
D1 (RAC) database usually has multiple
instances on separate servers for the
D2Storage
same shared database. In this model,
Local D the same database is associated with
each RAC instance, which meets the
Shared Storage
requirement that, at most, only one
database is associated with an instance.

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 2
Connecting to the Database Instance

• Connection: Communication between a user process and an instance


• Session: Specific connection of a user to an instance through a user process

User Server
SQL> Select … process process
User
Session

Connection

Session

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 3
Oracle Database Memory Structures

•Oracle Database creates and uses memory structures for


various purposes. For example, memory stores program
code being run, data that is shared among users, and
private data areas for each connected user.
•Two basic memory structures are associated with an
instance:
• System Global Area (SGA): Group of shared memory
structures, known as SGA components, that contain data
and control information for one Oracle Database instance.
The SGA is shared by all server and background
processes. Examples of data stored in the SGA include
cached data blocks and shared SQL areas.
• Program Global Areas (PGA): Memory regions that
contain data and control information for a server or
background process. A PGA is nonshared memory created
by Oracle Database when a server or background
process is started. Access to the PGA is exclusive to the
server process. Each server process and background
process has its own PGA.

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 4
Shared Pool

The data dictionary is a collection of database tables and views


• Library cache containing reference information about the database, its
structures, and its users. Oracle Database accesses the data
• Shared SQL area Shared
Data Dictionary
Cache dictionary frequently during SQL statement parsing. This access
SQL
• Data dictionary cache Area Server Result is essential to the continuing operation of Oracle Database.
Cache

• Server result cache A shared SQL area contains the parse tree and execution plan
Other
for a given SQL statement. Oracle Database saves memory by
Library
Reserved Pool using one shared SQL area for SQL statements run multiple
Database
Shared pool
Cache
buffer
Redo log times, which often happens when many users run the same
buffer
cache application.
The server result cache contains the SQL query result cache
Streams
Large pool Java pool
pool
Fixed SGA and PL/SQL function result cache, which share the same
infrastructure. The server result cache contains result sets, not
System Global Area (SGA) data blocks.
The reserved pool is a memory area in the shared pool that
Oracle Database can use to allocate large contiguous chunks
of memory.

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 5
Database Buffer Cache

• Is part of the SGA •The database buffer cache is the portion of the SGA that holds
block images read from the data files or constructed dynamically to
• Holds copies of data blocks that are read from data files satisfy the read consistency model. All users who are concurrently
• Is shared by all concurrent users connected to the instance share access to the database buffer
cache.
•The first time an Oracle Database user process requires a particular
Keep pool
piece of data, it searches for the data in the database buffer cache.
Recycle Database If the process finds the data already in the cache (a cache hit), it
Redo log
pool Shared pool buffer
buffer
can read the data directly from memory. If the process cannot find
cache the data in the cache (a cache miss), it must copy the data block
nK buffer
cache from a data file on disk into a buffer in the cache before accessing
Java pool
Streams the data. Accessing data through a cache hit is faster than
Large pool Fixed SGA
pool accessing data through a cache miss.
• The keep buffer pool and the recycle buffer pool are used for
System Global Area (SGA) specialized buffer pool tuning. The keep buffer pool is designed to
retain buffers in memory longer than the LRU would normally
retain them. The recycle buffer pool is designed to flush buffers
from memory faster than the LRU normally would.

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 6
Redo Log Buffer

•Is a circular buffer in the SGA •The redo log buffer is a circular buffer in the
•Holds information about changes made to the database SGA that holds information about changes
•Contains redo entries that have the information to redo made to the database. This information is
changes made by operations such as DML and DDL stored in redo entries. Redo entries contain the
information necessary to reconstruct (or redo)
changes that are made to the database by
Database
Redo log
DML, DDL, or internal operations. Redo entries
Shared pool buffer
cache
buffer are used for database recovery if necessary.
•As the server process makes changes to the
Redo log
Large pool Java pool
Streams
pool
Fixed SGA buffer cache, redo entries are generated and
buffer
written to the redo log buffer in the SGA. The
System Global Area (SGA) redo entries take up continuous, sequential
space in the buffer. The log writer background
process writes the redo log buffer to the active
redo log file (or group of files) on disk.

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 7
Large Pool

• Provides large memory allocations for:


The database administrator can configure an
• Session memory for the shared server and the Oracle XA optional memory area called the large pool to
interface
• I/O server processes
provide large memory allocations for:
• Oracle Database backup and restore operations • Session memory for the shared server and the
Oracle XA interface (used where transactions
interact with multiple databases)
Database Redo log • I/O server processes
buffer
Shared pool buffer
cache I/O RECYCLE
buffer
Free
memory
Parallel
Query
• Oracle Database backup and restore
buffer pool
Streams
Response Request Advanced operations
Large pool Java pool Fixed SGA queue
queue Queuing
pool
Large pool
• Parallel Query operations
System Global Area (SGA)
• Advanced Queuing memory table storage

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 8
Program Global Area (PGA)

The Program Global Area (PGA) is a private memory region containing


data and control information for a server process
Every PGA contains stack space. In a dedicated server environment,
each user connecting to the database instance has a separate server
process. For this type of connection, the PGA contains a subdivision of
memory known as the user global area (UGA). The UGA is composed of
the following:
• Cursor area for storing runtime information on cursors
• User session data storage area for control information about a
session
• SQL working areas for processing SQL statements consisting of:
- A sort area for functions that order data such as ORDER BY
and GROUP BY
- A hash area for performing hash joins of tables
- A create bitmap area used in bitmap index creation common to
data warehouses
- A bitmap merge area used for resolving bitmap index plan
execution
In a shared server environment, multiple client users share the server
process. In this model, the UGA is moved into the SGA (shared pool or
large pool if configured) leaving the PGA with only stack space.

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 9
Quiz

The memory region that contains data and control information


for a server or background process is called:

a. Shared pool
b. PGA
c. Buffer cache
d. User session data

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 10
Answer: b

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 11
Quiz

What is read into the database buffer cache from data files?

a. Rows
b. Changes
c. Blocks
d. SQL

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 12
Answer: c

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 13
Process Architecture

User process • Dedicated server: For each session, the


• Is the application or tool that connects database application is run by a user
to the Oracle database process that is served by a dedicated
server process that executes Oracle
Database processes database server code.
• Server process: Connects to the Oracle • Shared server: Eliminates the need for
instance and is started when a user a dedicated server process for each
establishes a session connection. A dispatcher directs
• Background processes: Are started multiple incoming network session
when an Oracle instance is started requests to a pool of shared server
Daemon / Application processes processes. A shared server process
serves any client request
• Networking listeners
Oracle Database 12c: Administration Workshop
Exploring Oracle Database Architecture 14
Process Structures

Server Processes
Oracle Database creates server processes to handle the requests
Instances (ASM and Database separate) of user processes connected to the instance. The user process
represents the application or tool that connects to the Oracle
System Global Area (SGA) database. It may be on the same machine as the Oracle
PGA database, or it may exist on a remote client and use a network
Server
process Background processes to reach the Oracle database. The user process first
Required: DBWn CKPT LGWR communicates with a listener process that creates a server
Listener
SMON PMON process in a dedicated environment.
RECO
LREG
Server processes created on behalf of each user’s application can
MMON MMNL perform one or more of the following:
Others
Grid Infrastructure Processes • Parse and run SQL statements issued through the application.
Optional: ARCn Others
(ASM and Oracle Restart) • Read necessary data blocks from data files on disk into the
User ohas ocssd
shared database buffers of the SGA (if the blocks are not
process diskmon already present in the SGA).
orarootagent oraagent cssdagent • Return results in such a way that the application can process
the information.

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 15
Process Structures

Writes modified (dirty) buffers in the database buffer cache to • The Database Writer process
disk:
(DBWn) writes the contents of
• Asynchronously while performing other processing buffers to data files. The DBWn
• To advance the checkpoint processes are responsible for
writing modified (dirty) buffers in
the database buffer cache to disk.
Although one Database Writer
DBWn
process (DBW0) is adequate for
Database buffer Database Witer Data files
most systems, you can configure
cache process
additional processes to improve
write performance

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 16
Log Writer Process (LGWR)
•The Log Writer process (LGWR) is responsible for
Writes the redo log buffer to a redo log file on disk
redo log buffer management by writing the redo log
• When a user process commits a transaction buffer entries to a redo log file on disk. LGWR writes
• When an online redo log switch occurs all redo entries that have been copied into the buffer
• When the redo log buffer is one-third full or contains 1 MB of buffered since the last time it wrote.
data
•LGWR starts and coordinates multiple helper
• Before a DBWn process writes modified buffers to disk processes that concurrently perform some of the
• When three seconds have passed since the last write work. LGWR handles the operations that are very
• Serves as coordinator of LGnn processes and ensures correct order for fast, or must be coordinated, and delegates
operations that must be ordered operations to the LGnn that could benefit from
concurrent operations, primarily writing the redo
from the log buffer to the redo log file and posting
LGWR the completed write to the foreground process that
Redo log
buffer is waiting.
LGnn

LGnn Redo log files

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 17
Checkpoint Process (CKPT)

Records checkpoint information in •A checkpoint is a data structure that defines a


- Control file system change number (SCN) in the redo
thread of a database. Checkpoints are
- Each data file header
recorded in the control file and in each data file
Signals DBWn to write blocks to disk header. They are a crucial element of
recovery.
•When a checkpoint occurs, Oracle Database must
update the headers of all data files to record the
details of the checkpoint. This is done by the CKPT
process. The CKPT process does not write blocks
CKPT Control file to disk; DBWn always performs that work. The
SCNs recorded in the file headers guarantee that
Checkpoint
process
all changes made to database blocks before that
SCN have been written to disk.
Data files

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 18
System Monitor Process (SMON)

• Performs recovery at instance startup • The System Monitor process (SMON)


performs recovery at instance startup if
• Cleans up unused temporary segments necessary. SMON is also responsible for
cleaning up temporary segments that are no
longer in use. If any terminated transactions
were skipped during instance recovery
because of file-read or offline errors, SMON
recovers them when the tablespace or file is
SMON
Instance
brought back online.
System Monitor
• SMON checks regularly to see whether the
process
process is needed. Other processes can call
Temporary
SMON if they detect a need for it.
segment

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 19
Process Monitor Process (PMON)

•Performs process recovery when a user process fails •The Process Monitor process (PMON) performs
process recovery when a user process fails.
•Cleans up the database buffer cache PMON is responsible for cleaning up the database
•Frees resources that are used by the user process buffer cache and freeing resources that the user
process was using. For example, it resets the
•Monitors sessions for idle session timeout status of the active transaction table, releases
locks, and removes the process ID from the list of
active processes.
Server •PMON periodically checks the status of
process
dispatcher and server processes, and restarts any
that have stopped running (but not any that
PMON
Oracle Database has terminated intentionally).
User
Database buffer
•Like SMON, PMON checks regularly to see
whether it is needed; it can be called if another
Failed user process Process Monitor
cache
process

process detects the need for it.

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 20
Listener Registration Process (LREG)

•The Listener Registration process, LREG, registers


• Registers information about the database information about the database instance and dispatcher
processes with the Oracle Net Listener. LREG provides the
instance and dispatcher processes with the listener with the following information:
• Names of the database services
Oracle Net Listener • Name of the database instance associated with the
services and its current and maximum load
• Service handlers (dispatchers and dedicated servers)
Instance available for the instance, including their type, protocol
addresses, and current and maximum load
•When the instance starts, LREG attempts to connect to the
Memory Structures listener. If the listener is running, LREG passes information
(System Global Area) to it. If the listener is not running, LREG periodically
attempts to connect to it. It may take up to 60 seconds for
LREG to register the database instance with the listener
Process Structures after the listener has started.
LREG listener •You can use the ALTER SYSTEM REGISTER command
to immediately initiate service registration after starting
the listener.

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 21
Archiver Processes (ARCn)

• Copy redo log files to a designated storage device after a log •The Archiver processes (ARCn) copy redo
switch has occurred log files to a designated storage device
after a log switch has occurred. ARCn
• Can collect transaction redo data and transmit that data to
processes are present only when the
standby destinations
database is in ARCHIVELOG mode and
automatic archiving is enabled.
•If you anticipate a heavy workload for
archiving (such as during bulk loading of
ARCn data), you can increase the maximum
number of Archiver processes. There can
Archiver process Copies of redo log
files
Archive destination
also be multiple archive log destinations. It
is recommended that there be at least one
Archiver process for each destination. The
default is to have four Archiver processes.
Oracle Database 12c: Administration Workshop
Exploring Oracle Database Architecture 22
Archiver Processes (ARCn)

The files that comprise an Oracle database are as follows:


• Control files: Each database has one unique control file that contains data about the
database itself (that is, physical database structure information). Multiple copies may be
maintained to protect against total loss. It can also contain metadata related to backups.
The control file is critical to the database. Without the control file, the database cannot be
opened.
• Data files: Contain the user or application data of the database, as well as metadata
and the data dictionary
Control files Data files Online redo log files • Online redo log files: Allow for instance recovery of the database. If the database server
crashes and does not lose any data files, the instance can recover the database with the
information in these files.
•The following additional files are used during the operation of the database:
• Parameter file: Is used to define how the instance is configured when it starts up
• Password file: Allows users using the SYSDBA, SYSOPER, SYSBACKUP, SYSDG, SYSKM,
Parameter file Backup files Archived redo log and SYSASM roles to connect remotely to the instance and perform administrative tasks
files • Backup files: Are used for database recovery. You typically restore a backup file when a
media failure or user error has damaged or deleted the original file.
• Archived redo log files: Contain an ongoing history of the data changes (redo) that are
generated by the instance. Using these files and a backup of the database, you can
recover a lost data file.
Password file Alert log and trace files • Trace files: Each server and background process can write to an associated trace file.
When an internal error is detected by a process, the process dumps information about the
error to its trace file. Some of the information written to a trace file is intended for the
database administrator, whereas other information is for Oracle Support Services.

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 23
Oracle Container Database

A pluggable database (PDB) is a set of database schemas that


• Pluggable database: Is a set of database schemas appears logically to users and applications as a separate
that appears logically to users and applications as database. But at the physical level, the multitenant container
database (CDB) has a database instance and database files, just as
a separate database a non-container database does.
It is easy to plug non-CDBs into a CDB.
• Multitenant container database: Has a database
A CDB avoids redundancy of:
instance and database files at the physical level Background processes
Memory allocation
• All pluggable databases share:
Oracle metadata in several data dictionaries
- Background processes A CDB grouping several applications has one instance,
consequently one set of background processes, one SGA
allocation and one data dictionary in the root container, common
- Shared/process memory for all PDBs, each PDB maintaining its own application data
dictionary.
- Oracle metadata When applications need to be patched or upgraded, the
maintenance operation is performed only once on the CDB and,
consequently, all applications are updated at the same time.

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 24
Quiz

The Process Monitor process (PMON):

a. Performs recovery at instance startup


b. Performs process recovery when a user process fails
c. Automatically resolves all in-doubt transactions
d. Writes the redo log buffer to a redo log file

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 25
Answer: b

Oracle Database 12c: Administration Workshop


Exploring Oracle Database Architecture 26
Create Oracle Database

• Database creation prepares several operating Creating a database includes the


system files so they can work together as an following operations:
Oracle database. You need only create a • creating new datafiles or erasing
database once, regardless of how many data that existed in previous
datafiles it has or how many instances access datafiles
it. Creating a database can also erase • creating information structures that
information in an existing database and Oracle requires to access and use
create a new database with the same name the database (the data dictionary)
and physical structure.
• creating and initializing the control
files and redo log files for the
database
Oracle Database 12c: Administration Workshop
Create oracle database 1
Create Oracle Database

Ways to create new oracle database:


• Using the Database Configuration
Assistant
• Using the silent mode (shell script)
• Using backup & recovery
Note : The database installation will
be covered in the administration
guide in detail
Oracle Database 12c: Administration Workshop
Create oracle database 2
Configuring the Oracle Network Environment

• Oracle Net Services enables network


connections from a client or middle-tier
application to the Oracle server. After a
network session is established, Oracle
Application RDBMS Net acts as the data courier for both the
Oracle Net Oracle Net
client application and the database
TCP/IP
Client or network server. It is responsible for establishing
middle tier
Listener Database server and maintaining the connection between
the client application and database
server, as well as exchanging messages
between them. Oracle Net (or something
Oracle Net Oracle Net that simulates Oracle Net, such as Java
configuration files configuration files
Database Connectivity) is located on
each computer that needs to talk to the
database server.
Oracle Database 12c: Administration Workshop
Configuring the oracle network environment 1
Oracle Net Listener

•Oracle Net Listener (or simply the listener)


is the gateway to the Oracle instance for all
nonlocal user connections. A single
listener can service multiple database
instances and thousands of client
Enterprise Manager Listener connections.
Cloud Control or
Oracle Net Manager •You can use Enterprise Manager Cloud
Oracle databases
Control or Oracle Net Manager to configure
the listener and specify log file locations.
•Advanced administrators can also configure
Oracle Net
configuration files Oracle Net Services by manually editing the
<ORACLE_HOME> configuration files, if necessary, with a
/network/admin/
listener.ora
standard operating system (OS) text editor
. such as vi or gedit.
/
s
qOracle Database 12c: Administration Workshop
l Configuring the oracle network environment 2
Establishing Oracle Network Connections

To make a client or middle-tier connection, Oracle Net requires the client to


know the:
•For an application to connect to a service
• Host where the listener is running
through Oracle Net Listener, the
application must have information about
• Port that the listener is monitoring
that service, including the address or host
• Protocol that the listener is using
where the listener resides, the protocol
• Name of the service that the listener is handling
that the listener accepts, and the port that
the listener monitors. After the listener is
located, the final piece of information that
the application needs is the name of the
service to which it wants to connect.
Names resolution
•Oracle Net names resolution is the
process of determining this connection
information.
Oracle Database 12c: Administration Workshop
Configuring the oracle network environment 3
Using the Listener Control Utility

$ lsnrctl The Listener Control Utility enables you to control the listener. With
LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 09-JUL-2013 08:47:42 lsnrctl, you can:
Copyright (c) 1991, 2013, Oracle. All rights reserved.
• Start the listener
• Stop the listener
Welcome to LSNRCTL, type "help" for information.
• Check the status of the listener
LSNRCTL> help • Reinitialize the listener from the configuration file parameters
The following operations are available • Dynamically configure many listeners
An asterisk (*) denotes a modifier or extended command:
• Change the listener password
start stop status services • The basic command syntax for this utility is:
version reload save_config trace
• LSNRCTL> command [listener_name]
spawn quit exit set*
show* • When the lsnrctl command is issued, the command acts on the
default listener (named LISTENER) unless a different listener name
is specified or the SET CURRENT_LISTENER command is executed.
If the listener name is LISTENER, the listener_name argument can
be omitted. The valid commands for lsnrctl are shown in the slide.
• Note: The lsnrctl utility is located in both the Grid Infrastructure
home and the Oracle Database home. It is important to set the
environment variables to the appropriate home before using it.

Oracle Database 12c: Administration Workshop


Configuring the oracle network environment 4
Listener Control Utility Syntax

Commands for the Listener Control Utility •The lsnrctl commands can be issued from within the
can be issued from the command line or
from the lsnrctl prompt. utility (prompt syntax) or from the command line. The
following two commands have the same effect but use
Command-line syntax: command-line syntax and prompt syntax, respectively:
•Command-line syntax:
• $ lsnrctl start
•$ lsnrctl <command name> •Prompt syntax:
•$ lsnrctl start • $ lsnrctl
• LSNRCTL for Linux: Version 12.1.0.1.0 - Production on
•$ lsnrctl status 09-JUL-2013 08:47:42
• Copyright (c) 1991, 2013, Oracle. All rights
reserved. Welcome to LSNRCTL, type "help" for

Prompt syntax: information.


• LSNRCTL> start

•LSNRCTL> <command •The command-line syntax is typically used to execute an


individual command or scripted commands. If you plan to
name> LSNRCTL> execute several consecutive lsnrctl commands, the
prompt syntax is more efficient. Note that the
start listener_name argument is omitted, and the command
•LSNRCTL> status would thus affect the listener named LISTENER.

Oracle Database 12c: Administration Workshop


Configuring the oracle network environment 5
Testing Oracle Net Connectivity

•tnsping is the Oracle Net equivalent of


The tnsping utility that tests Oracle Net service aliases: the TCP/IP ping utility. It offers a quick test
• Ensures connectivity between the client and the
to verify that the network path to a
Oracle Net Listener
destination is good. For example, enter
• Does not verify that the requested service is available
tnsping orcl in a command-line
window.
• Supports Easy Connect Names Resolution:
•The utility validates that the host name, port,
tnsping host01.example.com:1521/orcl
and protocol reach a listener. It does not
• Supports local and directory naming: actually check whether the listener handles
tnsping orcl the service name. The tnsping utility also
reveals the location of the configuration files.
In a system with multiple ORACLE_HOME
locations, this can be helpful.

Oracle Database 12c: Administration Workshop


Configuring the oracle network environment 6
Quiz

Which configuration files are used to configure the listener?


a. listener.ora
b. listener.conf
c. tnsnames.ora
d. tnsnames.conf
e. sqlnet.ora
f. sqlnet.conf

Oracle Database 12c: Administration Workshop


Configuring the oracle network environment 7
Answer: a, e
Managing the Database Instance

Initialization Parameter Files When you start the instance, an initialization parameter file is read.
There are two types of parameter files.
• Server parameter file (SPFILE): This is the preferred type of
initialization parameter file. It is a binary file that can be written to and
read by the database server and must not be edited manually. It
resides on the server on which the Oracle instance is executing; it is
persistent across shutdown and startup. The default name of this file,
which is automatically sought at startup, is spfile<SID>.ora.
• Text initialization parameter file: This type of initialization parameter
file can be read by the database server, but it is not written to by the
server. The initialization parameter settings must be set and changed
manually by using a text editor so that they are persistent across
shutdown and startup. The default name of this file (which is
spfileorcl.ora
automatically sought at startup if an SPFILE is not found) is
init<SID>.ora.
or
•It is recommended that you create an SPFILE as a dynamic way to
initorcl.ora maintain initialization parameters.
•Note: The Oracle Database server searches the $ORACLE_HOME/dbs
directory on Linux for the initialization files.

Oracle Database 12c: Administration Workshop


Managing the Database Instance 1
Initialization Parameters: Examples

Parameter Specifies • CONTROL_FILES parameter: Specifies one or more control file names. Oracle
strongly recommends that you multiplex and mirror control files. Range of values:
from one to eight file names (with path names). Default value: OS dependent.
CONTROL_FILES One or more control file names
• DB_FILES parameter: Specifies the maximum number of database files that can be
DB_FILES opened for this database. Range of values: OS dependent. Default value: 200.
Maximum number of database files
• PROCESSES parameter: Specifies the maximum number of OS user processes that
PROCESSES Maximum number of OS user processes that can
can simultaneously connect to an Oracle server. This value should allow for all
simultaneously connect background processes and user processes. Range of values: from 6 to an OS-
dependent value. Default value: Dynamic and dependent on the number of CPUs.
DB_BLOCK_SIZE Standard database block size used by all • DB_BLOCK_SIZE parameter: Specifies the size (in bytes) of an Oracle database
tablespaces block. This value is set at database creation and cannot be subsequently changed.
This specifies the standard block size for the database. All tablespaces will use
DB_CACHE_SIZE Size of the standard block buffer cache this size by default. Range of values: 2048 to 32768 (OS-dependent). Default
value: 8192.
• DB_CACHE_SIZE parameter: Specifies the size of the default buffer pool. Range of
values: At least 4 MB times the number of CPUs (smaller values are automatically
rounded up to this value). Default value: 0 if SGA_TARGET is set, otherwise the
larger of 48 MB or (4 MB*CPU_COUNT).

Oracle Database 12c: Administration Workshop


Managing the Database Instance 2
Changing Initialization Parameter Values

There are two types of initialization parameters.


• Static parameters:
Static parameters: Affect the instance or entire database and can be
- Can be changed only in the parameter file modified only by changing the contents of the text initialization
parameter file or the server parameter file. Static parameters require the
- Require restarting the instance before taking effect database to be shut down and restarted to take effect. They cannot be
changed for the current instance.
• Dynamic parameters: Dynamic parameters: Can be changed while the database is online. There
are two types:
- Can be changed while database is online • Session-level parameters affect only a user session. Examples include
national language support (NLS) parameters that can be used to specify
- Can be altered at: national language settings for sorts, date parameters, and so on. You
can use these in a given session; they expire when the session ends.
- Session level • System-level parameters affect the entire database and all sessions.
Examples include modifying the SGA_TARGET value and setting archive
- System level log destinations. These parameters stay in effect based on the SCOPE
specification. To make them permanent, you have to add these
- Are valid for duration of session or based on SCOPE parameter settings to the server parameter file by specifying the
setting SCOPE=both option or manually editing the text initialization parameter
file.
- Are changed by using ALTER SESSION and ALTER SYSTEM • Dynamic parameters can be changed by using the ALTER SESSION and
ALTER SYSTEM commands.
commands

Oracle Database 12c: Administration Workshop


Managing the Database Instance 3
Changing Parameter Values: Examples

•The first statement in the slide is an example of


SQL> ALTER SESSION changing a session-level parameter. The user is
2 SET NLS_DATE_FORMAT ='mon dd yyyy'; setting the session date format to be mon dd yyyy.
As a result, any queries on the date will display
Session altered. dates in that format. Session-level parameters can
also be set in applications by using PL/SQL.
SQL> SELECT SYSDATE FROM dual;
•The second statement changes the maximum
SYSDATE number of failed login attempts before the
----------- connection is dropped. It includes a comment and
oct 17 2012 explicitly states that the change is to be made only
in the server parameter file. After the specified
SQL> ALTER SYSTEM SET
2 SEC_MAX_FAILED_LOGIN_ATTE
number of failure attempts, the connection is
MPTS=2 automatically dropped by the server process. This is
3 COMMENT='Reduce for not a dynamic parameter and the Oracle database
tighter security.' instance will need to be restarted before the change
4 SCOPE=SPFILE; can take effect
System altered.
Oracle Database 12c: Administration Workshop
Managing the Database Instance 4
Quiz

The majority of database parameters are dynamic and can be


changed without having to shut down the database instance.
a. True
b. False

Oracle Database 12c: Administration Workshop


Managing the Database Instance 5
Answer: a
Starting Up an Oracle Database Instance:
NOMOUNT

The database instance and database go through stages as the database is made available
for access by users. The database instance is started, the database is mounted, and then the
database is opened.
An instance is typically started only in NOMOUNT mode during database
creation, during re-creation of control files, or in certain backup and recovery
scenarios.
OPEN
When an instance is started, the following takes place:
STARTUP • Searching $ORACLE_HOME/dbs for a file of a particular name in this
sequence:
MOUNT 1. Search for spfile<SID>.ora.
2. If spfile<SID>.ora is not found, search for spfile.ora.
3. If spfile.ora is not found, search for init<SID>.ora.
This is the file that contains initialization parameters for the instance. Specifying
NOMOUNT the PFILE parameter with STARTUP overrides the default behavior.
• Allocating the SGA
Instance
• Starting the background processes
started
SHUTDOWN • Opening the alert_<SID>.log file and the trace files
Note: SID is the system ID, which identifies the instance name (for example, ORCL).

Oracle Database 12c: Administration Workshop


Managing the Database Instance 7
Starting Up an Oracle Database Instance:
MOUNT

Mounting a database includes the following:


• Associating a database with a previously started instance
• Locating and opening all the control files specified in the
parameter file
OPEN • Reading the control files to obtain the names and statuses of
STARTUP the data files and online redo log files. (However, no checks
are performed to verify the existence of the data files and
online redo log files at this time.)
MOUNT To perform specific maintenance operations, start an instance
and mount a database, but do not open the database.
Control file For example, the database must be mounted but must not be
opened for this opened during the following tasks:
• Renaming
NOMOUNT instance be renameddata files.
when the(Data files for
database an offline tablespace can
is open.)
• Enabling and disabling online redo log file archiving options
Instance • Performing full database recovery
started Note: A database may be left in MOUNT mode even though an
SHUTDOWN OPEN request has been made. This may be because the
database needs to be recovered in some way. If recovery is
performed while in the MOUNT state, the redo logs are open for
reads and the data files are open as well to read the blocks
needing recovery and to write blocks if required during recovery.

Oracle Database 12c: Administration Workshop


Managing the Database Instance 8
Starting Up an Oracle Database Instance:
OPEN

A normal database operation means that an instance is


started and the database is mounted and opened. With a
normal database operation, any valid user can connect to the
database and perform typical data access operations.
OPEN
Opening the database includes the following:
STARTUP All files opened as
• Opening the data files
described by the control
MOUNT file for this instance • Opening the online redo log files
If any of the data files or online redo log files are not present
Control file
opened for this
when you attempt to open the database, the Oracle server
NOMOUNT instance returns an error.
During this final stage, the Oracle server verifies that all data
Instance files and online redo log files can be opened, and checks the
started consistency of the database. If necessary, the System Monitor
SHUTDOWN
(SMON) background process initiates instance recovery.
You can start up a database instance in restricted mode so
that only Oracle Database users with the RESTRICTED
SESSION system privilege can connect to the database.

Oracle Database 12c: Administration Workshop


Managing the Database Instance 9
Startup Options: Examples

The slide shows the SQL*Plus syntax to start up the


database.
• Using the SQL*Plus utility: 1.This command starts the instance, associates the
SQL> startup
database files to it, and mounts and opens the
database.
2.This command starts the instance and the database
1
is not mounted.
3.This command mounts a database from the
SQL> startup nomount NOMOUNT state.
4.This command opens the database from the MOUNT
2
SQL> alter database open; 4 state.
When the database is enabled with Oracle Restart, the
• Using thealter
SQL> Serverdatabase
Control utility with Oracle Restart
mount; Server Control (SRVCTL) utility can be used to start
$ srvctl start database –d orcl –o mount
the database instance. The SRVCTL utility has the
advantage that it can also start all required dependent
3
resources such as the ASM instance, ASM disk
groups, and listener.
Oracle Database 12c: Administration Workshop
Managing the Database Instance 11
Shutdown Modes

Shutdown Modes A I T N Shutdown modes are progressively more accommodating of


current activity in this order:
Allows new connections No No No No
• ABORT: Performs the least amount of work before shutting
Waits until current sessions end No No No Yes down. Because this mode requires recovery before startup,
use it only when necessary. It is typically used when no other
Waits until current transactions end No No Yes Yes
form of shutdown works, when there are problems with
Forces a checkpoint and closes files No Yes Yes Yes starting the instance, or when you need to shut down
immediately because of an impending situation (such as
notice of a power outage within seconds).
• IMMEDIATE: Is the most typically used option. Uncommitted
Shutdown modes: transactions are rolled back.
• A = ABORT • TRANSACTIONAL: Allows existing transactions to finish, but
• I = IMMEDIATE does not allow new transactions to start
• T = TRANSACTIONAL • NORMAL: Waits for sessions to disconnect
• N = NORMAL If you consider the amount of time that it takes to perform the
shutdown, you find that ABORT is the fastest and NORMAL is
the slowest. NORMAL and TRANSACTIONAL can take a long
time depending on the number of sessions and transactions.

Oracle Database 12c: Administration Workshop


Managing the Database Instance 12
Shutdown Options

SHUTDOWN NORMAL
NORMAL is the default shutdown mode if no mode is specified. A normal database shutdown
proceeds with the following conditions:
On the way down: During: On the way up: • No new connections can be made.
• The Oracle server waits for all users to disconnect before completing the shutdown.
• Uncommitted • No instance • Database and redo buffers are written to disk.
SHUTDOWN
changes rolled NORMAL
recovery • The Oracle server closes and dismounts the database before shutting down the instance.
back, for or • The next startup does not require an instance recovery.
IMMEDIATE SHUTDOWN SHUTDOWN TRANSACTIONAL
TRANSACTIO A shutdown in TRANSACTIONAL mode prevents clients from losing data, including results from
• Database buffer their current activity. A transactional database shutdown proceeds with the following
NAL conditions:
cache written or • No client can start a new transaction on this particular instance.
to data files SHUTDOWN • A client is disconnected when the client ends the transaction that is in progress.
• Resources IMMEDIATE • When all transactions have been completed, a shutdown occurs immediately.
released • The next startup does not require an instance recovery.
SHUTDOWN IMMEDIATE
A shutdown in IMMEDIATE mode proceeds with the following conditions:
• Current SQL statements being processed by the Oracle database are not completed.
Consistent database • The Oracle server does not wait for the users who are currently connected to the database
to disconnect.
• The Oracle server rolls back active transactions and disconnects all connected users.
• The Oracle server closes and dismounts the database before shutting down the instance.
• The next startup does not require an instance recovery.

Oracle Database 12c: Administration Workshop


Managing the Database Instance 13
Shutdown Options

On the way down: During: On the way up: SHUTDOWN ABORT


• Modified buffers • Online redo If shutdown in NORMAL, TRANSACTIONAL, and IMMEDIATE
SHUTDOWN ABORT
not written to or
log files used modes does not work, you can abort the current database
data files Instance failure to reapply instance. Aborting an instance proceeds with the following
• Uncommitted or changes conditions:
STARTUP • Current SQL statements being processed by the Oracle
changes not FORCE
• Undo
rolled back segments server are immediately terminated.
used to roll • The Oracle server does not wait for users who are currently
back connected to the database to disconnect.
uncommitted • Database and redo buffers are not written to disk.
changes • Uncommitted transactions are not rolled back.
• Resources • The instance is terminated without closing the files.
Inconsistent database released • The database is not closed or dismounted.
• The next startup requires instance recovery, which occurs
automatically.
Note: It is not advisable to back up a database that is in an
inconsistent state.
Oracle Database 12c: Administration Workshop
Managing the Database Instance 14
Shutdown Options: Examples

The slide shows examples using both SQL*Plus and


the SRVCTL utility to shut down the database.
• Using SQL*Plus: • This command initiates a normal shutdown. The
SQL> shutdown
database will not shut down until all users have
logged out.
1 • This command initiates a transactional
shutdown. The database will not shut down until
SQL> shutdown transactional
all existing transactions are completed.
• This command initiates an immediate shutdown.
2 Uncommitted transactions will be rolled back.
SQL> shutdown abort 4
• This command initiates a shutdown abort.
• SQL>
Using theshutdown immediate
SRVCTL utility with Oracle Restart When the database is enabled with Oracle Restart,
$ srvctl stop database –d orcl –o abort the SRVCTL utility can be used to shut down the
3 database instance.

Oracle Database 12c: Administration Workshop


Managing the Database Instance 15
Managing User Security

Database User Accounts • To access the database, a user must specify a valid
database user account and successfully authenticate as
required by that user account. Each database user has a
unique database account.
Each database user account has:
• Unique username: Usernames cannot exceed 30 bytes,
• A unique username cannot contain special characters, and must start with a
• An authentication method letter.
• A default tablespace • Authentication method: The most common authentication
method is a password. Oracle Database supports
• A temporary tablespace password, global, and external authentication methods
• A user profile (such as biometric, certificate, and token authentication).
• An account status • Default tablespace: This is a place where a user creates
objects if the user does not specify some other tablespace.
A schema: • Temporary tablespace: This is a place where temporary
• Is a collection of database objects that are owned by objects, such as sorts and temporary tables, User profile:
a database user This is a set of resource and password restrictions
assigned to the user.
• Has the same name as the user account
• Account status: Users can access only “open” accounts.
The account status may be “locked” and/or “expired.”

Oracle Database 12c: Administration Workshop


Managing User Security 1
Predefined Administrative Accounts

• SYS: •The SYS and SYSTEM accounts have the database


– Owns the data dictionary and the Automatic Workload administrator (DBA) role granted to them by default. In
Repository (AWR) addition, the SYS account has all privileges with ADMIN
– Used for startup and shutdown of the database instance OPTION and owns the data dictionary. To connect to
the SYS account, you must use the AS SYSDBA clause
• SYSTEM: Owns additional administrative tables and views
for a database instance and AS SYSASM for an
• SYSBACKUP: Facilitates Oracle Recovery Manager Automatic Storage Management (ASM) instance. Any
(RMAN) backup and recovery operations user that is granted the SYSDBA privilege can connect to
• SYSDG: Facilitates Oracle Data Guard operations the SYS account by using the AS SYSDBA clause.
• SYSKM: Facilitates Transparent Data Encryption wallet Only “privileged” users who are granted the SYSDBA,
operations SYSOPER, or SYSASM privileges are allowed to start up
and shut down instances. The SYSTEM account does
not have the SYSDBA privilege. SYSTEM is also
granted the AQ_ADMINISTRATOR_ROLE and
MGMT_USER roles. The SYS and SYSTEM accounts are
required accounts in the database.
•They cannot be dropped.

Oracle Database 12c: Administration Workshop


Managing User Security 2
Creating and managing a User

• Use the CREATE USER statement to


create and configure a database
• Using SQL*Plus:
user, which is an account through
SQL> create user user_name identified by “PASSWORD”;
which you can log in to the
SQL> grant create session to user_name
database, and to establish the
SQL> alter user user_name quota unlimited on means by which Oracle Database
tablespace_name
permits access by the user.
IDENTIFIED Clause
• The IDENTIFIED clause lets you
indicate how Oracle Database
authenticates the user.
Oracle Database 12c: Administration Workshop
Managing User Security 3
Privileges

There are two types of user privileges:


• System: Enables users to perform particular actions in the A privilege is a right to execute a particular type of SQL
database statement or to access another user’s object.
• Object: Enables users to access and manipulate a specific Privileges are divided into two categories:
object • System privileges: Each system privilege allows a user to
perform a particular database operation or class of
database operations. For example, the privilege to create
tablespaces is a system privilege. System privileges can be
granted by the administrator or by someone who has been
given explicit permission to administer the privilege. There
are more than 170 distinct system privileges. Many system
privileges contain the ANY clause.
HR_DBA
• Object privileges: Object privileges allow a user to perform a
particular action on a specific object, such as a table, view,
Object privilege: System privilege:
sequence, procedure, function, or package. Without specific
Update employees Create session
permission, users can access only their own objects. Object
privileges can be granted by the owner of an object, by the
administrator, or by someone who has been explicitly given
permission to grant privileges on the object.

Oracle Database 12c: Administration Workshop


Managing User Security 4
Revoking System Privileges
with ADMIN OPTION

System privileges that have been granted directly with a GRANT


command can be revoked by using the REVOKE SQL statement. Users
DBA with ADMIN OPTION for a system privilege can revoke the privilege from
Joe any other database user.
User
Emily
The slide illustrates the following situation.
GRANT
Privilege Scenario
• The DBA grants the CREATE TABLE system privilege to Joe with ADMIN
OPTION.
Object
• Joe creates a table.
DBA Joe Emily
REVOKE • Joe grants the CREATE TABLE system privilege to Emily.

REVOKE CREATE • Emily creates a table.


TABLE FROM joe; • The DBA revokes the CREATE TABLE system privilege from Joe.
Result
Joe’s table still exists, but Joe cannot create new tables. Emily’s table still
exists, and she still has the CREATE TABLE system privilege.
Oracle Database 12c: Administration Workshop
Managing User Security 5
Revoking System Privileges
with GRANT OPTION

Cascading effects can be observed when revoking a system privilege


that is related to a data manipulation language (DML) operation. For
Bob Joe Emily example, if the SELECT ANY TABLE privilege is granted to a user, and if
GRANT that user has created procedures that use the table, all procedures
that are contained in the user’s schema must be recompiled before
they can be used again.
Revoking object privileges also cascades when given with GRANT
OPTION. As a user, you can revoke only those privileges that you have
REVOKE Bob Joe Emily granted. For example, Bob cannot revoke the object privilege that Joe
granted to Emily. Only the grantee or a user with the privilege called
GRANT ANY OBJECT PRIVILEGE can revoke object privileges.
Scenario
• Joe is granted the SELECT object privilege on EMPLOYEES with
GRANT OPTION.
• Joe grants the SELECT privilege on EMPLOYEES to Emily.
• The SELECT privilege is revoked from Joe. This revoke is cascaded to
Emily as well.
Oracle Database 12c: Administration Workshop
Managing User Security 6
Assigning Privileges to Roles and Assigning Roles to
Users

•In most systems, it is time-consuming and error-prone to grant


necessary privileges to each user individually. Oracle software
provides for easy and controlled privilege management through roles.
Roles are named groups of related privileges that are granted to users
Users or to other roles. Roles are designed to ease the administration of
Jenny David Rachel privileges in the database and, therefore, improve security.
•Role characteristics
• Privileges are granted to and revoked from roles as though the role
Roles HR_MGR HR_CLERK were a user.
• Roles are granted to and revoked from users or other roles as though
they were system privileges.
• A role can consist of both system and object privileges.
Delete Create Update • A role can be enabled or disabled for each user who is granted the
Privileges role.
employees. Job. employees.
• A role can require a password to be enabled.
Insert Select • Roles are not owned by anyone, and they are not in any schema.
•In the slide example, the SELECT and UPDATE privileges on the
employees. employees.
employees table and the CREATE JOB system privilege are granted
to the HR_CLERK role. DELETE and INSERT privileges on the
employees table and the HR_CLERK role are granted to the HR_MGR
role. The manager is granted the HR_MGR role and can now select,
delete, insert, and update the employees table.

Oracle Database 12c: Administration Workshop


Managing User Security 7
Creating a Role

Secure Roles Roles are usually enabled by default, which means that if a role is
granted to a user, then that user can exercise the privileges given to
the role. Default roles are assigned to the user at connect time.
It is possible to:
• Roles can be nondefault and enabled when required. • Make a role nondefault. The user must now explicitly enable the
SET ROLE vacationdba; role before the role’s privileges can be exercised.
• Have a role require additional authentication by using the
IDENTIFIED clause to indicate that a user must be authorized by
• Roles can be protected through authentication. a specified method before the role is enabled with the SET ROLE
• Roles can also be secured programmatically. statement. The default authentication for a role is None.
• Create secure application roles that can be enabled only by
CREATE ROLE secure_application_role executing a PL/SQL procedure successfully. The PL/SQL
IDENTIFIED USING <security_procedure_name>; procedure can check things such as the user’s network address,
the program that the user is running, the time of day, and other
elements needed to properly secure a group of permissions.
• Administer roles easily using the Oracle Database Vault option.
Secure application roles are simplified, and traditional roles can be
further restricted.
•Note: Role authentication can be defined by using Enterprise
Manager Cloud Control, but not in Enterprise Manager Database
Express.

Oracle Database 12c: Administration Workshop


Managing User Security 8
Quiz

A database role:

a. Can be enabled or disabled


b. Can consist of system and object privileges
c. Is owned by its creator
d. Cannot be protected by a password

Oracle Database 12c: Administration Workshop


Managing User Security 9
Answer: b
Managing Database Storage Structures

Logical Physical Tablespaces


•A database is divided into logical storage units called tablespaces, which group
Database related logical structures or data files together. For example, tablespaces commonly
group all of an application’s segments to simplify some administrative operations.
Data Blocks
Tablespace Data file
•At the finest level of granularity, an Oracle database’s data is stored in data blocks.
One data block corresponds to a specific number of bytes of physical space on the
Segment
disk. A data block size is specified for each tablespace when it is created. A
Storage System database uses and allocates free database space in Oracle data blocks.
• SAN • NFS Extents
Extent
• NAS • ASM •The next level of logical database space is an extent. An extent is a specific
number of contiguous Oracle data blocks (obtained in a single allocation) that are
• Exadata used to store a specific type of information. Oracle data blocks in an extent are
Oracle data • File System logically contiguous but can be physically spread out on disk because of RAID
block striping and file system implementations.
Segments
•The level of logical database storage above an extent is called a segment. A
segment is a set of extents allocated for a certain logical structure

Oracle Database 12c: Administration Workshop


Managing Database Storage Structures 1
Creating a New Tablespace

Create new datafile using sql*plus • A tablespace must have at


least one file.
Create tablespace TABLESPACE_NAME datafile • When more space is required,
‘DATAFILE_NAME’ size “size” ;
extents will be added up to a
maximum size.
Create tablespace TABLESPACE_NAME datafile
‘DATAFILE_NAME’ size “size” autoextend on maxsize
“size”;

Oracle Database 12c: Administration Workshop


Managing Database Storage Structures 2
Altering a Tablespace

Changing the status: A tablespace can be in one of three different


statuses or states. Any of the following three states may not be
available because their availability depends on the type of
tablespace.
• Read Write: The tablespace is online and can be read from and
written to.
alter tablespace TABLESPACE_NAME read only • Read Only: Specify read-only to place the tablespace in
transition read-only mode. In this state, existing transactions can
be completed (committed or rolled back), but no further data
manipulation language (DML) operations are allowed on objects
in the tablespace. The tablespace is online while in the read-
alter tablespace TABLESPACE_NAME offline; only state. You cannot make the SYSTEM or SYSAUX
tablespaces read-only.
Offline: You can take an online tablespace offline so that this
portion of the database is temporarily unavailable for general use.
The rest of the database is open and available for users to access
data. When you take it offline, you can use the following options:
Normal
Temporary
Immediate

Oracle Database 12c: Administration Workshop


Managing Database Storage Structures 3
Adding a Data File to a Tablespace

• Changing the size: You can


add space to an existing
tablespace by either adding
Alter tablespace TABLESPACE_NAME add datafile
“DATAFILE_NAME” size “SIZE”;
data files to the tablespace or
changing the size of an
Alter database datafile “DATAFILE_NAME” resize
existing data file.
“SIZE”;
• You can change settings of a
data file by expanding the
tablespace.

Oracle Database 12c: Administration Workshop


Managing Database Storage Structures 4
Moving or Renaming an Online Data File

• Relocating an online data file: • You can rename or move an


ALTER DATABASE MOVE DATAFILE
'/disk1/myexample01.dbf' TO
online data file from one kind
'/disk2/myexample01.dbf'; of storage system to another
• Copying a data file from a file system to ASM: while the database is opened
ALTER DATABASE MOVE DATAFILE
'/disk1/myexample01.dbf' TO
and accessing the file.
'+DiskGroup2' KEEP;


• Queries and DML and DDL
Renaming an online data file:
ALTER DATABASE MOVE DATAFILE
operations can be performed
'/disk1/myexample1.dbf' TO
'/disk1/myexample01.dbf';
while the data file is being
moved.

Oracle Database 12c: Administration Workshop


Managing Database Storage Structures 5
Implementing Oracle Database Auditing

Restricting Access to Data and Services


A secure system ensures the •All users must not have access to all data. Depending
confidentiality of the data that on what is stored in your database, restricted access
can be mandated by business requirements, by
it contains. There are customer expectations, and (increasingly) by legal
restrictions.
several aspects of security: Authenticating Users
•To enforce access controls on sensitive data, the system
• Restricting access to data must first know who is trying to access the data.
Monitoring for Suspicious Activity
and services •Even authorized and authenticated users can
sometimes compromise your system. Identifying unusual
• Authenticating users database activity (such as an employee who suddenly
begins querying large amounts of credit card
• Monitoring for suspicious information, research results, or other sensitive
information) can be the first step to detecting information
activity theft.

Oracle Database 12c: Administration Workshop


Managing Database Storage Structures 1
Implementing Oracle Database Auditing

• The option to audit use of the DELETE


AUDIT DELETE ANY TABLE BY ACCESS WHENEVER NOT ANY TABLE privilege is DELETE ANY
SUCCESSFUL; TABLE.
AUDIT DELETE ANY TABLE BY ACCESS; • To audit all successful and
unsuccessful uses of the DELETE ANY
AUDIT SELECT TABLE, INSERT TABLE, DELETE TABLE, EXECUTE TABLE system privilege.
PROCEDURE BY ACCESS WHENEVER NOT SUCCESSFUL; • To audit all unsuccessful SELECT,
AUDIT DELETE ANY TABLE BY ACCESS WHENEVER NOT INSERT, and DELETE statements on all
SUCCESSFUL; tables and unsuccessful uses of the
EXECUTE PROCEDURE system
privilege, by all database users, and by
individual audited statement.
Oracle Database 12c: Administration Workshop
Managing Database Storage Structures 2
Backup and Recovery: Concepts & Configuration

DBA Responsibilities
• Base recovery requirements on data
• Protect the database from failure wherever possible
criticality.
• Increase the mean time between failures (MTBF) – Recovery Point Objective (RPO):
• Protect critical components by using redundancy Tolerance for data loss — How
• Decrease the mean time to recover (MTTR)

frequently should backups be taken? Is
Minimize the loss of data
point-in-time recovery required?
– Recovery Time Objective (RTO):
Tolerance for down time — Down time:
Problem identification + recovery
planning + systems recovery — Tiered
RTO per level of granularity (database,
tablespace, table, row)
Oracle Database 12c: Administration Workshop
Backup and Recovery: Concepts & Configuration 1
Categories of Failure

Failures can generally be divided into the following categories:


• Statement failure: A single database operation
• Statement failure
(select, insert, update, or delete) fails.
• User process failure
• Network failure
• User process failure: A single database session
• User error
fails.
• Instance failure • Network failure: Connectivity to the database is
• Media failure lost.
• User error: A user successfully completes an
operation, but the operation (dropping a table
or entering bad data) is incorrect.
• Instance failure: The database instance shuts
down unexpectedly.
• Media failure: A loss of any file that is needed
for database operation (that is, the files have
been deleted or the disk has failed).
Oracle Database 12c: Administration Workshop
Backup and Recovery: Concepts & Configuration 2
Understanding Instance Recovery: Checkpoint
(CKPT) Process

Every three seconds (or more frequently), the


CKPT process stores data in a control file to
CKPT is responsible for:
SGA
document the modified data blocks that DBWn
• Updating data file headers with has written from the SGA to disk. This is called
checkpoint information an “incremental checkpoint.” The purpose of a
Database
• Updating control files with buffer cache checkpoint is to identify that place in the online
checkpoint information redo log file where instance recovery is to begin
• Signaling DBWn at (which is called the “checkpoint position”).
full checkpoints DBWn

Database Writer Checkpoints exist for the following reasons:


process • To ensure that modified data blocks in
memory
that dataare
is written
not lost to
in the disk
case of regularly
a system so
or
database failure
Control • To reduce the time required for instance
CKPT
files recovery
following(Only
the thecheckpoint
last online redoneedlog file
to entries
be
processed for recovery.)
Checkpoint process
Data files • To ensure that all committed data has been
written to data files during shutdown

Oracle Database 12c: Administration Workshop


Backup and Recovery: Concepts & Configuration 3
Understanding Instance Recovery: Redo Log
Files and Log Writer

Redo log files: • Redo log files record changes to the


• Record changes to the SGA
database as a result of transactions
database
and internal Oracle server actions.
• Should be multiplexed to Redo log buffer

protect against loss


(A transaction is a logical unit of work
Log Writer (LGWR) writes: LGWR consisting of one or more SQL
• At commit Log Writer
statements run by a user.) Redo log
• When one-third full files protect the database from loss
• Every three seconds of integrity because of system
• Before DBWn writes Redo log
group 1
Redo log
group 2
Redo log
group 3
failures caused by power outages,
• Before clean shutdowns disk failures, and so on. Redo log
files should be multiplexed to ensure
that the information stored in them is
not lost in the event of a disk failure.
Oracle Database 12c: Administration Workshop
Backup and Recovery: Concepts & Configuration 4
Understanding Instance Recovery

•Automatic instance or crash recovery: • The Oracle database automatically


•Is caused by attempts to open a database
recovers from instance failure. All that
needs to happen is for the instance to be
whose files are not synchronized on shutdown started normally. If Oracle Restart is
•Uses information stored in redo log groups to enabled and configured to monitor this
synchronize files database, then this happens automatically.
•Involves two distinct operations: The instance mounts the control files and
then attempts to open the data files.
–Rolling forward: Redo log changes (both
When it discovers that the data files have
committed and uncommitted) are applied not been synchronized during shutdown,
to data files. the instance uses information contained in
–Rolling back: Changes that are made but not the redo log groups to roll the data files
committed are returned to their original
forward to the time of shutdown. Then the
database is opened and any uncommitted
state. transactions are rolled back.
Oracle Database 12c: Administration Workshop
Backup and Recovery: Concepts & Configuration 5
Phases of Instance Recovery

• For an instance to open a data file, the system


1. Instance startup (data files Instance change number (SCN) contained in the data file’s
are out of sync) SGA header must match the current SCN that is stored in
2. Roll forward (redo)
the database’s control files
3. Committed and uncommitted Background • If the numbers do not match, the instance applies
processes redo data from the online redo logs, sequentially
data in files
“redoing” transactions until the data files are up-to-
4. Database opened date. After all data files have been synchronized with
Database
5. Roll back (undo) the control files, the database is opened and users
6. Committed data in files SCN: can log in.
SCN:140 SCN:143 74-101
• When redo logs are applied, all transactions are
SCN: applied to bring the database up to the state as of
SCN:129 102-143
the time of failure. This usually includes transactions
Undo
that are in progress but have not yet been
SCN: SCN:143
Redo log committed. After the database has been opened,
99
group those uncommitted transactions are rolled back.
Data files
Control
files
• At the end of the rollback phase of instance recovery,
the data files contain only committed data.
Oracle Database 12c: Administration Workshop
Backup and Recovery: Concepts & Configuration 6
Comparing Complete and Incomplete Recovery

• Recovery can have two kinds of scope: • When you perform complete recovery, you bring
• Complete recovery: Brings the database or tablespace up the database to the state where it is fully up- to-
to the present, including all committed data changes made date, including all committed data modifications to
to the point in time when the recovery was requested the present time.
• Incomplete or point-in-time recovery (PITR): Brings the
database or tablespace up to a specified point in time in • Incomplete recovery, however, brings the database
the past, before the recovery operation was requested or tablespace to some point of time in the past.
This is also known as “point-in-time recovery
(PITR).” It means there are missing transactions;
Complete
Time of
crash
any data modifications done between the recovery
recovery
destination time and the present are lost. In many
Point-in-time
recovery Recovery
cases, this is the desirable goal because there may
Restore from Missing transactions task started have been some changes made to the database
this backup after point-in-time recovery at this time
that need to be undone. Recovering to a point in
the past is a way to remove the unwanted changes.

Oracle Database 12c: Administration Workshop


Backup and Recovery: Concepts & Configuration 7
Complete Recovery Process

The following steps describe what takes place during


complete recovery:
1.Damaged or missing files are restored from a backup.
Arch ived
log Archived 2.Changes from incremental backups, archived redo log
Online files, and online redo log files are applied as necessary.
log Redo log The redo log changes are applied to the data files until
Changes applied Undo applied the current online log is reached and the most recent
transactions have been re-entered. Undo blocks are
2 4
generated during this entire process. This is referred to
as rolling forward or cache recovery.
3.The restored data files may now contain committed and
1 3 5 uncommitted changes.
Restored Data files containing 4.The undo blocks are used to roll back any uncommitted
data committed and uncommitted Recovered
files transactions data files changes. This is sometimes referred to as transaction
recovery.
5.Tconsistent
he data files
withare now
the in adata
other recovered
files in state and are
the database.
Oracle Database 12c: Administration Workshop
Backup and Recovery: Concepts & Configuration 8
Point-in-Time Recovery Process

The steps to perform a point-in-time recovery are as follows:


1. Restore the data files from backup: The backup that is used must be
Arch ived from before your target recovery point. This entails either copying
log hived files using OS commands or using the RMAN RESTORE command.
logX
A r Online
2. Use the RECOVER command: Apply redo from the archived redo
c Xo log
Red
log files, including as many as necessary to reach the restore point
Changes applied to point in time (PIT) Database
opened
destination.
Undo applied
2 3. State of over-recovery: Now the data files contain some
4 5 committed and some uncommitted transactions because
the redo can contain uncommitted data.
1 4. Use the ALTER DATABASE OPEN command: The database is opened
3 6 before undo is applied. This is to provide higher availability.
Restored data Data files containing 5. Apply undo data: While the redo was being applied, redo supporting
committed and PIT-recovered
files from as far
back as necessary uncommitted data files the undo data files was also applied. So the undo is available to be
transactions up to PIT applied to the data files in order to undo any uncommitted
transactions. That is done next.
6. Process complete: The data files are now recovered to the point in
time that you chose
Oracle Database 12c: Administration Workshop
Backup and Recovery: Concepts & Configuration 9
Quiz

Statement failure is never by design and always requires the


DBA to address the issue.

a. True
b. False

Oracle Database 12c: Administration Workshop


Backup and Recovery: Concepts & Configuration 10
Answer: b
Quiz

During instance recovery, which of the following operations


take place?
a. Data files are restored from backups.
b. Changes made by committed and uncommitted
transactions are applied to the data files via redo log
entries.
c. Uncommitted transactions are rolled back.
Answer: b, c
Configuring for Recoverability

• To configure your database for maximum • Schedule regular backups: Most media failures require that you
recoverability, you must: restore the lost or damaged file from backup.
• Multiplex control files: All control files associated with a database
• Schedule regular backups are identical. Recovering from the loss of a single control file is not
difficult; recovering from the loss of all control files is much more
• Multiplex control files challenging.
• Multiplex redo log groups • Multiplex redo log groups: To recover from instance or media
failure, redo log information is used to roll data files forward to the
• Retain archived copies of redo logs last committed transaction. If your redo log groups rely on a single
redo log file, the loss of that file means that data is likely to be lost.
• Retain archived copies of redo logs: If a file is lost and restored from
backup, the instance must apply redo information to bring that file
up to the latest SCN contained in the control file. With the default
setting, the database can overwrite redo information after it has
been written to the data files. Your database can be configured to
retain redo information in archived copies of the redo logs. This is
known as placing the database in ARCHIVELOG mode.

Oracle Database 12c: Administration Workshop


Backup and Recovery: Concepts & Configuration 12
Configuring the Fast Recovery Area

• Fast recovery area: •The fast recovery area is a space that is set aside on disk to contain
archived logs, backups, flashback logs, multiplexed control files, and
– Strongly recommended for simplified backup storage multiplexed redo logs. A fast recovery area simplifies backup storage
management management and is strongly recommended. You should place the fast
– Storage space (separate from working database files) recovery area on storage space that is separate from the location of
– Location specified by the DB_RECOVERY_FILE_DEST your database data files and primary online log files and control file.
parameter •The amount of disk space to allocate for the fast recovery area
– Size specified by the DB_RECOVERY_FILE_DEST_SIZE depends on the size and activity levels of your database. As a general
parameter rule, the larger the fast recovery area, the more useful it is. Ideally, the
– Large enough for backups, archived logs, flashback logs, fast recovery area should be large enough for copies of your data and
multiplexed control files, and multiplexed redo logs control files and for flashback, online redo, and archived logs needed to
recover the database with the backups kept based on the retention
– Automatically managed according to your retention policy
policy. (In short, the fast recovery area should be at least twice the size
• Configuration of the fast recovery area of the database so that it can hold one backup and several archived
logs.)
includes specifying the location, size, and
•Space management in the fast recovery area is governed by a
retention policy. backup retention policy. A retention policy determines when files are
obsolete, which means that they are no longer needed to meet your
data recovery objectives. The Oracle Database server automatically
manages this storage by deleting files that are no longer needed.
Oracle Database 12c: Administration Workshop
Backup and Recovery: Concepts & Configuration 13
Multiplexing Control Files

• To protect against database failure, •A control file is a small binary file that describes
the structure of the database. It must be available
your database should have multiple for writing by the Oracle server whenever the
copies of the control
ASM Storage file. Storage
File System database is mounted or opened. Without this file,
Best One copy on each disk group At least two copies, each on separate disk the database cannot be mounted, and recovery or
Practice (such as +DATA and +FRA) (at least one on separate disk controller) re-creation of the control file is required. Your
Steps to No additional control file 1. Alter the SPFILE with the ALTER database should have a minimum of two control
create copies required SYSTEM SET files on different storage devices to minimize the
additional control_files command.
control 2. Shut down the database. impact of a loss of one control file.
files 3. Copy control file to a new •The loss of a single control file causes the
location.
4. Open the database and verify the
instance to fail because all control files must be
addition of the new control file. available at all times. However, recovery can be a
simple matter of copying one of the other control
files. The loss of all control files is slightly more
difficult to recover from but is not usually
catastrophic.
Oracle Database 12c: Administration Workshop
Backup and Recovery: Concepts & Configuration 14
Redo Log Files

•Redo log groups are made up of one or more redo log


files. Each log file in a group is a duplicate of the
Multiplex redo log groups to protect against media failure and others. Oracle Corporation recommends that redo log
groups have at least two files per group. If using file
loss of data. This increases database I/O. It is suggested
system storage, then each member should be
that redo log groups have:
distributed on separate disks or controllers so that no
single equipment failure impacts an entire log group. If
• At least two members (files) per group you are using ASM storage, then each member should
• Each member: be in a separate disk group, such as +DATA and +FRA.
– On a separate disk or •The loss of an entire current log group is one of the
controller if using +DAT Member Member Member most serious media failures because it can result in
a a
file system storage
A
a loss of data. The loss of a single member of a multiple-
– In a separate disk +FRA Member Member Member
member log group is trivial and does not affect
group b b b database operation (other than causing an alert to be
(such as +DATA and +FRA)
if using ASM
Group 1 Group 2 Group 3 published in the alert log). Recovery from the loss of
an entire log group requires advanced recovery
techniques and is discussed in the course titled Oracle
Database 12c: Backup and Recovery Workshop.

Oracle Database 12c: Administration Workshop


Backup and Recovery: Concepts & Configuration 15
Creating Archived Redo Log Files

To preserve redo information, •The Oracle Database server treats the online redo log
create archived copies of redo log groups as a circular buffer in which to store transaction
information, filling one group and then moving on to the
files by performing the following next. After all groups have been written to, the Oracle
steps: Database server begins overwriting information in the
first log group.
• Specify archived redo log file- •To configure your database for maximum
recoverability, you must instruct the Oracle
naming convention. Database server to make a copy of the online redo
log group before allowing it to be overwritten. These
• Specify one or more archived copies are known as archived redo log files.
•To facilitate the creation of archived redo log files:
redo log file locations. 1.Specify a naming convention for your archived
redo log files.
• Place the database in 2.Specify a destination or destinations for storing
ARCHIVELOG mode.
Online redo
your archived redo log files.
3.Place the database in ARCHIVELOG mode.
log files Archived
redo log files
Oracle Database 12c: Administration Workshop
Backup and Recovery: Concepts & Configuration 16
Configuring ARCHIVELOG Mode

•To place the database in ARCHIVELOG mode, • Placing the database in ARCHIVELOG mode prevents redo logs
from being overwritten until they have been archived.
perform the following steps: • In Enterprise Manager Cloud Control, select Availability >
• Using Enterprise Manager Cloud Control: Backup & Recovery > Recovery Settings. Select “ARCHIVELOG
Mode” and click Apply. The database instance must be
1. On the Recovery Settings page, select restarted after making this change.
“ARCHIVELOG Mode” and click Apply. The • To issue the SQL command to put the database in
database can be set to ARCHIVELOG mode ARCHIVELOG mode, the database must be in MOUNT mode. If
only from the MOUNT state. the database is currently open, you must shut it down cleanly
(not abort), and then mount it as shown in the following
2. Restart the database instance by clicking example:
“Yes” when prompted. shutdown immediate ;
• Using SQL commands: startup mount
– Mount the database. alter database archivelog;
– Issue the ALTER DATABASE ARCHIVELOG alter database open;
• With the database in NOARCHIVELOG mode (the default),
command. recovery is possible only until the time of the last backup. All
– Open the database. transactions made after that backup are lost.

Oracle Database 12c: Administration Workshop


Backup and Recovery: Concepts & Configuration 17
Quiz

Which parameters configure the fast recovery area?

a. FLASH_RECOVERY_AREA_SIZE
b. DB_RECOVERY_FILE_DEST
c. FLASH_RECOVERY_AREA_LOC
d. DB_RECOVERY_FILE_DEST_SIZE

Oracle Database 12c: Administration Workshop


Backup and Recovery: Concepts & Configuration 18
Answer: b, d
Performing Database Backups & Recovery

User-Managed Backup

A user-managed backup can be performed interactively. However, most often it entails


A user-managed scenario: the writing of scripts to perform the backup. There are several scenarios that can be run,
and scripts must be written to handle them.
• Is a manual process of tracking backup needs and status
Some of the actions that scripts must take:
• Typically uses your own written scripts • Querying V$DATAFILE to determine the data files that need to be backed up and
• Requires that database files be put in the correct mode for their current state
• Querying V$LOGFILE to identify the online redo log files
backup
• Querying V$CONTROLFILE to identify the control file to back up
• Relies on operating system commands to make backups
• Placing each tablespace in online backup mode
of files • Querying V$BACKUP to see what data files are part of a tablespace that has
been placed in online backup mode
• Issuing operating system copy commands to copy the data files to the backup
location
• Bringing each tablespace out of online backup mode

Oracle Database 12c: Administration Workshop


Performing Database Backups & Recovery 1
Understanding Backup Terminology

•Whole database backup: Includes all data files and at least one control
file (Remember that all control files in a database are identical.)
• Backup strategy may include: •Partial database backup: May include zero or more tablespaces and zero
or more data files; may or may not include a control file
– Entire database (whole)
•Full backup: Makes a copy of each data block that contains data and
– Portion of the database (partial) that is within the files being backed up
• Backup type may indicate inclusion of: •Incremental backup: Makes a copy of all data blocks that have changed
since a previous backup. Oracle Database supports two levels of
– All data blocks within your chosen files (full) incremental backup (0 and 1). A level 1 incremental backup can be one of
– Only information that has changed since a previous two types: cumulative or differential. A cumulative backup backs up all
backup (incremental) changes since the last level 0 backup. A differential backup backs up all
changes since the last incremental backup (which could be either a level 0

Cumulative (changes since last level 0) or level 1 backup). Change Tracking with RMAN supports incremental

Differential (changes since last incremental) backups.
•Offline backups (also known as “cold” or consistent backup): Are taken
while the database is not open. They are consistent because, at the time of
• Backup mode may be: the backup, the system change number (SCN) in data file headers matches
– Offline (consistent, cold) the SCN in the control files.
– Online (inconsistent, hot) Control Online •Online backups (also known as “hot” or inconsistent backup): Are taken
files redo log while the database is open. They are inconsistent because, with the
Data files Database files database open, there is no guarantee that the data files are synchronized
with the control files.

Oracle Database 12c: Administration Workshop


Performing Database Backups & Recovery 2
Understanding Types of Backups

Backups may be stored as:


• Image copies •Image copies: Are duplicates of data or
• Backup sets archived log files (similar to simply
copying the files by using operating
system commands)
Data file #1 Data file #1 Data file #2

Data file #2 Data file #3 Data file #4 •Backup sets: Are collections of one or
Data file #3
Data file #5 Data file #6 more binary files that contain one or more
Data file #4
Backup set data files, control files, server parameter
(Binary, compressed files in
Data file #5 Oracle proprietary format) files, or archived log files. With backup
Data file #6
sets, empty data blocks are not stored,
Image copies thereby causing backup sets to use less
(Duplicate data and log files in OS format)
space on the disk or tape. Backup sets
can be compressed to further reduce the
space requirements of the backup.
Oracle Database 12c: Administration Workshop
Performing Database Backups & Recovery 3
RMAN Backup Types

• Full, or “level 0 Full Backups


A full backup contains all used
incremental backup” •A full backup is different from a whole database backup. A full data file
data file blocks.
backup is a backup that includes every used data block in the file.
• A level 0 incremental backup is RMAN copies all blocks into the backup set or image copy, skipping
equivalent to a full backup that only those data file blocks that are not part of an existing segment. For
has been marked as level 0. a full image copy, the entire file contents are reproduced exactly. A full
Cumulative backup cannot be part of an incremental backup strategy; it cannot be
• A cumulative level 1 incremental backup
the parent for a subsequent incremental backup.
incremental backup contains
only blocks modified since the Incremental Backups
last level 0 incremental •An incremental backup is either a level 0 backup, which includes
backup. every block in the data files except blocks that have never been used,
Differential or a level 1 backup, which includes only those blocks that have been
• A differential level 1 incremental backup changed since a previous backup was taken. A level 0 incremental
incremental backup contains backup is physically identical to a full backup. The only difference is
only blocks modified since the that the level 0 backup (as well as an image copy) can be used as the
last incremental backup. base for a level 1 backup, but a full backup can never be used as the
base for a level 1 backup.
•Incremental backups are specified using the INCREMENTAL keyword
of the BACKUP command. You specify INCREMENTAL LEVEL [0 | 1].
Oracle Database 12c: Administration Workshop
Performing Database Backups & Recovery 4
RMAN Backup Types

RMAN can create multilevel incremental backups as follows:


• Differential: Is the default type of incremental backup that backs up all blocks changed after the most recent incremental backup at either level
1 or level 0
• Cumulative: Backs up all blocks changed after the most recent backup at level 0
Examples
• To perform an incremental backup at level 0, use the following command:
RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE;
• To perform a differential incremental backup, use the following command:
RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;
• To perform a cumulative incremental backup, use the following command:
RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;
RMAN makes full backups by default if neither FULL nor INCREMENTAL is specified. Unused block compression causes never-written blocks to be
skipped when backing up data files to backup sets, even for full backups.
A full backup has no effect on subsequent incremental backups, and is not considered part of any incremental backup strategy, although a full image
copy backup can be incrementally updated by applying incremental backups with the RECOVER command.
Note: It is possible to perform any type of backup (full or incremental) of a database that is in NOARCHIVELOG mode—if, of course, the database is
not open. Note also that recovery is limited to the time of the last backup. The database can be recovered to the last committed transaction only
when the database is in ARCHIVELOG mode.

Oracle Database 12c: Administration Workshop


Performing Database Backups & Recovery 5
Using RMAN Commands to Create Backups

1. In a terminal session, start RMAN and connect to the target database.


2. Execute configuration commands:
1 - CONFIGURE DEFAULT DEVICE TYPE TO disk;
$ rman target /
2 RMAN> CONFIGURE … - CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY;
RMAN> BACKUP
- CONFIGURE CONTROLFILE AUTOBACKUP ON;
3 DATABASE PLUS 3. A whole database backup is a copy of all data files and the control
ARCHIVELOG; file. You can optionally include the server parameter file (SPFILE)
and archived redo log files. Using RMAN to make an image copy of
all the database files simply requires mounting or opening the
database, starting RMAN, and entering the BACKUP command
shown in the slide.
• Optionally, you can supply the DELETE INPUT option when backing
up archive log files. That causes RMAN to remove the archive log
files after backing them up. This is useful especially if you are not
Control using a fast recovery area, which would perform space management
Control Archived redo SPFILE
Data files file
files for you, deleting files when space pressure grows. In that case, the
log file
command in the slide would look like the following:
• RMAN> BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
• You can also create a backup (either a backup set or image copies)
of previous image copies of all data files and control files in the
database by using the following command:
• RMAN> BACKUP COPY OF DATABASE;

Oracle Database 12c: Administration Workshop


Performing Database Backups & Recovery 6
Quiz

Using the change-tracking feature, an image copy backup


performed by RMAN can skip blocks that have not changed
since the last backup.
a. True
b. False

Oracle Database 12c: Administration Workshop


Performing Database Backups & Recovery 7
Answer: b
Opening a Database

To open a database:
• All control files must be present and synchronized
• All online data files must be present and synchronized •As a database moves from the shutdown stage to
being fully open, it performs internal consistency
• At least one member of each redo log group must be
checks with the following stages:
present • NOMOUNT: For an instance to reach the NOMOUNT (also
known as STARTED) status, the instance must read the
initialization parameter file. No database files are
checked while the instance enters the NOMOUNT state.
• MOUNT: As the instance moves to the MOUNT status, it
OPEN checks whether all control files listed in the initialization
STARTUP
parameter file are present and synchronized. If even
MOUNT one control file is missing or corrupt, the instance
returns an error (noting the missing control file) to the
NOMOUNT
administrator and remains in the NOMOUNT state.
• OPEN: When the instance moves from the MOUNT
SHUTDOWN
state to the OPEN state, it does the following:
•- Checks whether all redo log groups known to
the control file have at least one member present.
Any missing members are noted in the alert log.

Oracle Database 12c: Administration Workshop


Performing Database Backups & Recovery 8
Keeping a Database Open

After the database is open, it fails in case of the loss of: •After a database is open, instance failure can be caused
• Any control file by media failure: for example, by the loss of a control file,
• A data file belonging to the system or undo tablespaces the loss of an entire redo log group, or the loss of a data
file belonging to the SYSTEM or UNDO tablespaces.
• An entire redo log group (As long as at least one member
Even if an inactive redo log group is lost, the database
of the group is available, the instance remains open.)
would eventually fail due to log switches.
•In many cases, the failed instance does not completely
shut down but is unable to continue to perform work.
Recovering from these types of media failure must be
done with the database down. As a result, the
administrator must use the SHUTDOWN ABORT command
before beginning recovery efforts.
•The loss of data files belonging to other tablespaces
does not cause instance failure, and the database can
be recovered while open, with work continuing in other
tablespaces.
•These errors can be detected by inspecting the alert log
file or by using the Data Recovery Advisor.
Oracle Database 12c: Administration Workshop
Performing Database Backups & Recovery 9
Loss of a Control File

•The options for recovery from the loss of a control file depend on the storage configuration of the
If a control file is lost or corrupted, the instance normally aborts. control files and on whether at least one control file remains or have all been lost.
• If control files are stored in ASM disk groups, recovery •If using ASM storage, and at least one control file copy remains, you can perform guided
recovery using Enterprise Manager or perform manual recovery using RMAN as follows:
options are as follows:
1. Put the database in NOMOUNT mode.
– Perform guided recovery using Enterprise Manager. 2. Connect to RMAN and issue the RESTORE CONTROLFILE command to restore the control
– Put database in NOMOUNT mode and use an RMAN file from an existing control file, for example:
command to restore control file from existing control file. • restore controlfile from
RMAN> restore controlfile from • '+DATA/orcl/controlfile/current.260.695209463';
'+DATA/orcl/controlfile/current.260.695209463'; 3. After the control file is successfully restored, open the database.
• If control files are stored as regular file system files, then: •If your control files are stored as regular file system files and at least one control file copy
remains, then, while the database is down, you can just copy one of the remaining control files
– Shut down the database to the missing file’s location. If the media failure is due to the loss of a disk drive or controller,
– Copy existing control file to replace lost control file copy one of the remaining control files to some other location and update the instance’s
parameter file to point to the new location. Alternatively, you can delete the reference to the
After control file is successfully restored, open the database. missing control file from the initialization parameter file. Remember that Oracle recommends
having at least two control files at all times.
•Note: Recovering from the loss of all control files is covered in the course titled Oracle
Database 12c: Backup and Recovery Workshop.

Oracle Database 12c: Administration Workshop


Performing Database Backups & Recovery 10
Loss of a Redo Log File

If a member of a redo log file group is lost and if the Recovering from the loss of a single redo log group member should not affect the
running instance.
group still has at least one member, note the following
•To perform this recovery by using SQL commands:
results:
1. Determine whether there is a missing log file by examining the alert log.
• Normal operation of the instance is not affected. 2. Restore the missing file by first dropping the lost redo log member:
• You receive a message in the alert log notifying you • ALTER DATABASE DROP LOGFILE MEMBER '<filename>'
that a member cannot be found. • Then add a new member to replace the lost redo log member:
• You can restore the missing log file by dropping the • ALTER DATABASE ADD LOGFILE MEMBER '<filename>‘ TO GROUP <integer>
lost redo log member and adding a new member. • Note: If you are using Oracle Managed Files (OMF) for your redo log files and you use
the preceding syntax to add a new redo log member to an existing group, that new
• If the group with the missing log file has been redo log member file will not be an OMF file. If you want to ensure that the new redo
archived, you can clear the log group to re-create log member is an OMF file, then the easiest recovery option would be to create a new
the missing file. redo log group and then drop the redo log group that had the missing redo log
member.
3. If the media failure is due to the loss of a disk drive or controller, rename the missing
file.
4. If the group has already been archived, or if you are in NOARCHIVELOG mode, you may
choose to solve the problem by clearing the log group to re-create the missing file or
files. You can clear the affected group manually with the following command:
• ALTER DATABASE CLEAR LOGFILE GROUP <integer>;

Oracle Database 12c: Administration Workshop


Performing Database Backups & Recovery 11
Loss of a Data File in NOARCHIVELOG Mode

If the database is in NOARCHIVELOG mode and if any •The loss of any data file from a database in NOARCHIVELOG
data file is lost, perform the following tasks: mode requires complete restoration of the database,
1. Shut down the instance if it is not already down. including control files and all data files.
•With the database in NOARCHIVELOG mode, recovery is possible
2. Restore the entire database—including all data and
only up to the time of the last backup. So users must re-enter all
control files—from the backup.
changes made since that backup.
3. Open the database. •To perform this type of recovery by using Enterprise Manager
4. Have users re-enter all changes that were Cloud Control:
made since the last backup. 1. Shut down the instance if it is not already down.
2. Select Availability > Backup & Recovery > Perform Recovery.
3. Select Whole Database as the type of recovery.
•If you have a database in NOARCHIVELOG mode that has an
incremental backup strategy, RMAN first restores the most recent
level 0 and then RMAN recovery applies the incremental backups.

Oracle Database 12c: Administration Workshop


Performing Database Backups & Recovery 12
Quiz

An Oracle Database instance will not fail if the following event


occurs:
a. Loss of a control file if there is a remaining multiplexed
control file
b. Loss of the SYSTEM tablespace
c. Loss of one redo log member if there is a remaining
multiplexed redo log member from the same group of the
lost member
d. Loss of the active undo tablespace

Oracle Database 12c: Administration Workshop


Performing Database Backups & Recovery 13
Answer: c
Improving Your Backups

When certain types of backups occur, RMAN is


able to skip some blocks. Unallocated blocks,
which are above the high-water mark (HWM) may
The following blocks may be
skipped during certain types of be skipped. Also, some allocated blocks that no
Unallocated longer belong to a segment (are not in use) may
backup operations:
• Unallocated blocks: These are be skipped, provided the following are true:
HWM
above the data file’s high- • There are no guaranteed restore points defined.
water mark (HWM). • The data file contains data only for locally
Unused managed tablespaces.
• Unused blocks: These are
blocks that have been • The data file is being backed up to a backup
allocated but no longer belong Allocated set as part of a full backup or a level 0
to a segment. incremental.
Data file
• The backup is going to disk, or Oracle Secure
Backup is the media manager.

Oracle Database 12c: Administration Workshop


Improving Your Backups 1
Compressing Backups

While unused block compression decreases the number of


blocks that are written to the backup (and the backup time),
RMAN can perform binary compression on any backup set that binary compression can be used to algorithmically compact
is generated. the data that is written. The available compression
• It can be performed in addition to unused block algorithms are HIGH, MEDIUM, LOW, and BASIC.
compression. You do not have to perform any additional steps when
• Available compression algorithms are HIGH, MEDIUM, LOW, restoring a compressed backup. Note, however, that
and BASIC. compression and decompression operations require CPU
• No extra steps are required by the DBA to restore a resources. So both creating and restoring a compressed
compressed backup. backup will probably take longer and require more system
CONFIGURE COMPRESSION ALGORITHM 'HIGH/MEDIUM/LOW/BASIC' resources.
run { When choosing an algorithm, consider your disk space in
SET COMPRESSION ALGORITHM 'HIGH/MEDIUM/LOW/BASIC'; addition to dynamic system resources such as CPU and
.. } memory.
BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG;
You can configure compression per device type or
One-time configuration
individually for a backup set as shown in the slide.

Oracle Database 12c: Administration Workshop


Improving Your Backups 2
Using RMAN Backup Compression

•The following level or compression ratios are


Compression Considerations Requires Advanced
Ratio or Compression Option available:
Level • LOW: This level is the fastest. It uses the
LOW Fastest. Best suited to address
backup: CPU resources.
least CPU, but provides less compression
MEDIUM Fast. Good balance of CPU
than
usage and compression ratio. • MEDIUM.
HIGH Best compression ratio at the • MEDIUM: This level provides a good balance
expense of high CPU
consumption. Best suited to of CPU usage and compression ratio.
address backup constraint:
network. • HIGH: This level provides the best
BASIC
compression ratio, but consumes the most
Fair. Compression ratio similar to
MEDIUM at expense of CPU.
additional CPU usage.
Compression ratio between • BASIC: This offers a compression ratio
MEDIUM and HIGH.
comparable to MEDIUM, at the expense
of additional CPU consumption.
Oracle Database 12c: Administration Workshop
Improving Your Backups 3
Quiz

Binary compression is used to compact the data that is written


to the backup file.
a. True
b. False

Oracle Database 12c: Administration Workshop


Improving Your Backups 4
Answer: a
Backing Up and Restoring Very Large Files

Multisection backups of a single data file:


RMAN command syntax: • Are created by RMAN, with your specified size
BACKUP <options> SECTION SIZE <integer> [K | M | G]
value
• Are for backup sets and image copies
VALIDATE DATAFILE <options> SECTION SIZE <integer> [K | M | G]
•Are for full and incremental
Example: backups Benefits:
RMAN> BACKUP DATAFILE 5 SECTION SIZE = 25M TAG 'section25mb'; • Reduce image copy creation
backing up blocks 1 through 3200 time
piece • Are processed independently
handle=/u01/.../o1_mf_nnndf_SECTION25MB_382dryt4_.bkp (serially or in parallel)
tag=SECTION25MB comment=NONE
... •Benefit Exadata
backing up blocks 9601 through 12800
Requirements and
piece
handle=/u01/.../o1_mf_nnndf_SECTION25MB_382dsto8_.bkp restrictions:
tag=SECTION25MB comment=NONE
• COMPATIBLE=12.0
• Not for control or
password files
Oracle Database 12c: Administration Workshop
Improving Your •Backups
Not 5for applying a large
Archival Backups: Concepts

•If you need to preserve an online backup for a


Archival backup specified amount of time, RMAN normally assumes
you might want to perform point-in-time recovery for
Log 250 Log 900 any time since that backup to the present. To satisfy
this scenario, RMAN keeps the archived logs for that
Backup A Backup B Backup S
time period.
•However, you may have a requirement to simply keep
Now the specific backup (and what is necessary to keep it
consistent and recoverable) for a specified amount of
time—for example, for two years. You do not intend to
recover to a point in time since that backup, but you just
End of Q1 Recovery window of 7 days •want to be able to recover to the exact time of the
backup, and no later. You also want to maintain a
Log nnn and Backup Not needed for retention policy retention policy that keeps your backup area free of
clutter, so making it reach back two years is not
Backup Needed for retention policy acceptable.

Oracle Database 12c: Administration Workshop


Improving Your Backups 6
Cataloging Additional Backup Files

• Use the START WITH option to catalog all


Using the CATALOG command: files found in the specified directory tree.
• To catalog existing backup files that are no longer listed in Provide a prefix that indicates the
the control file for RMAN restore operation directory and possibly a file prefix to look
• To add the following file types to the recovery catalog: for. You cannot use wildcards; this is
– CONTROLFILECOPY: Control file copies only a prefix.
– DATAFILECOPY: Data file copies
– BACKUPPIECE: Backup pieces • RMAN> CATALOG START WITH
– ARCHIVELOG: Archived redo log files '/tmp/bset';
• With the START WITH option:
• This command also catalogs any backup
RMAN> CATALOG ARCHIVELOG '/disk1/arch_logs/archive1_731.log',
'/disk1/arch_logs/archive1_732.log'; files that are found in directory trees
RMAN> CATALOG START WITH '/tmp/arch_logs/‘;
that begin with /tmp/bset.

Oracle Database 12c: Administration Workshop


Improving Your Backups 7
Quiz

Multisection backups can be taken of image copies and backup


sets for full and incremental backups.

a. True
b. False

Oracle Database 12c: Administration Workshop


Improving Your Backups 8
Answer: a
Quiz

Backups should be taken only of data files. Backups of non–


data files do not add to a backup and recovery strategy.

a. True
b. False

Oracle Database 12c: Administration Workshop


Improving Your Backups 10
Answer: b
Moving Data

Oracle Data Pump: Overview •Oracle Data Pump enables very high-speed data and metadata loading and
unloading of Oracle databases. The Data Pump infrastructure is callable via
the DBMS_DATAPUMP PL/SQL package. Thus, custom data movement
utilities can be built by using Data Pump.
As a server-based facility for high-speed data and metadata •Oracle Database provides the following tools:
movement, Oracle Data Pump: • Command-line export and import clients called expdp and impdp,
• Is callable via DBMS_DATAPUMP respectively
• Provides the following tools: • Export and import interface in Enterprise Manager Cloud Control
– expdp •Data Pump automatically decides the data access methods to use; these
can be either direct path or external tables. Data Pump uses direct path
– impdp
load and unload when a table’s structure allows it and when maximum
– GUI interface in Enterprise Manager Cloud Control single-stream performance is desired. However, if there are clustered
• Provides four data movement methods: tables, referential integrity constraints, encrypted columns, or several other
items, Data Pump uses external tables rather than direct path to move the
– Data file copying data.
– Direct path •The ability to detach from and re-attach to long-running jobs without
– External tables affecting the job itself enables you to monitor jobs from multiple locations
while they are running. All stopped Data Pump jobs can be restarted
– Network link support without loss of data as long as the metainformation remains undisturbed. It
• Detaches from and re-attaches to long-running jobs does not matter whether the job is stopped voluntarily or involuntarily due
to a crash.
• Restarts Data Pump jobs

Oracle Database 12c: Administration Workshop


Moving Data 1
Performing a Data Pump export

Create Directory
CREATE OR REPLACE DIRECTORY DIRECTORY_NAME AS ‘PATH’;
• The directory object is only a
GRANT READ, WRITE ON DIRECTORY test_dir TO USER_NAME;
pointer to a physical directory,
Export TABLE :EXAMPLE creating it does not actually
expdp system/manager1@ORCL tables=EMP,DEPT directory=DIR_NAME
create the physical directory on
dumpfile=DUMP_NAME.dmp logfile=LOG_NAME.log the file system of the database
Export schema :EXAMPLE
server.
expdp system/manager1@ORCL schemas=HR directory=DIR_NAME
dumpfile=DUMP_NAME.dmp logfile=LOG_NAME.log

Oracle Database 12c: Administration Workshop


Moving Data 2
Performing a Data Pump import

Import TABLE :EXAMPLE • Data can be exported for later


impdp system/manager1@ORCL tables=EMP,DEPT directory=DIR_NAME
dumpfile=DUMP_NAME.dmp logfile=LOG_NAME.log
importing (loading) into another
Oracle database or into a non-
Import schema :EXAMPLE Oracle database. Data that has
impdp system/manager1@ORCL schemas=HR directory=DIR_NAME been unloaded from a non-
dumpfile=DUMP_NAME.dmp logfile=LOG_NAME.log
Oracle database can be loaded
into an Oracle database, if the
data is in a suitable format for
loading.

Oracle Database 12c: Administration Workshop


Moving Data 3
Data Pump Import: Transformations

You can remap: •Because object metadata is stored as XML in the dump file set, it is
• Data files by using REMAP_DATAFILE easy to apply transformations when DDL is being formed during
• Tablespaces by using REMAP_TABLESPACE import. Data Pump Import supports several transformations:
• REMAP_DATAFILE is useful when moving databases across
• Schemas by using REMAP_SCHEMA
platforms that have different file-system semantics.
• Tables by using REMAP_TABLE • REMAP_TABLESPACE enables objects to be moved from
• Data by using REMAP_DATA one tablespace to another.
• REMAP_SCHEMA provides the old FROMUSER /TOUSER
REMAP_TABLE = 'EMPLOYEES':'EMP' capability to change object ownership.
• REMAP_TABLE provides the ability to rename entire tables.
• REMAP_DATA provides the ability to remap data as it is
being inserted.

Oracle Database 12c: Administration Workshop


Moving Data 4
Quiz

Like other database objects, directory objects are owned by the


user that creates them unless another schema is specified
during creation.

a. True
b. False
Answer: b
END

You might also like