Monday, February 3, 2025

Oracle Database vs Database Instance

 

Oracle Database vs. Oracle Database Instance

Oracle uses a multi-layered architecture where the database and database instance are distinct yet interconnected. Understanding their differences is key for Oracle DBAs.


1. Oracle Database 📂

An Oracle Database is a collection of physical files that store data and metadata. It consists of:
Datafiles (.dbf) – Store actual user and system data.
Control files (.ctl) – Track database structure and SCN.
Redo log files (.log) – Record all changes for recovery.
Temporary & Undo tablespaces – Handle transactions and rollback.
Archived logs – Used for database recovery (in ARCHIVELOG mode).

Password File  

✅ Alert logs logs 

Trace logs logs 


🔹 The database persists even when the Oracle instance is shut down.


2. Oracle Database Instance 🚀

An Oracle Instance is a combination of memory structures (SGA & PGA) and background processes that interact with the database.

Instance Components:

SGA (System Global Area) – Shared memory that holds cached data and SQL execution plans.
PGA (Program Global Area) – Memory specific to each session/process.
Background Processes – Key ones include:

  • DBWR (Database Writer) – Writes data from memory to disk.
  • LGWR (Log Writer) – Writes redo logs to disk for recovery.
  • SMON (System Monitor) – Handles recovery and maintenance.
  • PMON (Process Monitor) – Manages user connections and process cleanup.

🔹 The instance exists only when the database is running.


Key Differences:

FeatureOracle DatabaseOracle Instance
DefinitionA collection of physical storage filesA combination of memory structures & background processes
PersistencePermanent (even after shutdown)Temporary (exists only when running)
ComponentsDatafiles, Control files, Redo logs, TablespacesSGA, PGA, Background Processes (DBWR, LGWR, PMON, SMON, etc.)
LocationStored on diskResides in RAM (memory)
Startup Required?Exists even when shut downCreated only when the database starts
Example/u01/oradata/orcl/system01.dbforcl (instance name) managed by pmon

Real-World Example:

  • When you start an Oracle database, an instance is created in memory.
  • When you shut down the database, the instance is removed, but the database files remain.
  • If a server crashes, the database files remain intact, but the instance must be restarted.

Command to Check Database & Instance:


SELECT name, open_mode FROM v$database; -- Checks database status SELECT instance_name, status FROM v$instance; -- Checks instance status


Oracle Database Server Configuration

Single Instance Database

A Single Instance Database is the most common Oracle Database deployment where one
database is managed by one instance on a single server


Architecture of a Single Instance Database

A Single Instance Database consists of:
One Oracle Database (datafiles, control files, redo logs, archive logs).
One Oracle Instance (SGA, PGA, background processes like DBWR, LGWR, SMON, PMON).
One Server hosting the instance and database.



+----------------------+ | Server | | +--------------+ | | | Instance | | 🟢 Instance manages memory (SGA/PGA) & processes | | (SGA, PGA) | | | +--------------+ | | | | | +--------------+ | | | Database | | 🟢 Database stores data (tablespaces, control files) | +--------------+ | +----------------------+


Key Features of a Single Instance Database

🔹 One-to-One Mapping → One instance manages one database.
🔹 Runs on a Single Server → CPU, memory, and disk resources belong to one system.
🔹 Uses Default Listener → Connects users via Oracle Net Listener (tnsnames.ora).
🔹 No High Availability (HA) Features → If the server fails, the database is down.
🔹 Supports Standby Databases → Can be used with Oracle Data Guard for disaster recovery.


Benefits of a Single Instance Database

Simple Deployment – Easy to install, configure, and manage.
Lower Cost – No need for shared storage or multiple nodes.
Efficient Performance – Best for applications that don’t require high availability.
Easier Backup & Recovery – Managed using RMAN (Recovery Manager).


Limitations of a Single Instance Database

No Automatic Failover – If the instance crashes, the database goes down.
No Load Balancing – Cannot distribute the workload across multiple nodes.
Scaling is Limited – Cannot scale horizontally like Oracle RAC.



Use Cases for a Single Instance Database

Development & Testing Environments – Simple setup for application testing.
Small to Medium Applications – Where high availability is not a critical requirement.
Standalone Systems – Used in banking, healthcare, and retail for isolated systems.


A Single Instance Database is ideal for low to medium workloads, but for

high availability,

solutions like Oracle RAC or Data Guard are recommended.


Multi Single Instance database on Same Server



+----------------------------------------------------------+ | Server | | +----------------+ +----------------+ | | | Oracle Home 1 | | Oracle Home 2 | | | | (Version 19) | | (Version 18) | | | +----------------+ +----------------+ | | | | | | +-----+-----+ +-----+-----+ | | | Database 1 | | Database 2 | | | | (db1) | | (db2) | | | +-----+-----+ +-----+-----+ | | | | | | +----+----+ +----+----+ | | | Datafiles | | Datafiles | | | | Control | | Control | | | | Redo Log | | Redo Log | | | +----+----+ +----+----+ | | | | | | +-----------------+ +----------------------------+. | | Listener for db1 | | Listener for db2 | | | (Port 1521) | | (Port 1522) | | +-----------------+ +----------------------------+ +----------------------------------------------------------+



Oracle RAC (Real Application Cluster )



Multiple Oracle Homes

Each database instance on the server can have its own Oracle Home, which is a directory

that contains the Oracle software binaries, libraries, and executables.

  • Oracle Home 1: /u01/app/oracle/product/19.0.0/dbhome_1 (for db1)
  • Oracle Home 2: /u01/app/oracle/product/18.0.0/dbhome_2 (for db2)

These separate Oracle Homes allow each instance to use its own Oracle binaries and

configurations (even different versions if needed).




1 comment:

  1. Please log into an Oracle server, set up your environment with the database shutdown and perform a "start nomount". The database is NOT running, only the Oracle instance. You can start the instance without the database running.

    ReplyDelete