0% found this document useful (0 votes)
3 views39 pages

30 DAY Oracle DBA Refresher

The document outlines the role and responsibilities of an Oracle Database Administrator (DBA), emphasizing their importance in managing Oracle databases across various environments. It covers key tasks such as database installation, backup and recovery, performance tuning, security management, and user management. Additionally, the document introduces fundamental concepts like Oracle database architecture, tablespaces, and essential DBA skills, setting the stage for a comprehensive 30-day learning journey.

Uploaded by

adiel0012345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views39 pages

30 DAY Oracle DBA Refresher

The document outlines the role and responsibilities of an Oracle Database Administrator (DBA), emphasizing their importance in managing Oracle databases across various environments. It covers key tasks such as database installation, backup and recovery, performance tuning, security management, and user management. Additionally, the document introduces fundamental concepts like Oracle database architecture, tablespaces, and essential DBA skills, setting the stage for a comprehensive 30-day learning journey.

Uploaded by

adiel0012345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 39

Welcome to hashtag#Day1 of our 30-day Oracle DBA Journey!

Let’s start with the basics:

What exactly is Oracle Database Administration (DBA)?

An Oracle Database Administrator (DBA) is a crucial role in managing and


maintaining Oracle databases—whether it’s for a small business or a large
enterprise.

Here's a snapshot of what Oracle DBAs do:

🔑 Key Responsibilities of an Oracle DBA:

1) Database Installation and Configuration: Oracle DBAs install and configure


Oracle Database software on various systems. They ensure the database is properly
set up for development, testing, and production environments.

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.

5) Monitoring and Maintenance: Regularly monitoring the database for potential


issues is key to maintaining optimal performance. DBAs use various Oracle tools and
logs to track the health of the system.

6) Patching and Upgrading: Keeping the Oracle Database up-to-date with the latest
patches and upgrades is critical for both performance and security.

🔍 Why is the Role of a DBA Important?

In today’s digital world, databases store everything from customer information to


financial records. Oracle DBAs are the gatekeepers of this critical data. Without
them, organizations could face system downtime, data loss, or even security
breaches.

💡 Top Skills for an Oracle DBA:

Technical Knowledge:

✓Understanding of Oracle architecture, SQL, PL/SQL, and database backup and


recovery processes.

✓Problem-Solving: Quickly diagnosing and fixing database issues to minimize


downtime.

✓Attention to Detail: Precision in managing data structures, security settings, and


recovery plans.

✓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.

Welcome to hashtag#Day02 of our Oracle DBA Journey!

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.

---

### Step 1: Pre-Installation Setup


1. Create Groups and User:

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

### Step 2: Download and Extract Oracle Database

1. Download Oracle 19c Software from the [Oracle


website](https://lnkd.in/dsukETQZ).

2. Extract the Files:


bash
unzip -d /u01/app/oracle/product/19.0.0/dbhome_1

### Step 3: Installing Oracle Database

1. Set Environment Variables:

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

2. Run Oracle Installer:

bash
cd $ORACLE_HOME
./runInstaller

3. Follow the Installation Wizard to configure the database (choose default options
for a basic setup).

4. Run Root Scripts (as prompted by the installer):

bash
su root
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/19.0.0/dbhome_1/root.sh
### Step 4: Post-Installation

1. Start the Listener:

bash
lsnrctl start

2. Start the Oracle Database:

bash
sqlplus / as sysdba
STARTUP

3. Verify Installation:

bash
lsnrctl status
ps -ef | grep pmon

Welcome to hashtag#Day03 of our Oracle DBA Journey!

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

Oracle’s memory is divided into:


- System Global Area (SGA):Shared memory that stores data and control information
for the database.

- Database Buffer Cache: Holds data that’s read or written.

- Shared Pool: Saves SQL execution plans and parsed statements.

- Redo Log Buffer:Logs changes made to the database for recovery.

- Large Pool: Optional, used for large processes like backups.

- Program Global Area (PGA): Private memory for individual sessions, used for
operations like sorting data during queries.

---

2. Oracle Processes

Oracle uses processes to manage tasks, divided into:

- Background Processes: Handle core operations like:

- DB Writer: Writes changes from memory to disk.

- Log Writer: Logs changes for recovery.

- Checkpoint: Syncs memory and disk data

- System & Process Monitors: Recover databases after crashes and manage failed
processes.

- User Processes:Represent client activities like executing SQL queries.

---

3. Storage Structures

Oracle stores data in several key structures:

- Datafiles:Store user data (tables, indexes, etc.).

- Control Files:Keep track of the database's structure and state.

- Redo Log Files: Record all changes for recovery.

- Tablespaces:Logical containers for organizing datafiles and related objects.

---

### 4. Instance vs. Database

- 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.

Welcome to hashtag#Day05 of our Oracle DBA Journey!

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.

✓What Are Tablespaces?

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.

✓Key Types of Tablespaces:

1) SYSTEM and SYSAUX Tablespaces:


