Oracle Structure

27
Introduction to Oracle Physical Structure Logical Structure SGA / PGA  Background Processes Backup Methods Computer Science Database CS01 Administrative Tasks

Transcript of Oracle Structure

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 1/27

Introduction to Oracle

Physical Structure

Logical Structure SGA / PGA 

Background Processes

Backup Methods Computer Science Database – CS01

Administrative Tasks

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 2/27

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 3/27

Physical Structures

Datafiles (*.dbf) The datafiles contain all the database data. The data of logical database

structures, such as tables and indexes, is physically stored in the datafilesallocated for a database.

Control Files (*.ctl) Every Oracle database has a control file. A control file contains entries that

specify the physical structure of the database such as Database name and theNames and locations of datafiles and redo log files.

Redo Log Files (*.log)

The primary function of the redo log is to record all changes made to data. If afailure prevents modified data from being permanently written to the datafiles,then the changes can be obtained from the redo log, so work is never lost.

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 4/27

Physical Structures (cont’d) 

 Archive Log Files (*.log)

Oracle automatically archives log files when the database is in ARCHIVELOGmode. This prevents oracle from overwriting the redo log files before they havebeen safely archived to another location.

Parameter Files (initSID.ora)

Parameter files contain a list of configuration parameters for that instance anddatabase.

 Alert and Trace Log Files (*.trc) Each server and background process can write to an associated trace file. When an internal

error is detected by a process, it dumps information about the error to its trace file. Thealert log of a database is a chronological log of messages and errors.

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 5/27

Logical Structures

Tablespaces

 A database is divided into logical storage units called tablespaces, which grouprelated logical structures together. One or more datafiles are explicitly createdfor each tablespace to physically store the data of all logical structures in a

tablespace.

Oracle Data Blocks

 At the finest level of granularity, Oracle database data is stored in data blocks.One data block corresponds to a specific number of bytes of physical databasespace on disk. The standard block size is specified by the DB_BLOCK_SIZE

initialization parameter.

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 6/27

Logical Structures (cont’d) 

Extents

The next level of logical database space is an extent. An extent is a specificnumber of contiguous data blocks, obtained in a single allocation, used to store aspecific type of information.

Segments

 Above extents, the level of logical database storage is a segment. A segment is aset of extents allocated for a certain logical structure. The different types of segments are :

Data segment – stores table data

Index segment – stores index data

Temporary segment – temporary space used during SQL execution

Rollback Segment – stores undo information

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 7/27

Logical Structures (cont’d) 

Schema Overview

 A schema is a collection of database objects. A schema is owned by a databaseuser and has the same name as that user. Schema objects are the logicalstructures that directly refer to the database's data. Schema objects include

structures like tables, views, and indexes.

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 8/27

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 9/27

Oracle Instance

 An Oracle database server consists of anOracle database and an Oracle instance.

Every time a database is started, a systemglobal area (SGA) is allocated and Oraclebackground processes are started. The

combination of the background processesand memory buffers is called an Oracleinstance.

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 10/27

System Global Area (SGA)

The System Global Area (SGA) is a shared memory region that contains data andcontrol information for one Oracle instance. Users currently connected to an Oracledatabase share the data in the SGA. The SGA contains the following memorystructures :

Database Buffer Cache

Database buffers store the most recently used blocks of data. The set of database buffers in an instance is the database buffer cache. The buffer cachecontains modified as well as unmodified blocks. Because the most recently (andoften, the most frequently) used data is kept in memory, less disk I/O is

necessary, and performance is improved.

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 11/27

System Global Area (cont’d) 

Redo Log Buffer of the SGA 

The redo log buffer stores redo entries —a log of changes made to the database.The redo entries stored in the redo log buffers are written to an online redo log,which is used if database recovery is necessary. The size of the redo log is static.

Shared Pool of the SGA 

The shared pool contains shared memory constructs, such as shared SQL areas. A shared SQL area is required to process every unique SQL statement submittedto a database. A shared SQL area contains information such as the parse treeand execution plan for the corresponding statement.

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 12/27

Program Global Area (PGA)

PGA is a memory buffer that contains data and control information for aserver process. A server process is a process that services a client’srequests. A PGA is created by oracle when a server process is started. Theinformation in a PGA depends on the oracle configuration. The PGA area is

a non-shared area of memory created by oracle when a server process isstarted.

The basic difference between SGA and PGA is that PGA cannot be sharedbetween multiple processes in the sense that it is used only forrequirements of a particular process whereas the SGA is used for the whole

instance and it is shared.

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 13/27

Oracle Background Processes

 An Oracle database uses memory structures and processes to manage and access thedatabase. All memory structures exist in the main memory of the computers thatconstitute the database system. Processes are jobs that work in the memory of thesecomputers.

Oracle creates a set of background processes for each instance. The backgroundprocesses consolidate functions that would otherwise be handled by multiple Oracleprograms running for each user process. They asynchronously perform I/O andmonitor other Oracle processes to provide increased parallelism for betterperformance and reliability.

