30 DAY Oracle DBA Refresher
30 DAY Oracle DBA Refresher
2) Backup and Recovery: The DBA is responsible for ensuring that data is backed up
regularly and can be recovered quickly in case of failures. They use tools like
RMAN (Recovery Manager) to automate this critical task.
3) Performance Tuning: It’s the DBA's job to make sure the database runs
efficiently. This can involve optimizing SQL queries, configuring the system's
memory, and managing disk I/O to reduce bottlenecks.
4) Security Management: DBAs are also responsible for safeguarding the database.
They manage user access, roles, and permissions to ensure that only authorized
users can access sensitive data.
6) Patching and Upgrading: Keeping the Oracle Database up-to-date with the latest
patches and upgrades is critical for both performance and security.
Technical Knowledge:
✓Continuous Learning: Staying up to date with new Oracle releases, features, and
cloud technologies.
This post introduces the Oracle DBA role and its importance, setting the stage for
the deeper technical concepts that will follow in the next 29 days.
Today, we'll cover the installation of Oracle Database on a Linux system. Here’s a
simplified, step-by-step guide with essential commands to get Oracle up and
running.
---
bash
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
2. Create Directories:
bash
mkdir -p /u01/app/oracle/product/19.0.0/dbhome_1
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01
3. Install Prerequisites:
bash
yum install -y oracle-database-preinstall-19c
bash
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/ product/19.0.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
bash
cd $ORACLE_HOME
./runInstaller
3. Follow the Installation Wizard to configure the database (choose default options
for a basic setup).
bash
su root
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/19.0.0/dbhome_1/root.sh
### Step 4: Post-Installation
bash
lsnrctl start
bash
sqlplus / as sysdba
STARTUP
3. Verify Installation:
bash
lsnrctl status
ps -ef | grep pmon
Today, we’ll take a look at Oracle Database Architecture, which is key for
understanding how Oracle functions internally. Let’s break it down simply:
1. Memory Structures
- Program Global Area (PGA): Private memory for individual sessions, used for
operations like sorting data during queries.
---
2. Oracle Processes
- System & Process Monitors: Recover databases after crashes and manage failed
processes.
---
3. Storage Structures
---
- Instance: The memory (SGA) and background processes that manage the database.
- Database:The physical files (datafiles, control files, redo logs) that hold all
the data.
In short, Oracle Database uses memory to temporarily store and process data,
processes to manage operations, and storage structures to hold actual data on disk.
All of these work together to efficiently run the database.
Today, we’re diving into Tablespaces—a fundamental concept that every Oracle DBA
needs to master. Tablespaces are the logical layer between physical storage
(datafiles) and database objects like tables and indexes. They help manage how data
is stored and organized in the Oracle database.
A tablespace is a logical storage unit that groups related database objects (e.g.,
tables, indexes, etc.). Each tablespace consists of one or more datafiles on disk.
It acts as a bridge between logical objects and physical storage, organizing data
in a way that makes it easier to manage.
2) User Tablespaces:
Purpose: Used to store user data, such as tables and indexes created by users.
Why They Matter: This is where you, as a DBA, will focus your efforts in managing
space for user data.
3) Temporary Tablespaces:
Purpose: Store temporary data needed during operations like sorting or hashing.
Why They Matter: Helps manage intermediate results of queries and other temporary
data processing
4)Undo Tablespaces:
Purpose: Used to store undo data, which helps in rolling back transactions and
supporting read consistency.
Why They Matter: Ensures that the database can rollback transactions safely and
keeps data consistent.
Temporary and Undo tablespaces are automatically managed by Oracle but can be
customized for performance tuning.
✓Tablespace Management:
•Creating a Tablespace:
•Adding a Datafile:
•Resizing a Datafile:
Today, we’re focusing on User Management and Security, two critical aspects of
being an Oracle DBA. Properly managing users and securing the database is essential
for maintaining the integrity and safety of your data.
Key Concepts:
1) User Accounts:
Purpose: Users access the database through accounts that are granted specific
permissions.
Why It Matters: Each user has defined privileges, limiting what they can do within
the database.
2)Roles:
Purpose: A role is a set of privileges that can be assigned to users.
Why It Matters: Instead of assigning individual permissions, you can assign a role
that groups related privileges, simplifying user management.
3)Privileges:
System Privileges: Allow users to perform actions at the database level (e.g.,
create users, alter database).
Object Privileges: Control access to specific database objects like tables, views,
or procedures (e.g., select, insert, update).
4)Profiles:
Purpose: Profiles limit resources for users, such as connection time or memory
usage.
Why It Matters: Helps prevent one user from monopolizing resources, ensuring fair
use of the database.
✓Creating a User:
SQL> CREATE USER AMIT IDENTIFIED BY password;
✓Creating a Role:
SQL> CREATE ROLE data_analyst;
Today, we'll dive into the key Oracle processes that run behind the scenes to keep
the database operating smoothly. Understanding these processes is essential for
managing, troubleshooting, and optimizing Oracle Database.
1. User Processes
User processes interact with the Oracle database on behalf of the end-user or
application.
Initiates SQL Queries: Users connect to the database and run SQL commands.
Communicates with Server Processes: User processes communicate with Oracle's server
processes to execute SQL, retrieve data, and perform transactions.
Example: When you run a query in an application, it triggers a user process to
interact with the database.
2. Background Processes
These are crucial for the proper functioning of the database. They perform tasks
such as writing data to disk, recovering the system, and maintaining the database's
internal consistency.
Here are the most important background processes:
ARCn (Archiver)
Purpose: Copies redo log files to archive storage after a log switch.
Role: Helps with database recovery and backups by keeping historical logs.
Today, we will dive into one of the most critical aspects of database management:
Backup and Recovery. Proper backup and recovery strategies ensure that your
database can be restored in the event of data loss, corruption, or system failures.
1. Physical Backups:
These include copies of the physical database files (datafiles, control files, and
redo logs). Physical backups are essential for recovering from disk failures or
corruption.
Tools used: RMAN (Recovery Manager), a built-in Oracle utility that automates
backup and recovery processes.
2. Logical Backups:
Logical backups involve exporting the schema, tables, or database objects using
utilities like Data Pump Export/Import. These are typically used for migration or
object-level recovery.
Backup Strategies
* Full Backup:
A complete copy of the entire database, including all datafiles, control files, and
archived redo logs. Full backups can be time-consuming but are essential for point-
in-time recovery.
*Incremental Backup:
Backs up only the changes since the last backup. Incremental backups are faster and
save storage space but require more steps during recovery.
*Cumulative Backup:
Similar to incremental backups, but they include all changes made since the last
full backup.
Recovery Concepts
** Media Recovery:
This involves restoring datafiles from backups and applying redo logs to recover
lost data. Media recovery is typically required when files are corrupted or lost.
**Instance Recovery:
Oracle automatically performs instance recovery when a database crashes due to a
failure, such as a power outage. This process restores the database to a consistent
state without manual intervention.
RMAN (Recovery Manager) is Oracle's powerful tool for managing backups and
performing recovery. With RMAN, you can:
This command performs a full backup of the database and includes the archived redo
logs, ensuring point-in-time recovery.
💥 Execution Plans: Analyzed using EXPLAIN PLAN to understand how Oracle executes a
query.
💥Indexes: Creating indexes on frequently queried columns can speed up data
retrieval, though excessive indexing can slow down write operations
💥SQL Hints: Can be used to enforce specific join methods, like nested loop joins,
to improve query performance.
# Memory Management:
Oracle uses two main memory structures: System Global Area (SGA) and Program Global
Area (PGA). The SGA is shared among all database sessions, while the PGA is
allocated per session. Efficient memory management is key to maintaining good
performance, and the SGA_TARGET and PGA_AGGREGATE_TARGET parameters control memory
allocation.
✓SGA: Includes components like the buffer cache and shared pool.
✓PGA: Handles SQL execution and sorting for individual user sessions.
Regular monitoring with tools like AWR, Active Session History (ASH), and Oracle
Enterprise Manager (OEM) is crucial to understanding system performance trends and
addressing issues before they escalate.
Best Practices:
Today, we delve into the fundamentals of Oracle networking, which is essential for
enabling seamless communication between client applications and Oracle databases.
Proper understanding of these concepts helps DBAs troubleshoot connectivity issues
and configure database access efficiently.
👉Connection Process
1) Client Request: The client sends a connection request using a specified
connection string.
2) Listener Response: The listener accepts the request, identifies the database
instance, and establishes a connection.
3) Session Creation: A dedicated server process is created to handle the client’s
session.
2) Instance Tuning
✓Tuning the Oracle instance involves adjusting the memory settings, such as the
System Global Area (SGA) and Program Global Area (PGA), to optimize resource usage.
✓Monitor memory allocation and make adjustments to parameters like SGA_TARGET and
PGA_AGGREGATE_TARGET to improve performance.
3) I/O Performance
✓Disk I/O can become a bottleneck if not managed correctly. Use tools like
Automatic Workload Repository (AWR) and Active Session History (ASH) reports to
monitor I/O operations.
✓Implementing proper disk striping and storage technologies can enhance read/write
performance.
Mastering Oracle performance tuning is essential for DBAs to ensure efficient and
reliable database operations. By focusing on SQL optimization, instance tuning, I/O
performance, and continuous monitoring, you can significantly enhance the
performance of your Oracle databases. Join us tomorrow as we continue our journey
into the world of Oracle DBA!
Today, we’ll dive into the various Oracle backup strategies, focusing on full,
incremental, and differential backups. Understanding these backup methods is
crucial for ensuring data safety and recovery in the event of a failure or
disaster.
1)Full Backup
A full backup captures the entire database at a specific point in time
-Recovery: Restoring from a full backup requires the least amount of time since all
data is available in one backup set.
Command Example:
RMAN> BACKUP DATABASE;
2)Incremental Backup
An incremental backup captures only the data that has changed since the last
backup, whether it was a full backup or a previous incremental backup.
Types:
-Level 0 Incremental: Same as a full backup. It establishes the baseline for
subsequent incremental backups.
-Level 1 Incremental: Captures only changes since the last Level 0 or Level 1
backup.
-When to Use:
Suitable for environments with frequent data changes, as it reduces the amount of
storage space and time required for backups.
-Recovery: Restoring from incremental backups requires the last full backup and all
subsequent incremental backups.
Command Example:
RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;
3)Differential Backup
A differential backup captures all changes made since the last full backup.
-Recovery: Restoring from a differential backup requires the last full backup and
the most recent differential backup.
Command Example:
RMAN> BACKUP INCREMENTAL DATABASE;
✓Frequency of Backups
✓Retention Policy
✓Testing Restores
✓Automate Backups
✓Offsite Backups
✓Monitor Backup Performance
Today, we will explore Oracle Data Guard, a vital feature for ensuring high
availability and disaster recovery for Oracle databases. Understanding Data Guard
is essential for any DBA who wants to provide a robust solution for protecting data
in case of failures.
Oracle Data Guard is a feature of Oracle Database that provides a comprehensive set
of services to create, maintain, manage, and monitor one or more standby databases.
A standby database is a replica of the primary database that is maintained in sync
with it. In the event of a failure of the primary database, the standby database
can be activated to ensure minimal downtime and data loss.
Oracle Data Guard is a powerful tool for ensuring high availability and disaster
recovery for your Oracle databases. By understanding its components and how to
configure it, you can safeguard your data and minimize downtime.
Today, we’re diving into Oracle Automatic Storage Management (ASM), a key component
that simplifies the management of database storage, enhances performance, and
ensures optimal resource utilization. Understanding ASM is crucial for Oracle DBAs
working with large-scale databases and high-performance environments.
2. Scalability:
- You can dynamically add or remove disks from ASM disk groups, which provides
flexibility in scaling your storage based on demand without affecting the
database's availability.
3. Performance Enhancement:
- By striping data across multiple disks, ASM improves I/O performance, ensuring
faster read and write operations.
4. Data Protection:
- ASM uses redundancy features like mirroring to protect against disk failures. It
can automatically mirror data across different disks to provide fault tolerance.
✓ASM Components
1. ASM Disk Groups:
- Disk groups are the fundamental unit of storage in ASM. A disk group is a
collection of disks that ASM manages as a single unit. Database files are allocated
from disk groups, and ASM automatically stripes and mirrors files across the disks
in the group.
2. ASM Disks:
- ASM disks are the physical or logical storage units that make up a disk group.
These can be raw devices, LUNs (Logical Unit Numbers), or partitions.
3. ASM Extents:
- ASM breaks down database files into extents and distributes them across all the
disks in the disk group. This striping improves performance by allowing multiple
I/O operations to occur simultaneously.
4. ASM Mirroring:
- ASM provides three levels of redundancy:
- External Redundancy: No mirroring; relies on external storage systems for
redundancy.
- Normal Redundancy: Two-way mirroring to protect against a single disk failure.
- High Redundancy: Three-way mirroring to protect against two disk failures.
5. ASM Instance:
- ASM requires a separate instance (distinct from the database instance) to manage
the storage. The ASM instance doesn’t store data but coordinates and manages the
allocation of storage.
In this session, we will explore the key concepts of Oracle Database security,
focusing on roles, profiles, and auditing. By understanding these elements, you can
better manage user access and maintain a secure database environment.
- User Accounts: Identifying individual users who can access the database.
- Roles: Grouping privileges to simplify user management.
- Profiles: Defining resource limits and password policies.
- Auditing: Tracking and recording user activity for compliance and monitoring.
2. User Accounts
A user account in Oracle Database allows individuals to connect to the database and
perform actions based on the privileges granted to them.
3. Roles
Roles in Oracle Database are named sets of privileges that can be granted to users.
They simplify the management of privileges by allowing DBAs to group related
privileges together. For example, if multiple users require similar access levels,
you can create a role and assign it to them, rather than granting each privilege
individually.
4. Profiles
Profiles are used to manage user resource limits and password policies. Each
profile can enforce specific restrictions on users, such as limits on CPU usage,
sessions, and idle time.
5. Auditing
Auditing in Oracle Database involves tracking and recording user activities. It is
essential for compliance with regulations and for monitoring potentially
unauthorized actions. Oracle provides two types of auditing: standard auditing and
fine-grained auditing.
✓Patch Set Updates (PSU): Regularly released patches that include bug fixes and
security enhancements.
cd $ORACLE_HOME/OPatch
./opatch lsinventory
export ORACLE_HOME=/path/to/your/oracle_home
export ORACLE_SID=your_sid
cd $ORACLE_HOME/bin
./opatch apply
./opatch lsinventor
SQL> STARTUP;
SQL>EXEC DBMS_STATS.GATHER_DATABASE_STATS;
------------------
5. Snapshot Cloning
Snapshot Cloning is a method where storage-level snapshots are used to clone
databases. This method is fast and efficient for environments where storage systems
support snapshotting.
6.Oracle CloneDB
CloneDB is an Oracle feature introduced in Oracle 11g that allows administrators to
create clones of databases quickly by leveraging NFS (Network File System). CloneDB
creates sparse files for datafiles, which reduces the need for full copies of the
datafiles and speeds up the cloning process
Oracle Data Pump, a powerful utility for exporting and importing data and metadata
between Oracle databases. Data Pump provides high-speed movement of data and is a
critical tool for Oracle DBAs, especially for backup, recovery, migration, and data
transfer tasks.
Data Pump is a versatile and efficient tool for Oracle DBAs to move, backup, and
restore data across different environments. Understanding how to use expdp and
impdp effectively can greatly enhance database administration capabilities.
Welcome to hashtag#Day19 of our Oracle DBA journey!
Oracle Real Application Clusters (RAC) allows multiple instances of the Oracle
database to run on different servers, but share a single physical database. This
architecture improves availability, scalability, and reliability of the database
system. If one node in the cluster fails, the other nodes continue to function,
ensuring minimal downtime.
---
# Key Features of Oracle RAC:
1. High Availability (HA):
RAC provides high availability by allowing continuous service even when one or
more nodes in the cluster fail. The workload is redistributed across the remaining
nodes.
2. Scalability:
As the workload grows, more nodes can be added to the cluster to handle the
increased demand without affecting the overall performance.
3. Load Balancing:
RAC automatically distributes workload among all the active nodes in the cluster,
ensuring that no single node is overwhelmed.
4. Failover:
If one node fails, another node in the cluster automatically takes over the
processing. This failover is seamless, and users may not even notice any downtime.
5. Shared Storage:
All nodes in a RAC environment share a single storage pool. The database files are
located on shared storage, accessible by all nodes in the cluster.
6. Cache Fusion:
RAC uses Cache Fusion technology to manage data consistency across multiple
instances, ensuring that all nodes see the same data at the same time, and changes
are coordinated efficiently.
---
Stay tuned and follow Amit Amrao for more Oracle DBA tips and tricks!
Oracle's data dictionary is a set of read-only tables and views that store metadata
and provide crucial information about the database's structure, objects, users,
privileges, performance, and other important aspects.
Key characteristics:
✓Read-only: DBAs and users can query it, but cannot directly modify it.
✓Automatic updates: When database objects are created, altered, or deleted, the
dictionary is automatically updated.
✓System-maintained: Oracle manages this data internally.
✓Base Tables: These are the internal tables owned by the SYS user. They store the
actual metadata but are not directly accessible.
✓Data Dictionary Views: These are the views built on top of the base tables and are
categorized as:
✓Object Management:
-DBA_TABLES, ALL_TABLES, USER_TABLES: To check table structures.
-DBA_INDEXES, ALL_INDEXES: To gather information about indexes.
✓Storage Management:
-DBA_DATA_FILES: To monitor datafiles and their usage.
-DBA_SEGMENTS: For checking space usage of different segments.
-DBA_TABLESPACES: Information about the tablespaces and their statuses.
✓Performance Tuning:
-V$SESSION: Monitor active sessions.
-V$SQL: View SQL queries in execution.
-V$SYSTEM_EVENT: For identifying system-wide waits.
-V$PROCESS: To get information about background processes.
Welcome to hashtag#Day21 of our Oracle DBA Jounary !
✓Challenges:
- License Cost: Oracle Multitenant requires specific licensing, which may add cost.
- Learning Curve: DBAs familiar with traditional databases may need to adapt to
managing CDBs and PDBs.
Each stage initializes different components of the Oracle instance and database.
1. Nomount Stage
In this stage, Oracle initializes the instance, which includes allocating memory
and starting the background processes.
What Happens:
The System Global Area (SGA) is allocated.
Background processes like DBWn, LGWR, SMON, and PMON are started.
The control files, datafiles, and redo logs are not yet accessed
Use Case:
Typically used for creating a new database or restoring a control file.
2. Mount Stage
In this phase, the Oracle instance starts to access the control files and prepares
the database for opening.
SQL> STARTUP MOUNT;
3. Open Stage
In the final stage, Oracle opens the database and makes it available for user
access.
What Happens:
The datafiles and redo logs are opened.
Oracle verifies data consistency, and if needed, instance recovery occurs using the
redo logs.
SQL>STARTUP;
Use Case:
To fully start the database and allow connections and transactions.
1. Shutdown Normal
- This is the default and most graceful method to shut down the database. It allows
existing sessions to complete their work.
What Happens:
- New connections are not allowed.
- Oracle waits for all users to disconnect.
- Background processes terminate after all users are disconnected.
SQL>SHUTDOWN NORMAL;
Use Case:
- Used when there is no urgency, and all users can complete their work.
2. Shutdown Immediate
- This is a more forceful shutdown where all active transactions are rolled back,
and users are immediately disconnected.
What Happens:
- All active transactions are rolled back.
- Users are forcibly disconnected.
- The instance is stopped without waiting for users to finish.
- Commonly used when a fast shutdown is required, but data must remain consistent.
3. Shutdown Abort
- This is the most abrupt and forceful shutdown method. It stops the instance
immediately, without waiting for any process to complete.
What Happens:
- Oracle immediately halts the instance without performing a clean shutdown.
- Upon the next startup, Oracle performs instance recovery to ensure consistency.
Use Case:
- Used in emergency situations when the database is not responding or when a quick
restart is required.
4. Shutdown Transactional
- Oracle allows active transactions to complete but does not allow new transactions
or user connections.
What Happens:
- Oracle waits for active transactions to finish.
- Once all transactions are complete, the database shuts down.
Use Case:
- Used when you want to avoid interrupting active transactions but need to shut
down as soon as they are complete.
Understanding the various startup and shutdown stages and commands is essential for
effective Oracle database management. Knowing which method to use and when ensures
proper maintenance, recovery, and availability of the database system.
Welcome to hashtag#Day23 Part -I of our Oracle DBA Jounary !
✓chmod 755 filename # Assign read, write, and execute for the owner, read and
execute for group and others
✓chmod 644 filename # Assign read/write for the owner, read-only for group and
others
File Ownership:
chown oracle:dba /u01/app/oracle # Change owner to Oracle user and group to dba
5. Networking Commands
Oracle often communicates with clients or other database instances over the
network. Basic networking commands are essential.
✓ ifconfig - View network interfaces (may need ip addr on newer systems
✓ ping - Check network connectivity.
✓ netstat - View open ports and active connections.
9. Log Management
System logs and Oracle logs are vital for troubleshooting database and system
issues.
✓/var/log/messages: Main system log.
tail -f /var/log/messages # Continuously monitor system logs
✓Oracle alert log:
tail -f $ORACLE_BASE/diag/rdbms/orcl/orcl/trace/alert_orcl.log # Monitor Oracle
alert log
9. Log Management
System logs and Oracle logs are vital for troubleshooting database and system
issues.
✓/var/log/messages: Main system log.
tail -f /var/log/messages # Continuously monitor system logs
✓Oracle alert log:
tail -f $ORACLE_BASE/diag/rdbms/orcl/orcl/trace/alert_orcl.log # Monitor Oracle
alert log
✓ Scenario:
You accidentally delete some rows from a table and need to recover the data without
restoring from a backup. We’ll use a Guaranteed Restore Point to quickly revert the
changes.
Create a Guaranteed Restore Point: A guaranteed restore point allows you to roll
back the database to this exact point in time. Create the restore point before
making any changes:
SQL> CREATE RESTORE POINT before_delete GUARANTEE FLASHBACK DATABASE;
Shutdown the Database: The database must be in MOUNT mode to perform a flashback.
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
Flashback the Database to the Restore Point: Use the FLASHBACK DATABASE command to
revert the database to the state it was in when the restore point was created.
SQL> FLASHBACK DATABASE TO RESTORE POINT before_delete;
Open the Database: Once the flashback is complete, open the database with the
RESETLOGS option:
Guaranteed Restore Point ensures that flashback logs are kept even if there is
pressure on disk space, so you can always revert to this point.
Using flashback can help avoid restoring from backups and minimize downtime, making
recovery quick and efficient.