|René Nyffenegger's collection of things on the web|
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
Oracle's Redo Log
The redo log makes it possible to replay SQL statements.
Before Oracle changes data in a datafile it writes these changes to the redo log. If something happens to one of the datafiles, a backed up datafile can be restored and the redo, that was written since, replied, which brings the datafile to the state it had before it became unavailable.
The same technique is also used in a data guard environment (standby databases): One database (the primary database) records all changes and sends them to the standby databases. These standby databases in turn apply (reply) the arrived redo which keeps the synchronized with the primary database.
Archive Log vs Noarchive Log
As Oracle rotates through its redo log groups, it will eventually overwrite a group which it has already written to. Data that is being overwriten would of course be useless for a recovery scenario. In order to prevent that, a database can (and for production databases should) be run in archive log mode. Simply stated, in archive log mode, Oracle makes sure that online redo log files are not overwritten unless they have been savely archived somewhere.
A database can only be recoverd from media failure if it runs under archive log.
See also Archive vs Noarchive Log Mode
LGWR writes the redo log buffers to disk.
The background process in charge for archiving redo logs is ARCn (if automatic archiving is enabled.)
In order to find out in which mode the instance runs, one can use archive log list from within sql plus.
All changes that are covered by redo is first written into the log buffer. The idea to first store it in the memory is to reduce disk IO. Of course, when a transaction commits, the redo log buffer must be flushed to disk, because otherwise the recovery for that commit could not be guaranteed. It is LGWR (Log Writer) that does that flushing.
Determining amount of generated redo log
select n.name, t.value from v$mystat t join v$statname n on t.statistic# = n.statistic# where n.name = 'redo size';
See also the package redo_diff
RBA (Redo Byte Address)
The RBA consists of three parts and is ten bytes long:
Log sequence number
Whenever Oracle (or more precisely, the log writer process) writes to another online redo log file group (also referred to as log switch), the log sequence number increments by one.
If the database is opened with reset logs, the log sequence number is reset to 1.
Determining optimal redo log size
The optimal size of redo log files can be queried with
See also managed standby databases.
ASM simplifies the optimal layout of redo log files.
Minimizing generation of redo
For a few operations, it is possible to minimize the generation of redo if the nologging option is set.
Redo transport services
Redo transport services transport redo data from one server to another.
Redo is totally different from undo (rollback).
Thanks to Seghir Souidi and Hubert Savio who helped improve this page.