什么是checkpoint

checkpoint是什么?
z~Pi\*N#^"u-s!n*e4^0checkpoint是数据库的一个内部事件,
-g[gh$l)i q0这个事件激活以后会触发数据库写进程(DBWR)将数据缓冲(DATA BUFFER CACHE)中的脏数据块写出到数据文件中。

checkpoint的作用是什么?
HcvT4Yd0checkpoint主要2个作用:1、保证数据库的一致性,ITPUB个人空间k&| yAV}P.k t
这是指将脏数据写出到硬盘,保证内存和硬盘上的数据是一样的;ITPUB个人空间BG~&k&V-iK.v%d
2、缩短实例恢复的时间,实例恢复要把实例异常关闭前没有写出到硬盘的脏数据通过日志进行恢复。ITPUB个人空间$w&_ Qw+]
如果脏块过多,实例恢复的时间也会很长,检查点的发生可以减少脏块的数量,从而提高实例恢复的时间。

checkpoint就像word的自动保存一样。

checkpoint的类型:
(C e(w!pChc0完全检查点:ITPUB个人空间(W[ R8cMs
定义:清除脏列表(DIRTY LIST OR CHECKPOINT ENQUEUE)中所有数据块。ITPUB个人空间o"uF%Mp9q-ly
什么时候发生:ALTER SYSTEM CHECKPOINT; SHUTDOWN;
8c} OM9]Q0增量检查点:ITPUB个人空间1qoX2d uIf.{&s'z
定义:根据检查点的条件清除脏列表中的部分数据块,直到满足所有检查点条件为止。ITPUB个人空间q |;Q+@Ot*^ {
什么时候发生:CKPT进程每3秒被唤醒,CKPT检查当前的所有checkpoint条件,
)]1C1o6@ `!o0如果任何一个条件不能被满足,那么CKPT发出增量检查点。ITPUB个人空间)u;f"Q E L7Ux5~5B
检查点条件有哪些?ITPUB个人空间Y)ACkLF
90% OF THE SMALLEST REDO LOGFILEITPUB个人空间%YXzB'lw?
FAST_START_MTTR_TARGETITPUB个人空间 eGY&f9@ B.P-_7P+n
FAST_START_IO_TARGET
9cf Qt%P\c-?S0LOG_CHECKPOINT_TIMEOUTITPUB个人空间r#D7fN&A9Bi x
LOG_CHECKPOINT_INTERVAL

90% OF THE SMALLEST REDO LOGFILE :
cy-z|i [*e0\0意味着最后一次增量检查点与当前日志文件末尾所差的redo block数量如果超过最小redo log的90%,那么就会触发增量检查点。
+J].W^#^T'F3r0FAST_START_MTTR_TARGET:实例恢复的时间限制,
,i*Nbc AY-hCRX0oracle将这个时间换算成redo blocks数量,当log buffer中未写入log file的redo block数量超过这个值,就会触发增量检查点。
}0W'A%NY&Y M(z&U0FAST_START_IO_TARGET:实例恢复所需要读取的redo blocks数量,ITPUB个人空间0wnp Kp
当log buffer中未写入log file的redo block数量超过这个值,就会触发增量检查点。
)I+`TO I {0LOG_CHECKPOINT_TIMEOUT:2次增量检查点的时间间隔。
5yiw2ldf|Uz0LOG_CHECKPOINT_INTERVAL:最后一次增量检查点与当前日志文件末尾所差的redo block数量。

注意:增量检查点并不是将脏列表中的所有脏块都写出到数据文件中,而是写出一部分,保证满足所有条件即可。

 

 

相关概念:RBA checkpoin rba on-disk rba RBA:redo block address 重作日志地址ITPUB个人空间2K'u^B&Jk
logfile sequence number(4bytes)
~U*W|&xP3w0logfile block number(4bytes)
7Z Uh9s%vK0redo entry offset(2bytes)
4L P9p(Z+w5c#[0checkpoint rba:最后一次检查点对应的重作日志地址,意味着这个地址之前的redo log都是实例恢复不需要的。
?N$r4_9p"[0实例恢复的起点
)X7[3~B t,~;Pf*E&nm0on-disk rba:当前日志中最新的重作日志地址。ITPUB个人空间;G0D4a%r{7Q
实例恢复的终点

相关视图:x$kcccp v$instance_recovery v$instance_recovery实例恢复对应的视图:ITPUB个人空间 ??/jI9E"d;cm
actual_redo_blks:最后一次检查点到当前日志尾所差的redo blocks数量;
9J{Q+O#O2m!v6Z0target_redo_blks:所有检查点条件中最小的条件相差的redo blocks数量;
kP6v/L)ay^7?0log_file_size_redo_blks:最小日志组的90%大小所对应的redo blocks数量;--这是一个增量检查点条件
U4p4w]]5W0log_chkpt_timeout_redo_blks:有log_checkpoint_timeout参数所转换的redo blocks数量; --这也是一个增量检查点条件
j5rBRb9S0target_mttr:有fast_start_mttr_target参数所限制的实例恢复的最大时间ITPUB个人空间&Q Rh,c Y}u$X?
estimated_mttr:根据当前最后一次检查点与日志尾所差的redo blocks数量估算出来的mttr。

x$kcccp 增量检查点对应的视图:
'd;cd)K h kAE s0CPLRBA_SEQ:最后一次增量检查点对应rba的第一部分--日志序列号;ITPUB个人空间0m5V8Oc n@[t
CPLRBA_BNO:最后一次增量检查点对应rba的第二部分--日志块数;ITPUB个人空间5F%N"yWS
CPLRBA_BOF:最后一次增量检查点对应rba的第三部分--日志偏移量;ITPUB个人空间8@-E cr9t9gb$S
CPODR_SEQ:日志尾的rda的第一部分--日志序列号;ITPUB个人空间 _J&?P0UVi
CPODR_BNO:日志尾的rda的第二部分--日志块数;
Q6eD*r zn.xJ0CPODR_BOF:日志尾的rda的第二部分--日志偏移量;
Acvy&}:_"PRP%D0CPHBT:检查点心跳数。

ITPUB个人空间9M'r?2T;D&[%o
实验测试:ITPUB个人空间)zJw%x#F X*f,l*w
1、完全检查点:

SQL> show parameter log_checkpoint_

NAME TYPE VALUE
Y9]U"f Vw(`0------------------------------------ ---------------------- --------
Qz*DJRW0log_checkpoint_interval integer 0
u4A|HvBb0log_checkpoint_timeout integer 0
$[ ]wlm0`j0log_checkpoints_to_alert boolean TRUE

SQL> alter system checkpoint;

系统已更改。

日志中的信息:完全检查点立即执行。
;b!k0LW8N&`%o+u1]0Beginning global checkpoint up to RBA [0x52f.5c2.10], SCN: 0x0000.0045bf00
f%\vC2JH0Completed checkpoint up to RBA [0x52f.5c2.10], SCN: 0x0000.0045bf00

