对参数FAST_START_MTTR_TARGET = 0 的误解及设定
--===============================================
--对参数FAST_START_MTTR_TARGET = 0 的误解及设定
--===============================================
笔者Google了一下关于描述了FAST_START_MTTR_TARGET参数,看到很多文章将该参数置为0时为启用自动调整的检查点功能
对其中FAST_START_MTTR_TARGET=0为启用自动调整的检查点的这个观点笔者着是不敢苟同。
一、关于FAST_START_MTTR_TARGET参数
是一个加快实例恢复的参数,我们可以根据服务级别来定义一个合理的、可接受的值,该值的单位为秒。比如设定为60s,即2分钟。
假定该值处于合理的情况之下,则一旦实例崩溃,在60s以内实例应当能够被恢复。合理即是该值不能太大,也不能太小。太大则实例恢
复所需的时间较长,太小则导致大量数据的及时写入,增加了系统的I/O。
影响实例恢复时间长短的主要因素即是从最近检查点位置到联机重做日志尾部之间的距离。距离越长则所需要的cache recovery 和undo、
redo的时间越长。所以如何有效的缩短最近检查点位置与联机重做日志尾部之间的距离,这正是FAST_START_MTTR_TARGET的目的。
关于检查点的触发条件有很多,比如日志切换、数据库shutdown、开始结束备份表空间等。检查点的分类也很多,比如完全检查点、部
分检查点、增量检查点等。
FAST_START_MTTR_TARGET的值实际上也是触发检查点的一个触发条件。当内存中产生的dirty buffer所需的恢复时间(estimated_mttr)
如果到达FAST_START_MTTR_TARGET的指定时间,则检查点进程被触发。检查点进程一旦被触发,将通知DBWn进程将按检查点队列顺序将脏数
据写入到数据文件,从而缩短了最后检查点位置与联机重做日志间的距离,减少了实例恢复所需的时间。
关于实例的恢复以及检查的具体分类描述等,请参考:
Oracle实例和Oracle数据库(Oracle体系结构)
二、FAST_START_MTTR_TARGET = 0的质疑
很多文章描述了FAST_START_MTTR_TARGET = 0,即为未设置,表示启用自动检查点功能,下面是来自Oracle的官方文档中的一段,
原文的链接为:Fast-Start Fault Recovery
Fast-start checkpointing refers to the periodic writes by the database writer (DBWn) processes for the purpose of writing changed data blocks from the Oracle buffer cache to disk and advancing the thread-checkpoint. Setting the database parameter FAST_START_MTTR_TARGET to a value greater than zero enables the fast-start checkpointing feature. Fast-start checkpointing should always be enabled for the following reasons:
It reduces the time required for cache recovery, and makes instance recovery time-bounded and predictable. This is accomplished by limiting the number of dirty buffers (data blocks which have changes in memory that still need to be written to disk) and the number of redo records (changes in the database) generated between the most recent redo record and the last checkpoint.
Fast-Start checkpointing eliminates bulk writes and corresponding I/O spikes that occur traditionally with interval- based checkpoints, providing a smoother, more consistent I/O pattern that is more predictable and easier to manage. If the system is not already near or at its maximum I/O capacity, fast-start checkpointing will have a negligible impact on performance. Although fast-start checkpointing results in increased write activity, there is little reduction in database throughout, provided the system has sufficient I/O capacity.
从第一段中粗体标记的描述来看,当设定一个大于0的值给FAST_START_MTTR_TARGET,则自动调整检查点功能别启用。即fast-start
checkpointing,更准确的说应该是快速启动检查点功能
再看下面的这段描述,这段来自Oracle 10g OCP workshop I 14-17 英文版教程(Edition 3.1 December 2008)
Explicit setting of the FAST_START_MTTR_TARGET parameter to 0 disables automatic checkpoint tuning.Explicit setting of the FAST_START_MTTR_TARGET parameter to a value other than 0 also enables the Redo Log Advisor.
从上面的描述可以看出,如果将FAST_START_MTTR_TARGET设置为将关闭检查点自动调整功能。
三、设定FAST_START_MTTR_TARGET
根据实际需要来设定FAST_START_MTTR_TARGET的值,这个值的设定需要考虑到可接受的实例的恢复时间、可承受的I/O吞吐量等等。
假定我们将该值设定为
SQL> alter system set fast_start_mttr_target = 30 ;
在事务频繁的时间段来考察视图v$instacne_recovery提供的值
SQL> desc v$instance_recovery; --查看v$instance_recovery视图的结构
Name Null? Type
----------------------------------------- -------- ----------------------------
RECOVERY_ESTIMATED_IOS NUMBER
ACTUAL_REDO_BLKS NUMBER
TARGET_REDO_BLKS NUMBER
LOG_FILE_SIZE_REDO_BLKS NUMBER
LOG_CHKPT_TIMEOUT_REDO_BLKS NUMBER
LOG_CHKPT_INTERVAL_REDO_BLKS NUMBER
FAST_START_IO_TARGET_REDO_BLKS NUMBER
TARGET_MTTR NUMBER
ESTIMATED_MTTR NUMBER
CKPT_BLOCK_WRITES NUMBER
OPTIMAL_LOGFILE_SIZE NUMBER
ESTD_CLUSTER_AVAILABLE_TIME NUMBER
WRITES_MTTR NUMBER
WRITES_LOGFILE_SIZE NUMBER
WRITES_LOG_CHECKPOINT_SETTINGS NUMBER
WRITES_OTHER_SETTINGS NUMBER
WRITES_AUTOTUNE NUMBER
WRITES_FULL_THREAD_CKPT NUMBER
两个字段:
TARGET_MTTR -->参照fast_start_mttr_target参数中设定的值计算出来的一个值
ESTIMATED_MTTR -->系统根据dirty buffer 中计算出来的值
可能出现的情况
1.TARGET_MTTR > ESTIMATED_MTTR --大量的事务将导致这种情况的出现
2.TARGET_MTTR < ESTIMATED_MTTR --数据库刚刚启动时,几乎没有事务时会出现这种情况
SQL> select recovery_estimated_ios,actual_redo_blks ,target_redo_blks ,
2 target_mttr,estimated_mttr
3 from v$instance_recovery;
RECOVERY_ESTIMATED_IOS ACTUAL_REDO_BLKS TARGET_REDO_BLKS TARGET_MTTR ESTIMATED_MTTR
---------------------- ---------------- ---------------- ----------- --------------
55 147 707 33 27
可以在负载的情况下根据TARGET_MTTR来值通过v$mttr_target_advice调整该参数
四、启用MTTR Advisory
需要设置两个参数
STATISTICS_LEVEL -->置为typical 或者all
FAST_START_MTTR_TARGET -->置为非零值
SQL> show parameter mttr; --目标mttr_time设定为30 s
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fast_start_mttr_target integer 30
SQL> select target_mttr,estimated_mttr from v$instance_recovery; --系统计算出来的mttr为33
TARGET_MTTR ESTIMATED_MTTR
----------- --------------
33 27
SQL> select mttr_target_for_estimate tar_est,dirty_limit,estd_cache_writes est_c_w,
2 estd_cache_write_factor est_c_w_f,estd_total_writes est_t_w,estd_total_write_factor est_t_w_f
3 from v$mttr_target_advice;
TAR_EST DIRTY_LIMIT EST_C_W EST_C_W_F EST_T_W EST_T_W_F
---------- ----------- ---------- ---------- ---------- ----------
60 5028 3762 .7376 3762 .7376
34 1000 5100 1 5100 1
68 6248 3762 .7376 3762 .7376
52 3808 3762 .7376 3762 .7376
45 2735 3845 .7539 3845 .7539
--mttr_target_for_estimate有一个值为的最接近设定的目标时间30,以及由系统计算出的的target_mttr时间33
--同时也给出了几组不同的mttr_target值及dirty_limit,cache_write,io 等来供DBA来选择设定合适的mttr
五、两个重要的视图
v$instacne_recovery
v$mttr_target_advice
六、更多
Oracle实例和Oracle数据库(Oracle体系结构)
Oracle 联机重做日志文件(ONLINE LOG FILE)