Monday, February 14, 2011

Log Files

Each Oracle database has a redo log. This redo log records all changes made in data files.
Purpose
The redo log makes it possible to replay SQL statements.
Before Oracle changes data in a data file it writes these changes to the redo log. If something happens to one of the data files, a backed up data file can be restored and the redo, that was written since, replied, which brings the data file to the state it had before it became unavailable.
Archive Log vs. No archive 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 overwritten 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 safely archived somewhere.
A database can only be recovered from media failure if it runs under archive log.
Log Buffer
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.

No comments:

Post a Comment