Purpose: Store Oracle’s internal data (metadata and system-related objects).
Why They Matter: These are critical for the functioning of the database and should
be left for Oracle 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.

✓✓ How Tablespaces Work:


A tablespace is made up of datafiles, which physically store the data on disk.
When you create a table or index, it is assigned to a particular tablespace. Oracle
manages the physical storage (datafiles), while you as a DBA manage the logical
storage (tablespaces).

Temporary and Undo tablespaces are automatically managed by Oracle but can be
customized for performance tuning.

✓Tablespace Management:

Managing tablespaces involves monitoring the space usage, adding or resizing


datafiles, and making sure that there is always enough space for database
operations. You can use the following commands to manage tablespaces:

•Creating a Tablespace:

SQL>CREATE TABLESPACE users DATAFILE 'users01.dbf' SIZE 50M AUTOEXTEND ON;

•Adding a Datafile:

SQL>ALTER TABLESPACE users ADD DATAFILE 'users02.dbf' SIZE 100M;

•Resizing a Datafile:

SQL>ALTER DATABASE DATAFILE 'users01.dbf' RESIZE 200M;

Tablespaces are essential for managing data efficiently in Oracle databases.


Tomorrow, we’ll move on to User Management and Security—another key skill for DBAs!
Welcome to hashtag#Day06 of our Oracle DBA Journey!

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.

Basic User Management Commands:.

✓Creating a User:
SQL> CREATE USER AMIT IDENTIFIED BY password;

✓Granting Privileges to a User:


SQL> GRANT CREATE SESSION TO AMIT;

✓Creating a Role:
SQL> CREATE ROLE data_analyst;

✓Assigning Privileges to a Role:


SQL> GRANT SELECT, INSERT ON employees TO data_analyst

✓Assigning a Role to a User:


SQL> GRANT data_analyst TO AMIT;
Why Security Matters:

✓Data Protection: Securing user accounts and managing privileges prevent


unauthorized access and accidental data changes.
✓Resource Management: Controlling user access helps manage resources, ensuring
performance stability.
✓Compliance: Many organizations must meet regulatory requirements regarding data
access and security, making user management a priority.

Welcome to hashtag#Day07 of our Oracle DBA journey!

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.

Oracle Processes Overview


Oracle Database runs several processes, categorized into two types:

1) User Processes: These are initiated by users or applications to interact with


the database.
2) Background Processes: These are internal processes Oracle runs automatically to
manage database operations.

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:

DBWn (Database Writer)


Purpose: Writes modified (dirty) data blocks from memory (Buffer Cache) to disk.
Role: Helps free up space in the memory cache for new operations.

LGWR (Log Writer)


Purpose: Writes redo log entries from the Redo Log Buffer to the online redo log
files.
Role: Ensures that all changes made to the database are recorded for recovery in
case of failure.

SMON (System Monitor)


Purpose: Responsible for instance recovery after a crash.
Role: Cleans up temporary segments and coalesces free space in the database.

PMON (Process Monitor)


Purpose: Cleans up after failed processes, such as rolling back uncommitted
transactions.
Role: Frees resources held by failed processes and ensures system stability.

CKPT (Checkpoint Process)


Purpose: Updates control files and datafile headers with the latest checkpoint
information.
Role: Reduces recovery time by writing consistent data to disk periodically.

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.

Why Are These Processes Important for a DBA?


Understanding and managing these processes allows you to:
Diagnose performance issues: Like slow writes (DBWn) or redo log waits (LGWR).
Optimize system performance: By configuring parameters related to these processes.
Ensure system reliability: Through monitoring SMON, PMON, and ARCn for any recovery
or cleanup tasks.
Welcome to hashtag#Day08 of our Oracle DBA Journey!

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.

hashtag#Why Backup and Recovery Are Essential


Oracle databases store vast amounts of data, and losing this data could be
catastrophic. A well-planned backup strategy ensures that you can recover your
database to a consistent state after an unexpected issue, whether it’s a hardware
failure, a software bug, or human error.

## Types of Oracle Backups ##

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.

Using RMAN for Backup and Recovery

RMAN (Recovery Manager) is Oracle's powerful tool for managing backups and
performing recovery. With RMAN, you can:

-Create backups (full, incremental, and archived log backups).


-Automate the backup and restore process.
-Validate backups to ensure their integrity.
-Recover the database to a point in time.

Example of an RMAN Backup Command:

RMAN> BACKUP DATABASE PLUS ARCHIVELOG;

