How Oracle Database Redo and Archived Logs function
All the Oracle changes made to the db are recorded in the redo log files, these files along with any archived redo logs enable a dba to recover the database to any point in the past. Oracle will write all committed changes to the redo logs first before applying them to the data files.
The redo logs guarantee that no committed changes are ever lost. Redo log files consist of redo records which are group of change vectors each referring to specific changes made to a data block in the db. The changes are first kept in the redo buffer but are quickly written to the redo log files.
1- Online
2- Archive
Oracle uses the concept of groups and a minimum of 2 groups are required, each group having at least one file. They are used in a circular fashion when one group fills up oracle will switch to the next log group.
When will the LGWR process write redo information from the redo buffer to the online redo logs:
-user commits a transaction
-redo log buffer becomes 1/3 full
-redo buffer contains 1MB of changed records
-switch of the log files
Online
Current : log group that is being actively being written too.
Active : the files in the log group are required for instance recovery.
Inactive: the files in the log group are not required for instance recovery and can be over written.
Unused : log group has never been written too, a new group.
Invalid : the file is corrupt or missing.
Stale : the log file is new and never been used.
Deleted : the log file is no longer being used.
-blank- : the log file is currently being used.
Archived Logs
When a redo log file fills up and before it is used again the file is archived for safe keeping,
this archive file with other redo log files can recover a database to any point in time.
It is best practice to turn on ARCHIVELOG mode which performs the archiving automatically.
The log files can be written to a number of destinations (up to 10 locations), even to a standby database,
using the parameters log_archive_dest_n and log_archive_min_succeed_dest you can control how Oracle writes its log files.
When the database is running in ARCHIVELOG mode, the log writer process (LGWR) cannot reuse and hence overwrite a redo log group until it has been archived. The background process ARCn automates archiving operations when automatic archiving is enabled. The database starts multiple archiver processes as needed to ensure that the archiving of filled redo logs does not fall behind.
We can use archived logs to:
- Recover a database
- Update a standby database
- Get information about the history of a database using the Log Miner utility