ALTER DATABASE ADD LOGFILE
GROUP 4 ('+DATA', '+RECO') SIZE 1G;
Sizing Guidelines
Target log switches every 15–30 minutes during peak load.
Peak Redo Rate
Recommended Log Size
≤ 5 MB/s
1–4 GB
5–25 MB/s
4–16 GB
25–50 MB/s
16–32 GB
> 50 MB/s
32 GB+
Number of groups: Minimum 2 (required). Recommended 3–4+ per thread (especially RAC).
2. Multiplexing Redo Log Files
Oracle strongly recommends multiplexing. Each redo log group consists of one or more identical members. LGWR writes concurrently to all members of the current group.
Benefit: Protection against media failure, I/O errors, or corruption. Eliminates a single point of failure for redo.
Best Practices
At least 2 members per group
Keep the configuration symmetrical (all groups same number of members and size)
Members of the same group on different physical disks / failure groups
SQL Examples
Check Current Configuration
-- Groups
SELECT group#, thread#, bytes/1024/1024 AS "Size MB", members, status
FROM v$log ORDER BY group#;
-- Members
SELECT group#, member, status FROM v$logfile ORDER BY group#;
Add a New Multiplexed Group
ALTER DATABASE ADD LOGFILE
GROUP 10 ('+DATA/redo10a.log', '+RECO/redo10b.log') SIZE 1G;
Add a Member to an Existing Group
ALTER DATABASE ADD LOGFILE MEMBER '+RECO/redo01b.log' TO GROUP 1;
Force Log Switches & Cleanup (for resizing)
ALTER SYSTEM SWITCH LOGFILE;
ALTER SYSTEM CHECKPOINT;
ALTER DATABASE DROP LOGFILE GROUP 1; -- Only when INACTIVE
Overall Best Practices Summary
Aspect
Recommendation
Reason
Multiplexing
≥ 2 members/group
Redundancy
Placement
Different disks/failure groups
Survive hardware failure
Storage
Fast storage (+DATA)
LGWR performance
Groups
3–4+ per thread
Availability during archiving
Size
15–30 min switches
Balance perf vs recovery
ASM
+DATA + +RECO
Modern standard
Monitoring
-- Recent switches
SELECT TRUNC(first_time, 'HH24') AS hour, COUNT(*) AS switches
FROM v$log_history
WHERE first_time > SYSDATE - 1
GROUP BY TRUNC(first_time, 'HH24')
ORDER BY hour;
Purpose of redo logs
The purpose of a redo log file is to preserve a record of committed transactions for a database. Oracle uses this record for two purposes:
crash recovery and
media recovery.
The record preserved in the redo log allows Oracle to recover committed changes that would otherwise be lost in the event of a system crash. The combination of archived and online redo log files allows you to:
Restore a data file from a backup, and
Replay all the subsequent changes to bring the data file up to date.
Protecting redo logs
If you lose your redo log files, you lose your ability to recover fully from a crash or a drive failure. How then do you protect the redo log files? The answer is that you mirror them. Redo log files need to be mirrored just as control files need to be mirrored. The following multiplex illustrates one possible mirroring scenario:
Multiplexed online redo log members are distributed across independent storage so LGWR can continue writing when a member or storage device fails; failed members should be replaced promptly.
Mirroring: hardware versus software
On some systems, particularly UNIX systems, you may have the choice of using either hardware or software mirroring. The question then becomes which to use? I once posed that question to an Oracle newsgroup, and it induced some amount of debate. There's certainly a performance advantage to mirroring in hardware, but there appears to be a slight theoretical risk of hardware-induced corruption as well. Personally, I'm a bit paranoid, and use both hardware and software mirroring, preferring not to place all my eggs in one basket.
With hardware mirroring, you can have just one redo log member in each group as far as Oracle is concerned,
and leave the job of writing a duplicate copy to the hardware RAID controller. When software mirroring is used, it is the Oracle software that writes to each redo log member. In the next lesson, you will learn how to list the redo log files in your database to see how many groups you have and how many members you have in each group.