Wednesday, May 30, 2012

Creation of Physical standby DB


alter database create standby controlfile as '/orcl/oradata/PROD2/ctrl_PROD_01.ctl';

$ rman target /
RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT ‘/backup/%d_%s_%T_CONTROL_STDBY’ ;
Export ORACLE_SID=standby_db
rman target sys/passwd@Primary_db auxiliary /
run {
allocate auxiliary channel c1 type disk;
allocate auxiliary channel c2 type disk;
allocate auxiliary channel c3 type disk;
allocate auxiliary channel c4 type disk;
allocate auxiliary channel c5 type disk;
allocate auxiliary channel c6 type disk;
DUPLICATE TARGET DATABASE FOR STANDBY;
}

Tuesday, May 29, 2012

Top 5 Wait events in AWR

Common Oracle AWR Wait Events Explained

This document provides an overview of frequently observed wait events in Oracle Automatic Workload Repository (AWR) reports, categorized by their primary area of impact. Understanding these wait events is crucial for diagnosing and resolving performance bottlenecks in an Oracle database.

DB FILE Type Waits – Physical I/O

These events indicate waits related to physical I/O operations from datafiles.

  1. DB File Sequential Reads

    • Description: The user process is reading buffers into the SGA buffer cache and is waiting for a physical I/O call to return. Typically a single-block read.

    • Common Causes: Memory starvation (insufficient buffer cache), non-selective indexes, high concurrency on specific blocks.

  2. DB File Scattered Reads

    • Description: Similar to db file sequential reads, but the session is reading multiple data blocks (e.g., from a full table scan) and scattering them into different, non-contiguous buffers in the SGA.

    • Common Causes: Full table scans, insufficient indexing, large sorting operations.

  3. Direct Path Writes

    • Description: Occurs when a process is writing buffers directly from the session's Program Global Area (PGA) to datafiles, bypassing the SGA buffer cache. The process waits for the write call to complete.

    • Common Causes: Direct-path INSERT operations (e.g., INSERT /*+ APPEND */), data loads (e.g., SQL*Loader direct path), parallel DML.

  4. Direct Path Reads

    • Description: An I/O operation that reads data directly into the session's PGA instead of the SGA.

    • Common Causes: Parallel query execution (parallel slaves retrieving data), sorting to disk, hash joins spilling to disk, temporary tablespace activity.

  5. DB File Parallel Writes

    • Description: This wait event is associated with the Database Writer (DBWR) process. DBWR compiles a set of dirty blocks, hands the batch over to the OS for writing to datafiles, and waits for the I/O to complete.

    • Common Causes: High database activity generating many dirty blocks, backup operations, partitioned table usage (where DBWR writes blocks for multiple partitions in parallel).

  6. DB File Parallel Reads

    • Description: Occurs during database recovery, where blocks that need to be changed are read in parallel. Can also happen during buffer prefetching as an optimization.

    • Common Causes: Instance recovery, crash recovery, certain optimization paths (e.g., multi-block reads for specific operations).

  7. DB File Single Write

    • Description: Used to wait for the writing of single blocks, typically file headers.

    • Common Causes: File header writes (e.g., during checkpointing, file resizing), excessive number of data files.

  8. Direct Path Read Temp

    • Description: Reading data directly from temporary files into the PGA.

    • Common Causes: Extensive temporary segment activity due to large sorts, hash joins, temporary table usage, or bitmap operations that spill to disk.

  9. Direct Path Write Temp

    • Description: Writing data directly to temporary files from the PGA.

    • Common Causes: Similar to Direct Path Read Temp, indicating heavy use of temporary tablespace for sorts, hashes, or temporary tables.

BUFFER Type Waits – Logical I/O

