Oracle Database Architecture (Part 04)

Oracle Storage Structures


A-The Physical Structure :

The physical storage structures include three types of files (Critical files that make up a database) :
  1. Control files :Locations of other physical files, database name, database block size, database character set, and recovery information. These files are required to open the database.
  2. Data files :All application data and internal metadata
  3. Redo log files : Record of all changes made to the database; used for instance recovery.
Files not technically part of the database :
  1. Password file : Optional file used to store names of users who have been granted the SYSDBA and SYSOPER privileges
  2. Parameter file (pfile ,spfile): Configuration parameters for the SGA, optional Oracle features, and background processes.
  3. Archived redo log files : Copy of the contents of online redo logs, used for database recovery and for change capture.
  4. Oracle Net files : Entries that configure the database listener and client-todatabase connectivity
  5. Flashback log file :If the database has flashback logging enabled, files are written to the fast recovery area.

Control Files :

Store important information that is not available anywhere else , Include :

  1. The name of the database .
  2. A database-creation timestamp .
  3. The names, locations, and sizes of the data files and redo log files .
  4. Tablespace information .
  5. Redo log information used to recover the database in the case of a disk failure or user error.
  6. Archived log information .
  7. RMAN backup information .
  8. Checkpoint information .
To shows the types of information kept in the control file : 
  • SELECT type FROM v$controlfile_record_section;
The control files are created when the database is created in the locations specified in the control_files parameter in the parameter file.
Oracle uses the CKPT background process to automatically update each of these files as needed, keeping the contents of all copies of the control synchronized.

To display the names and locations and size of all the database’s control files.
  • SELECT name, file_size_blks, block_size FROM v$controlfile;
The control files can be stored in any directory; however, it is better if they are physically stored on different disks.




Data files :

the physical files that actually store the data that has been inserted into each table in the database.
data files are the physical structure behind another database storage area called a tablespace.
A tablespace is a logical storage area within the database.
Tablespaces group logically related segments.

By default, every Oracle Database must have at least three tablespaces (Required):
  1. SYSTEM : Stores the data dictionary tables and PL/SQL code.
  2. SYSAUX : Stores segments used for database options such as the Automatic Workload Repository, Online Analytical Processing (OLAP), and Spatial .
  3. TEMP : Used for performing large sort operations. TEMP is required when the SYSTEM tablespace is created as a locally managed tablespace; otherwise, it is optional.


To shows the data files associated with each tablespace in the database : 
  • SELECT tablespace_name, file_name FROM dba_data_files ORDER BY tablespace_name;
If the user has performed a committed transaction that modifies that data, the database writer process (DBWn) ultimately writes the modified data back to the data files.



Redo Log Files :

Whenever a user performs a transaction in the database, the information needed to reproduce this transaction in the event of a database failure is written to the redo log files, and the user does not get a confirmation of the commit until the transaction is successfully written to the redo log files.
 
Because of the important role that redo logs play in Oracle’s recovery mechanism, they are usually multiplexed. 
This means that each redo log contains one or more copies of itself in case one of the copies becomes corrupt or is lost because of a hardware failure. 
Collectively, these sets of redo logs are referred to as redo log groups. 
Each multiplexed file within the group is called a redo log group member. 
Oracle automatically writes to all members of the redo log group to keep the files in sync. 
Each redo log group must be composed of one or more members.


Each database must have a minimum of two redo log groups because redo logs are used in a circular fashion.
To shows information on redo logs in the database : 
To display which redo log group is currently active and being written to by LGWR :
  • SELECT group#, members, status FROM v$log ORDER BY group#;

To view the names of the redo log groups and the names and locations of their members :
  • SELECT group#, member FROM v$logfile ORDER BY group# ;


LGWR eventually writes this recovery information to the active redo log group until that log group is filled. LGWR switches to the next redo log until that log group fills with transaction information, and so on, until all available redo logs are used. When the last redo log is used, LGWR wraps around and starts using the first redo log again.(overwritten)

The following are the statuses available for log files : 
  1. UNUSED - Online redo log is new and never been written to.
  2. CURRENT - The current active redo log.
  3. ACTIVE - Log is active but is not the current log. It is needed for crash recovery.(FULL)
  4. CLEARING - A short time status during ALTER DATABASE CLEAR LOGFILE statement. After the log is cleared, the status changes to UNUSED.
  5. CLEARING_CURRENT - Current log is being cleared of a closed thread. The log file may be in this status if there is an I/O error writing the new log information.
  6. INACTIVE - Log is no longer needed for instance recovery.
If the database is operating in archive log mode, the contents of these previously used logs are copied to a secondary location before the log is reused by LGWR

Nearly all production databases run in archive-log mode because they need to be able to redo all transactions since the last backup in the event of a hardware failure or user error that damages the database.

If LGWR needs to write to the redo log group that ARCn is trying to copy but cannot because the destination is full, the database hangs until space is cleared on the drive.





B-The Logical Structure

Oracle logically divides the database into smaller units to manage, store, and retrieve data efficiently. 

  1. Tablespaces : The database is logically divided into smaller units at the highest level, called tablespaces. A tablespace has a direct relationship to the physical structure—a data file can belong to one and only one tablespace. A tablespace could have more than one data file associated with it.
  2. Segments : A segment is a set of extents allocated for logical structures such as tables, indexes, clusters, table partitions, materialized views, and so on. Whenever you create a logical structure that stores data, Oracle allocates a segment, which contains at least one extent, which in turn has at least one block. A segment is created when a table, index, materialized view, or a clustered table is created. 
  3. Extents : An extent is the next level of logical grouping. It is a grouping of contiguous blocks, allocated in one chunk. Because they are allocated in contiguous chunks, extents cannot spawn multiple data files.
  4. Blocks : A block is the smallest unit of storage in Oracle. A block is usually a multiple of the operating-system block size. A data block corresponds to a specific number of bytes of storage space.  The block size is based on the parameter DB_BLOCK_SIZE and is determined when the database is created.

A segment can be associated to only one tablespace; 
The extents of a segment may belong to more than one datafile. 




Exploring the Data Dictionary for Physical and Logical Structures
A-Physical Storage Structures
  1. Control Files
    • V$CONTROLFILE
  2. Redo Log Files
    • V$LOG
    • V$LOGFILE
  3. Data Files—The tablespace number (V$) or name (DBA) links a data file to its logical storage structure
    • V$DATAFILE
    • V$TEMPFILE
    • DBA_DATA_FILES
    • DBA_TEMP_FILES

B-Logical Storage Structures
  1. DBA_TABLESPACES
  2. DBA_SEGMENTS
  3. DBA_EXTENTS

Next Post Previous Post
No Comment
Add Comment
comment url