390 likes | 482 Views
Oracle Architecture. Instances and Databases (1/2). Instances and Databases (2/2). Instance Logical Temporal Database Physical Forever An instance can connect to one and only one database. The Component of a Database (1/21). Tablespace (1/2) A logical structure
E N D
Instances and Databases (2/2) • Instance • Logical • Temporal • Database • Physical • Forever • An instance can connect to one and only one database.
The Component of a Database (1/21) • Tablespace (1/2) • A logical structure • Each tablespace must consists of one or more datafiles, and each datafile can belong to only one tablespace.
The Component of a Database (2/21) • Tablespace (2/2)
The Component of a Database (3/21) • Three fundamental types of physical files in an Oracle database • Control files • Datafiles • Redo log files • Oracle Managed Files (OMFs) (Oracle9i)
The Component of a Database (5/21) • Control files (1/3) • Contents • A list of all the other files in the database • The name of the database • When the database was created • The current state of the datafiles • Need recovery • Read-only • If the database closed cleanly the last time it was shut down • The time period covered by each archived redo log • What backups have been performed for the database
The Component of a Database (6/21) • Control files (2/3) • Control file parameters (INIT.ORA) • MAXLOGFILES • MAXLOGMEMBERS • MAXLOGHISTORY • MAXDATAFILES • MAXINSTANCES
The Component of a Database (7/21) • Control files (3/3) • Multiple control files • At least two control files • The CONTROL_FILE parameter in the INIT.ORA file
The Component of a Database (8/21) • Datafiles (1/5) • Data • Tables • Indexes • Data dictionary • Rollback segments
The Component of a Database (9/21) • Datafiles (2/5) • Oracle block • Composed of operating system blocks • The DB_BLOCK_SIZE parameter in INIT.ORA • 2K to 32K • Oracle with Very Large Memory support • 64KB • Prior to Oracle9i, a single block size for the entire database. • With Oracle9i • A default block size for the database, up to five nonstandard block sizes in the database. • A single block size for each tablespace, but block sizes can be mixed within a database. • OLTP vs. data warehouse
The Component of a Database (10/21) • Datafiles (3/5)
The Component of a Database (11/21) • Datafiles (4/5) • Datafile header • The first block of each datafile. • Contains critical information used to maintain the overall integrity of the database. • Checkpoint structure.
The Component of a Database (12/21) • Datafiles (5/5) • Extent • A set of data blocks that are contiguous within an Oracle datafile. • Segment • An object that takes up space in an Oracle database.
The Component of a Database (13/21) • Redo log files (1/9) • Redo log files store a “recording” of the changes made to the database as a result of transactions and internal Oracle activities. • The recording of the changes in the redo logs is vital because it plays back the changes that were lost when the failure occurs.
The Component of a Database (14/21) • Redo log files (2/9) • Suppressing redo logging • UNRECOVERABLE (Oracle7) • NOLOGGING (Oracle 8)
The Component of a Database (15/21) • Redo log files (3/9) • A thread of redo
The Component of a Database (16/21) • Redo log files (4/9) • How Oracle uses the redo logs
The Component of a Database (17/21) • Redo log files (5/9) • Naming conventions for redo logs
The Component of a Database (18/21) • Redo log files (6/9) • Archived redo logs • Two types of redo logs • Online redo logs • Archived redo logs • Two modes with respect to archiving redo logs • NOARCHIVELOG • ARCHIVELOG
The Component of a Database (19/21) • Redo log files (7/9) • Two step to enable automatic archiving • Turn archive logging on • ALTER DATABASE ARCHIVELOG • Set parameters in INIT.ORA • LOG_ARCHIVE_START = TRUE • LOG_ARCHIVE_DEST • LOG_ARCHIVE_FORMAT • %S • %s • %T • %t
The Component of a Database (20/21) • Redo log files (8/9) • Multiple archive log destinations • INIT.ORA parameters • LOG_ARCHIVE_DUPLEX_DEST • LOG_ARCHIVE_MIN_SUCCEED_DEST
The Component of a Database (21/21) • Redo log files (9/9)
The Components of an Instance (1/14) • An Oracle instance can be defined as • An area of shared memory • System global area (SGA) • Change the SGA size • Prior to Oracle9i, stop and restart the instance. • With Oracle9i, while the Oracle instance is still running. • A collection of background processes
The Components of an Instance (2/14) • Some physical files that can be considered as part of the instance • The instance initialization (INIT.ORA) file • Many parameters may be altered dynamically. • Oracle9i • SPFILE • The instance configuration (CONFIG.ORA) file • Optional • The password file • Optional
The Components of an Instance (4/14) • Memory structure for an instance (1/4) • Database buffer cache • Caches blocks of data retrieved from the database. • “Least recently used” (LRU) algorithm. • Waiting to perform I/O until absolutely necessary. • Multiple buffer pools • DEFAULT • All objects use this cache unless otherwise indicated. • KEEP • For frequently used objects. • RECYCLE • For objects that are less likely to access again.
The Components of an Instance (5/14) • Memory structure for an instance (2/4) • Shared pool • Caches various constructs that can be shared among users. • SQL statements • Stored procedures • Data dictionary
The Components of an Instance (6/14) • Memory structure for an instance (3/4) • Redo log buffer • Caches redo information until it’s written to the physical redo log files.
The Components of an Instance (7/14) • Memory structure for an instance (4/4) • Large pool • Introduced in Oracle8 • To reduce the demand on the shared pool for certain large memory allocation. • Buffering I/O for various server process • Storing session memory for the Multi-Threaded Server • Using the XA protocol for distributed transactions
The Components of an Instance (8/14) • Background processes for an instance (1/7) • Database Writer (DBWR) • Writes database blocks from the database buffer cache in the SGA to the datafiles on disk. • Up to 10 DBWR processes, from DBW0 to DBW9. • Two main reasons for writing blocks out of the cache: • To perform a check point. • To free space in the cache.
The Components of an Instance (9/14) • Background processes for an instance (2/7) • Log Writer (LGWR) • Writes the redo information from the log buffer in the SGA to all copies of the current redo log file on disk. • When a transaction is committed, Oracle makes the redo information permanent by invoking the Log Writer to write it to disk.
The Components of an Instance (10/14) • Background processes for an instance (3/7) • System Monitor (SMON) • Maintains overall health and safety for an Oracle instance. • Performs crash recovery after an instance failure. • Coordinates and performs recovery for a failed instance when more than one instance accessing the same database. • Cleans up adjacent pieces of free space in the datafiles by merging them into one piece. • Gets rid of space used for sorting rows when the space is no longer needed.
The Components of an Instance (11/14) • Background processes for an instance (4/7) • Process Monitor (PMON) • Watches over the user processes that access the database. • Cleaning up any of the resources and releasing any locks if a user process terminates abnormally.
The Components of an Instance (12/14) • Background processes for an instance (5/7) • Archiver (ARCH) • Reads the redo log files once Oracle has filled them and writes a copy of the used redo log files to the specified archive log destination(s). • Up to 10 archiver process (ARCn).
The Components of an Instance (13/14) • Background processes for an instance (6/7) • Checkpoint (CKPT) • Performs checkpoints. • Updates the control file and database file headers to update the checkpoint data when the checkpoint is complete.
The Components of an Instance (14/14) • Background processes for an instance (7/7) • Recover (RECO) • Automatically cleans up failed or suspended distributed transactions.