您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)怎么理解checkpoint cnt和checkpoint scn,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。
[說(shuō)明]模仿eygle大師的一篇文章,自己動(dòng)手做了一下,感覺(jué)只有這樣才能印象深刻。原文參考:http://www.eygle.com/archives/2004/06/checkpoint_scn_ckpcnt.html
1. 在不同情況下dump控制文件
SQL> alter session set events 'immediate trace name CONTROLF level 10';
Session altered.
SQL> alter tablespace system begin backup;
Tablespace altered.
SQL> alter session set events 'immediate trace name CONTROLF level 10';
Session altered.
SQL> alter system checkpoint;
System altered.
SQL> alter session set events 'immediate trace name CONTROLF level 10';
Session altered.
SQL> alter tablespace system end backup;
Tablespace altered.
SQL> alter session set events 'immediate trace name CONTROLF level 10';
Session altered.
SQL>
2. 從udump目錄萃取出trace file中關(guān)于system表空間的信息,加以分析
a. 系統(tǒng)正常情況下dump的信息
***************************************************************************
DATA FILE RECORDS
***************************************************************************
(blkno = 0x6, size = 180, max = 100, in-use = 3, last-recid= 0)
DATA FILE #1:
(name #6) D:\OPT\ORACLE9I\PRODUCT\9.2.0\ORADATA\ORA92US\SYSTEM01.DBF
creation size=0 block size=8192 status=0xe head=6 tail=6 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:55 scn: 0x0000.00194116 04/14/2021 19:36:49
Stop scn: 0xffff.ffffffff 04/13/2008 20:48:26
Creation Checkpointed at scn: 0x0000.00000005 03/17/2008 15:57:33
thread:0 rba:(0x0.0.0)
enabled threads: 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000
Offline scn: 0x0000.00192482 prev_range: 0
Online Checkpointed at scn: 0x0000.00192483 04/11/2008 19:27:07
thread:1 rba:(0x1.2.0)
enabled threads: 01000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000
Hot Backup end marker scn: 0x0000.00000000
aux_file is NOT DEFINED
b.alter tablespace system begin backup以后
我們注意到Checkpoint cnt增加了1,此處觸發(fā)了一次表空間checkpoint.
***************************************************************************
DATA FILE RECORDS
***************************************************************************
(blkno = 0x6, size = 180, max = 100, in-use = 3, last-recid= 0)
DATA FILE #1:
(name #6) D:\OPT\ORACLE9I\PRODUCT\9.2.0\ORADATA\ORA92US\SYSTEM01.DBF
creation size=0 block size=8192 status=0xe head=6 tail=6 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:56 scn: 0x0000.001941a7 04/14/2021 19:39:26
Stop scn: 0xffff.ffffffff 04/13/2008 20:48:26
Creation Checkpointed at scn: 0x0000.00000005 03/17/2008 15:57:33
thread:0 rba:(0x0.0.0)
enabled threads: 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000
Offline scn: 0x0000.00192482 prev_range: 0
Online Checkpointed at scn: 0x0000.00192483 04/11/2008 19:27:07
thread:1 rba:(0x1.2.0)
enabled threads: 01000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000
Hot Backup end marker scn: 0x0000.00000000
aux_file is NOT DEFINED
c.alter system checkpoint之后
此時(shí)Checkpoint cnt增加,但是scn不再改變
***************************************************************************
DATA FILE RECORDS
***************************************************************************
(blkno = 0x6, size = 180, max = 100, in-use = 3, last-recid= 0)
DATA FILE #1:
(name #6) D:\OPT\ORACLE9I\PRODUCT\9.2.0\ORADATA\ORA92US\SYSTEM01.DBF
creation size=0 block size=8192 status=0xe head=6 tail=6 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:57 scn: 0x0000.001941a7 04/14/2021 19:39:26
Stop scn: 0xffff.ffffffff 04/13/2008 20:48:26
Creation Checkpointed at scn: 0x0000.00000005 03/17/2008 15:57:33
thread:0 rba:(0x0.0.0)
enabled threads: 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000
Offline scn: 0x0000.00192482 prev_range: 0
Online Checkpointed at scn: 0x0000.00192483 04/11/2008 19:27:07
thread:1 rba:(0x1.2.0)
enabled threads: 01000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000
Hot Backup end marker scn: 0x0000.00000000
aux_file is NOT DEFINED
d.alter tablespace system end backup之后
此時(shí)數(shù)據(jù)文件頭的凍結(jié)被取消,scn開(kāi)始變化
***************************************************************************
DATA FILE RECORDS
***************************************************************************
(blkno = 0x6, size = 180, max = 100, in-use = 3, last-recid= 0)
DATA FILE #1:
(name #6) D:\OPT\ORACLE9I\PRODUCT\9.2.0\ORADATA\ORA92US\SYSTEM01.DBF
creation size=0 block size=8192 status=0xe head=6 tail=6 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:58 scn: 0x0000.001941b3 04/14/2021 19:39:54
Stop scn: 0xffff.ffffffff 04/13/2008 20:48:26
Creation Checkpointed at scn: 0x0000.00000005 03/17/2008 15:57:33
thread:0 rba:(0x0.0.0)
enabled threads: 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000
Offline scn: 0x0000.00192482 prev_range: 0
Online Checkpointed at scn: 0x0000.00192483 04/11/2008 19:27:07
thread:1 rba:(0x1.2.0)
enabled threads: 01000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000
Hot Backup end marker scn: 0x0000.00000000
aux_file is NOT DEFINED
Checkpoint cnt用于保證在正常操作中使用的數(shù)據(jù)文件是當(dāng)前版本.在恢復(fù)時(shí)防止恢復(fù)數(shù)據(jù)文件的錯(cuò)誤版本.Checkpoint cnt是一直遞增的,即使表空間處于熱備份模式.
由于表空間的創(chuàng)建時(shí)間不盡相同,所以不同表空間/數(shù)據(jù)文件的Checkpoint cnt通常是不同的 (編者注:從dump文件中確實(shí)可以看到這一點(diǎn),不同的datafile的checkpoint cnt確實(shí)不一樣).
我們知道:
在數(shù)據(jù)庫(kù)open的過(guò)程中,Oracle要進(jìn)行兩次檢查 (編者注:按照eygle在其他很多地方自己的說(shuō)法,實(shí)際情況要復(fù)雜很多,這里只是簡(jiǎn)要說(shuō)明。也許只有Oracle的開(kāi)發(fā)人員才知道到底要做哪些事情~~~).
第一次檢查數(shù)據(jù)文件頭中的Checkpoint cnt是否與對(duì)應(yīng)控制文件中的Checkpoint cnt一致.
如果相等 (編者注:其實(shí)如果相等,則System Checkpoint SCN = Datafile Checkpoint SCN = Start SCN), 進(jìn)行第二次檢查.
第二次檢查數(shù)據(jù)文件頭的開(kāi)始SCN和對(duì)應(yīng)控制文件中的結(jié)束SCN是否一致
如果結(jié)束SCN等于開(kāi)始SCN,則不需要對(duì)那個(gè)文件進(jìn)行恢復(fù) (編者注:如果不等,即Stop SCN為無(wú)窮大,則需要Istance Recovery).
(編者注:這里的open過(guò)程的說(shuō)法和我前面轉(zhuǎn)載的關(guān)于SCN的文章不盡相同,但是我個(gè)人理解第一次就是做是否需要Media Recovery的檢查;第二次就是做是否需要做Instance Recovery的檢查。第一步如果文件版本不一致,就開(kāi)始做Media Recover,根據(jù)相應(yīng)的SCN確定需要的log;如果不需要Media Recovery,則檢查是否需要Instance Recovery,如果Stop SCN的值為無(wú)窮大,則需要,而且要提交redo logs直到最新的那一個(gè))
對(duì)每個(gè)數(shù)據(jù)文件都完成檢查后,打開(kāi)數(shù)據(jù)庫(kù).同時(shí)將每個(gè)數(shù)據(jù)文件的結(jié)束SCN設(shè)置為無(wú)窮大。
關(guān)于怎么理解checkpoint cnt和checkpoint scn就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。