1.Data block 是包含几个os block,也就是一对多的关系。
2.Data files 中的是 data block
Redo log files 中的 redo block 是os block
3.Data block 中记录的是完整的信息
Redo block 中记录的是最简单的信息
在8i 以前的版本,只有两个参数用来影响recovery,那就是log_checkpoint_interval和log_checkpoint_time。以log_checkpoint_interval=10000举例。意思很简单,就是经过10000个redo block后就引发checkpoint,这样恢复时,就绝对是在这10000个redo block中。
但是这样做有个缺点,就是因为redo block(os block)不等于data block。假如datablock中的数据很小,比如1,修改成2,那么10000个redo block中包含的信息却可以是远远大于10000个data block,假如data block中的数据很大,比如123456789,修改成987654321,那么10000个redo block中包含的信息却可以是远远小于10000个data block。
这样,在恢复时,尽管是读10000个redo blcok,但是这个10000个redo block中所包含的data block有可能是很少,也有可能是很多,很难把握恢复的时间。
于是,在8i中就引进了fast_start_io_tBarget这个参数来弥补这个不足。计算机自动计算redo block中所包含的data block的多少。例如fast_start_io_target=10000,t1(第一次checkpoint),在t1后有5000个redo block记录了,但是这个5000个redo block中只包含了7000个data block,那么redo block继续记录,到了redo block到8000个时,计算机发现这8000个redo block中包含了10000个data block,那么就引起t2(第二次checkpoint),凡是在t1和t2之间的任何crash,都可以保证recovery的时间肯定在这 10000个data block的读写时间之内(因为1个data block的I/O 是可以估算的)
所以说,设置fast_start_io_target比设置log_checkpoint_interval,log_checkpoint_time这个两个参数更为准确。假如3个参数一起设置,那么只要达到任一参数值时,就引发checkpoint。
例如:fast_start_io_target=10000,log_checkpoint_interval=10000,log_checkpoint_time=1800。
在redo block=10000时,所包含的data block却只有8000,就触发log_checkpoint_interval
在redo block=8000时,所包含的data block 却有10000,就触发fast_start_io_target
------------------------------------ ----------- ------------------------------
fast_start_mttr_target integer 0
SQL>
通常,如果我们必须严格控制实例或节点恢复时间,那么我们可以设置FAST_START_MTTR_TARGET为期望时间值;如果恢复时间不需要严格控制,那么我们可以不设置FAST_START_MTTR_TARGET参数,从而启用Oracle10g的自动检查点调整特性。
------------------------------------ ----------- ------------------------fast_start_mttr_target integer 0
在启动数据库的时候,我们可以从alert文件中看到如下信息:
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
检查v$instance_recovery视图,我们可以发现Oracle10g中的改变:
2 ESTIMATED_MTTR EMTTR,WRITES_MTTR WMTTR,WRITES_OTHER_SETTINGS WOSET,
3 CKPT_BLOCK_WRITES CKPTBW,WRITES_AUTOTUNE WAUTO,WRITES_FULL_THREAD_CKPT WFTCKPT
4 from v$instance_recovery;
---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
49407 0 68 0 0 3649819 3506125 3130700
在以上视图中,WRITES_AUTOTUNE字段值就是指由于自动调整检查点执行的写出次数,
而CKPT_BLOCK_WRITES指的则是由于检查点写出的Block的数量。
第一个参数LOG_CHECKPOINTS_TO_ALERT就不说了,我们来看看第二个参数FAST_START_PARALLEL_ROLLBACK。
The duration of cache recovery processing is determined by two factors: the number of data blocks that have changes at SCNs higher than the SCN of the checkpoint, and the number of log blocks that need to be read to find those changes.
Frequent checkpointing writes dirty buffers to the datafiles more often than otherwise, and so reduces cache recovery time in the event of an instance failure. If checkpointing is frequent, then applying the redo records in the redo log between the current checkpoint position and the end of the log involves processing relatively few data blocks. This means that the cache recovery phase of recovery is fairly short.
However, in a high-update system, frequent checkpointing can reduce runtime performance, because checkpointing causes DBWn processes to perform writes.
从这里可以看到,CHECKPOINT也并不是越频繁越好,当然,也不是间隔越久越好,关键是要根据系统的具体情况来把握一个合理的“度”。
Cache Recovery (Rolling Forward)
During the cache recovery step, Oracle applies all committed and uncommitted changes in the redo log files to the affected data blocks. The work required for cache recovery processing is proportional to the rate of change to the database (update transactions each second) and the time between checkpoints.
To make the database consistent, the changes that were not committed at the time of the crash must be undone (in other words, rolled back). During the transaction recovery step, Oracle applies the rollback segments to undo the uncommitted changes.
使用FAST-START ON-DEMAND ROLLBACK特点,ORACLE自动允许在数据库打开之后开始新的事务,这通常只需要很短的CACHE RECOVERY时间。如果一个用户试图访问被异常中止进程锁定的记录,ORACLE回滚那些新事务请求的记录,也就是说,因需求而回滚。因而,新事务不需要等待漫长的事务回滚时间。在FAST-START ON-DEMAND ROLLBACK中,后台进程SMON充当一个调度员,使用多个服务器进程并行回滚一个事务集。
该选项包含三个主要增强:
2.Fast-Start On-Demand Rollback
3.Fast-Start Parallel Rollback.
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
2 where Parameter='Fast-Start Fault Recovery';
-------------------------------------------------- ---------------
Fast-Start Fault Recovery TRUE
Practical Values for FAST_START_MTTR_TARGET
The maximum value for FAST_START_MTTR_TARGET is 3600 seconds (one hour). If you set the value to more than 3600, then Oracle rounds it to 3600.