从v$instance_recovery 中看到actual_redo_blks瞬间为0,说明完全检查点清除脏列表上的所有的脏块。

同时也会完成之前没有完成的日志切换检查点,这时查询v$log,active的状态转变为inactive。

第1个窗口ITPUB个人空间i-p$X0BS^@
SQL> alter system checkpoint;

系统已更改。

第2个窗口ITPUB个人空间l8cs)}8f"[B L6zz
10:24:54 SQL> select actual_redo_blks from v$instance_recovery;

ACTUAL_REDO_BLKS
\$m5dGtA0----------------
:[e\.y,LB4IQ:DKH0128

10:25:09 SQL> /

ACTUAL_REDO_BLKSITPUB个人空间_m:xZqND_
----------------
f*LQ7d vH0128

10:25:11 SQL> /

ACTUAL_REDO_BLKS
:B2y `3i^3}V3~0----------------
kM8Q}'S ~d00

10:25:45 SQL>

此时查看警报日志:ITPUB个人空间#g X1H0G)A!a'cy_'G
Beginning global checkpoint up to RBA [0x531.8f.10], SCN: 0x0000.00461fd1ITPUB个人空间+c4aEHU6U:O
Completed checkpoint up to RBA [0x531.8f.10], SCN: 0x0000.00461fd1

531转成十进制就是1329,是当前的在线日志序列号:
7vTk%Ca2b6c/B0SQL> select group#,sequence#,status from v$Log;

GROUP# SEQUENCE# STATUS
W5uE3vR:@5pF0---------- ---------- ---------------------------ITPUB个人空间 C9psu&i7~I:q*c,J)o
4 1328 INACTIVEITPUB个人空间D Iv y_
5 1329 CURRENTITPUB个人空间 T!y,Bi'I P.Ui
6 1327 INACTIVE

SQL> alter system dump logfile 'D:ORACLEORADATATEST9REDO05.LOG';

系统已更改。

转储日志,找到对应的rba

REDO RECORD - Thread:1 RBA: 0x000531.0000008f.0010 LEN: 0x0428 VLD: 0x02
/P/RY7v6cLr u%w2K8f0SCN: 0x0000.00461fd1 SUBSCN: 1 12/05/2006 10:25:43
_[L2A3P H q2~4F0CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ: 0 OP:23.1
^)C%Y$h*vvNcN]_B+r0Block Written - afn: 1 rdba: 0x00403162(1,12642)ITPUB个人空间|1U,P K*y|?
scn: 0x0000.00461f88 seq: 0x01 flg:0x06
YBN v^/Ni n0Block Written - afn: 1 rdba: 0x00403159(1,12633)
_$f5c$V(q#s0scn: 0x0000.00461f88 seq: 0x01 flg:0x06
@AP%t(n9U0Block Written - afn: 1 rdba: 0x00403158(1,12632)
R3l{ m$wzK-S0scn: 0x0000.00461f88 seq: 0x01 flg:0x06ITPUB个人空间6xbv#X#U9c
Block Written - afn: 1 rdba: 0x0040314b(1,12619)ITPUB个人空间*C Y/pQr
scn: 0x0000.00461f88 seq: 0x01 flg:0x06
&GLo"v*J-f0h.r0Block Written - afn: 1 rdba: 0x0040314a(1,12618)
:N+]pP%t i |9SR0scn: 0x0000.00461f88 seq: 0x01 flg:0x06
m!@/wY5e*BM%H&j0Block Written - afn: 1 rdba: 0x00403149(1,12617)
"m V)c?D5f L(p0scn: 0x0000.00461f88 seq: 0x01 flg:0x06ITPUB个人空间 T/{cI*z|
Block Written - afn: 1 rdba: 0x00401efa(1,7930)ITPUB个人空间}c2SR%inc4Mt`.m
scn: 0x0000.00461fca seq: 0x01 flg:0x06ITPUB个人空间3z7W.pMO|5lN#Oz
Block Written - afn: 1 rdba: 0x00401eba(1,7866)
~ZLr Y0vMx0scn: 0x0000.00461fcc seq: 0x01 flg:0x06
m]_b:x#Y hE}0Block Written - afn: 1 rdba: 0x00401387(1,4999)
t3P(R+N+K'W0scn: 0x0000.00461f88 seq: 0x01 flg:0x06ITPUB个人空间E1BLj^%z0N'V2_
Block Written - afn: 1 rdba: 0x00401386(1,4998)ITPUB个人空间 sUyPAK9bV*Os
scn: 0x0000.00461f88 seq: 0x01 flg:0x06
.lo/N$Ap!vKP0Block Written - afn: 1 rdba: 0x00401373(1,4979)
3w:eC|6eS;\?'|0scn: 0x0000.00461f88 seq: 0x01 flg:0x06
7u%uU'H@?#r:L0Block Written - afn: 1 rdba: 0x00401372(1,4978)ITPUB个人空间#F:Zc'k+W
scn: 0x0000.00461f88 seq: 0x01 flg:0x06
h'FK \x0Block Written - afn: 1 rdba: 0x00401370(1,4976)
%k:g-q6[V%uM U&S0scn: 0x0000.00461f88 seq: 0x01 flg:0x06
y,nZO7z7A2\w.s'Y0Block Written - afn: 1 rdba: 0x0040136a(1,4970)
E]#m&p1T1B0scn: 0x0000.00461f88 seq: 0x01 flg:0x06ITPUB个人空间:dug9AKr
Block Written - afn: 1 rdba: 0x00401365(1,4965)ITPUB个人空间 X"h&AM B
scn: 0x0000.00461f88 seq: 0x01 flg:0x06ITPUB个人空间7mR-i] Q}m\0N
Block Written - afn: 1 rdba: 0x00401363(1,4963)ITPUB个人空间 JqF%}*{'WJ;M
scn: 0x0000.00461f88 seq: 0x01 flg:0x06ITPUB个人空间3SWO ])I9?tU ~k
Block Written - afn: 1 rdba: 0x00401347(1,4935)ITPUB个人空间&{&N7k#fhk)v
scn: 0x0000.00461f88 seq: 0x01 flg:0x06
A_K a5q-|h1F+d9@0Block Written - afn: 1 rdba: 0x00400e8c(1,3724)
a hC%]#Hw0scn: 0x0000.00461f62 seq: 0x01 flg:0x06ITPUB个人空间'T+}2s$F:~\'X
Block Written - afn: 1 rdba: 0x00400cae(1,3246)
BA BLv N8M.j0scn: 0x0000.00461f88 seq: 0x01 flg:0x06ITPUB个人空间t^v\P*wj
Block Written - afn: 1 rdba: 0x00400cac(1,3244)ITPUB个人空间&|.L{s%}/Aw
scn: 0x0000.00461f88 seq: 0x01 flg:0x06
"`3Kv)@D0Block Written - afn: 1 rdba: 0x00400cab(1,3243)
f1J;L `2HB$i0scn: 0x0000.00461f88 seq: 0x01 flg:0x06
A%^%`2tt,r[b}'z0Block Written - afn: 1 rdba: 0x00400ca9(1,3241)ITPUB个人空间 sO\c4`,ySa
scn: 0x0000.00461f88 seq: 0x01 flg:0x06ITPUB个人空间(A v^@ _+R1T:o*k
Block Written - afn: 1 rdba: 0x004005da(1,1498)ITPUB个人空间7WFe%FD r)Je^+^X
scn: 0x0000.00461f90 seq: 0x01 flg:0x06
%C5A/b[1o7qh0Block Written - afn: 1 rdba: 0x004005ca(1,1482)
&l+`#x@ ZHE0F.B;@z,W0scn: 0x0000.00461f90 seq: 0x01 flg:0x06
5U.?'Bp7vP [0Block Written - afn: 1 rdba: 0x00400181(1,385)ITPUB个人空间jclc%WkC
scn: 0x0000.00461f5d seq: 0x01 flg:0x04
^ lW%gdV-X0Block Written - afn: 1 rdba: 0x0040006a(1,106)ITPUB个人空间E:J-O~JsA
scn: 0x0000.00461f5e seq: 0x01 flg:0x06
G$m tzw)G`F+H |D0Block Written - afn: 1 rdba: 0x0040002b(1,43)ITPUB个人空间)C2eU9Uu
scn: 0x0000.00461f88 seq: 0x01 flg:0x06
3~/iU"_e#u9kO8WM0Block Written - afn: 1 rdba: 0x00400028(1,40)ITPUB个人空间(t%d oL6X"I D)\8^3OB2m
scn: 0x0000.00461f88 seq: 0x01 flg:0x06
CfD2YT-z0Block Written - afn: 1 rdba: 0x00400027(1,39)ITPUB个人空间!^2r;Naj,L
scn: 0x0000.00461f88 seq: 0x01 flg:0x06ITPUB个人空间S5[)g0E4j4M
Block Written - afn: 1 rdba: 0x00400026(1,38)
*]$PJ*zMq#E0scn: 0x0000.00461f88 seq: 0x01 flg:0x06
i7L zQt e}i0Block Written - afn: 1 rdba: 0x00400023(1,35)
ms3_kD+\4E%@0scn: 0x0000.00461f88 seq: 0x01 flg:0x06ITPUB个人空间dW/M/?;n3M&^J3g
Block Written - afn: 1 rdba: 0x00400018(1,24)ITPUB个人空间,K PctfJ Ih~
scn: 0x0000.00461f4b seq: 0x01 flg:0x04
4Si]p!z4`!c([$[0Block Written - afn: 2 rdba: 0x0081645c(2,91228)ITPUB个人空间u0l?Pf)R3FYM| _-y
scn: 0x0000.00461f6d seq: 0x02 flg:0x04
,] ^P}s1n0Block Written - afn: 2 rdba: 0x0081645b(2,91227)ITPUB个人空间!Z-I1^5pc5f`m%T
scn: 0x0000.00461fc8 seq: 0x01 flg:0x04
j2iEvc$L#P'U0Block Written - afn: 2 rdba: 0x008072d3(2,29395)ITPUB个人空间)s+Y bU1q\%J3S6n
scn: 0x0000.00461f65 seq: 0x02 flg:0x04ITPUB个人空间k%^z{2B }X`
Block Written - afn: 2 rdba: 0x008072d2(2,29394)ITPUB个人空间+|o!f)\7vgJr
scn: 0x0000.00461fcb seq: 0x01 flg:0x04ITPUB个人空间4Hc {REC)N*n#G
Block Written - afn: 2 rdba: 0x00802ffa(2,12282)
uq$K Y8dm2t|n"o0scn: 0x0000.00461f6a seq: 0x02 flg:0x04
O0pU~%B$F|,Y Q0Block Written - afn: 2 rdba: 0x00802ff9(2,12281)ITPUB个人空间P/Q6ECG r
scn: 0x0000.00461fc3 seq: 0x02 flg:0x04ITPUB个人空间&CU7?Q2i.S-d]6q"x?
Block Written - afn: 2 rdba: 0x00802df1(2,11761)
rm _a%G[7\ h}s0scn: 0x0000.00461f6c seq: 0x02 flg:0x04ITPUB个人空间3q%cAo9sj0LP0?
Block Written - afn: 2 rdba: 0x00802df0(2,11760)ITPUB个人空间sj.|K/Q {dg+Y._ n
scn: 0x0000.00461fc6 seq: 0x03 flg:0x04
#X3qd;X+b7V|1c@0Block Written - afn: 2 rdba: 0x00802d66(2,11622)ITPUB个人空间(_@%zW\ j a;v6pF+L
scn: 0x0000.00461fc9 seq: 0x03 flg:0x04
4l3fl@s:L+K0Block Written - afn: 2 rdba: 0x00802d65(2,11621)
~ t!^+l8{z.B]T0scn: 0x0000.00461f63 seq: 0x02 flg:0x04
7@LF1\^,he C3u0Block Written - afn: 2 rdba: 0x00802d64(2,11620)ITPUB个人空间`aes K5z
scn: 0x0000.00461f74 seq: 0x01 flg:0x04
t(Rrm;DG+h#Hr0Block Written - afn: 2 rdba: 0x00802c18(2,11288)ITPUB个人空间8`K.]^v*[w3z
scn: 0x0000.00461f67 seq: 0x02 flg:0x04ITPUB个人空间3qIXc7rzZ
Block Written - afn: 2 rdba: 0x00802c17(2,11287)ITPUB个人空间"}nM3yR yG*y)I
scn: 0x0000.00461fb4 seq: 0x01 flg:0x04ITPUB个人空间*f[Qy'f(e_R
Block Written - afn: 2 rdba: 0x00802b92(2,11154)ITPUB个人空间7uhmswEf0K
scn: 0x0000.00461f68 seq: 0x02 flg:0x04
~Y,l7|MW0Block Written - afn: 2 rdba: 0x00802b89(2,11145)ITPUB个人空间'?}&o |8| x/U)]J
scn: 0x0000.00461fbf seq: 0x02 flg:0x04
RD_N2M+~0Block Written - afn: 2 rdba: 0x008028e0(2,10464)
]/]0l K0E/Lb7a0scn: 0x0000.00461f69 seq: 0x02 flg:0x04
#yLCD.nd Nr3[0Block Written - afn: 2 rdba: 0x008028df(2,10463)
X@FXD td'J r5i0scn: 0x0000.00461fc1 seq: 0x01 flg:0x04ITPUB个人空间[2\Dk8K6j&S2M
Block Written - afn: 2 rdba: 0x00801472(2,5234)
^'S2F b3X5k8g0scn: 0x0000.00461f6b seq: 0x02 flg:0x04ITPUB个人空间aE!In6C8U)SMo$[
Block Written - afn: 2 rdba: 0x00801471(2,5233)ITPUB个人空间*}9]eL-|I:^
scn: 0x0000.00461fc5 seq: 0x01 flg:0x04ITPUB个人空间5tQr(c-q yv8|"} m;uU
Block Written - afn: 2 rdba: 0x00800a64(2,2660)ITPUB个人空间8r;c5|7] o#D]:nK E
scn: 0x0000.00461f66 seq: 0x02 flg:0x04
|z~-eZ0Block Written - afn: 2 rdba: 0x00800a63(2,2659)
mK DN/B|0scn: 0x0000.00461fcc seq: 0x01 flg:0x04
t+^\)FC7|c%?8p0Block Written - afn: 2 rdba: 0x00800099(2,153)
8TyWk^0scn: 0x0000.00461fc9 seq: 0x01 flg:0x04ITPUB个人空间H"B p4JzE8^9C.M
Block Written - afn: 2 rdba: 0x00800089(2,137)ITPUB个人空间 Gy*Q rV7e n2c
scn: 0x0000.00461fc7 seq: 0x01 flg:0x04
nm d @.P)R0Block Written - afn: 2 rdba: 0x00800079(2,121)
,v4u c X!U ~0scn: 0x0000.00461fc6 seq: 0x01 flg:0x04ITPUB个人空间5u:xoa_/cy
Block Written - afn: 2 rdba: 0x00800069(2,105)
1yQ \~ ?g?0scn: 0x0000.00461fc4 seq: 0x01 flg:0x04
7mP ?Zu%?0Block Written - afn: 2 rdba: 0x00800059(2,89)
H;y(Da ^e~}0scn: 0x0000.00461fc2 seq: 0x01 flg:0x04ITPUB个人空间)m+D#KR%TXlNF
Block Written - afn: 2 rdba: 0x00800049(2,73)
k3c9vZ.T?:A3@0scn: 0x0000.00461fc0 seq: 0x01 flg:0x04
o*zyYgAcK1d2b y0Block Written - afn: 2 rdba: 0x00800039(2,57)
+m4OGV.a _0scn: 0x0000.00461fb5 seq: 0x01 flg:0x04ITPUB个人空间m4l!_&i%];q{6uQ"l
Block Written - afn: 2 rdba: 0x00800029(2,41)ITPUB个人空间!o q VHNh$ve-\)v ^
scn: 0x0000.00461fcd seq: 0x01 flg:0x04
FfZ X@ q0Block Written - afn: 2 rdba: 0x00800019(2,25)ITPUB个人空间XXJ_ By:E
scn: 0x0000.00461fcc seq: 0x01 flg:0x04ITPUB个人空间%rJ8gI eU^z{ u
Block Written - afn: 2 rdba: 0x00800009(2,9)ITPUB个人空间,Z9V)wgB*`
scn: 0x0000.00461fca seq: 0x01 flg:0x04
Q,jXxWo"K/x(n0Block Written - afn: 1 rdba: 0x00400009(1,9)ITPUB个人空间&Ncr$Wm h`S)y#v
scn: 0x0000.00461f5e seq: 0x01 flg:0x04

