关于redo大小设置问题的总结

Oracle通过Redo来保证数据库的事务可以被重演,从而使得在故障之后,数据可以被恢复。Redo对于Oracle数据库来说至关重要。

在数据库中,Redo的功能主要通过3个组件来实现:Redo Log BufferLGWR后台进程Redo Log File(在归档模式下,Redo Log File最终会经由ARCn进程写出为归档日志文件)。

Redo Log Buffer位于SGA之中,是一块循环使用的内存区域,其保存数据库变更的相关信息。这些信息以重做条目(Redo Entries)形式存储(Redo Entries也经常称为Redo Records)。Redo Entries包含重构、重做数据库变更的重要信息,这些变更包括INSERT、UPDATE、DELETE、CREATE、ALTER或者DROP等。

Redo Entries的内容被Oracle数据库进程从用户的内存空间(PGA)复制到SGA中的Redo Log Buffer之中Redo Entries在内存中占用连续的顺序空间,由于Redo Log Buffer是循环使用的,Oracle通过一个后台进程LGWR不断把Redo Log Buffer的内容写出到Redo Log File中,Redo Log File同样是循环使用的。


我们知道,用户数据通常在Buffer Cache中修改,Oracle通过高速缓存来提高数据操作的性能。当用户在Buffer Cache中修改数据时,Oracle并不会立即将变更数据写出到数据文件上,因为独立的离散写出效率会很低。到目前为止,计算机系统中最容易出现瓶颈的仍然是磁盘的I/O操作,Oracle这样做的目的是为了减少IO的压力,当修改过的数据达到一定数量之后,可以进行高效地批量写出。

大部分传统数据库(当然包括Oracle)在处理数据修改时都遵循no-force-at-commit策略。也就是说,在提交时并不强制写。那么为了保证数据在数据库发生故障时(例如:断电)可以恢复,Oracle引入了Redo机制,通过连续的、顺序的日志条目的写出将随机的、分散的数据块的写出推延。这个推延使得数据的写出可以获得批量效应等性能提升。

同Redo Log Buffer类似,Redo Log File也是循环使用的,Oracle允许使用最少两个日志组。



所以为了提高系统的读写性能,设置redo文件的大小是很重要的


有足够多的组,避免一组写满换下一组,而另一组正在归档。
设置太小会造成频繁的切换。

标准的可以是高峰期3-5分钟 5Z就是调整的大小, 一般15-20分钟切换一次

查看最近的单位小时内的切换情况

SELECT  trunc(first_time) "Date",

        to_char(first_time, 'Dy') "Day",
        count(1) "Total",
        SUM(decode(to_char(first_time, 'hh24'),'00',1,0)) "h0",
        SUM(decode(to_char(first_time, 'hh24'),'01',1,0)) "h1",
        SUM(decode(to_char(first_time, 'hh24'),'02',1,0)) "h2",
        SUM(decode(to_char(first_time, 'hh24'),'03',1,0)) "h3",
        SUM(decode(to_char(first_time, 'hh24'),'04',1,0)) "h4",
        SUM(decode(to_char(first_time, 'hh24'),'05',1,0)) "h5",
        SUM(decode(to_char(first_time, 'hh24'),'06',1,0)) "h6",
        SUM(decode(to_char(first_time, 'hh24'),'07',1,0)) "h7",
        SUM(decode(to_char(first_time, 'hh24'),'08',1,0)) "h8",
        SUM(decode(to_char(first_time, 'hh24'),'09',1,0)) "h9",
        SUM(decode(to_char(first_time, 'hh24'),'10',1,0)) "h10",
        SUM(decode(to_char(first_time, 'hh24'),'11',1,0)) "h11",
        SUM(decode(to_char(first_time, 'hh24'),'12',1,0)) "h12",
        SUM(decode(to_char(first_time, 'hh24'),'13',1,0)) "h13",
        SUM(decode(to_char(first_time, 'hh24'),'14',1,0)) "h14",
        SUM(decode(to_char(first_time, 'hh24'),'15',1,0)) "h15",
        SUM(decode(to_char(first_time, 'hh24'),'16',1,0)) "h16",
        SUM(decode(to_char(first_time, 'hh24'),'17',1,0)) "h17",
        SUM(decode(to_char(first_time, 'hh24'),'18',1,0)) "h18",
        SUM(decode(to_char(first_time, 'hh24'),'19',1,0)) "h19",
        SUM(decode(to_char(first_time, 'hh24'),'20',1,0)) "h20",
        SUM(decode(to_char(first_time, 'hh24'),'21',1,0)) "h21",
        SUM(decode(to_char(first_time, 'hh24'),'22',1,0)) "h22",
        SUM(decode(to_char(first_time, 'hh24'),'23',1,0)) "h23"
FROM    V$log_history
group by trunc(first_time), to_char(first_time, 'Dy')
Order by 1

根据情况调整redo大小



操作方法:

查看redo文件状态,把不活动的删除:

select lf.GROUP#,lf.MEMBER,lg.STATUS from v$logfile lf,v$log lg
where lf.GROUP#=lg.GROUP#;

切换redo文件的语句:alter system switch logfile;

删除redo组:alter database drop logfile group 2;

加入组:alter database add logfile group 9 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\R
EDO09.LOG' size 100m;

注意2点:1删除组不会删除数据文件请手动删除,2redo最少有2个组




  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值