Database Administrator Duties

DBA Responsibilities
Install and upgrade ORACLE server and applications
Create primary database storage and primary objects
Allocate system storage and plan future storage needs
Modify the database structures
Enroll and monitor user access to the database
Back up and recover the database
Maintain system Security
Monitor and optimize performance
Understanding the Oracle Architecture
Database Structures
|
Physical Structure |
Definition |
|
Datafiles |
Contain all of the database data; logical structures , such as tables and indexes |
|
Redo Log Files |
Hold records of all changes made to the database for recovery purposes |
|
Control Files |
Record the physical structure and status of the database |
|
Parameter File |
Contain startup values for database parameters (often referred as the init.ora file ) |
Notes adapted from the ORACLE 7.1 On-Line Documentation. Oracle Corp.
An Oracle Instance
Every running Oracle database is associated with an Oracle instance.
Every time a database is started on a database server, Oracle allocates a memory area called the System Global Area (SGA) and starts one or more Oracle processes.
The combination of the SGA and the Oracle processes is called an Oracle database instance.
The memory and processes of an instance work to manage the database's data efficiently and serve the one or multiple users of the associated database.
- Oracle starts an instance, then mounts a database to the instance.
- Multiple instances can execute concurrently on the same machine, each accessing its own physical database.
Process Structure
The Oracle's process architecture is designed to maximize performance.
- A process is a "thread of control" or a mechanism in an operating system that can execute a series of steps.
- Some operating systems use the terms job or task.
- A process normally has its own private memory area in which it runs.
Two goals of a process structure might be
- to simulate a private environment for multiple processes to work simultaneously, as though each process has its own private environment
- to allow multiple processes to share computer resources, which each process needs, but no process needs for long periods of time
Single-Process Oracle Instance
A single-user Oracle instance is a database system in which all Oracle code is executed by one process.
All code of Oracle and the lone user's database application is executed by a single process.
For example, Oracle running under the MS DOS operating system on a PC can only be accessed by a single user because MS DOS is not capable of running multiple processes.

Multiple-Process Oracle Instance
Multi-user Oracle uses several processes to execute different parts of Oracle, and a separate process for each connected user.
- In a multiple-process system, processes can be categorized into two groups: user processes and Oracle processes.
- Each process in a multiple-process Oracle instance performs a specific job.
- By dividing the work of Oracle and database applications into several processes, multiple users and applications can simultaneously connect to a single database instance while the system maintains adequate performance.
- Most database systems are multi-user, because one of the primary benefits of a database is managing data needed by multiple users at the same time.

Type of Processes
In a multiple-process system, processes are categorized into two groups: User Processes and Oracle Processes
1- User Processes
When a user runs an application program, such as a Pro*C program, or an Oracle tool, such as Server Manager, Oracle creates a user process to run the user's application.
2- Oracle Processes
There are two types: server processes and background processes.
2-1. Server Processes: Server processes (or the server portion of combined user/server processes) created on behalf of each user's application may perform one or more of the following:
- parse and execute SQL statements issued via the application
- read necessary data blocks from disk (datafiles) into the shared database buffers of the SGA, if the blocks are not already present in the SGA
- return results in such a way that the application can process the information
Background Processes