ITPUB个人空间$BIo+Ru H@5L
注意 这条redo record的scn:SCN: 0x0000.00461fd1,和检查点scn是一致的。

SQL> select file#,checkpoint_change# from v$datafile;

FILE# CHECKPOINT_CHANGE#
\7~]6O`.nk5F M%L Q0---------- ------------------
2~dJSF u01 4595665ITPUB个人空间t7U"qKX fN!c
2 4595665
}z4G)o$c0[1I03 4595665
j\ d/a+F"~Q3vl04 4595665ITPUB个人空间_#}Xv q?CR
5 4595665ITPUB个人空间 Z5ube)Q;VI
6 4595665
H+w*K"~+R U dZ4q D r07 4595665

已选择7行。

SQL> select to_char(4595665,'xxxxxxx') from dual;

TO_CHAR(4595665,ITPUB个人空间"M*Ep)s4S
----------------
Z._G Cj0461fd1

ITPUB个人空间e6V,G^X }
研究写出脏块的数量:

SQL> select count(1) from v$bh where dirty='Y';

COUNT(1)ITPUB个人空间S DS+|f
----------ITPUB个人空间-o6he!D]
42

SQL> alter system checkpoint;

系统已更改。

SQL> select count(1) from v$bh where dirty='Y';

COUNT(1)ITPUB个人空间'Djgj&M6vO[
----------
vIMW^ xZ0v+w$x011

SQL> select file#,checkpoint_change# from v$datafile;

FILE# CHECKPOINT_CHANGE#
y9g'^1Fy2m0---------- ------------------
s5Rn+fZ.Bj.],t+~01 4596768ITPUB个人空间~,M!j9U,T,a1kp
2 4596768ITPUB个人空间@1VpuEcZL
3 4596768ITPUB个人空间7F&q)S%b5mosu
4 4596768ITPUB个人空间 yxK7i&S?i4a/p4i
5 4596768ITPUB个人空间s k.^U{?7Qy9W ^
6 4596768
[$~|0a5n o R^07 4596768

已选择7行。

SQL> select to_char(4596768,'xxxxxxx') from dual;

TO_CHAR(4596768,ITPUB个人空间/A@6S.j k4]qex
----------------ITPUB个人空间N&{.E UK ~\%t
462420

找到462420的redo record:正好是31个脏块ITPUB个人空间%M(e(Wsw:AT\A/dY
REDO RECORD - Thread:1 RBA: 0x000531.0000028d.0010 LEN: 0x0218 VLD: 0x02
4hv J){Q7Y0SCN: 0x0000.00462420 SUBSCN: 1 12/05/2006 10:48:14
k$C's/lfH"Ly0CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ: 0 OP:23.1
DS@-i8\,`0Block Written - afn: 1 rdba: 0x00401efa(1,7930)ITPUB个人空间*VVj$T$a
scn: 0x0000.00462413 seq: 0x01 flg:0x06ITPUB个人空间Qu*\vJP kW
Block Written - afn: 1 rdba: 0x00400e8c(1,3724)ITPUB个人空间7IO:Nf)OZw
scn: 0x0000.0046237f seq: 0x01 flg:0x06
2y6K AmihT0Block Written - afn: 1 rdba: 0x00400d5a(1,3418)ITPUB个人空间i6x9a+F@,[
scn: 0x0000.0046227e seq: 0x01 flg:0x06
2}5k/M!}4yJ-_8b9|#~0Block Written - afn: 2 rdba: 0x0081645c(2,91228)ITPUB个人空间 ]xUf'@2?)u!D^
scn: 0x0000.004623fd seq: 0x01 flg:0x04ITPUB个人空间? u,|/by4{
Block Written - afn: 2 rdba: 0x0081645b(2,91227)
/b,|(V9RX+k%c0scn: 0x0000.0046215e seq: 0x02 flg:0x04
};M b+[p1f0Block Written - afn: 2 rdba: 0x008072d2(2,29394)ITPUB个人空间[r&p+F'\0V
scn: 0x0000.0046240a seq: 0x01 flg:0x04
Lm)@(lx0Block Written - afn: 2 rdba: 0x00802ffa(2,12282)ITPUB个人空间`E'u_Dj)Q:OuVl a%g
scn: 0x0000.00462412 seq: 0x03 flg:0x04
.LFc&o^ [N0Block Written - afn: 2 rdba: 0x00802ff9(2,12281)ITPUB个人空间5dLr5Y7];Y
scn: 0x0000.004622f8 seq: 0x03 flg:0x04
Gc(h5Z-m0Block Written - afn: 2 rdba: 0x00802df1(2,11761)
lj2s0lkgy Y0scn: 0x0000.00462415 seq: 0x01 flg:0x04
pVj3Q%^0Block Written - afn: 2 rdba: 0x00802df0(2,11760)ITPUB个人空间D{yT%} ^?S
scn: 0x0000.004622a9 seq: 0x01 flg:0x04ITPUB个人空间,_^[7ZVB~:\ r
Block Written - afn: 2 rdba: 0x00802d66(2,11622)ITPUB个人空间,hG;G{%FH/C*]N;Vv
scn: 0x0000.004620ea seq: 0x03 flg:0x04
*X s{{ g@0@1t0Block Written - afn: 2 rdba: 0x00802d65(2,11621)
+pW k3ww(j;[2JR0scn: 0x0000.00462408 seq: 0x02 flg:0x04ITPUB个人空间$IzTL/e{kH
Block Written - afn: 2 rdba: 0x00802c18(2,11288)
_?_-}m+X-GyS0scn: 0x0000.0046240e seq: 0x01 flg:0x04
#]?3k{ UZnZ4[.^0Block Written - afn: 2 rdba: 0x00802c17(2,11287)
(J v!\7R)[0@ lU0scn: 0x0000.0046207e seq: 0x03 flg:0x04ITPUB个人空间:?(e%j[${'q
Block Written - afn: 2 rdba: 0x00802b92(2,11154)ITPUB个人空间2Z a:x.k}(V\ X"B
scn: 0x0000.0046240f seq: 0x03 flg:0x04
kG+E%jn)[0Block Written - afn: 2 rdba: 0x00802b89(2,11145)
J]/TuXQ'j(p:Q0scn: 0x0000.004622f4 seq: 0x03 flg:0x04ITPUB个人空间Dl:b!Woq'V(kc.[
Block Written - afn: 2 rdba: 0x008028df(2,10463)
:e3U*W&zg2D+zi0scn: 0x0000.00462411 seq: 0x01 flg:0x04ITPUB个人空间-zDj+Qa&a4P-m7h
Block Written - afn: 2 rdba: 0x00801472(2,5234)ITPUB个人空间^8i B!o7qhkHj)q4g
scn: 0x0000.00462414 seq: 0x01 flg:0x04
D f&CGp)_#G![ [0Block Written - afn: 2 rdba: 0x00801471(2,5233)ITPUB个人空间!oi7W)T/J'd1B
scn: 0x0000.004623c1 seq: 0x03 flg:0x04
,P z*q tcA0Block Written - afn: 2 rdba: 0x00800a63(2,2659)ITPUB个人空间i-e\ v0zF7~ q
scn: 0x0000.0046240c seq: 0x02 flg:0x04
&L7|Rm3BnI0Block Written - afn: 2 rdba: 0x00800099(2,153)ITPUB个人空间(o|B.~N8toV TK
scn: 0x0000.004623fe seq: 0x01 flg:0x04
lw&]V j+S4T%i;v0Block Written - afn: 2 rdba: 0x00800089(2,137)
fcOh |#b;@7?-DB P0scn: 0x0000.00462416 seq: 0x01 flg:0x04ITPUB个人空间P/a f!m-s6\5Ik8S\
Block Written - afn: 2 rdba: 0x00800079(2,121)ITPUB个人空间/_Z/tP6R~!r#m
scn: 0x0000.00462415 seq: 0x01 flg:0x04
E}:sB4^&`3`;mv2y0Block Written - afn: 2 rdba: 0x00800069(2,105)
,n(a0p~l1h/N'X0scn: 0x0000.00462413 seq: 0x01 flg:0x04
m-|Cad&J4{0Block Written - afn: 2 rdba: 0x00800059(2,89)ITPUB个人空间2i4X OXi)HC
scn: 0x0000.00462412 seq: 0x01 flg:0x04ITPUB个人空间7adDVqUU1S(}
Block Written - afn: 2 rdba: 0x00800049(2,73)
h7v)Q*D0PU*h4z.L0scn: 0x0000.00462410 seq: 0x01 flg:0x04ITPUB个人空间%Z;ZOx!hy0V H$z
Block Written - afn: 2 rdba: 0x00800039(2,57)
Oh%Q4PKf;XC0scn: 0x0000.0046240f seq: 0x01 flg:0x04
w5D3|X^0Block Written - afn: 2 rdba: 0x00800029(2,41)ITPUB个人空间9`$Mu:_V!i
scn: 0x0000.0046240d seq: 0x01 flg:0x04ITPUB个人空间7OK4x:bjk3js6y
Block Written - afn: 2 rdba: 0x00800019(2,25)ITPUB个人空间.O:U^~ NR1m Gn
scn: 0x0000.0046240b seq: 0x01 flg:0x04
Too.C4C J b]0N.l0Block Written - afn: 2 rdba: 0x00800009(2,9)ITPUB个人空间EEw&S,eiv
scn: 0x0000.00462409 seq: 0x01 flg:0x04ITPUB个人空间t!M"Z GN]E
Block Written - afn: 1 rdba: 0x00401eba(1,7866)ITPUB个人空间PEU4@7mv$Sf
scn: 0x0000.00462415 seq: 0x01 flg:0x06

REDO RECORD - Thread:1 RBA: 0x000531.0000028f.0010 LEN: 0x01bc VLD: 0x01
}]:y'MT0SCN: 0x0000.00462422 SUBSCN: 1 12/05/2006 10:48:17

