Database Administrator Duties

 

DBA Responsibilities

    1. Install and upgrade ORACLE server and applications
    2. Create primary database storage and primary objects
    3. Allocate system storage and plan future storage needs
    4. Modify the database structures
    5. Enroll and monitor user access to the database
    6. Back up and recover the database
    7. Maintain system Security
    8. 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

 

  1. Every running Oracle database is associated with an Oracle instance.
  2. 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.
  3. The combination of the SGA and the Oracle processes is called an Oracle database instance.
  4. 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.
  1. Oracle starts an instance, then mounts a database to the instance.
  2. 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.

  1. A process is a "thread of control" or a mechanism in an operating system that can execute a series of steps.
  2. Some operating systems use the terms job or task.
  3. A process normally has its own private memory area in which it runs.

 

Two goals of a process structure might be

Single-Process Oracle Instance

 

Multiple-Process Oracle Instance

 

Multi-user Oracle uses several processes to execute different parts of Oracle, and a separate process for each connected user.

 

 

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:

      1. parse and execute SQL statements issued via the application
      2. 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
      3. 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)

  1. Performs all writing of buffers to datafiles.
  2. Is responsible for buffer cache management.

 

Buffer Cache Management.

  1. When a buffer in the buffer cache is modified, it is marked "dirty".
  2. DBWR keeps the buffer cache "clean" by writing dirty buffers to disk.
  3. 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.
  4. 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:

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:

    1. writes the redo log buffer to a redo log file on disk.
    2. 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:

 

Background Processes: SMON

The System Monitor process (SMON)

  1. performs instance recovery at instance start up.
  2. SMON is also responsible for cleaning up temporary segments that are no longer in use
  3. it also combines contiguous free extents to make larger blocks of free space available.
  4. 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)

    1. performs process recovery when a user process fails.
    2. 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.
    3. 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)

  

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.

How Dispatchers Work ?

  1. When an instance starts, the listener opens and establishes a communication pathway through which users connect to Oracle.
  2. Each dispatcher gives the listener an address at which the dispatcher listens for connection requests.
  3. 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:

  1. A database server machine is currently running Oracle using multiple background processes.
  2. 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.
  3. 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.
  4. The user executes a single SQL statement. For example, the user inserts a row into a table.
  5. The dedicated server process receives the statement. At this point, two paths can be followed to continue processing the SQL statement:

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.