Database Adminstration Notes 12
Database Adminstration Notes 12
BY
SHABNAM MURSALEEN
The Oracle family consists of a comprehensive suite of software, cloud solutions, and hardware
products developed by Oracle Corporation. Its core offerings include database management
systems, enterprise applications, cloud infrastructure, and specialized engineered systems.
Oracle products and services cater to a wide range of industries and businesses, providing robust
tools for managing data, running business applications, and modernizing IT infrastructures.
SQL is the standard language used to interact with relational databases. Common SQL
operations include:
Examples:
Create a Table:
CREATE TABLE Employees (
EmpID INT PRIMARY KEY,
Name VARCHAR(50),
Department VARCHAR(30),
Salary DECIMAL(10, 2)
);
Insert Data:
INSERT INTO Employees (EmpID, Name, Department, Salary)
VALUES (101, 'John Doe', 'IT', 75000.00);
Query Data:
SELECT Name, Department FROM Employees WHERE Salary > 50000;
SQL simplifies complex data management tasks, making it an essential skill for database
professionals.
A Database Administrator (DBA) is responsible for managing, maintaining, and securing the
organization’s databases to ensure smooth operations and optimal performance. The DBA serves
as the backbone of data management and ensures business continuity.
Importance of a DBA:
Conclusion
The Oracle family provides a comprehensive suite of tools to manage enterprise data and
processes efficiently. The concepts of RDBMS and SQL form the foundation for organizing and
querying data. A DBA’s role is pivotal in maintaining the health, security, and performance of
databases, making them a critical asset to any organization
The Oracle Database architecture can be broken into three main components:
1. Memory Structures
Memory structures in Oracle Database are used to store data, SQL queries, and program code for
efficient processing. They are divided into two key areas:
System Global Area (SGA): Shared memory used by all server processes. Key
components:
o Database Buffer Cache: Caches data blocks read from the database to reduce
disk I/O.
o Shared Pool: Stores parsed SQL statements and execution plans.
o Redo Log Buffer: Temporarily stores redo entries before they are written to disk.
o Java Pool: Used for Java-based applications running in the database.
o Large Pool: Optional memory area for large operations (e.g., backups, parallel
queries).
o Streams Pool: Used for Oracle Streams data replication.
Program Global Area (PGA): Private memory for each server process, which stores
session-specific data, like sort operations and SQL execution.
2. Process Structures
Oracle Database uses several processes to manage user requests, data storage, and recovery
operations. These are categorized as:
Server Processes: Handle user connections and execute SQL statements.
Background Processes: Support database operations. Common examples include:
o DBWn (Database Writer): Writes modified data blocks from memory to disk.
o LGWR (Log Writer): Writes redo log entries from the redo buffer to the log
files.
o CKPT (Checkpoint Process): Signals when a checkpoint occurs, ensuring data
consistency.
o SMON (System Monitor): Performs instance recovery after a failure.
o PMON (Process Monitor): Cleans up resources when a process fails.
o ARCn (Archiver): Archives redo logs for recovery purposes.
o MMON (Manageability Monitor): Collects and analyzes database performance
data.
3. Storage Structures
Storage structures manage the physical and logical layout of database data.
Logical Structures:
o Tablespaces: Logical storage units consisting of one or more data files.
o Segments: Allocate space for database objects (e.g., tables, indexes).
o Extents and Blocks: Smallest units of storage in a tablespace.
Physical Structures:
o Data Files: Store database data.
o Redo Log Files: Store redo entries for data recovery.
o Control Files: Contain metadata about the database structure.
In a multi-instance architecture, multiple database instances share access to the same database
files. This is achieved using Oracle RAC (Real Application Clusters).
Components: Each instance has its own SGA and background processes, but they
coordinate using the Global Cache Service (GCS).
Use Case: High availability and scalability for mission-critical applications.
Advantages:
o Load balancing across multiple instances.
o Automatic failover in case of instance failure.
Limitations:
o Requires specialized hardware and network configuration.
o More complex to set up and maintain.
1. Server Processes:
o Handle user connections and queries.
o Can be dedicated (one server process per user) or shared (multiple users share a
process).
2. Key Background Processes:
o DBWn: Writes dirty buffers to data files.
o LGWR: Ensures transaction durability by writing redo logs.
o ARCn: Archives redo logs for disaster recovery.
o SMON: Handles instance recovery and temporary segment cleanup.
o PMON: Frees resources from failed processes.
Conclusion
Oracle Database architecture is highly modular and flexible, ensuring efficient data management
for various business scenarios. While single-instance databases are ideal for smaller setups,
multi-instance architectures like RAC are suited for high-performance and high-availability
needs. The interplay of memory structures, processes, and storage structures ensures reliable
and scalable database operations.
Oracle's network environment enables communication between clients and the database server
using Oracle Net Services. Proper configuration ensures efficient and secure connectivity,
including support for shared server architecture.
Oracle Net Services enables database connections between clients and servers, as well as
between servers themselves. The configuration involves setting up network files on both the
server and the client.
1. Listener.ora (Server-Side)
o Defines the database listener that listens for client connection requests.
o Located at: $ORACLE_HOME/network/admin/listener.ora.
2. Tnsnames.ora (Client-Side)
o Maps service names to database connection details (host, port, service).
o Located at: $ORACLE_HOME/network/admin/tnsnames.ora.
3. Sqlnet.ora (Client and Server-Side)
o Configures the Oracle Net client and server, including security, timeouts, and
naming methods.
o Located at: $ORACLE_HOME/network/admin/sqlnet.ora.
The listener.ora file defines the database listener, which handles incoming connections from
clients.
Example of listener.ora:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl.example.com)
(SID_NAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/19c/dbhome_1)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
SID_NAME: Specifies the database instance name.
GLOBAL_DBNAME: Fully qualified database name used by clients.
ADDRESS: Specifies the protocol (TCP), host, and port.
lsnrctl start
Example of tnsnames.ora:
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.example.com)
)
)
tnsping ORCL
Example of sqlnet.ora:
NAMES.DIRECTORY_PATH = (TNSNAMES, EZCONNECT)
SQLNET.AUTHENTICATION_SERVICES = (NONE)
Oracle Net Manager and command-line tools can be used to manage and troubleshoot the
network environment.
3. TNSPING:
o Verifies if the client can reach the listener.
o Usage:
o tnsping ORCL
Conclusion
Configuring and managing the Oracle network environment involves properly setting up network
files (listener.ora, tnsnames.ora, sqlnet.ora) and using tools like Oracle Net Manager and
lsnrctl. Adopting a shared server architecture can significantly improve resource utilization in
high-concurrency environments. Let me know if you'd like assistance with a specific
implementation or troubleshooting!
Installing Oracle Database software and creating a database is a critical step for setting up an
Oracle Database environment. This process involves using the Oracle Universal Installer
(OUI) and the Database Configuration Assistant (DBCA). Below are detailed steps and
explanations.
The Oracle Universal Installer (OUI) is a graphical interface that simplifies the installation of
Oracle Database software.
Pre-Installation Requirements
1. System Requirements:
o Ensure sufficient CPU, memory, and disk space.
o Supported operating system (e.g., Windows, Linux, Unix).
2. Prerequisites:
o Install required packages (for Linux) or prerequisites (for Windows).
o Set kernel parameters (Linux only).
3. Oracle User:
o Create an OS-level user (e.g., oracle) for managing the database.
o Assign appropriate permissions to the Oracle installation directory.
The Database Configuration Assistant (DBCA) is a GUI tool for creating and managing Oracle
databases.
Steps to Create a Database Using DBCA
1. Launch DBCA:
o On Linux: Run dbca from the Oracle Home /bin directory.
o On Windows: Launch DBCA from the Start menu.
2. Database Creation Steps:
o Step 1: Select Operation:
Choose "Create a Database."
o Step 2: Select Database Type:
Choose between "Custom Database" (manual settings) or "General
Purpose/Transaction Processing."
o Step 3: Specify Database Name and SID:
Provide a Global Database Name (e.g., orcl.example.com) and System
Identifier (SID) (e.g., orcl).
o Step 4: Configure Storage:
Select storage type: File System, ASM (Automatic Storage Management),
or OMF (Oracle Managed Files).
o Step 5: Configure Memory Settings:
Allocate memory for the SGA and PGA.
Use the "Automatic Memory Management" option if desired.
o Step 6: Enable Database Features:
Enable optional components (e.g., Oracle Text, Spatial, OLAP).
o Step 7: Define Administrative Accounts:
Set passwords for SYS and SYSTEM accounts.
o Step 8: Specify Backup Options:
Configure recovery settings (e.g., enable ARCHIVELOG mode).
o Step 9: Finish Creation:
Review settings and create the database.
3. Verify Database Creation:
o Check the alert log and data dictionary views (e.g., v$database) to confirm
successful creation.
o Connect using SQL*Plus:
o sqlplus / as sysdba
o SELECT name FROM v$database;
The Instance
The Database
Definition: A database is a collection of physical files that store data, metadata, and logs.
Key Physical Files:
o Data Files: Store actual data (tables, indexes, etc.).
o Redo Log Files: Record changes for recovery purposes.
o Control Files: Maintain metadata about the database structure.
Logical Structures:
o Tablespaces: Logical storage units containing data files.
o Segments, Extents, Blocks: Hierarchical organization of data.
Conclusion
The installation and configuration of Oracle Database involve using the Oracle Universal
Installer (OUI) for software installation and the Database Configuration Assistant (DBCA)
for database creation. Understanding the instance, database, and data dictionary is crucial for
managing and optimizing Oracle Database systems. Let me know if you need assistance with any
specific step or command!
Managing an Oracle instance involves controlling the startup and shutdown processes,
understanding database initialization parameters, monitoring alert logs and trace files, and
utilizing data dictionary and dynamic performance views for database monitoring and tuning.
1. NOMOUNT Stage:
o The instance is started, and memory structures (SGA) and background processes
(DBWn, LGWR, etc.) are initialized.
o Control files, data files, and redo log files are not yet opened.
o This stage is primarily used for administrative tasks, such as database creation or
restoring control files.
o Command:
o STARTUP NOMOUNT;
2. MOUNT Stage:
o The instance locates and opens the control file specified in the init.ora or spfile.
o Data files and redo log files are not yet opened but are referenced in the control
file.
o This stage is often used for recovery operations.
o Command:
o STARTUP MOUNT;
3. OPEN Stage:
o The database is fully opened, and all data files and redo log files are accessible.
o The database is ready for user access and transaction processing.
o Command:
o STARTUP;
The shutdown process ensures that all changes are saved and users are disconnected cleanly.
1. SHUTDOWN IMMEDIATE:
o Rolls back active transactions, disconnects users, and closes the database.
o Recommended for regular maintenance.
o Command:
o SHUTDOWN IMMEDIATE;
2. SHUTDOWN NORMAL:
o Waits for all users to disconnect before shutting down.
o Command:
o SHUTDOWN;
3. SHUTDOWN TRANSACTIONAL:
o Waits for active transactions to complete before disconnecting users and shutting
down.
o Command:
o SHUTDOWN TRANSACTIONAL;
4. SHUTDOWN ABORT:
o Immediately terminates the database instance without saving changes.
o Should be used only in emergencies.
o Command:
o SHUTDOWN ABORT;
Initialization parameters are configuration settings that control the behavior of an Oracle
instance. These are stored in the parameter file:
1. Memory Management:
o SGA_TARGET: Total size of the System Global Area (SGA).
o PGA_AGGREGATE_TARGET: Total size of the Program Global Area (PGA).
o MEMORY_TARGET: Unified memory management for both SGA and PGA.
2. File Locations:
o DB_NAME: Name of the database.
o CONTROL_FILES: Path to the control file(s).
o DB_FILES: Maximum number of database files.
3. Logging and Recovery:
o LOG_ARCHIVE_DEST: Location for archived redo logs.
o UNDO_TABLESPACE: Specifies the undo tablespace.
4. Performance Tuning:
o DB_BLOCK_SIZE: Size of a database block.
o DB_CACHE_SIZE: Size of the database buffer cache.
Alert Log
Purpose: The alert log is a chronological log of messages and errors related to the
database instance. It records important events such as startup, shutdown, errors, and
changes to database structure.
Location:
o Default directory: $ORACLE_BASE/diag/rdbms/<db_name>/<instance_name>/trace
o File name: alert_<instance_name>.log
Content:
o Instance startup and shutdown details.
o Errors (ORA-xxxx).
o Background process messages.
o Space-related warnings.
Trace Files
Purpose: Trace files provide detailed diagnostic information for debugging and
performance analysis.
Types:
o User Trace Files: Generated for specific user sessions.
o Background Trace Files: Generated by background processes like DBWn,
LGWR, and SMON.
Location:
o Same as the alert log directory (trace folder).
Monitoring Logs
Data Dictionary
The data dictionary is a collection of metadata about the database. It contains information about
database objects, users, privileges, and more.
Query Examples:
SELECT table_name FROM all_tables;
SELECT username FROM dba_users;
SELECT object_name, object_type FROM dba_objects;
Dynamic performance views provide real-time information about the database instance,
including memory, performance, and process activity.
1. Instance Information:
o V$INSTANCE: Details about the instance (e.g., status, version).
o V$DATABASE: Information about the database (e.g., name, mode).
2. SELECT instance_name, status FROM v$instance;
3. SELECT name, open_mode FROM v$database;
4. Memory Usage:
o V$SGA: Details about the SGA usage.
o V$PGA: Information about the PGA.
5. SELECT * FROM v$sga;
6. SELECT * FROM v$pga;
7. Performance and Tuning:
o V$SQLAREA: Statistics about shared SQL statements.
o V$SESSION: Information about active sessions.
8. SELECT sql_id, executions, sql_text FROM v$sqlarea;
9. SELECT sid, username, status FROM v$session;
10. File Information:
o V$DATAFILE: Details about data files.
o V$LOG: Information about redo log files.
11. SELECT name, status FROM v$datafile;
12. SELECT group#, status FROM v$log;
Conclusion
Managing an Oracle instance involves:
Let me know if you'd like more detailed steps or examples for any specific aspect!
Managing database storage structures is a core task for a DBA, as it ensures the database
operates efficiently and that there is adequate storage for data growth and performance. Below is
an explanation of the concepts and tasks involved.
Tablespaces
Data Files
1. Blocks:
o Smallest unit of storage in an Oracle database.
o Default size: 8 KB (can be configured during database creation).
2. Extents:
o A group of contiguous blocks allocated for storing data.
o Extents grow as more space is needed for objects.
3. Segments:
o A segment is a collection of extents allocated for a database object (e.g., table,
index).
o Types of Segments:
Data Segment: Stores table data.
Index Segment: Stores index data.
Undo Segment: Stores undo data.
4. Tablespaces:
o Logical containers for segments and extents.
3. Automatic Storage Management (ASM)
What is ASM?
Benefits of ASM:
1. Disk Groups:
o Logical storage containers for ASM disks.
o Example: DATA, FRA (Fast Recovery Area).
2. ASM Instances:
o A separate Oracle instance that manages ASM storage.
Creating a Tablespace
Key Options:
Altering a Tablespace
Dropping a Tablespace
1. Drop a Tablespace:
2. DROP TABLESPACE users INCLUDING CONTENTS AND DATAFILES;
o INCLUDING CONTENTS: Deletes all objects in the tablespace.
o AND DATAFILES: Deletes associated physical files.
Reclaiming Space
Conclusion
Definition:
Key Aspects:
1. Creation:
o Users must be created to interact with the database.
o Each user is assigned default and temporary tablespaces for storing their objects
and managing temporary operations.
2. Account Status:
o Accounts can be active, locked, or expired.
o Inactive accounts can be locked to prevent unauthorized access.
3. Security Settings:
o Password complexity, expiration policies, and account resource limits ensure
strong user account security.
2. Privileges
Definition:
Privileges are permissions granted to users or roles, allowing them to perform specific
actions on the database.
Types of Privileges:
1. System Privileges:
o Allow users to perform administrative or system-level tasks.
o Examples:
CREATE SESSION: Allows the user to log in to the database.
CREATE TABLE: Allows the user to create tables.
DROP USER: Allows the user to delete user accounts.
2. Object Privileges:
o Allow users to perform actions on specific database objects (tables, views, etc.).
o Examples:
SELECT: Allows querying data in a table.
INSERT: Allows inserting data into a table.
UPDATE: Allows modifying existing data in a table.
3. Roles
Definition:
Types of Roles:
1. Predefined Roles:
o Oracle provides default roles, such as DBA, CONNECT, and RESOURCE.
o Example:
DBA: Full administrative privileges.
CONNECT: Basic privileges for database connectivity.
2. Custom Roles:
o DBAs can create custom roles to group specific privileges tailored to
organizational requirements.
Benefits of Roles:
4. Profiles
Definition:
A profile is a set of limits and security parameters applied to user accounts to control
their resource usage and define password policies.
Key Features:
1. Resource Limits:
o Profiles can limit the CPU time, number of sessions, and idle time for a user.
o Prevents resource overuse and ensures fair resource distribution.
2. Password Policies:
o Profiles enforce password complexity, reuse restrictions, and expiration rules.
o Ensures strong passwords and protects against unauthorized access.
3. Default Profile:
o All users are assigned a default profile unless a custom profile is specified.
Conclusion
A well-implemented user security strategy ensures controlled access to the database, protects
sensitive data, and reduces the risk of unauthorized activities. Let me know if you need further
details!
Database architecture refers to the design and structure of a database system that manages,
organizes, stores, and retrieves data efficiently. In Oracle databases, the architecture follows a
layered approach, ensuring scalability, performance, and security.
Refers to the actual files stored on disk that make up the database.
Key Components:
o Datafiles: Store the actual user and system data.
o Control Files: Record the structure of the database, including names and
locations of datafiles and redo logs.
o Redo Log Files: Record all changes made to the database for recovery purposes.
o Archive Log Files: Copies of redo log files used for backup and recovery.
The database is logically divided into tablespaces, which are further divided into smaller
units.
Key Components:
o Tablespaces: Logical containers for database objects (tables, indexes, etc.).
o Segments: A collection of extents used to store data for a specific object.
o Extents: A set of contiguous blocks allocated to a segment.
o Blocks: The smallest unit of storage in Oracle, typically 8KB by default.
3. Instance
Oracle uses multiple processes to manage database operations efficiently. Processes can be
categorized as:
1. Background Processes
2. Server Processes
3. User Processes
Database Modes
2. Multi-Instance Architecture
1. Tablespaces
2. Datafiles
1. User Layer:
o Users interact with the database using SQL, tools, or applications.
o Communication occurs via client/server architecture.
2. Database Layer:
o Includes memory, processes, and data storage.
o Manages transactions, data retrieval, and recovery.
3. Storage Layer:
o Physical storage of data in datafiles and redo log files.
o Provides data persistence and recovery capabilities.
1. Scalability: Supports growing data and user loads with features like Oracle RAC.
2. High Availability: Ensures minimal downtime using features like Data Guard and RAC.
3. Efficiency: Memory and process structures optimize query execution and storage usage.
4. Security: Fine-grained access control at the user and object levels.
5. Reliability: Robust recovery mechanisms using redo logs and archive logs.
Let me know if you need a specific part of the architecture elaborated further!