您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Oracle RBA 浅谈

2024/12/31 21:04:34发布26次查看
今天来和大家简单谈一下rba ,rba = redo byte address 。讲到rba,这里涉及到了几点需要大家提前预知,即controlfile header,c
今天来和大家简单谈一下rba ,rba = redo byte address 。 
讲到rba,这里涉及到了几点需要大家提前预知,即controlfile header,ckpt process 与 dbwn process , dirty buffer 。
先来看一下rba的构成:
它由3部分组成,4byte+4byte+2byte分别为 logfile sequence number ,logfile block number,byte offsetinto the block ,即redo 序列号,redo block 号,以及偏移量。
并且全部使用16进制。
例如:rba= 0x000024.000011bd.0010
seq#=0x000024=36
blk#=0x000011bd=4541
ofs#=0x0010=16
接下来说一下instance recovery
这里的checkpoint position 其实就是cache low rba, end of redo thread就是最后一个on-disk rba。
大家都知道实例恢复的时候需要从cache low rba 到 on-disk rba  , lowrba  与 on-disk 全部存储在控制文件里面,on-diskrba 可以简单的理解为是 lgwr 最后写日志文件的地址。那么cache low rba是如何而来呢?
cache low rba 其实就是ckpt进程每3秒写入到controlfileheader 上面的rba 。所以下面的文章将cache low rba 命名为ckpt rba 。
大家知道 ckpt 分为三种,即 database check points ,,tablespace and datafile checkpoints和incremental checkpoints。这里和第三种checkpoints有关。增量检查点的存在是为了防止在发生日志切换的时候,写出大量的dirty block 到disk上面,它每3秒会监控一下dbwn写出block的情况,并且写到controlfile header里面(不包括datafile header)。
这里有几点需要注意:
1.     dbwn 写出 dirtyblock 是使用一个叫做ckpt queue的双向链表来维护的,按照lrba的顺序写出dirty block 到 disk 上面。
2.     每个dirty block 上面都有一个lrba ,并且有一个指向ckpt queue的指针。
3.     dbwn触发条件,请详见concepts。
好,下面我们用实验说话: 
1.     先取出几个块的数据01:57:02 dex@fake> select * from
01:58:10  2  (
01:58:10  3  selectdbms_rowid.rowid_relative_fno(substr(rowid,1,15)||'aaa') as file# ,
01:58:10  4        dbms_rowid.rowid_block_number(substr(rowid,1,15)||'aaa') as blk#,
01:58:10  5         max(t.id),max(t.name)
01:58:10  6    from dex.t
01:58:10  7   group by substr(rowid,1,15)
01:58:10  8   )
01:58:10  9   where rownum
     file#       blk# max(t.id) max(t.name)
---------- ---------- ---------- --------------------
         4        446     37949 name
         4        447     38433 name
         4        442     39401 name
看一下x$bh
02:02:17 sys@fake> select dbablk ,lrba_seq,lrba_bno,flag from x$bh b where file#=4 and dbablk in (442,446,447);
    dbablk   lrba_seq  lrba_bno       flag
---------- ---------- ---------- ----------
       442          0          0    524288
       447          0          0    524288
       446          0          0    524288
看一下当前的ckpt rba 和 ondisk rba
02:02:21 sys@fake> selectcplrba_seq,cplrba_bno,cplrba_bof,cpodr_seq,cpodr_bno,cpodr_bof,cphbt,cpodt fromx$kcccp where indx=0 ;
cplrba_seq cplrba_bno cplrba_bof  cpodr_seq cpodr_bno  cpodr_bof      cphbt cpodt
---------- ---------- ---------- -------------------- ---------- ---------- --------------------
        37      10567          0         37     13157          0  791349660 08/15/2012 02:02:02
2.     更新数据02:07:16 sys@fake> update dex.t setwhere id=37949 ;
1 row updated.
02:10:46 sys@fake> update dex.t setwhere id=38433 ;
1 row updated.
02:10:46 sys@fake> update dex.t setwhere id=39401 ;
1 row updated.
02:10:48 sys@fake> commit ;
commit complete.
3.     查看一下各种状态状态为脏数据
02:10:51 sys@fake> select dbablk ,lrba_seq,lrba_bno,flag from x$bh b where file#=4 and dbablk in (442,446,447);
   dbablk   lrba_seq   lrba_bno       flag
---------- ---------- ---------- ----------
      442         37      14429  33554433
      447         37      14429  33554433
      446         37      14429  33554433
现在的ckpt rba 为14104
02:10:56 sys@fake> selectcplrba_seq,cplrba_bno,cplrba_bof,cpodr_seq,cpodr_bno,cpodr_bof,cphbt,cpodt fromx$kcccp where indx=0 ;
cplrba_seq cplrba_bno cplrba_bof  cpodr_seq cpodr_bno  cpodr_bof      cphbt cpodt
---------- ---------- ---------- -------------------- ---------- ---------- --------------------
       37      14104          0         37     14437          0  791349830 08/15/2012 02:10:51
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product