3. Objectives
After completing this lesson, you should be able to:
• Describe the Oracle Database architecture
• Oracle server architecture.
• Memory architecture
• Backup and Recovery using manual method and RMAN.
4. The Oracle Database
The Oracle Relational Database Management System
(RDBMS) is a database management system that provides
an open, comprehensive, integrated approach to
information management.
5. Database
Data files
Online redo
log files
Control
files
Oracle Database Architecture: Overview
Database
buffer
cache
Shared pool
Data dictionary
cache
Library
cache
PMONSMON Others
Server
process
PGA
Archived
log files
User
process
Instance
ARCn
SGA
DBWn
Redo log
buffer
LGWRCKPT
6. Connecting to the Database
• Connection: Communication between a user process
and an instance
• Session: Specific connection of a user to an instance
through a user process
SQL> Select … Session
Connection
USER
User
7. Database
Oracle Database Server Structures
PMONSMON Others
Data files
Instance
ARCn
Control
files
DBWn LGWRCKPT
Storage structures
User
process
Server
process
Online redo
log files
Memory structures
Processes
Database
buffer
cache
Shared pool
Data dict.
cache
Library
cache
SGA
Redo log
buffer
8. Oracle Memory Architecture
SGA
Database buffer
cache
Redo log
buffer
Java
pool
Streams
pool
Shared pool
Large pool
PGA PGA PGA
Background
process
Server
process 1
Server
process 2
Shared
SQL area
Library
cache
Data Dictionary
cache
Other
I/O Buffer
Response
queue
Request
queue
Free
memory
9. Process Architecture
• User process
– Is started when a database user or a batch process
connects to Oracle Database
• Database processes
– Server process: Connects to the Oracle instance and is
started when a user establishes a session
– Background processes: Are started when an Oracle
instance is started
PMONSMON Others
Instance
ARCnDBWn LGWRCKPT
PGA
User
process
Server
process Background processes
Database
buffer
cache
Shared pool
Data dictionary
cache
Library
cache
SGA
Redo log
buffer
11. Oracle Memory Structures
SGA
Java pool
Database
buffer cache
Shared pool
Redo
buffer
Large poolStreams pool
Server
process
1
PGA
Server
process
2
PGA
Back-
ground
process
PGA
Keep buffer
cache
Recycle
buffer cache
nK block size
buffer caches
12. Database Storage Architecture
Online redo log files
Password file
Parameter file Archived redo log
files
Control files Data files
Alert log and trace files
Backup files
13. Logical and Physical Database Structures
Database
Logical Physical
Tablespace Data file
OS block
Segment
Extent
Oracle data
block
Schema
14. Tablespaces and Data Files
• Tablespaces consist of one or more data files.
• Data files belong to only one tablespace.
USERS tablespace
Data file 1 Data file 2
16. Oracle Backup and Recovery
SolutionsThese Oracle utilities and features provide
the tools necessary to maintain a
recoverable system:
• Recovery Manager (RMAN)
– Incremental backups
– Block media recovery
– Unused block compression
– Binary compression
– Backup encryption
• Data Pump
17. Types of RMAN Commands
RMAN commands are of the following
types:
• Stand-alone command:
– Is executed individually at the RMAN prompt
– Cannot appear as subcommands within RUN
• Job command:
– Must be within the braces of a RUN command
– Is executed as a group
Some commands can be executed as
either a stand-alone or a job command.
18. Configuring ARCHIVELOG
ModeTo place the database in ARCHIVELOG
mode, perform the following steps:
• Using Enterprise Manager
– Select the “ARCHIVELOG Mode” check box.
– Click Apply. The database can be set to
ARCHIVELOG mode only from the MOUNT state.
– Click Yes when asked whether you want to restart
the database.
• Using SQL commands
– Mount the database.
– Issue the ALTER DATABASE ARCHIVELOG
command.
19. Configuring Your Database for
Backup and Recovery
Operations
• Operate the database in ARCHIVELOG mode.
• Configure the Flash Recovery Area.
Archiver
(ARCn)
Archived
redo log files
Online redo
log files
Archived
redo log files
Control file
backups
Data file backups
Oracle Database 11 g : Administration Workshop II 1 -
Oracle Database 11 g : Administration Workshop II 1 - The Oracle Database A database is a collection of data treated as a unit. The purpose of a database is to store and retrieve related information. An Oracle Database reliably manages a large amount of data in a multiuser environment so that many users can concurrently access the same data. This is accomplished while delivering high performance. At the same time, the database prevents unauthorized access and provides efficient solutions for failure recovery.
Oracle Database 11 g : Administration Workshop II 1 - Oracle Database Architecture An Oracle database server consists of an Oracle database and one or more database instances.The instance consists of memory structures and background processes. Every time an instance is started, a shared memory area called the System Global Area (SGA) is allocated and the background processes are started. The database consists of both physical structures and logical structures. Because the physical and logical structures are separate, the physical storage of data can be managed without affecting access to logical storage structures.
Oracle Database 11 g : Administration Workshop II 1 - Connecting to the Database Connection and session are closely related to user process but are very different in meaning. A connection is a communication pathway between a user process and an Oracle Database instance. A communication pathway is established using available interprocess communication mechanisms (on a computer that runs both the user process and Oracle Database) or network software (when different computers run the database application and Oracle Database, and communicate through a network). A session represents the state of a current user login to the database instance. For example, when a user starts SQL*Plus, the user must provide a valid username and password, and then a session is established for that user. A session lasts from the time the user connects until the time the user disconnects or exits the database application. Multiple sessions can be created and exist concurrently for a single Oracle Database user who is using the same username. For example, a user with the username/password of HR / HR can connect to the same Oracle Database instance several times.
Oracle Database 11 g : Administration Workshop II 1 - Database Structures After starting an instance, the Oracle software associates the instance with a specific database. This is called mounting the database. The database is then ready to be opened, which makes it accessible to authorized users. Multiple instances can execute concurrently on the same computer, each accessing its own physical database. You can look at the Oracle Database architecture as various interrelated structural components. An Oracle instance uses memory structures and processes to manage and access the database. All memory structures exist in the main memory of the computers that constitute the database server. Processes are jobs that work in the memory of these computers. A process is defined as a “thread of control” or a mechanism in an operating system that can run a series of steps.
Oracle Database 11 g : Administration Workshop II 1 - Oracle Memory Structures Oracle Database creates and uses memory structures for various purposes. For example, memory stores program code being run, data shared among users, and private data areas for each connected user. Two basic memory structures are associated with an instance: The System Global Area (SGA) is a group of shared memory structures, known as SGA components, that contain data and control information for one Oracle Database instance. The SGA is shared by all server and background processes. Examples of data stored in the SGA include cached data blocks and shared SQL areas. The Program Global Areas (PGAs) are memory regions that contain data and control information for a server or background process. A PGA is nonshared memory created by Oracle Database when a server or background process is started. Access to the PGA is exclusive to the server process. Each server process and background process has its own PGA.
Oracle Database 11 g : Administration Workshop II 1 - Process Architecture The processes in an Oracle Database system can be categorized into two major groups: User processes that run the application or Oracle tool code. Oracle Database processes that run the Oracle database server code. They include server processes and background processes. When a user runs an application program or an Oracle tool such as SQL*Plus, Oracle Database creates a user process to run the user’s application. Oracle Database also creates a server process to execute the commands issued by the user process. In addition, the Oracle server also has a set of background processes for an instance that interact with each other and with the operating system to manage the memory structures and asynchronously perform I/O to write data to disk, and perform other required tasks. The process structure varies for different Oracle Database configurations, depending on the operating system and the choice of Oracle Database options. The code for connected users can be configured as a dedicated server or a shared server. With dedicated server, for each user, the database application is run by a user process that is served by a dedicated server process that executes Oracle database server code. A shared server eliminates the need for a dedicated server process for each connection. A dispatcher directs multiple incoming network session requests to a pool of shared server processes. A shared server process serves any client request.
Oracle Database 11 g : Administration Workshop II 1 - Process Structures Server Processes Oracle Database creates server processes to handle the requests of user processes connected to the instance. In some situations when the application and Oracle Database operate on the same computer, it is possible to combine the user process and corresponding server process into a single process to reduce system overhead. However, when the application and Oracle Database operate on different computers, a user process always communicates with Oracle Database through a separate server process. Server processes created on behalf of each user’s application can perform one or more of the following tasks: Parsing and running SQL statements issued through the application Reading necessary data blocks from data files on disk into the shared database buffers of the SGA, if the blocks are not already present in the SGA Returning results in such a way that the application can process the information Background Processes To maximize performance and accommodate many users, a multiprocess Oracle Database system uses some additional Oracle Database processes called background processes. An Oracle Database instance can have many background processes.
Oracle Database 11 g : Administration Workshop II 14 - Oracle Memory Structures The basic memory structures associated with an Oracle instance include: System Global Area (SGA): Shared by all server and background processes. Examples of data stored in the SGA include cached data blocks and shared SQL areas. Program Global Area (PGA): Private to each server and background process; there is one PGA for each process. The SGA is a shared memory area that contains data and control information for the instance, including the following: Database buffer cache: Caches blocks of data retrieved from disk Redo log buffer: Caches redo information until it can be written to disk Shared pool: Caches various constructs that can be shared among users Large pool: Optional area used for buffering large I/O requests in support of parallel query, shared server, Oracle XA, and certain types of backup operations Java pool: Holds session-specific Java code and data within the Java Virtual Machine (JVM) Streams pool: Used by Oracle Streams Keep buffer cache: Holds data that is kept in the buffer cache as long as possible Recycle buffer cache: Holds data that is quickly aged out of the buffer cache n K block size buffer caches: Caches data blocks that are of a different size than the default database block size; used to support transportable tablespaces
Oracle Database 11 g : Administration Workshop II 1 - Oracle Database Storage Architecture The files that constitute an Oracle database are organized into the following: Control files: Contain data about the database itself (that is, physical database structure information). These files are critical to the database. Without them, you cannot open data files to access the data within the database. Data files: Contain the user or application data of the database, as well as metadata and the data dictionary Online redo log files: Allow for instance recovery of the database. If the database server crashes and does not lose any data files, then the instance can recover the database with the information in these files. The following additional files are important to the successful running of the database: Parameter file: Is used to define how the instance is configured when it starts up Password file: Allows sysdba / sysoper / sysasm to connect remotely to the instance and perform administrative tasks Backup files: Are used for database recovery. You typically restore a backup file when a media failure or user error has damaged or deleted the original file. Archived redo log files: Contain an ongoing history of the data changes (redo) that are generated by the instance. Using these files and a backup of the database, you can recover a lost data file. That is, archive logs enable the recovery of restored data files.
Oracle Database 11 g : Administration Workshop II 1 - Logical and Physical Database Structures The database has logical structures and physical structures. Tablespaces A database is divided into logical storage units called tablespaces, which group related logical structures together. For example, tablespaces commonly group all of an application’s objects to simplify some administrative operations. You may have a tablespace for application data and an additional one for application indexes. Databases, Tablespaces, and Data Files The relationship among databases, tablespaces, and data files is illustrated in the slide. Each database is logically divided into one or more tablespaces. One or more data files are explicitly created for each tablespace to physically store the data of all logical structures in a tablespace. If it is a TEMPORARY tablespace, then instead of a data file, the tablespace has a temporary file.
Oracle Database 11 g : Administration Workshop II 1 - Tablespaces and Data Files A database is divided into logical storage units called tablespaces, which can be used to group related logical structures together. Each database is logically divided into one or more tablespaces. One or more data files are explicitly created for each tablespace to physically store the data of all logical structures in a tablespace. Note: You can also create bigfile tablespaces. These tablespaces can have only a single file, which is often very large. The file may be any size up to maximum that the row ID architecture will permit. The maximum size is the block size for the tablespace times 2 to the 36th power, or 128 TB for a 32 KB block size. The traditional smallfile tablespaces (which are the default) usually contain multiple data files, but the files cannot be as large. For more information about the bigfile tablespaces, see the Database Administrator’s Guide .
Buffer Cache You can configure the buffer cache by specifying a value for the DB_CACHE_SIZE parameter. The buffer cache holds copies of the data blocks from the data files having a block size of DB_BLOCK_SIZE . The buffer cache is a part of the SGA; so all users can share these blocks. The server processes read data from the data files into the buffer cache. To improve performance, the server process sometimes reads multiple blocks in a single read operation. The DBW n process writes data from the buffer cache into the data files. To improve performance, DBW n writes multiple blocks in a single write operation. At any given time, the buffer cache may hold multiple copies of a single database block. Only one current copy of the block exists, but to satisfy queries, server processes may need to construct read-consistent copies from past image information. This is called a consistent read (CR) block. The least recently used (LRU) list reflects the usage of buffers. The buffers are sorted on the basis of a combination of how recently and how often they have been referenced. Thus, buffers that are most frequently and recently used are found at the most recently used end. Incoming blocks are copied to a buffer from the least recently used end, which is then assigned to the middle of the list, as a starting point. From here, the buffer works its way up or down the list, depending on usage.
Oracle Database 11 g : Administration Workshop II 2 - Oracle Backup and Recovery Solutions The following are major backup and recovery solutions: Recovery Manager: A command-line tool for performing backup and recovery. Some of the major features available when using RMAN are: Incremental backups: A type of backup in which only data blocks that have changed since the last incremental backup are written to the backup Block media recovery: A method of recovering specific blocks of data, as opposed to entire tables (with Data Pump) or data files (with RMAN) Unused block compression: A space-saving method by which blocks that have never been used are not written to the backup Binary compression: A space-saving feature in which backup files are compressed using well-known algorithms (comparable to utilities such as zip on Linux) Backup encryption: A security device for protecting backups you make Data Pump: A command-line tool for exporting and importing table data from and to OS files
Oracle Database 11 g : Administration Workshop II 2 - Types of RMAN Commands You can issue two basic types of RMAN commands: stand-alone and job commands. Stand-alone commands are executed at the RMAN prompt and are generally self-contained. Some of the stand-alone commands are: CHANGE CONNECT CREATE CATALOG , RESYNC CATALOG CREATE SCRIPT , DELETE SCRIPT , REPLACE SCRIPT Job commands are usually grouped and executed sequentially inside a command block. If any command within the block fails, RMAN ceases processing; no further commands within the block are executed. The effects of any already executed commands still remain, though; they are not undone in any way. An example of a command that can be run only as a job command is ALLOCATE CHANNEL . The channel is allocated only for the execution of the job, so it cannot be issued as a stand-alone command. There are some commands that can be issued either at the prompt or within a RUN command block, such as BACKUP DATABASE . If you issue stand-alone commands, RMAN allocates any needed channels by using the automatic channel allocation feature. You can execute stand-alone and job commands in interactive mode or batch mode.
Oracle Database 11 g : Administration Workshop II 2 - Configuring ARCHIVELOG Mode Placing the database in ARCHIVELOG mode prevents redo logs from being overwritten until they have been archived. In Enterprise Manager, do this by navigating to Availability > Recovery Settings and selecting the ARCHIVELOG Mode check box. The database must be restarted after making this change. To issue the SQL command to put the database in ARCHIVELOG mode, the database must be in MOUNT mode. In order to get to the MOUNT state, the database must be in the SHUTDOWN state; if the database is currently open, you must shut it down, and then mount it. The following shows the commands to shut down an open database, put it in ARCHIVELOG mode, and then open it: SQL> SHUTDOWN IMMEDIATE SQL> STARTUP MOUNT SQL> ALTER DATABASE ARCHIVELOG; SQL> ALTER DATABASE OPEN; With the database in NOARCHIVELOG mode (the default), recovery is possible only until the time of the last backup. All transactions made after that backup are lost.
Oracle Database 11 g : Administration Workshop II 2 - Configuring Your Database for Backup and Recovery Operations When you operate your database in ARCHIVELOG mode, you have more recovery options after a data loss, including point-in-time recovery of the database or some tablespaces. It is recommended that you take advantage of the Flash Recovery Area to store as many backup and recovery–related files as possible, including disk backups and archived redo logs. Some features of Oracle Database backup and recovery, such as Oracle Flashback Database and guaranteed restore points, require the use of a Flash Recovery Area. Both of the features are covered in detail later in this lesson.
Oracle Database 11 g : Administration Workshop II 2 - ARCHIVELOG Mode As modifications to data in the database are made, the redo data is written out to the online redo log file. A given file is specified as being written to at a given time. When it is full, the Archiver process (ARC n ) copies the online log file to another location that serves as an archive of that file, which can be preserved for as long as you need it. This provides more opportunities for recovery, because you can save, back up, and restore all of the archive redo logs ever generated. Because the online redo log files are reused in a circular fashion, there is a protocol for controlling when one is allowed to be reused. In ARCHIVELOG mode, the database only begins writing to an online redo log file if it has been archived. This ensures that every redo log file has a chance to be archived.