This command performs a full backup of the database and includes the archived redo
logs, ensuring point-in-time recovery.

Backup and recovery are critical components of database administration. By


understanding the types of backups and implementing proper strategies, you can
ensure that your Oracle database remains resilient and recoverable in the event of
any failure.
Welcome to hashtag#Day09 of our Oracle DBA journey!

Performance tuning is a critical aspect of database administration. It involves


optimizing the Oracle database to ensure smooth operations, improve query
performance, and make efficient use of system resources like CPU, memory, and disk
I/O. The main goal of tuning is to reduce response times, maximize throughput, and
ensure that the database is scalable and responsive to users' needs.

# Key Performance Metrics:


✓Response Time: The time taken by the database to process a query and return
results.
✓Throughput: The number of transactions or queries processed in a given time
period.
✓Resource Utilization: Monitoring the use of CPU, memory, and I/O to detect
bottlenecks.

# SQL Query Optimization:


SQL queries often have the biggest impact on performance. Optimizing queries
involves analyzing execution plans, ensuring the proper use of indexes, and
applying SQL hints to guide the optimizer towards better execution strategies.Tools
like Automatic Workload Repository (AWR) and SQL Tuning Advisor help identify
problematic queries and offer tuning suggestions.

💥 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.

# Managing I/O Operations:


Disk I/O is often the slowest part of database operations. Improving I/O
performance involves optimizing queries to reduce unnecessary disk reads, using
Automatic Storage Management (ASM) to balance I/O across disks, and leveraging disk
striping to distribute data.
# Configuration and Parameter Tuning:
Oracle’s initialization parameters have a significant impact on performance. Key
parameters include:

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:

✓Regularly review and optimize SQL queries.


✓Ensure proper indexing strategies.
Continuously monitor memory and I/O usage.
✓Adjust initialization parameters for optimal performance.

Welcome to hashtag#Day10 of our Oracle DBA journey!

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.

✌️Key Concepts of Oracle Networking


1)Oracle Net (SQL*Net)
Oracle Net is the network interface that allows communication between client
applications and the Oracle database. It handles the connection establishment,
manages the transport of SQL requests from clients to the server, and returns the
results back to the client.
2)hashtag#Listener
The Oracle Listener is a server-side process that listens for incoming connection
requests from clients. It operates on a designated port (default: 1521) and directs
requests to the appropriate database instance. Key configuration is done in the
listener.ora file.
3)hashtag#TNS (Transparent Network Substrate)
TNS defines the protocol that Oracle Net uses for connecting clients to databases.
It includes connection details like hostname, port, and service name. The
tnsnames.ora file on the client machine contains the mapping of network service
names to their corresponding database connect strings.

👉Components of Oracle Networking


✓Client: The user’s machine or application sending requests to the database.
✓Server: The machine where the Oracle database resides.
✓Network Protocol: Primarily TCP/IP, but Oracle supports other protocols as well.
✓Database Service: A logical representation of the database clients connect to.

👉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.

👉Common Networking Issues


✓Listener Down: If the listener isn’t running, clients cannot connect.
✓Incorrect tnsnames.ora: Errors in this file can lead to connectivity problems.
Ensure all details are accurate.
✓Firewall Restrictions: Firewalls can block the database port (1521), preventing
connections. Ensure the necessary ports are open.

👌Best Practices for Oracle Networking

✓Monitor Logs: Regularly review the listener log


($ORACLE_HOME/network/log/listener.log) for any issues.
✓Secure Connections: Implement SSL or Kerberos for secure authentication between
clients and the database.
✓Load Balancing: Utilize Oracle Net features to distribute connections among
multiple servers for improved performance and availability.

Understanding Oracle networking is essential for ensuring reliable database access.


Properly configuring files like listener.ora and tnsnames.ora allows DBAs to
facilitate efficient and secure communication between clients and Oracle databases.
Welcome to hashtag#Day11 of our Oracle DBA journey!

Today, we’ll explore the fundamentals of Oracle performance tuning, which is


crucial for ensuring that your Oracle database runs efficiently and effectively.
Understanding how to identify performance bottlenecks and optimize database
operations can significantly enhance the user experience and system reliability.

👉What is Performance Tuning?


Performance tuning in Oracle involves analyzing and adjusting database settings and
SQL queries to improve system performance. The goal is to make the best use of
system resources while minimizing response time for database operations

👉Key Areas of Focus in Performance Tuning

1) SQL Query Optimization


✓SQL queries are the primary way users interact with the database. Optimizing SQL
involves examining execution plans, reducing complexity, and ensuring the most
efficient use of indexes.
✓Execution Plans: Use the EXPLAIN PLAN command to analyze how Oracle executes SQL
statements and identify potential inefficiencies.
✓Indexing: Proper indexing can drastically improve query performance. Understand
when to create indexes and how to manage them.

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.