These events relate to contention or issues within the SGA buffer cache.

  1. Free Buffer Waits

    • Description: Occurs when a session needs a free buffer in the SGA but none are immediately available. Oracle waits for a buffer to become available.

    • Common Causes:

      • DBWR not writing dirty buffers fast enough (e.g., slow I/O, undersized DB_WRITER_PROCESSES).

      • A file was read-only and is now read-write, requiring invalidation of existing buffers.

      • Need for a buffer in CR (Consistent Read) or recovery modes.

      • Insufficient DB_CACHE_SIZE.

  2. Buffer Busy Wait

    • Description: A session cannot access a needed data block because it is currently being used or modified by another session.

    • Common Causes:

      • Hot blocks (frequently accessed blocks, e.g., index root blocks, segment header blocks).

      • Insufficient free lists for a table (pre-ASSM).

      • Too few rollback segments (pre-Automatic Undo Management).

      • High concurrency on specific data or index blocks.

  3. Latch Free Waits

    • Description: Latches are internal Oracle locking mechanisms that protect SGA data structures. This wait occurs if a session needs to acquire a latch that is currently held by another session.

    • Common Causes: High concurrency on shared memory structures (e.g., library cache latch, shared pool latch, cache buffers chains latch), inefficient SQL (e.g., excessive parsing).

Log Type Waits

These events are related to the redo log buffer and online redo log files.

  1. Log File Parallel Write

    • Description: The Log Writer (LGWR) process is writing the redo buffer to the online redo log files in parallel and waits for the I/O to complete.

    • Common Causes: Slow I/O subsystem for redo logs, insufficient redo log group members, large redo generation rates.

  2. Log Buffer Space

    • Description: A session waits for space to become available in the log buffer because redo information is being generated faster than LGWR can write it to the redo files.

    • Common Causes: Log buffer is too small (LOG_BUFFER), redo log files are on disks with I/O contention, very high transaction rates.

  3. Log File Switch (Archiving Needed)

    • Description: A log switch is pending, but the next online redo log file cannot be used because it has not yet been archived.

    • Common Causes: Archiver processes are slow or stopped, archive destination is full or slow, insufficient archiver processes (LOG_ARCHIVE_MAX_PROCESSES).

  4. Log File Switch (Checkpoint Incomplete)

    • Description: A log switch is pending, but the checkpoint for the next log file has not completed, preventing LGWR from wrapping into it.

    • Common Causes: Redo log files are sized too small, FAST_START_MTTR_TARGET is set too high, slow I/O for datafiles (impacting checkpoint completion).

  5. Log File Switch Completion

    • Description: Sessions are waiting for a log switch operation to fully complete.

    • Common Causes: Slow I/O for redo logs, issues with archiver processes, or slow checkpoint completion.

  6. Log File Sync

    • Description: When a user session commits, its redo information must be flushed to the redo logfile. The session waits for LGWR to write the log buffer to disk and then post the user session. The wait time includes both the write and the post.

    • Common Causes: Slow I/O to redo logs (most common), high commit rate, CPU contention affecting LGWR, network latency in RAC environments.

PX – Parallel Query

These events are related to operations performed by parallel execution processes.

  • Master Note Parallel Execution Wait Events (Doc ID 1097154.1): Refer to this Oracle Support document for detailed information on parallel execution wait events.

GC – Global Cache (RAC Related)

These events indicate contention or waits in Oracle Real Application Clusters (RAC) environments for accessing data blocks across instances.

  • gc current block request: Waiting for a current version of a data block from another instance.

  • gc cr block request: Waiting for a consistent read (CR) version of a data block from another instance.

  • gc current block 3-way: A more complex scenario for current block requests involving three instances.

  • gc current block busy: The requested current block is busy on the holding instance.

  • gc cr block grant 2-way: A simpler scenario for consistent read block requests.

Undo or Rollback Segment Related

These events are associated with undo segment management and rollback operations.

  • Undo Related Wait Events & Known Issues (Doc ID 1575701.1): Consult this Oracle Support document for comprehensive details on undo-related wait events and common issues.

By analyzing the top wait events in AWR reports and understanding their causes, DBAs can effectively pinpoint and address performance bottlenecks in Oracle databases.