Background Processes
2-2 Background Processes
To maximize performance and accommodate many users, a multi-process Oracle system uses some additional Oracle processes called background processes.
|
Background
Process |
Acronym |
Definition |
|
Archiver |
ARCH |
Copies online REDO LOG files to a designated storage device once it has become full |
|
Checkpoint |
CKPT |
Updates datafile headers and control files on behalf of the LGWR when a checkpoint is completed |
|
Database Writer |
DBWR |
Writes data from the database buffer cache to the datafiles |
|
Lock Process |
LCKn |
Performs inter-instance locking in a parallel server system |
|
Log Writer |
LGWR |
Writes data from the redo log buffer to the redo log files. Updates datafile headers and control files if CKPT is not enabled |
|
Process Monitor |
PMON |
Performs process recovery when a user process fails |
|
Recoverer |
RECO |
Recovers failures involving distributed transactions |
|
System Monitor |
SMON |
Performs instance recovery at instance startup, does cleanup, and reclaims temporary segments |
|
Parallel Query |
Qnnn |
Performs parallel queries |
|
Snapshot |
SNPn |
Performs automatic refreshes of snapshots and handles the server job queues |
Background Processes: ARCH
The Archiver process (ARCH)
Copies online redo log files to a designated storage device once they become full. ARCH is present only when the redo log is used in ARCHIVELOG mode and automatic archiving is enabled.
Lock (LCKn)
With the Parallel Server option, up to ten Lock processes (LCK0, . . ., LCK9) provide inter-instance locking. However, a single LCK process (LCK0) is sufficient for most Parallel Server systems. See Oracle7 Parallel Server for more information about this background process.
Snapshot Refresh (SNPn)
With the distributed option, up to ten Snapshot Refresh processes (SNP0, ..., SNP9) can automatically refresh table snapshots. These processes wake up periodically and refresh any snapshots that are scheduled to be automatically refreshed. If more than one Snapshot Refresh process is used, the processes share the task of refreshing snapshots.
Background Processes: DBWR
Database Writer (DBWR) Database Writer process (DBWR)
Performs all writing of buffers to datafiles.
Is responsible for buffer cache management.
Buffer Cache Management.
- When a buffer in the buffer cache is modified, it is marked "dirty".
- DBWR keeps the buffer cache "clean" by writing dirty buffers to disk.
- As buffers are filled and dirtied by user processes, the number of free buffers diminishes. If the number of free buffers drops too low, user processes that must read blocks from disk into the cache are not able to find free buffers. DBWR manages the buffer cache so that user processes can always find free buffers.
- A LRU (least recently used) algorithm keeps the most recently used data blocks in memory
The DBWR process writes dirty buffers to disk under these conditions:
- When a server process moves a buffer to the dirty list and discovers that the dirty list has reached a threshold length, the server process signals DBWR to write.
- When a server process searches a threshold limit of buffers in the LRU list without finding a free buffer, it stops searching and signals DBWR to write (because not enough free buffers are available and DBWR must make room for more).
- When a time-out occurs (every three seconds), DBWR signals itself.
- When a checkpoint occurs, the Log Writer process (LGWR) signals DBWR.
Background Processes: LGWR
The Log Writer process (LGWR)
The redo log buffer is a circular buffer; when LGWR writes redo entries from the redo log buffer to a redo log file, server processes can then copy new entries over the entries in the redo log buffer that have been written to disk.
LGWR normally writes fast enough to ensure that space is always available in the buffer for new entries, even when access to the redo log is heavy.
LGWR Duties:
- writes the redo log buffer to a redo log file on disk.
- LGWR is responsible for redo log buffer management. LGWR writes all redo entries that have been copied into the buffer since the last time it wrote.
When things are written ?
LGWR writes one contiguous portion of the buffer to disk. LGWR writes:
- a commit record when a user process commits a transaction
- redo buffers every three seconds
- redo buffers when the redo log buffer is one-third full
- redo buffers when the DBWR process writes modified buffers to disk
Background Processes: SMON
The System Monitor process (SMON)
performs instance recovery at instance start up.
SMON is also responsible for cleaning up temporary segments that are no longer in use
it also combines contiguous free extents to make larger blocks of free space available.
In a Parallel Server environment, SMON performs instance recovery for a failed CPU or instance
SMON "wakes up" regularly to check whether it is needed. Other processes can call SMON if they detect a need for SMON to wake up.
Background Processes: PMON
The Process Monitor (PMON)
- performs process recovery when a user process fails.
- PMON is responsible for cleaning up the cache and freeing resources that the process was using. For example, it resets the status of the active transaction table, releases locks, and removes the process ID from the list of active processes.
- PMON periodically checks the status of dispatcher and server processes, and restarts any that have died (but not any that Oracle has killed intentionally).
Like SMON, PMON "wakes up" regularly to check whether it is needed, and can be called if another process detects the need for it.
Background Processes: RECO
The Recoverer process (RECO)
Is a process used with the distributed option that automatically resolves failures involving distributed transactions.
When the RECO process re-establishes a connection between involved database servers, it automatically resolves all in-doubt transactions.
The RECO process automatically removes rows corresponding to any resolved in-doubt transactions from each database's pending transaction table.
If the RECO process attempts to establish communication with a remote server, and the remote server is not available or the network connection has not been re-established, RECO automatically tries to connect again after a timed interval. However, RECO waits an increasing amount of time (growing exponentially) before it attempts another connection.
The RECO background process of an instance is only present if the system permits distributed transactions.
Background Processes:
Dnnn
Dispatcher Processes (Dnnn)
The Dispatcher processes allow several user processes to share a limited number of common server processes.
- Without a dispatcher, each user process would require one dedicated server process.
- With the multi-threaded server, fewer shared server processes are required for the same number of users.
How Dispatchers Work ?
- When an instance starts, the listener opens and establishes a communication pathway through which users connect to Oracle.
- Each dispatcher gives the listener an address at which the dispatcher listens for connection requests.
- When a user process makes a connection request, the listener process examines the request and determines if the user can use a dispatcher. If so, the listener process returns the address of the dispatcher process with the lightest load and the user process directly connects to the dispatcher.

An Example of How ORACLE works
The following example is a simple illustration of the dedicated server architecture of Oracle:
- A database server machine is currently running Oracle using multiple background processes.
- A client workstation runs a database application (in a user process) such as SQL*Plus. The client application attempts to establish a connection to the server using a SQL*Net driver.
- The database server is currently running the proper SQL*Net driver. The Listener process on the database server detects the connection request from the client database application and creates a dedicated server process on the database server on behalf of the user process.
- The user executes a single SQL statement. For example, the user inserts a row into a table.
- The dedicated server process receives the statement. At this point, two paths can be followed to continue processing the SQL statement:
- If the shared pool contains a shared SQL area for an identical SQL statement, the server process can use the existing shared SQL area to execute the client's SQL statement.
- If the shared pool does not contain a shared SQL area for an identical SQL statement, a new shared SQL area is allocated for the statement in the shared pool.
In either case, a private SQL area is created in the session's PGA and the dedicated server process checks the user's access privileges to the requested data.
- The server process retrieves data blocks from the actual datafile, if necessary, or uses data blocks already stored in the buffer cache in the SGA of the instance.
- The server process executes the SQL statement stored in the shared SQL area. Data is first changed in the SGA. It is permanently written to disk when the DBWR process determines it is most efficient to do so. The LGWR process records the transaction in the online redo log file only on a subsequent commit request from the user.
- If the request is successful, the server sends a message across the network to the user. If it is not successful, an appropriate error message is transmitted.
- Throughout this entire procedure, the other background processes are running and watching for any conditions that require intervention. In addition, Oracle is managing other transactions and preventing contention between different transactions that request the same data.
These steps show only the most basic level of operations that Oracle performs.