The most common background processes are :

System Monitor – SMON This database background process performs instance recovery at the start of the

database. SMON also cleans up temporary segments that are no longer in useand recovers dead transactions skipped during crash and instance recoverybecause of file-read or offline errors. It coalesces i.e. combines contiguous freeextents into larger free extents.

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 14/27

Background Processes (cont’d) 

Process Monitor - PMON This database background process cleans up failed user processes. PMON is

responsible for releasing the lock i.e. cleaning up the cache and freeingresources that the process was using. Its effect can be seen when a processholding a lock is killed.

Database Writer - DBWR  This background process is responsible for managing the contents of the data

block buffer cache and dictionary cache. DBWR performs batch writes of changed block. Since Oracle uses write-ahead logging, DBWR does not need towrite blocks when a transaction commits. In the most common case, DBWR writes only when more data needs to be read into the system global area and

too few database buffers are free. The least recently used data is written to thedatafiles first.  Although there is only one SMON and one PMON process running per database

instance, one can have multiple DBWR processes running at the same time. Notethe number of DBWR processes running is set via the DB_WRITER_PROCESSES.

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 15/27

Background Processes (cont’d) 

Log Writer - LGWR 

This background process manages the writing of the contents of the redo logbuffer to the online redo log files. LGWR writes the log entries in batch form. TheRedo log buffers entries always contain the most up-to-date status of the

database. 

 Archiver - ARCH The Archiver process reads the redo log files once Oracle has filled them and

writes a copy of the used redo log files to the specified archive logdestination(s). Actually, for most databases, ARCH has no effect on the overallsystem performance. On some large database sites, however, archiving can havean impact on system performance.

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 16/27

Background Processes (cont’d) 

Checkpoint - CKPT  All modified information in database buffer in the SGA is written to the datafiles

by a database write process (DBWR). This event indicates a checkpoint. Thecheckpoint process is responsible for signaling DBWR at checkpoints andupdating all of the datafiles and control files of the database.

Recover - RECO The recover process automatically cleans up failed or suspended distributed

transactions.

Job Queue Processes Job queue processes are used for batch processing. They run user jobs. They

can be viewed as a scheduler service that can be used to schedule jobs asPL/SQL statements or procedures on an Oracle instance. Given a start date andan interval, the job queue processes try to run the job at the next occurrence of the interval.

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 17/27

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 18/27

Computer Science Database

Server Information

Sun e4500

8GB Ram

8 x 400mhz CPU

32GB Disk for

Oracle 4mm DAT DDS3

Tape Backup

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 19/27

Computer Science Database

Instance Name : CS01 (v$database)

Instance Version : 8.1.6.0.0

Tablespaces : (dba_tablespaces) SYSTEM – holds all system tables

INDEX01 – user indexes

USERS01 – user tables USERS02 – user tables (faculty)

RBS – rollback segments

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 20/27

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 21/27

Backup Methods

Cold Backup (aka Consistent Backups)

The only way to make a consistent whole database

backup is to shut down the database with theNORMAL, IMMEDIATE, or TRANSACTIONAL optionsand make the backup while the database is closed.

 Advantage : No recovery is required after datafilesare restored – quicker restore

Disadvantage : No access to database during backuptime (depends on size/system speed)

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 22/27

Backup Methods (cont’d) 

Hot Backup (aka Inconsistent Backups) If the database must be up and running 24 hours a

day, seven days a week, then you have no choice but

to perform inconsistent backups of the wholedatabase. A backup of online datafiles is called anonline backup. This requires that you run yourdatabase in ARCHIVELOG mode.

 Advantage : Database remains open during backup Disadvantage : Large databases may have

performance impact during backup, recovery takeslonger and is slightly more complex

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 23/27

Backup Methods (cont’d) 

Logical backup (Export)

Logical backups are exports of schema objects, like

tables and stored procedures, into a binary file.Oracle utilities are used to move Oracle schemaobjects in and out of Oracle.

Not recommended for backup of a whole database,but useful for backing up individual objects orschemas or moving data into another database

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 24/27

 Administrative Tasks

Daily Checks

Check database availability

Check logs / trace files

Check free space / resources

Check for invalid objects

Check for broken jobs Verify backup

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 25/27

 Administrative Tasks (cont’d) 

Weekly Tasks

Collect statistics (database job)

 Archive / delete log files

Run performance reports (statspack)

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 26/27

 Administrative Tasks (cont’d) 

Others

 Applying patches

Database upgrades

New Database installations

Creating user accounts

7/29/2019 Oracle Structure

http://slidepdf.com/reader/full/oracle-structure 27/27

More Information

Oracle 10g Release 2 Database Documentation http://www.oracle.com/pls/db102/ 

Oracle Database / SQL Help http://asktom.oracle.com/ 

http://www.oracle.com/technology//index.html 

*FREE* Oracle Software Downloads

http://www.oracle.com/technology/software/index.html 

Oracle Database 10g Express Edition

Oracle SQL Developer

This Document Computer Science Homepage -> On-Line help