在数据库内部我们可以发现存在这样一个记时方式checpoint cnt,和我们通常的checkpoint scn是什么关系呢?
我们可以通过在不同的条件下转储控制文件
SQL> alter session set events 'immediate trace name CONTROLF level 8';
Session altered.
SQL> alter tablespace system begin backup;
Tablespace altered.
SQL> alter session set events 'immediate trace name CONTROLF level 8';
Session altered.
SQL> alter system checkpoint;
System altered.
SQL> alter session set events 'immediate trace name CONTROLF level 8'
Session altered.
SQL> alter tablespace system end backup;
Tablespace altered.
SQL> alter session set events 'immediate trace name CONTROLF level 8';
Session altered.
以下是转储控制跟踪文件信息,仅仅是system 表空间记录
正常情况下转储控制文件
***************************************************************************
DATA FILE RECORDS
***************************************************************************
(size = 428, compat size = 428, section max = 100, section in-use = 6,
last-recid= 22, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 11, numrecs = 100)
DATA FILE #1:
(name #4) /oradata/oradg/system01.dbf
creation size=38400 block size=8192 status=0xe head=4 tail=4 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:63 scn: 0x0000.00079cc7 03/09/2011 13:04:55
Stop scn: 0xffff.ffffffff 03/07/2011 14:00:46
Creation Checkpointed at scn: 0x0000.00000007 02/28/2011 15:38:52
thread:1 rba0x1.3.10)
执行了begin backup以后的信息:
***************************************************************************
DATA FILE RECORDS
***************************************************************************
(size = 428, compat size = 428, section max = 100, section in-use = 6,
last-recid= 22, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 11, numrecs = 100)
DATA FILE #1:
(name #4) /oradata/oradg/system01.dbf
creation size=38400 block size=8192 status=0xe head=4 tail=4 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:64 scn: 0x0000.00079d88 03/09/2011 13:11:00
Stop scn: 0xffff.ffffffff 03/07/2011 14:00:46
Creation Checkpointed at scn: 0x0000.00000007 02/28/2011 15:38:52
thread:1 rba0x1.3.10)
执行了手工检查点后的信息
***************************************************************************
DATA FILE RECORDS
***************************************************************************
(size = 428, compat size = 428, section max = 100, section in-use = 6,
last-recid= 22, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 11, numrecs = 100)
DATA FILE #1:
(name #4) /oradata/oradg/system01.dbf
creation size=38400 block size=8192 status=0xe head=4 tail=4 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:65 scn: 0x0000.00079d88 03/09/2011 13:11:00
Stop scn: 0xffff.ffffffff 03/07/2011 14:00:46
Creation Checkpointed at scn: 0x0000.00000007 02/28/2011 15:38:52
thread:1 rba0x1.3.10)
执行end backup 后system表空间状态后正常信息
***************************************************************************
DATA FILE RECORDS
***************************************************************************
DATA FILE #1:
(name #4) /oradata/oradg/system01.dbf
creation size=38400 block size=8192 status=0xe head=4 tail=4 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:66 scn: 0x0000.00079da8 03/09/2011 13:11:49
Stop scn: 0xffff.ffffffff 03/07/2011 14:00:46
Creation Checkpointed at scn: 0x0000.00000007 02/28/2011 15:38:52
thread:1 rba0x1.3.10)
上面注意到在执行热备份期间,文件的checkpoint scn并未变化,但是checkpoint cnt确是一直在增大,通常checkpoint cnd用于
保证在正常操作中使用的数据文件是当前版本,恢复时防止恢复数据文件的错误版本,checkpoint cnt通常在不同的表空间由于创建时间不同
所以通常不同,在数据库open过程中,oracle就是进行以下两次检查:
第一次检查文件头重的checkpoint cnt是否与对应的控制文件中的checkpoint cnt一致
第二次检查数据文件头的开始SCN和对应文件中的结束SCN是否一致
检查完成后,打开数据库后需要将每个数据文件结束SCN设置为无穷大
例如我们可以转储数据文件头信息记录如下信息:
SQL>alter session set events 'immediate trace name file_hdrs level 10';
DATA FILE #1:
(name #4) /oradata/oradg/system01.dbf
creation size=38400 block size=8192 status=0xe head=4 tail=4 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:66 scn: 0x0000.00079da8 03/09/2011 13:11:49
Stop scn: 0xffff.ffffffff 03/07/2011 14:00:46
Creation Checkpointed at scn: 0x0000.00000007 02/28/2011 15:38:52
thread:1 rba0x1.3.10)
enabled threads: 01000000 0
这部分来自控制文件
Tablespace #0 - SYSTEM rel_fn:1
Creation at scn: 0x0000.00000007 02/28/2011 15:38:52
Backup taken at scn: 0x0000.00079d88 03/09/2011 13:11:00 thread:1
reset logs count:0x2c5d3445 scn: 0x0000.00000001 reset logs terminal rcv data:0x0 scn: 0x0000.00000000
prev reset logs count:0x0 scn: 0x0000.00000000 prev reset logs terminal rcv data:0x0 scn: 0x0000.00000000
recovered at 03/08/2011 14:48:42
status:0x2004 root DBA:0x00400179 chkpt cnt: 66 ctl cnt:65
begin-hot-backup file size: 55040
Checkpointed at scn: 0x0000.00079da8 03/09/2011 13:11:49
thread:1 rba0x28.3c46.10)
这部分来自数据文件头
|
|