4)Configuration and Tuning Parameters


✓Adjusting database parameters using the ALTER SYSTEM command can lead to
performance improvements. Some common parameters include:
-OPTIMIZER_MODE
-ALL_ROWS
-DB_BLOCK_SIZE

5) Monitoring and Diagnosis


✓Use Oracle’s built-in tools such as SQL Trace, AWR, and ASH to gather performance
metrics. These tools help diagnose performance issues and identify trends over
time.
✓Regularly review wait events and resource usage to pinpoint where time is being
spent during query execution.

📝Common Performance Issues


✓Long Running Queries
✓High CPU Usage
✓Lock Contention

✌️Tools for Performance Tuning


-SQL Developer
-AWR Reports
-ASH Reports

👉Best Practices for Performance Tuning


1. Regular Monitoring
2. Benchmarking
3. Keep a record of document (SOP)

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!

Welcome to hashtag#Day12 of our Oracle DBA journey!

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.

📝Why Backup Strategies Matter


Backups are essential for protecting data against corruption, accidental deletion,
or catastrophic failures. A well-defined backup strategy ensures that your database
can be restored quickly and efficiently, minimizing downtime and data loss.

✓Types of Backups in Oracle

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;

Backup Strategies: Considerations and Best Practices

✓Frequency of Backups
✓Retention Policy
✓Testing Restores
✓Automate Backups
✓Offsite Backups
✓Monitor Backup Performance

Understanding and implementing effective backup strategies is crucial for Oracle


DBAs to ensure data integrity and availability. By utilizing full, incremental, and
differential backups, you can create a robust backup strategy that meets your
organization’s needs. Join us tomorrow as we continue to explore more advanced
topics in Oracle database management!
Welcome to hashtag#Day13 of our Oracle DBA journey!

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.

👉 What is Oracle Data Guard?

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.

✓Key Components of Oracle Data Guard


1. Primary Database
- The primary database is the main database that performs all transactions and
serves the application's read and write requests.
2. Standby Database
- The standby database is a synchronized copy of the primary database. It can be
either:
- Physical Standby: A physical copy of the primary database, which uses the same
binary format as the primary.
- Logical Standby: A standby database that is logically consistent with the
primary but may be in a different format (e.g., different table structures).
3. Redo Transport Services
- Redo transport services are responsible for transmitting redo data (the changes
made to the primary database) from the primary to the standby database. This can be
done using:
- Synchronous Transport: Guarantees that redo data is written to both the primary
and standby databases before confirming the transaction to the application. This
minimizes data loss but may impact performance.
- Asynchronous Transport: Sends redo data to the standby database without waiting
for confirmation. This improves performance but may result in some data loss if a
failure occurs.

4. Data Guard Broker


- The Data Guard Broker is a management framework that automates and simplifies
the management of Data Guard configurations. It provides a centralized interface
for monitoring and managing both primary and standby databases.

# Benefits of Using Oracle Data Guard


✓High Availability: Provides automatic failover capabilities, ensuring that the
database remains available even in the event of a failure.
✓Disaster Recovery: Protects against data loss due to disasters, hardware failures,
or human errors.
✓Reduced Downtime: Minimizes downtime during maintenance and upgrades by allowing
operations to continue on the standby database.
✓Data Protection:Ensures data integrity and consistency across primary and standby
databases.

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.

Welcome to hashtag#Day14 of our Oracle DBA journey!

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.

✓What is Oracle ASM?


Oracle ASM is a volume manager and a file system specifically designed for Oracle
databases. It automates and optimizes the storage management tasks, balancing data
placement, and maximizing disk utilization. ASM provides a way to manage database
files (like datafiles, control files, and log files) by abstracting the physical
storage, making it easier for DBAs to handle.

✓ Key Features of Oracle ASM


1. Simplified Storage Management:
- ASM automatically manages the placement of database files, distributing them
across all available disks. This reduces the need for manual intervention and
ensures even distribution of data.

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.

# Advantages of Using ASM


- Improved Performance
- High Availability
- Simplified Administration
- Dynamic Scaling

Welcome to hashtag#Day15 of our Oracle DBA journey!

Oracle Database Security: Roles, Profiles, and Auditing

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.

1. Oracle Database Security Fundamentals


Oracle Database security encompasses a variety of measures to protect data and
control access. This includes user authentication, authorization, and auditing.
Security can be implemented through various features, such as:

- 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.

Benefits of Using Roles:


- Simplifies privilege management.
- Enhances security by allowing for easier role-based access control.
- Reduces the risk of privilege escalation.

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.

