Conceptually, Oracle Redo Logs are a collection of Redo records. Redo records are a group of change vectors. Each change vector denotes a change made to a single database block. These entries are comprehensive enough to reconstruct the state of the database at any point in time, They also help in rolling back the database.
While operational, Redo Logs are buffered in a circular queue and persisted to files every time a transaction is complete or the buffer is full. Usually, a transaction is marked as completed only after the Redo Logs are successfully persisted. All Redo records corresponding to a specific transaction are identified using a unique identifier called system change number.
Planning the Redo Logs
These are the steps that you need to know when you plan the Redo Logs:
- Multiplexing Redo Log Files
- Placing Redo Log Members on Different Disks
- Setting the Size of Redo Log Members
- Choosing the Number of Redo Log Files
- Controlling Archive Lag
Online Redo Logs
Redo logs are the architectural component behind Oracle’s ability to recover from failures and ensure high availability. A redo log contains redo records that denote all changes that happened in an Oracle database. Replaying redo logs can bring a database to its state at any point in time from a base state. This way, redo logs facilitates the recovery of databases from software or hardware failures.
Redo logs also play an important role in Oracle replication. Most change data capture methods revolve around exploiting redo logs and copying changes from redo logs to the target database.
In the default configuration, the redo log will be overwritten by the log writing process, when the log file is switched. Oracle provides an ARCHIVELOG mode where log file data can be archived, enabling a much larger window of recovery points. Using this setting ensures that log files are never overwritten but archived to a remote or local location.
In case you need to add more redo logs than the default configuration, it can be done with the following command:
ALTER DATABASE ADD LOGFILE ('/oracle/dbs/log1c.rdo', '/oracle/dbs/log2c.rdo') SIZE 4M;
This is often done to make separate processes work based on different redo logs.
An important point to note here is that online redo logs always run on the master or the local system of the source database. There is another type of redo log called standby redo logs, that is configured to increase data protection in a replicated environment.
Understanding Oracle Standby Redo Logs
A standby database is typically configured for data protection during disasters. It also helps in recovering the main database. It can also act as a reporting database without affecting the performance of your transactional database. A standby database can be configured to work, based on the online redo logs or based on a separate log file called standby redo log file. While configuring a standby, an administrator needs to select whether he wants to go for a maximum protection standby configuration or maximum performance configuration.
Before going into the details, let us first examine how a standby database replication works. Broadly, the following activities are involved in this process:
- An archival process first archives the online redo log files.
- Another process then writes these archived logs into the standby database location.
- A recovery process then uses these archived logs to populate the standby database.
Since there is a delay between the recovery process decoding the archived log and writing it to the standby database, any unfortunate incident in this window can lead to data loss. This data loss can even go into, minutes even with Oracle’s super-fast recovery times. To avoid this, configuring standby redo logs is usually recommended.
Standby redo logs are created by a network server synch process that keeps track of the online redo database logs and writes continuously in a standby log file located in the destination database. The recovery process then uses the standby redo logs to write entries to the standby database rather than using the transported archived redo logs. The architecture, in this case, will be as shown in the following image.
A standby log can be created using the following command:
ALTER DATABASE ADD STANDBY LOGFILE GROUP 10
Oracle recommends using standby redo logs in all cases where the replication process is set up. Standby redo logs can bring your unfortunate data loss interval from minutes to seconds in the standby database.