Oracle Dba Notes
Oracle Dba Notes
Ans. In Oracle Database Administration (DBA), backup scheduling is a critical task to ensure
data availability, integrity, and recoverability. Backup strategies can be classified based on
various criteria, including frequency, type of backup, and the method used. Here is a detailed
classification of backup scheduling strategies:
1. Based on Frequency
a. Full Backup:
b. Incremental Backup:
Description: Copies only the data that has changed since the last backup.
Types:
o Cumulative Incremental (Level 1): Backs up all changes since the last full
backup.
o Differential Incremental (Level 0): Backs up all changes since the last
incremental backup.
Frequency: Typically done daily.
Pros: Faster and less resource-intensive than full backups.
Cons: Restoration can be more complex and time-consuming, as it may require
applying multiple incremental backups.
c. Differential Backup:
Description: Similar to cumulative incremental, but backs up all changes since the
last full backup.
Frequency: Typically done daily or multiple times per day.
Pros: Faster than full backups and simplifies restore compared to incremental
backups.
Cons: As the time since the last full backup increases, the size of differential backups
can grow significantly.
2. Based on Type
a. Physical Backup:
Description: Backs up the physical files used by the database (e.g., datafiles, control
files, redo log files).
Types:
o Cold Backup: Performed when the database is shut down.
o Hot Backup: Performed while the database is running and accessible to users.
Pros: Ensures a point-in-time snapshot of the database.
Cons: Cold backups require downtime; hot backups require careful coordination to
ensure data consistency.
b. Logical Backup:
Description: Backs up the logical data within the database (e.g., schemas, tables,
views).
Tools: Export/Import utilities (exp, imp), Data Pump (expdp, impdp).
Pros: Useful for individual object recovery and data migration.
Cons: Does not include physical structure or system-specific data.
3. Based on Method
a. Manual Backup:
b. Automated Backup:
Ans. Installing and managing an Oracle Database involves several steps and considerations to
ensure a smooth and efficient setup. Here is a detailed guide on the process:
1. Pre-Installation Steps
a. System Requirements:
Hardware: Ensure your system meets the minimum hardware requirements (CPU,
memory, disk space).
Software: Verify that your operating system is supported by the Oracle version you
plan to install.
Dependencies: Install necessary libraries and packages required by Oracle.
Download the appropriate Oracle Database software from the Oracle Technology
Network (OTN) or Oracle Software Delivery Cloud.
2. Installation Process
b. Create a Database:
3. Post-Installation Steps
a. Verify Installation:
Check Services: Ensure that Oracle services (e.g., Oracle Listener, database instance)
are running.
Connectivity: Test connectivity using tools like SQL*Plus or Oracle SQL Developer.
b. Configure Listener:
RMAN (Recovery Manager): Use RMAN for backup and recovery operations.
o Full Backup: backup database;
o Incremental Backup: backup incremental level 1 database;
o Restore and Recover: restore database; recover database;
Data Pump: Use Data Pump utilities (expdp and impdp) for logical backups and data
migration.
e. Patch Management:
f. Storage Management:
5. Advanced Administration
a. Data Guard:
Qu 3. What are the key features & benefits of Automatic Storage Management?
Disk Group Management: ASM manages groups of disks as a single unit, known as
a disk group, simplifying the configuration and management of storage.
File Management: Automatically manages database file placement and naming
within disk groups.
2. Dynamic Reconfiguration:
Disk Addition/Removal: Disks can be added or removed from disk groups without
downtime, allowing for flexible and scalable storage management.
Rebalancing: Automatically redistributes data across disks when disks are added or
removed, maintaining performance and availability.
Oracle Enterprise Manager (OEM): ASM integrates with OEM for easy
monitoring and management of storage.
RMAN Integration: Works seamlessly with Oracle Recovery Manager (RMAN) for
backup and recovery operations.
ASM Flex: Allows for flexible and isolated management of databases within the
same disk group.
Flex Clusters: Supports larger cluster configurations and provides enhanced high
availability.
Scalable Storage: ASM can manage very large storage configurations efficiently.
I/O Optimization: Optimizes I/O performance through intelligent data placement and
striping.
1. Simplified Administration:
Reduces the complexity of storage management by automating many tasks, such as file
placement and disk management.
Minimizes the need for manual intervention, reducing the risk of human errors.
2. Improved Performance:
Enhances database performance through striping, which distributes I/O load evenly across
all disks.
Optimizes read and write operations, leading to better overall system performance.
Ensures data availability and reliability through built-in mirroring and automatic failure
handling.
Provides robust protection against disk failures, minimizing downtime and data loss.
Reduces administrative overhead and operational costs associated with managing storage.
Efficiently utilizes available storage resources, potentially lowering storage hardware costs.
Qu 4. Elaborate on Undo Data and Redo Data administering techniques monitoring &
administrating.
Ans. Undo data and redo data are critical components in Oracle Database that ensure data
integrity and support various functionalities such as transaction rollback, read consistency,
and recovery operations. Effective monitoring and administration of these components are
essential for database performance and reliability. Here’s an in-depth look at undo data and
redo data, including techniques for monitoring and administering them:
Undo Data
Purpose:
Transaction Rollback: Enables the database to roll back incomplete transactions, restoring
the data to its previous state.
Read Consistency: Ensures that queries see a consistent snapshot of the data as of the query
start time, even if changes are being made concurrently.
Flashback Features: Supports Oracle's Flashback Query, Flashback Table, and Flashback
Database features, allowing users to view or revert to previous data states.
Storage:
Undo data is stored in undo tablespaces. Each transaction generates undo records, which
are stored in these tablespaces.
Monitoring Undo Data:
sql
Copy code
SELECT tablespace_name, SUM(bytes)/1024/1024 AS MB
FROM dba_data_files
WHERE tablespace_name = 'UNDOTBS1'
GROUP BY tablespace_name;
sql
Copy code
SELECT status, SUM(bytes)/1024/1024 AS MB
FROM dba_undo_extents
GROUP BY status;
3. Transaction Activity:
o Monitor the number of active transactions and the amount of undo data they
generate.
o SQL Query:
sql
Copy code
SELECT s.sid, s.username, t.used_ublk, t.used_urec
FROM v$transaction t, v$session s
WHERE t.ses_addr = s.saddr;
1. Undo Retention:
o Set an appropriate undo retention period to balance between ensuring read
consistency and efficient space usage.
o SQL Command:
sql
Copy code
ALTER SYSTEM SET undo_retention = 900;
sql
Copy code
ALTER DATABASE DATAFILE 'path_to_undo_datafile' RESIZE
new_size;
sql
Copy code
ALTER SYSTEM SET undo_management = 'AUTO';
ALTER SYSTEM SET undo_tablespace = 'UNDOTBS1';
Redo Data
Purpose:
Data Recovery: Ensures data can be recovered in case of a system failure by recording all
changes made to the database.
Synchronization: Helps in synchronizing standby databases in Oracle Data Guard setups.
Storage:
Redo data is stored in redo log files. Each database has a set of redo log groups, each
containing one or more redo log members.
sql
Copy code
SELECT group#, status, bytes/1024/1024 AS MB
FROM v$log;
sql
Copy code
SELECT COUNT(*) AS switches, TRUNC(first_time) AS date
FROM v$log_history
GROUP BY TRUNC(first_time);
sql
Copy code
ALTER DATABASE ADD LOGFILE GROUP group_number
('path_to_redo_log_file') SIZE size_in_MB;
sql
Copy code
ALTER DATABASE ADD LOGFILE GROUP new_group_number
('path_to_redo_log_file') SIZE size_in_MB;
ALTER DATABASE DROP LOGFILE GROUP group_number;
3. ARCHIVELOG Mode:
o Enable ARCHIVELOG mode to archive redo log files, essential for point-in-time
recovery.
o SQL Commands:
sql
Copy code
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;
sql
Copy code
RMAN> DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-7';
Qu 6. Explain Control and Redo log files? How its related to database.
Ans. Control files and redo log files are critical components of an Oracle database. They play
vital roles in ensuring data integrity, managing database operations, and enabling recovery in
case of failures. Here’s a detailed explanation of each:
Control Files
Definition:
Control files are binary files that record the physical structure of the database. They are
essential for the database to start and operate correctly.
Contents:
Startup and Shutdown: The control file is read at startup and is crucial for the database to
function. Without a valid control file, the database cannot be mounted or opened.
Database Recovery: Contains necessary information for recovering the database in case of
failure.
Data Integrity: Ensures that all parts of the database are consistent and coordinated.
Administration:
sql
Copy code
CONTROL_FILES = ('/u01/oracle/oradata/DBNAME/control01.ctl',
'/u02/oracle/oradata/DBNAME/control02.ctl')
Definition:
Redo log files record all changes made to the database. They are used to protect data in case
of a failure and to ensure data integrity.
Contents:
Redo Entries: Each redo entry contains information about a change made to the database,
such as data modifications, structural changes, and transaction control statements.
Data Recovery: Redo logs are crucial for recovering the database to a consistent state after a
failure. Oracle uses redo logs to replay changes made to the database.
Transaction Management: Redo logs ensure that transactions are properly committed or
rolled back.
Synchronization: Used in replication and standby database configurations to synchronize
data.
Administration:
Log Groups and Members: Redo logs are organized into groups, with each group containing
one or more members (copies). Groups provide redundancy, ensuring that the loss of one
member does not lead to data loss.
o Configuration example:
sql
Copy code
LOG_GROUPS = ( ('/u01/oracle/oradata/DBNAME/redo01.log'),
('/u02/oracle/oradata/DBNAME/redo02.log') )