Oracle MTTR( FAST_STAR…

来源:互联网 发布:sql清除两天前的数据 编辑:程序博客网 时间:2024/06/05 01:43
什么是FAST_START_MTTR_TARGET

参数FAST_START_MTTR_TARGET是指允许DBA指定数据库进行崩溃恢复需要的秒数。MTTR(mean time torestoration)指平均恢复时间。

恢复时间取决于读取log files的时间和处理需要恢复的数据块的时间。
参数log_checkpoint_interval设定了恢复过程中将要被读的重做记录的数目。
fast_start_io_target控制了需要被恢复的数据块数目。
然而,DBA可以通过单独设置参数来设置基于秒级的恢复时间限制。
LOG_CHECKPOINT_TIMEOUT限制了上一检查点和最近的重做记录之间的秒数。但他对于设置恢复时间限制来说都是不够精确的!

所以Oracle 10r2后有了FAST_START_MTTR_TARGET,实际上这个参数被转化为设置参数FAST_START_IO_TARGET,LOG_CHECKPOINT_INTERVAL两个参数。这个特性大大简化了限定数据库恢复时间,并增加了准确性。
 
fast_start_mttr_target是一个动态参数,可以在线修改。
例如: alter system set fast_start_mttr_target =60;
 
数据库的恢复有两个步骤,Cache Recovery和Transaction Recovery。首先进行CacheRecovery,相当于一个Rolling Forward的过程。即oracle会应用redolog文件中所有已经提交或在当机时还未提交的变化(因为所有变化在写入数据文件前都会先记录到redolog文件中)。然后进行Transaction Recovery,相当于一个RollingBack的过程。即为了使数据库达到一致性要求,Oracle会回退undotablespace(Oracle10g中取消了rollbacksegments,因为回滚段管理起来太复杂)中的所有未提交事务。
 
Oracle会周期性的记录检查点(checkpoint)。关于checkpoint:
  “A checkpoint is the highest system changenumber (SCN) such that all data blocks less than or equal to thatSCN are known to be written out to the data files. If a failureoccurs, then only the redo records containing changes at SCNshigher than the checkpoint need to be applied during recovery. Theduration of cache recovery processing is determined by two factors:the number of data blocks that have changes at SCNs higher than theSCN of the checkpoint, and the number of log blocks that need to beread to find those changes.”
 
因为checkpoint会促使后台进程DBWn将脏数据写入数据文件,所以频繁的checkpointingwrites有利于大大缩短数据库的恢复时间。但如此频繁的写入操作也会降低数据库的运行性能。如上面所说,这个频度由参数FAST_START_MTTR_TARGET决定。当FAST_START_MTTR_TARGET>0时,将会激活Fast-Start Fault Recovery 功能。关于Fast-StartFault Recovery:
  “The foundation of Fast-Start Fault Recovery isthe Fast-Start checkpointing architecture. Instead of conventionalevent-driven (that is, log switching) checkpointing, which doesbulk writes, fast-start checkpointing occurs incrementally. EachDBWn process periodically writes buffers to disk to advance thecheckpoint position. The oldest modified blocks are written firstto ensure that every write lets the checkpoint advance. Fast-Startcheckpointing eliminates bulk writes and the resultant I/O spikesthat occur with conventional checkpointing.”
 
一旦FAST_START_MTTR_TARGET被设定成实际可行的值时,那么你的数据库的平均恢复时间会尽量达到该值设定的大小。但有几点需要注意:
   
1. 当你设定FAST_START_MTTR_TARGET时必须禁用或者删除FAST_START_IO_TARGET,LOG_CHECKPOINT_INTERVAL,LOG_CHECKPOINT_TIMEOUT这三个参数。因为这三个参数将会和FAST_START_MTTR_TARGET互相干扰。

2. FAST_START_MTTR_TARGET的最大值是3600秒,当你设定的值超过3600秒,Oracle会按照3600秒来运行。

3.请为FAST_START_MTTR_TARGET设置一个实际可行的值。原则上FAST_START_MTTR_TARGET的最小值是1秒(先不讨论0的情况),但是把数值设的很低并不意味着你可以达成这个目标,因为最低的MTTRTARGET是有限制的,它依赖于你数据库的启动时间等因素。

你数据库实际能达到的MTTR TARGET称为effective MTTRtarget。你可以通过查询V$INSTANCE_RECOVERY视图的TARGET_MTTR列来查看该值。所以假如你将FAST_START_MTTR_TARGET设置过低不仅没有什么作用,反而还会因为频繁的checkpointingwrites操作降低了数据库的性能。同样假如你将FAST_START_MTTR_TARGET设置过高,他也不会比在你数据库最遭情况下(整个缓存中都是脏数据)花的时间更长。(原文:Ifyou set FAST_START_MTTR_TARGET to a time longer than the practicalrange, the MTTR target will be no better than the worst-casesituation.)
0 0