Fine-Grained Auditing (FGA):


FGA allows you to define specific conditions under which auditing occurs, providing
more granular control over auditing policies.

Best Practices for Database Security

1. Principle of Least Privilege


2. Regularly Review User Privileges
3. Implement Strong Password Policies
4. Utilize Auditing Effectively
5. Backup Audit Trails
6. Encrypt Sensitive Data

Oracle Database security is a multi-layered approach that involves user management,


role-based access control, profile management, and auditing. By understanding and
effectively implementing these security features, database administrators can help
protect sensitive data and maintain a secure database environment.
Welcome to hashtag#Day16 of our Oracle DBA journey!

Oracle Database Patch Management


Patch management is the process of applying updates to Oracle databases to fix
bugs, improve security, and enhance performance. Oracle releases various types of
patches, including:

✓Patch Set Updates (PSU): Regularly released patches that include bug fixes and
security enhancements.

✓One-Off Patches: Specific patches to address particular issues, typically not


bundled with PSUs.

✓Critical Patch Updates (CPU): Security patches released quarterly.

"Step-by-Step Commands to Apply Oracle Database PSU"


------------------
### Step 1: Pre-Application Preparation

1. Check Current Database Version:

SQL> SELECT * FROM v$version;

2. Summary of Pre-requisite Checks:


- Ensure database compatibility with the PSU.
- Check the current database version.
- Verify that the database is in a consistent state.
- Backup the database and confirm you have sufficient disk space.
- Review the README file for any specific prerequisites related to the patch.

3. Check the Database State:


- Ensure the database is in a consistent state.

SQL>SELECT status FROM v$instance;

4. Backup the Database using RMAN


RMAN> BACKUP DATABASE PLUS ARCHIVELOG;

5. Check Existing Patches:

cd $ORACLE_HOME/OPatch
./opatch lsinventory

6. Check for Pre-Installation Requirements:


- Review the README file that comes with the PSU for any specific prerequisites.
- Ensure you have sufficient disk space in the `$ORACLE_HOME` directory.

### Step 2: Apply the Patch

7. Stop the Database:

SQL> SHUTDOWN IMMEDIATE;

8. Set Environment Variables:

export ORACLE_HOME=/path/to/your/oracle_home
export ORACLE_SID=your_sid

9. Navigate to OPatch Directory:

cd $ORACLE_HOME/bin

10. Apply the Patch Using OPatch:

./opatch apply

11. Verify Patch Application:

./opatch lsinventor

### Step 3: Post-Application Steps

12. Start the Database:

SQL> STARTUP;

13. Run Post-Patch Scripts (if required):


- Execute any necessary scripts as per PSU documentation.

14. Gather Statistics:

SQL>EXEC DBMS_STATS.GATHER_DATABASE_STATS;

15. Validate Database Functionality:


- Perform application tests as needed.

16. Monitor Database Performance:


- Check performance metrics and logs.

------------------

** Why Patch Management is Important **:


✓Security: Protects against vulnerabilities and attacks.
✓Stability: Resolves known issues and bugs.
✓Performance: Improves overall database performance and functionality.

Welcome to hashtag#Day17 of our Oracle DBA journey!

Oracle Database Cloning, a vital process for database administrators

✓What is Oracle Database Cloning?


Database cloning is the process of creating an exact replica of an existing Oracle
database. This clone includes all data, configurations, and settings from the
original database. The cloned database can be located on the same server (duplicate
database) or on a different server entirely.

*Below are the types of Oracle Database cloning:

1. RMAN Cloning (Recovery Manager Cloning)


RMAN is Oracle's built-in tool for backup, recovery, and database duplication. It
is widely used for cloning databases because it is efficient, reliable, and
supports both active and backup-based cloning. RMAN supports creating a clone from
a running database (Active Database Duplication) or from backup files.

A. Active Database Duplication


B. Backup-Based Duplication

2. Cold Backup Cloning


Cold Backup Cloning involves creating a clone of the database after the source
database is completely shut down. This method ensures that the database is in a
consistent state because no transactions are happening while the files are copied.

3. Hot Backup Cloning


Hot Backup Cloning is performed while the source database is still running. The
database is placed in ARCHIVELOG mode, allowing backups of datafiles while
transactions continue. Datafiles are copied while the database is online, and
archived redo logs are applied later to synchronize the clone with the current
state of the source database.
4.Data Pump (Logical Cloning)
Oracle Data Pump is used for logical cloning by exporting the database objects from
the source database and importing them into a target database. This method allows
the transfer of specific database objects such as tables, schemas, or the entire
database.

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

7. Oracle RAC (Real Application Clusters) Cloning