ITPUB个人空间'Y6L|l4m1g
总结一下:完全检查点会清空buffer cache中所有脏块(有些特殊块不包含在内),
{mk:nn s%x*J/I0当alter system checkpoint 命令发出,完全检查点会立刻执行。
8q@"J vNEyw0如果是在生产库,由于脏块数量比较多,完全检查点的时间会很长,并占用一定的系统资源,这时操作系统的IO会变忙。

ITPUB个人空间gE @ S \#T,l
2、增量检查点:设置增量检查点的意义是通过提高检查点发生的次数,将脏块不断的,一点一点的写出到数据文件,ITPUB个人空间6J0I!Fl }K
这样可以避免由于完全检查点引起的高IO负载。
#o tCmt8G0a、第一个发生增量检查点的条件:90% OF THE SMALLEST REDO LOGFILE
,Q.`L2KA-p)x0一般很少有人更改log_checkpoint和fast_start参数,那些参数的默认值都设置的很大,ITPUB个人空间S)C;V/{ [xdC$A
所以还没到那些参数的阀值的时候,90%最小日志的条件就生效了(增量检查点是任何一个条件成立以后就会发生)。
4tHg q&G#w"{0实验一把:

SQL> show parameter log_checkpoint

NAME TYPE VALUE
\#j0F/P1UkZ0------------------------------------ ----------- ------------------------------
+SM_8f_;z-l0log_checkpoint_interval integer 0ITPUB个人空间8Y+N1Z]0K\
log_checkpoint_timeout integer 1800
z t2H2YN'e*l)tRuy@ q0log_checkpoints_to_alert boolean TRUE
+f+x w7_DR0SQL> show parameter fast_start

NAME TYPE VALUEITPUB个人空间 x1T.`"u]r0M0B8Hj
------------------------------------ ----------- ------------------------------
O(o!k o,{Xe b0fast_start_io_target integer 0ITPUB个人空间 JE A/Vm/n
fast_start_mttr_target integer 0ITPUB个人空间Q0_'{zJ7q'qT
fast_start_parallel_rollback string HIGH

SQL> create table test as select * from dba_objects;

Table created.

ps:增量检查点的触发条件的当前值都可以在v$instance_recovery中看到,而x$kcccp可以看到最后一次检查点的位置(用rba表示)和当前日志尾的位置(用rba表示)。

看看当前各个增量检查点触发条件的值:

SQL> select actual_redo_blks act,target_redo_blks target,LOG_FILE_SIZE_REDO_BLKS logfile,LOG_CHKPT_TIMEOUT_REDO_BLKS log_check,target_mttr tmttr,estimated_mttr es_mttr from v$instance_recovery;

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间xe rT9?
---------- ---------- ---------- ---------- ---------- ----------ITPUB个人空间(s5o#o;E8~ M5H
62967 170577 184320 170577 0 14
1_2p]%oYN+{']0--LOG_FILE_SIZE_REDO_BLKS的值是184320,这正好是日志文件的90%
+OXI3lq4Y;MI'y0--日志块是0.5K一个,换算成M,184320*0.5/1024=90 日志文件是100M

--再看一下最后一次检查点的位置:
9M+v+U#C)W!p%~\0SQL> select CPLRBA_SEQ,CPLRBA_BNO,CPODR_SEQ,CPODR_BNO from x$kcccp;

CPLRBA_SEQ CPLRBA_BNO CPODR_SEQ CPODR_BNO
z3U_NZmp ~6l3o*q0---------- ---------- ---------- ----------ITPUB个人空间@9E;t$`V
47 107610 47 170607
4O8h5h'O/c0--最后一次检查点发生在47号日志的17610块,当前日志也是47号,日志尾在170607块。

--这时从另一个窗口不断的执行 insert into test as select * from test where rownum < 100000;ITPUB个人空间$]P,@)K&@p@+?6x8[
--同时不断查询v$instance_recovery,可以看到新产生大量的日志块:

SQL> select actual_redo_blks act,target_redo_blks target,LOG_FILE_SIZE_REDO_BLKS logfile,LOG_CHKPT_TIMEOUT_REDO_BLKS log_check,target_mttr tmttr,estimated_mttr es_mttr from v$instance_recovery;

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间Rg A,Mn$b6r D
---------- ---------- ---------- ---------- ---------- ----------
IarQ#H xw4TQ063008 170612 184320 170612 0 14

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTR
(V'I[(g,b0---------- ---------- ---------- ---------- ---------- ----------
;~/S ~'gOC&}s082829 184320 184320 190439 0 14

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间1M;YpEFn/^q!d@
---------- ---------- ---------- ---------- ---------- ----------
*k[h0~l:d0103118 184320 184320 210728 0 14

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间&g7nUG3_o4g0a6^aK
---------- ---------- ---------- ---------- ---------- ----------
F/W E1|3@5k0103197 184320 184320 210807 0 20

--此时redo log也发生了切换:ITPUB个人空间;E6rrn3~4G-W-i#n
SQL> select * from v$Log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
\5YZLd!]xv0---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------ITPUB个人空间*rv~ v],u-Sd
1 1 47 104857600 3 NO ACTIVE 1210034 11-DEC-06ITPUB个人空间;?/d)T5gYN)~V
2 1 48 104857600 3 NO CURRENT 1213051 11-DEC-06ITPUB个人空间K4p7I3`9^
3 1 46 104857600 3 YES INACTIVE 1209429 11-DEC-06

--这里注意:当当前日志被写满以后,进行日志切换,这时触发了一个log switch checkpoint,但是仅仅是触发,而并没有完成。ITPUB个人空间 zvk5z"iuh%K
--后台警报日志:
a7]M*B#V0Mon Dec 11 15:06:26 2006ITPUB个人空间;?#~.if(v"^?:^
Beginning log switch checkpoint up to RBA [0x30.2.10], SCN: 0x0000.0012827b
j n4^%L/xk;`7gzv0Thread 1 advanced to log sequence 48
5CC2Tr\0Current log# 2 seq# 48 mem# 0: /u01/app/oracle/oradata/novo/redo02.log

--另外注意,47号日志的状态是ACTIVE,active的意思是这个日志组还包含实例恢复所需要的日志。这也说明log switch checkpoint并没有立即工作ITPUB个人空间;^PmW:d k
--这时看看最后一次检查点的位置:
E|6| kPz0SQL> select CPLRBA_SEQ,CPLRBA_BNO,CPODR_SEQ,CPODR_BNO from x$kcccp;

CPLRBA_SEQ CPLRBA_BNO CPODR_SEQ CPODR_BNO
x?1xE@m"f/gr0---------- ---------- ---------- ----------
(qJ3}h _@@047 107610 48 6161

--最后一次检查点的位置没变,还在47号日志上面,而当前日志尾已经到了48号的6161块上。这也印证了为什么44号日志的状态是ACTIVE的。

--再看看当前是否满足增量检查点的触发条件:
kGj8m2eJ0SQL> lITPUB个人空间yc't(c)VP
1* select actual_redo_blks act,target_redo_blks target,LOG_FILE_SIZE_REDO_BLKS logfile,LOG_CHKPT_TIMEOUT_REDO_BLKS log_check,target_mttr tmttr,estimated_mttr es_mttr from v$instance_recovery

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTR
sos*P%`8Ov5m0---------- ---------- ---------- ---------- ---------- ----------ITPUB个人空间H#Q2WR:G/`cc
103361 184320 184320 210971 0 20ITPUB个人空间)n;E%z/}aO
--没有满足,那么继续insertITPUB个人空间G7J,AF |Lm;n$J8P
--不断观察v$instance_recovery:ITPUB个人空间S9?^7I.V7yT&b
SQL> select actual_redo_blks act,target_redo_blks target,LOG_FILE_SIZE_REDO_BLKS logfile,LOG_CHKPT_TIMEOUT_REDO_BLKS log_check,target_mttr tmttr,estimated_mttr es_mttr from v$instance_recovery;

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间wI0uM!H3^v2F L4OS
---------- ---------- ---------- ---------- ---------- ----------
mcB$w,t063008 170612 184320 170612 0 14

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTR
gW(H0bsk N~aH4U0---------- ---------- ---------- ---------- ---------- ----------
Q |8O,|@VR082829 184320 184320 190439 0 14

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTR
?ymBBfb:Z%a0---------- ---------- ---------- ---------- ---------- ----------ITPUB个人空间1VjD D;N+O j
103118 184320 184320 210728 0 14

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间7b9Ng V4zD VlIM
---------- ---------- ---------- ---------- ---------- ----------
pU E m3|vu9}0103197 184320 184320 210807 0 20

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间x8nh8O|PVO
---------- ---------- ---------- ---------- ---------- ----------
zGv'Ad,mi y0103361 184320 184320 210971 0 20

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间HwW|'Q DMJ+B
---------- ---------- ---------- ---------- ---------- ----------ITPUB个人空间 _ez`y[
123466 184320 184320 231076 0 22

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间^F Idg#aC
---------- ---------- ---------- ---------- ---------- ----------
]Ojub _G+g0143954 184320 184320 251564 0 22

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间k-~.zjWr
---------- ---------- ---------- ---------- ---------- ----------ITPUB个人空间)N Z7x)rsv.ff
159205 184320 184320 258499 0 22

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTR
5cR}X^6~S$`s2l#\0---------- ---------- ---------- ---------- ---------- ----------ITPUB个人空间9[ID1DK7T4`U2J
184159 184320 184320 291769 0 26

