Redo Log Buffer初步调优

本文深入探讨了Redo Log Buffer的工作原理、关键配置参数、常见调优手段及诊断指标,旨在帮助数据库管理员高效管理和优化日志流程,减少等待事件,提升系统性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The Redo Log Buffer

LGWR只有1个进程,不像DBWn可以有多个。LGWR速度受限于ARCn和DBWn。

when LGWR writes?
  • A user process commits a transaction
  • Every three seconds
  • when the redo log buffer is one-third full
  • when a DBWn process writes modified buffers to disk, if the corresponding redo log
  • data has not already been written to disk.
Adjust LOG_BUFFER, 大小设置:512K or 128k*cpu_count,choose the greater
show parameter cpu_count;
查询Redo Log Buffer

SQL> select * from v$sgastat where name='log_buffer';

POOL         NAME                            BYTES
------------ -------------------------- ----------
             log_buffer                    5160960

Redo Log Buffer Inefficiency

产生日志太快,LGWR速度跟不上。
调优目标:始终有空余的redo log buffer可写;始终有空闲的redo log file可写。不要产生等待。
调优手段:通用:增加组数,增加每组的容量;其他手段:增加DBWn个数,增加ARCn个数。

诊断指标

  • v$session_wait   Log Buffer Space event (存在retries时会发生这个事件)
    • 查询Log Buffer Space event事件
      SQL> select sid, event, seconds_in_wait, state from v$session_wait
      where event='log buffer space%';
  • v$sysstat  Redo Buffer Allocation Retries(总共有多少条记录),  Redo Entries(redo log buffer没有空余空间再尝试)

因此调优目标就是:

  • There should be no Log Buffer Space waits. 
  • Redo Entries/Redo Buffer Allocation Retries near 0 

原因和调整措施

1. 磁盘争用导致redo log file无法及时写,确保redo log files放在独立的,速度快的磁盘上。

从v$system_event视图中,查询应log file switch completion event,该事件表明了由于log switch而导致的log file switch waits.

select event, total_waits, time_waited, average_wait
from v$system_event
where event like 'log file switch completion%';

措施:增加redo log files的大小


 2.  LGWR要写的下一组log file中对应的buffer cache中的脏数据还没有写入data file,由于DBWn写速度太慢或者要写的内容太多,LGWR必须等待DBWn进程。

在alert文件中,检查“CHECKPOINT NOT COMPLETE”信息。

从v$system_event视图中,查询Log File Switch (Checkpoint Incomplete) event。该事件表明了由于incomplete checkpoints而导致的log file switch waits.

select event, total_waits, time_waited, average_wait
from v$system_event
where event like 'log file switch (check%';
措施: 增加redo log的组数和大小,适量增加DBWn的个数


3. ARCn进程不够快阻止了LGWR写。

检查归档设备是否已经写满;增加redo log组;设置LOG_ARCHIVE_MAX_PROCESSES来增加归档进程数目。

从v$system_event中,查找Log File Switch (Archiving Needed) event, 该事件表明archiving issue导致了log file switch waits.

select event, total_waits, time_waited, average_wait
from v$system_event
where event like 'log file switch (arch%';



Reducing Redo Operations

ways to avoid logging bulk operations in the redo log:
  • Direct Path loading without archiving不产生redo
  • Direct Path loading with archiving use nologging mode
  • Direct Load Insert can use Nologging mode
  • Some SQL statements can use Nologgin mode.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值