In Oracle RAC environments, cloning involves creating a duplicate of a RAC
database. This can be done using RMAN, Data Pump, or snapshot technologies,
depending on the cluster setup and requirements.

8. Oracle Multitenant (PDB Cloning)


Oracle's Multitenant Architecture allows administrators to create clones of
Pluggable Databases (PDBs) easily. This type of cloning is available in Oracle 12c
and later versions.

Welcome to hashtag#Day18 of our Oracle DBA journey!

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.

× Key Concepts of Oracle Data Pump


✓Export (expdp): This utility extracts data from the database and writes it into a
dump file, which can later be imported into another database.
✓Import (impdp): The import utility reads the dump file created by expdp and re-
creates the database objects in another database.

× Benefits of Using Data Pump


✓High Performance: Uses parallelism to speed up data movement.
✓Flexibility: You can export/import full databases, schemas, tables, or selected
objects.
✓Network Mode: Allows direct loading of data across databases without creating a
dump file.

×Data Pump Components


✓Dump File: The file that stores exported data.
✓Log File: Captures details of the export/import process.
✓SQL File: Optionally stores the SQL commands that would be used to recreate the
database objects.

×Data Pump Commands

1. Export Command (expdp):


✓Export a full database:
$ expdp system/password@DBNAME FULL=Y DUMPFILE=full_db.dmp LOGFILE=full_db.log
✓Export a specific schema:
$ expdp system/password@DBNAME SCHEMAS=schema_name DUMPFILE=schema.dmp
LOGFILE=schema.log

2. Import Command (impdp):


✓Import the entire database:
$ impdp system/password@DBNAME FULL=Y DUMPFILE=full_db.dmp
LOGFILE=full_db_import.log
✓Import a specific schema:
$ impdp system/password@DBNAME SCHEMAS=schema_name DUMPFILE=schema.dmp
LOGFILE=schema_import.log

×Data Pump Advanced Options

✓INCLUDE/EXCLUDE: Specify which objects to include or exclude.


✓PARALLEL: Speed up the process by executing operations in parallel.
✓REMAP_SCHEMA: Change the schema while importing data.

×Practical Use Cases

✓Database Migration: Moving databases across different Oracle environments.


✓Data Archiving: Exporting old data for archival purposes.
✓Testing and Development: Creating test environments by cloning production data.

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.
---

✓Practical Use Cases:


1. High Availability Applications:
RAC is commonly used in applications where downtime is unacceptable, such as in
banking, e-commerce, or online transaction processing systems.
2. Scalable Systems:
As demand increases, businesses can add more servers to the RAC cluster to
increase capacity without disrupting existing services.
3. Data Center Optimization:
RAC helps organizations optimize resources in their data centers, allowing
multiple systems to share the same database, improving resource utilization.
---

# Commands to Manage RAC:

- Check RAC Status:


$ crsctl check cluster

- Start/Stop RAC Cluster:


$ srvctl start database -d db_name
$ srvctl stop database -d db_name

- Check Instance Information in RAC:


SQL> select INSTANCE_NUMBER, INSTANCE_NAME, STATUS from gv$instance;

- Adding a Node to the RAC:


$ srvctl add instance -d db_name -i instance_name -n node_name
---

Oracle RAC is a critical feature for organizations that require continuous


availability and scalable database systems. With its ability to provide fault
tolerance, load balancing, and seamless failover, RAC is a valuable solution for
mission-critical environments.

Stay tuned and follow Amit Amrao for more Oracle DBA tips and tricks!

Welcome to hashtag#Day20 of our Oracle DBA journey!

Understanding Data Dictionary Tables in Oracle Database

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.

As an hashtag#OracleDBA, mastering the data dictionary helps in effective database


administration, troubleshooting, and monitoring.

1. What is the Data Dictionary in Oracle?


The Oracle Data Dictionary is a centralized repository containing metadata—the data
about the data stored within the database. It holds information about database
structures such as tables, indexes, columns, users, roles, and more.

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.

2. Structure of the Data Dictionary


The data dictionary is organized into different categories, primarily consisting of
tables and views. These are structured in a way that allows different levels of
access for users depending on their privileges.

✓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:

hashtag#USER_Views: Show information about objects owned by the current user.


hashtag#ALL_Views: Show all objects accessible by the current user, including those
owned by other users.
hashtag#DBA_Views: Show detailed information about all objects in the database
(accessible only by DBAs).
hashtag#V$ Views (Dynamic Performance Views): Provide real-time performance and
session-related information about the Oracle instance.

3.Key Data Dictionary Views for Different DBA Tasks

✓Object Management:
-DBA_TABLES, ALL_TABLES, USER_TABLES: To check table structures.
-DBA_INDEXES, ALL_INDEXES: To gather information about indexes.