--这时actual redo blocks已经到了184149了,马上接近90% of redologfile,意味着再有一些日志进来以后,就会触发增量检查点。ITPUB个人空间3G'fvOE kJ
--这时47号日志的状态还是没有变化的,还是active:ITPUB个人空间C } e]8yd)^%e/?-C8h
SQL> select * from v$Log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIMITPUB个人空间;Lh[ rH1dT5r:?
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------ITPUB个人空间m_y Kb*^
1 1 47 104857600 3 NO ACTIVE 1210034 11-DEC-06
P/g L I,Yk8Yw5O02 1 48 104857600 3 NO CURRENT 1213051 11-DEC-06ITPUB个人空间(Wc {Hg}N
3 1 46 104857600 3 YES INACTIVE 1209429 11-DEC-06

--再次插入数据:

--actual redo blocks超过90% of logfile,这时应该触发增量检查点,最后一次查询是增量检查点发生之后的actual redo blocks值,已经小于90% of logfile。
3e]w`:d^+?0SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间}[1{nu1z1v,{`
---------- ---------- ---------- ---------- ---------- ----------
#JH2n2w g3^5@6k0204281 184320 184320 372918 0 28

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间5I:_ I!c(Uc [y
---------- ---------- ---------- ---------- ---------- ----------ITPUB个人空间,Ie!j d&?-L
204281 184320 184320 372918 0 28

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间 t-A"uctQB5OG Mv
---------- ---------- ---------- ---------- ---------- ----------
N*A'I|$E#M0183929 184320 184320 373265 0 28

--注意增量检查点只是写出一部分脏数据,只要保证actual redo blocks小于90% of logfile就可以了。ITPUB个人空间$qx3X*B&Y$B/E
--这时查询x$kcccp,发现最后一次检查点的位置已经升高,但依旧在47号日志上面:
5K h}o)yD h^0SQL> select CPLRBA_SEQ,CPLRBA_BNO,CPODR_SEQ,CPODR_BNO from x$kcccp;

CPLRBA_SEQ CPLRBA_BNO CPODR_SEQ CPODR_BNOITPUB个人空间k8aaK"ALK7R z
---------- ---------- ---------- ----------ITPUB个人空间w*Yy9P j(D#V@"c8u
47 185730 48 118320

--再次插入数据,并查询v$instance_recovery
m!k$Ar#w(T0S{ [~0SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间8i5h6\Mo
---------- ---------- ---------- ---------- ---------- ----------
M$K~F @3Ea [5w p0184588 184320 184320 393585 0 30

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTR
(NRdr+p}0---------- ---------- ---------- ---------- ---------- ----------ITPUB个人空间[7@5S PR-q
184588 184320 184320 393604 0 30

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间*D8@)Ue2o(C,@H
---------- ---------- ---------- ---------- ---------- ----------ITPUB个人空间5\I%s}8I` q
183868 184320 184320 393604 0 30

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTR
)C N"^(IIN`a0---------- ---------- ---------- ---------- ---------- ----------
/_O0`6J-cT C`0183869 184320 184320 393604 0 30

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间Ln%CS-x5zH*y1g$gPt
---------- ---------- ---------- ---------- ---------- ----------
Q.k.NP`0183881 184320 184320 393617 0 28

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间H*_*|kxS+DE
---------- ---------- ---------- ---------- ---------- ----------ITPUB个人空间5@\L!? ]+`#Lh2e
183881 184320 184320 393617 0 28

--由于再次超过阀值,增量检查点再次发生,并写出了一些脏块,此时查询x$kcccp,发现最后一次检查点的位置已经提到48号日志:ITPUB个人空间`&HA;q7^L5Z ]:E6j
SQL> select CPLRBA_SEQ,CPLRBA_BNO,CPODR_SEQ,CPODR_BNO from x$kcccp;

CPLRBA_SEQ CPLRBA_BNO CPODR_SEQ CPODR_BNOITPUB个人空间l0Bm-D1W0Q:AU)Lt
---------- ---------- ---------- ----------ITPUB个人空间-Usb{9p+Q IoIP
48 6072 48 188945

--观察alert log:log switch checkpoint 完成。
2x7i3y*M;H0aAd@(a0Mon Dec 11 15:29:08 2006ITPUB个人空间2B)Ye9j2f S6{V
Completed checkpoint up to RBA [0x30.2.10], SCN: 0x0000.0012827b
:c l;qU~-TkJ h&?b [0--这里注意RBA已经指向日志 0x30,转换成10进制就是,16×3=48,这与上面x$kcccp查到的情况是相符的。ITPUB个人空间t3gpd}?H8l
--由于最后一次检查点的位置已经超过47号日志,那么47号日志对于实例恢复来说就没有用了,来看看47号日志的状态:
y)p1f;I#Q9ugE0--观察v$log,47号日志的状态已经变为INACTIVEITPUB个人空间M-Ld k+OIAy*}
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIMITPUB个人空间NnN i%{!UFv*c
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
7MG}'w1OU!I1xH,H01 1 47 104857600 3 NO INACTIVE 1210034 11-DEC-06
i @8Nza1i jg02 1 48 104857600 3 NO CURRENT 1213051 11-DEC-06
nHNQm7L n.`03 1 46 104857600 3 YES INACTIVE 1209429 11-DEC-06

总结一下:通常所说的logfile switch 触发检查点,实际上就是给出一个标记,而并不真正去写脏块。等待增量检查点做到了那个标记,再标识完成。

ITPUB个人空间_4P+[7o*He6?w1S
b、第二个发生增量检查点的条件:LOG_CHECKPOINT_TIMEOUTITPUB个人空间I1G eU?}+N
这个参数说白了就是控制2次增量检查点之间所发生的时间间隔,超过这个间隔,就会触发增量检查点。ITPUB个人空间aIfA1?6R)F,~!wh{
从另外一个角度理解,就是脏块在buffer cache中所能存在的最大时间。

为了让实验更明显,把这个参数设小点,1分钟:
)kI+m'u;Z EInI0SQL> show parameter log_checkpoint

NAME TYPE VALUEITPUB个人空间{3zk3w$NB8~L
------------------------------------ ----------- ------------------------------ITPUB个人空间s|-u wM*S'x
log_checkpoint_interval integer 0ITPUB个人空间9kC6s:s.rLAw6OF
log_checkpoint_timeout integer 1800ITPUB个人空间 b~ Hw/{-P
log_checkpoints_to_alert boolean TRUEITPUB个人空间:u j k+NBM%m^
SQL> alter system set log_checkpoint_timeout = 60;

System altered.

SQL> show parameter log_checkpoint;

NAME TYPE VALUE
Y#[ u P`.Dum0------------------------------------ ----------- ------------------------------
-ft%E ~1j0z0log_checkpoint_interval integer 0
]9UQ(hL C0log_checkpoint_timeout integer 60ITPUB个人空间Z:?7At/l.K e
log_checkpoints_to_alert boolean TRUE

--查看v$instance_recovery视图:ITPUB个人空间3?rY3l x@l
SQL> l
d+H3}v$? CmX01* select actual_redo_blks act,target_redo_blks target,LOG_FILE_SIZE_REDO_BLKS logfile,LOG_CHKPT_TIMEOUT_REDO_BLKS log_check,target_mttr tmttr,estimated_mttr es_mttr from v$instance_recovery
Tu|"KR'E.ovvf0SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间h+v j&{ e/p _
---------- ---------- ---------- ---------- ---------- ----------ITPUB个人空间9vPl`d'n"~
7 15 184320 15 0 7

--看到target 和 log_CHECKPOINT_TIMEOUT的值是一样的,而且变的特别小,只要actual redo blocks超过这个数量就会触发增量检查点。

--下面重复上面的那个实验,不断的插入数据,以产生redo log,然后观察检查点发生的情况:ITPUB个人空间$|Q,ie0x'u
--先看看redo log的状态:
0AMRe7J v Z-bO0GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIMITPUB个人空间 S5`fWK0r I.i3o
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
OF dx!Zq@t_4w01 1 47 104857600 3 NO INACTIVE 1210034 11-DEC-06ITPUB个人空间F%Z*~Q2v
2 1 48 104857600 3 NO CURRENT 1213051 11-DEC-06ITPUB个人空间'[#Vck ]Ba9v
3 1 46 104857600 3 YES INACTIVE 1209429 11-DEC-06

--增量检查点的位置:ITPUB个人空间v^1J BU"F`|BK0m
SQL> select CPLRBA_SEQ,CPLRBA_BNO,CPODR_SEQ,CPODR_BNO from x$kcccp;

CPLRBA_SEQ CPLRBA_BNO CPODR_SEQ CPODR_BNOITPUB个人空间 y [KzU!?
---------- ---------- ---------- ----------ITPUB个人空间+qVyI/Z2lq#s
48 189440 48 189462

--插入数据,并观察v$instance_recovery

SQL> insert into test select * from test where rownum < 100000;

99999 rows created.

--观察v$instance_recoveryITPUB个人空间|[#]FUl
SQL> lITPUB个人空间 tz-[a)kO$Z
1* select actual_redo_blks act,target_redo_blks target,LOG_FILE_SIZE_REDO_BLKS logfile,LOG_CHKPT_TIMEOUT_REDO_BLKS log_check,target_mttr tmttr,estimated_mttr es_mttr from v$instance_recoveryITPUB个人空间%KP+EsW [/i
SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTR
6Is3Gn} sY0---------- ---------- ---------- ---------- ---------- ----------ITPUB个人空间d}*{@I pex$[~7l
20433 20433 184320 20433 0 10

SQL> /

ACT TARGET LOGFILE LOG_CHECK TMTTR ES_MTTRITPUB个人空间'}}2kNIu;m
---------- ---------- ---------- ---------- ---------- ----------
i6k&E'Q^lxZhB056 85 184320 85 0 10

--1分钟后发生了增量检查点,actual redo blocks减少了不少:ITPUB个人空间 g {'\8oP&Z$~:v?
--看看增量检查点的位置:ITPUB个人空间3I(S%e,L'w4t.?P*Nr
SQL> select CPLRBA_SEQ,CPLRBA_BNO,CPODR_SEQ,CPODR_BNO from x$kcccp;

CPLRBA_SEQ CPLRBA_BNO CPODR_SEQ CPODR_BNO
G'C%Rz*TTG0---------- ---------- ---------- ----------
0]QPn(@/CX048 189486 49 5126

SQL> /

CPLRBA_SEQ CPLRBA_BNO CPODR_SEQ CPODR_BNO
D0De f"Dv4le0---------- ---------- ---------- ----------ITPUB个人空间)a*^cY'{9l
49 5126 49 5183

--检查点的位置提升了2次,并提升到了49号日志,这时看到alert log中的log switch checkpoint也完成了:
0z Su"N2U,[ G1lB0Mon Dec 11 16:12:50 2006ITPUB个人空间PK.YoksA
Beginning log switch checkpoint up to RBA [0x31.2.10], SCN: 0x0000.00128ded
5w+dK*Q%x*S0Thread 1 advanced to log sequence 49
M jy,qcI-IP0Current log# 3 seq# 49 mem# 0: /u01/app/oracle/oradata/novo/redo03.log
*t/P!fM8|W7V8~0Mon Dec 11 16:13:56 2006
r3p{)E*wZ;X0Completed checkpoint up to RBA [0x31.2.10], SCN: 0x0000.00128ded

--这里注意从checkpoint begin到end的时间间隔是1分钟,这与log_checkpoint_timeout的条件是吻合的。ITPUB个人空间 @%Z"}S?:D4n6}*v8bh

你可能感兴趣的:(sql,C++,c,F#,C#)