✓Security & User Management:


-DBA_USERS: For managing user accounts.
-DBA_ROLES: For viewing roles in the database.
-DBA_SYS_PRIVS: To check system privileges granted to users and roles.
-DBA_TAB_PRIVS: To check table-specific privileges.

✓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.

✓Backup & Recovery:


-V$BACKUP: Shows the status of ongoing backups.
-V$ARCHIVED_LOG: Provides details about archived redo logs.

✓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 !

Oracle Multitenant Architecture Overview:


- Oracle introduced multitenant architecture starting with Oracle 12c.
- It allows for the creation of a Container Database (CDB) with multiple Pluggable
Databases (PDBs).
- This architecture improves resource management, consolidation and scalability.

✓Traditional Oracle Database(Pre-12c)


- Each database in a traditional architecture operates independently.
- It has its own system tablespace, control files, redo logs, background processes,
and memory structures.
- Database management and administration are performed on a per-database basis.
- Higher resource usage due to each database running separate instances of
processes.

✓Multitenant Database (12c and Later)


- Single Container Database (CDB) hosts multiple Pluggable Databases (PDBs).
- Shared system tablespaces, memory structures, redo logs, and background processes
across PDBs.
- Pluggable Databases (PDBs) are isolated but share a single container instance.
- PDBs can be plugged and unplugged from a CDB, making migration and management
easier.
- Easier consolidation: Multiple applications or databases can run within a single
CDB, saving resources.

✓Advantages of Multitenant Architecture:


1. Cost and Resource Efficiency: Shared memory and processes result in less
overhead.
2. Simplified Management: Centralized management of multiple databases through one
CDB.
3. Easy Migration: PDBs can be plugged or unplugged from a CDB, making database
migration simpler.
4. Backup & Recovery: Backups can be done at the CDB level or per PDB, offering
more flexibility.
5. Consolidation: It allows for the easy consolidation of multiple databases into a
single instance without complex architecture changes.

✓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.

The Oracle Multitenant architecture offers significant benefits, especially for


enterprises looking to consolidate databases and optimize resources. The ability to
manage multiple pluggable databases within a single container makes administration
more efficient, especially in cloud and large-scale environments.
Welcome to hashtag#Day22 Part - I of our Oracle DBA Jounary !

Overview of Oracle Database Startup Command

Oracle databases go through specific stages during startup and shutdown.


Understanding these processes ensures that database administrators (DBAs) can
manage the database correctly, avoid corruption, and perform maintenance tasks
efficiently.

Oracle Database Startup Process


The Oracle Database startup process consists of three primary stages: Nomount,
Mount, and Open.

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

SQL> STARTUP NOMOUNT;

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;

What Happens in the Background:


Reads Control Files: The control files are read to gather metadata about the
physical structure of the database, such as the locations of the datafiles and redo
log files.
Mounts the Database: The database is mounted, but no datafiles or redo log files
are opened yet.
The mount stage is often used during certain maintenance tasks, such as performing
recovery or renaming datafiles.

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.

Welcome to hashtag#Day22 Part -II of our Oracle DBA Jounary!

Oracle Database Shutdown Process


Oracle provides several methods to shutdown the database, each with different
behavior regarding how it handles active transactions and connected users.

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.

SQL> SHUTDOWN IMMEDIATE;

- 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.

SQL> SHUTDOWN ABORT;

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.

SQL> SHUTDOWN TRANSACTIONAL;

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 !

✓I missed this topic it should be covered in hashtag#Day2

✓Basics of Linux for Oracle DBA


Linux is the most popular operating system for running Oracle databases. As a DBA,
it's essential to understand the fundamental Linux commands and concepts to manage
the database environment effectively. In this session, we’ll cover the key aspects
of Linux that every Oracle DBA should know.

1. Linux File System Overview


Understanding the Linux file system is crucial because Oracle stores its files
(datafiles, control files, etc.) on the OS file system or ASM (Automatic Storage
Management).

Root Directory ( / ): The starting point of the Linux file system.


/home: Contains user home directories.
/etc: Stores system configuration files.
/var: Holds log files and other variable data.
/usr: Contains system applications and libraries.
/tmp: Used for temporary files.
/opt: Contains optional software packages, which can include Oracle binaries.

2. File and Directory Commands


Managing files and directories is essential for setting up and managing the Oracle
environment.

✓ls - List files and directories.


✓cd - Change directory
✓pwd - Display the current working directory.
✓mkdir - Create a new directory.
✓rm - Remove files or directories
✓cp - Copy files or directories

3. File Permissions and Ownership


Understanding file permissions is essential for securing Oracle-related files and
directories.
✓File Permissions: Read (r), Write (w), and Execute (x) permissions for the owner,
group, and others.

✓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

4. Process and Service Management


You'll need to manage Oracle-related processes and services frequently.
✓ps - View running processes.
✓ps -ef | grep pmon # List Oracle background processes
✓top - Monitor system resources like CPU and memory usage.
✓kill - Terminate processes.

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.

6. User Management in Linux


For Oracle installations, a specific user (oracle) and group (dba) are often
required.
✓Add a new user:
useradd -m oracle # Create a new user called 'oracle'
✓Add a new group:
groupadd dba # Create a group called 'dba'
✓Add user to group:
usermod -aG dba oracle # Add 'oracle' user to 'dba' group

Welcome to hashtag#Day23 Part -II of our Oracle DBA Jounary !

I missed this topic it should be covered in hashtag#Day2

hashtag#Basics of Linux for Oracle DBAs

7. Essential Linux Utilities for DBAs


Here are a few Linux utilities that DBAs use regularly:
✓df - Check disk space usage.
df -h # Human-readable format for disk space
✓du - Check directory size.
du -sh /u01 # Show size of /u01 directory
✓tar - Archive files (useful for backup).
tar -cvf backup.tar /u01/datafiles/ # Create a tarball of datafiles directory
tar -xvf backup.tar # Extract files from a tarball

8. Setting Environment Variables


For Oracle to function properly, certain environment variables need to be set for
the Oracle user.
✓ORACLE_HOME - Location where Oracle is installed.
✓ORACLE_SID - Database identifier.
To set them permanently, you can add the following lines to .bash_profile:
export ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH

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

10. Linux Scripting Basics


Understanding basic scripting can help automate Oracle DBA tasks

Example of a simple backup script:


#!/bin/bash
export ORACLE_SID=orcl
rman target / <<EOF
run {
backup database;
backup archivelog all;
}
EOF

Welcome to hashtag#Day23 Part -II of our Oracle DBA Jounary !

I missed this topic it should be covered in hashtag#Day2

hashtag#Basics of Linux for Oracle DBAs

7. Essential Linux Utilities for DBAs


Here are a few Linux utilities that DBAs use regularly:
✓df - Check disk space usage.
df -h # Human-readable format for disk space
✓du - Check directory size.
du -sh /u01 # Show size of /u01 directory
✓tar - Archive files (useful for backup).
tar -cvf backup.tar /u01/datafiles/ # Create a tarball of datafiles directory
tar -xvf backup.tar # Extract files from a tarball

8. Setting Environment Variables


For Oracle to function properly, certain environment variables need to be set for
the Oracle user.
✓ORACLE_HOME - Location where Oracle is installed.
✓ORACLE_SID - Database identifier.
To set them permanently, you can add the following lines to .bash_profile:
export ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH

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

10. Linux Scripting Basics


Understanding basic scripting can help automate Oracle DBA tasks

Example of a simple backup script:


#!/bin/bash
export ORACLE_SID=orcl
rman target / <<EOF
run {
backup database;
backup archivelog all;
}
EOF

✓Make sure to make the script executable:


chmod +x backup.sh

Welcome to hashtag#Day24 Part - II of our Oracle DBA Jounary !

✓ 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.

✓ Step 1: Enable Flashback Logging and Create a Guaranteed Restore Point


Check if the database is in ARCHIVELOG mode: Flashback operations require
ARCHIVELOG mode. Check the mode of your database using the following query:
SQL> SELECT log_mode FROM v$database;

If your database is in NOARCHIVELOG mode, follow these steps to enable ARCHIVELOG


mode:
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
SQL> ALTER DATABASE ARCHIVELOG;
SQL> ALTER DATABASE OPEN;

Enable Flashback Logging: Once in ARCHIVELOG mode, enable Flashback Logging to


allow the database to record flashback logs:
SQL> ALTER DATABASE FLASHBACK ON;

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;

✓ Step 2: Simulate a Mistake (Delete Rows)


Let’s assume you mistakenly delete rows from a table. For example:
SQL> DELETE FROM employees WHERE department_id = 10;
COMMIT;

Step 3: Flashback the Database to the Restore Point


After realizing the mistake, you can revert the database to the restore point.
Check available restore points: To verify the restore point, run:
SQL> SELECT NAME, SCN, TIME FROM v$restore_point;

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:

SQL> ALTER DATABASE OPEN RESETLOGS;

✓Step 4: Verify the Data


After the flashback, verify that the data has been restored:
SQL> SELECT * FROM employees WHERE department_id = 10;

✓ Step 5: Drop the Restore Point


Once the issue is resolved, you can drop the restore point if it is no longer
needed to free up space used by Flashback logs:

SQL> DROP RESTORE POINT before_delete;

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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy