楼主: grassbell

[精华] 偷窥Data block 的物理结构

[复制链接]
招聘 : 数据库管理员
论坛徽章:
3
授权会员
日期:2005-10-30 17:05:33会员2006贡献徽章
日期:2006-04-17 13:46:34ITPUB 11周年纪念徽章
日期:2012-10-09 18:05:07
71#
发表于 2005-8-23 23:40 | 只看该作者

Re: 这是我的猜测

最初由 ZALBB 发布
[B]0x02c00003 (11/3) 0000 0010 1100
10 11 = 11
0x0180003b (6/59) 0000 0001 1000
01 10 = 6
0x03400003 (13/3) 0000 0011 0100
11 01 = 13
0x08800003 (34/3) 0000 1000 1000
1000 10 = 34
0x01400003 (5/3)  0000 0001 0100
01 01   = 5
0x01000003 (4/3)  0000 0001 0000
01 00 = 4

也就是说,ORACLE是从倒数第3位开始,取其前面的”位数“来记录其文件的ID
我计算了POWER(2,10) = 1024,但查看了控制文件和参数文件,没有一个FILE参数
的值是1024的。 [/B]


这个dba其实是个rdba,用的file_id其实是
dba_extents.relative_fno 相对文件号~

在8i开始一个文件有2个文件号v$datafile.file# 和v$datafile.rfile#
相对文件号不超过1023,在数据库文件小于1023 时候 rfile#是=file#的~
比如dul用的就是rfile#号
现在明白了,要用它来算rdba的~

呵呵,真长见识。

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
3
授权会员
日期:2005-10-30 17:05:33会员2006贡献徽章
日期:2006-04-17 13:46:34ITPUB 11周年纪念徽章
日期:2012-10-09 18:05:07
72#
发表于 2005-8-24 21:22 | 只看该作者
这里两个块的dump的显示就很清晰了~
1、data file header block的dump
其实这个datafile header block并不是一个文件里的第一个块,这个其实是block# = 1的block~
block#=0还有一个块
这里面把块结构和每个字节的作用都标的很清楚了~

[php]
Block dump
Dump of KCBH (Kernel Cache layer Block Header, version 2)
Dump of KCBH (Kernel Cache layer Block Header, version 2)
(ty=K_BT   of=  0 sz= 1) TYPE (block type)             = 11(data file header)
(ty=UB1    of=  1 sz= 1) FRMT (format type)            = 2
(ty=UB1    of=  2 sz= 1) SPARE1(Unused)                = 0
(ty=UB1    of=  3 sz= 1) SPARE2(Unused)                = 0
(ty=KDBA   of=  4 sz= 4) RDBA (Relative Disk Block Address)= fno=7, bno=1
(ty=UB4    of=  8 sz= 4) BAS  (scn BASe)               = 0
(ty=UB2    of= 12 sz= 2) WRP  (scn WRaP)               = 0
(ty=UB1    of= 14 sz= 1) SEQ  (SEQuence)               = 1
(ty=UB1    of= 15 sz= 1) FLG  (FLaG)                   = 4
(ty=UB2    of= 16 sz= 2) CHKVAL(optional checksum)     = 52081
(ty=UB2    of= 18 sz= 2) SPARE3(unused)                = 0
Dump of KCCFH (Generic file header for each file type)
Dump of KCCFH (Generic file header for each file type)
(ty=KCKRL  of= 20 sz= 4) SWV  (Creating software version)= (8.1.0.0.0)
(ty=KCKRL  of= 24 sz= 4) CVN  (Compatibility version)  = (8.0.0.0.0)
(ty=UB4    of= 28 sz= 4) DBI  (Database ID)            = 2097583149
(ty=TEXT8  of= 32 sz= 8) DBN  (Database name)          = "DB817"
(ty=UB4    of= 40 sz= 4) CSQ  (Control file seq# at this hdr update)= 1690
(ty=UB4    of= 44 sz= 4) FSZ  (File size in # blocks)  = 1280
(ty=UB4    of= 48 sz= 4) BSZ  (file block size)        = 8192
(ty=UB2    of= 52 sz= 2) FNO  (file #)                 = 7
(ty=UB2    of= 54 sz= 2) TYP  (file type code)         = 3
(ty=UB4    of= 56 sz= 4) SPARE(Currently unused spare) = 0
(ty=UB4    of= 60 sz= 4) CKS  (backup set CHeckSum)    = 0
(ty=IDENT32 of= 64 sz=32) TAG  (backup TAG)             = ""
[/php]

2、普通数据块的dump
[php]
Block dump
Dump of KCBH (Kernel Cache layer Block Header, version 2)
Dump of KCBH (Kernel Cache layer Block Header, version 2)
(ty=K_BT   of=  0 sz= 1) TYPE (block type)             = 6(transaction managed
datablock with itl)
(ty=UB1    of=  1 sz= 1) FRMT (format type)            = 2
(ty=UB1    of=  2 sz= 1) SPARE1(Unused)                = 0
(ty=UB1    of=  3 sz= 1) SPARE2(Unused)                = 0
(ty=KDBA   of=  4 sz= 4) RDBA (Relative Disk Block Address)= fno=7, bno=113
(ty=UB4    of=  8 sz= 4) BAS  (scn BASe)               = 358007
(ty=UB2    of= 12 sz= 2) WRP  (scn WRaP)               = 0
(ty=UB1    of= 14 sz= 1) SEQ  (SEQuence)               = 1
(ty=UB1    of= 15 sz= 1) FLG  (FLaG)                   = 0
(ty=UB2    of= 16 sz= 2) CHKVAL(optional checksum)     = 0
(ty=UB2    of= 18 sz= 2) SPARE3(unused)                = 0
Dump of KTBBH (Transaction layer fixed header)
Dump of KTBBH (Transaction layer fixed header)
(ty=KDDBT  of= 20 sz= 1) TYP  (block type (table or index))= 1(table/cluster)
(ty=CC16   of= 21 sz= 1) PAD1 (CC generated padding)   = 0
(ty=CC32   of= 22 sz= 2) PAD2 (CC generated padding)   = 0
(ty=UB4    of= 24 sz= 4) SID  (Segment ID OBJ# or header dba)= 4236
Dump of KSCN (Kernel System Commit Number)
  (ty=UB4    of= 28 sz= 4) BAS  (Sys commit num base)    = 358007
  (ty=UB2    of= 32 sz= 2) WRP  (Sys commit num wrap)    = 0
  (ty=CC32   of= 34 sz= 2) PAD  (CC generated padding)   = 0
(ty=B2     of= 36 sz= 2) ICT  (number of itl entries)  = 2
(ty=KTBF   of= 38 sz= 1) FLG  (flags)                  = sym_prt_enum(), No de
cription for 3

(ty=UB1    of= 39 sz= 1) FSL  (free space lock)        = 0
(ty=KDBA   of= 40 sz= 4) FNX  (next block in free list)= fno=0, bno=0
Dump of KTBIT (Transaction entry)
Dump of KTBIT[0] (Transaction entry)
Dump of KXID (Kernel Xaction ID)
  (ty=UB2    of= 44 sz= 2) USN  (Undo Segment Number)    = 1
  (ty=UB2    of= 46 sz= 2) SLT  (SLot Number)            = 61
  (ty=UB4    of= 48 sz= 4) SQN  (Wrap Number)            = 14
Dump of KUBA (Kernel Undo Block Address)
  (ty=KDBA   of= 52 sz= 4) DBA  (undo address for last change)= fno=2, bno=262
  (ty=UB2    of= 56 sz= 2) SEQ  (sequence number)        = 20
  (ty=UB1    of= 58 sz= 1) REC  (record number index in block)= 28
  (ty=CC16   of= 59 sz= 1) PAD  (C-Compiler generated padding)= 0
(ty=KTBFL  of= 60 sz= 2) FLG  (num of locks in block and FLaG byte)= 32768
(ty=B2     of= 62 sz= 2) FSC  (Free Space Credit/sys commit num wrap)= 0
(ty=UB4    of= 64 sz= 4) BAS  (sys commit num BASe)    = 337748
Dump of KTBIT[1] (Transaction entry)
Dump of KXID (Kernel Xaction ID)
  (ty=UB2    of= 68 sz= 2) USN  (Undo Segment Number)    = 1
  (ty=UB2    of= 70 sz= 2) SLT  (SLot Number)            = 65
  (ty=UB4    of= 72 sz= 4) SQN  (Wrap Number)            = 14
Dump of KUBA (Kernel Undo Block Address)
  (ty=KDBA   of= 76 sz= 4) DBA  (undo address for last change)= fno=2, bno=262
  (ty=UB2    of= 80 sz= 2) SEQ  (sequence number)        = 20
  (ty=UB1    of= 82 sz= 1) REC  (record number index in block)= 30
  (ty=CC16   of= 83 sz= 1) PAD  (C-Compiler generated padding)= 0
(ty=KTBFL  of= 84 sz= 2) FLG  (num of locks in block and FLaG byte)= 32768
(ty=B2     of= 86 sz= 2) FSC  (Free Space Credit/sys commit num wrap)= 0
(ty=UB4    of= 88 sz= 4) BAS  (sys commit num BASe)    = 357878
Dump of KDBH (Data layer header)
Dump of KDBH (Data layer header)
(ty=KDBHF  of= 92 sz= 1) FLAG (Flag)                   = 0
(ty=KTNO   of= 93 sz= 1) NTAB (Number of entries in the table directory)= 1
(ty=KDBSNO of= 94 sz= 2) NROW (Number of entries in the row directory)= 7
(ty=KDBFLL of= 96 sz= 2) FRRE (First free row index entry)= 65535
(ty=KDBOFF of= 98 sz= 2) FSBO (Free space beginning offset)= 32
(ty=KDBOFF of=100 sz= 2) FSEO (Free space ending offset)= 8013
(ty=B2     of=102 sz= 2) AVSP (Available space in the block)= 7981
(ty=B2     of=104 sz= 2) TOSP (Total space that will be available)= 7981
Dump of KDTI (Table Index)
Dump of KDTI[0] (Table Index)
(ty=UB2    of=106 sz= 2) FRNO (First row number)       = 0
(ty=UB2    of=108 sz= 2) NROW (Number of rows for this table)= 7
Dump of KDRI (Row Index)
(ty=SB2    of=110 sz= 2) ROFF (Row OFFset)             = 8084
(ty=SB2    of=112 sz= 2) ROFF (Row OFFset)             = 8072
(ty=SB2    of=114 sz= 2) ROFF (Row OFFset)             = 8060
(ty=SB2    of=116 sz= 2) ROFF (Row OFFset)             = 8049
(ty=SB2    of=118 sz= 2) ROFF (Row OFFset)             = 8039
(ty=SB2    of=120 sz= 2) ROFF (Row OFFset)             = 8026
(ty=SB2    of=122 sz= 2) ROFF (Row OFFset)             = 8013

[/php]

使用道具 举报

回复
论坛徽章:
0
73#
发表于 2005-9-19 14:20 | 只看该作者
老大,小弟愚昧,想知道研究data block物理结构的意义。
如:有一数据库v$waitstat中data block值很大,从data block物理结构分析,改善地方在哪?

使用道具 举报

回复
论坛徽章:
3
数据库板块每日发贴之星
日期:2005-10-10 01:01:29数据库板块每日发贴之星
日期:2005-10-13 01:01:302011新春纪念徽章
日期:2011-02-18 11:43:35
74#
发表于 2005-10-11 13:07 | 只看该作者
比较难懂啊,不过还是谢谢你!

使用道具 举报

回复
论坛徽章:
2
设计板块每日发贴之星
日期:2008-05-13 01:02:19设计板块每日发贴之星
日期:2008-08-31 01:03:28
75#
发表于 2005-10-12 12:29 | 只看该作者
ding

使用道具 举报

回复
论坛徽章:
4
ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:442011新春纪念徽章
日期:2011-02-18 11:42:48蛋疼蛋
日期:2013-02-01 09:05:112013年新春福章
日期:2013-02-25 14:51:24
76#
发表于 2006-12-9 16:58 | 只看该作者
如何跟踪得到数据块的Trace文件?

Trace 文件:
*** 2004-07-25 15:48:01.000
Start dump data blocks tsn: 8 file#: 3 minblk 122 maxblk 122
buffer tsn: 8 rdba: 0x00c0007a (3/122)
scn: 0x0000.0068d716 seq: 0x01 flg: 0x02 tail: 0xd7160601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x00c0007a
Object id on Block? Y
seg/obj: 0x806d csc: 0x00.68d714 itc: 2 flg: O typ: 1 - DATA
fsl: 0 fnx: 0x0 ver: 0x01

Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0004.00b.00000fac 0x00801885.008c.56 --U- 1 fsc 0x0000.0068d716
0x02 0x0000.000.00000000 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000

data_block_dump,data header at 0x552105c
===============
tsiz: 0x1fa0
hsiz: 0x14
pbl: 0x0552105c
bdba: 0x00c0007a
76543210
flag=--------
ntab=1
nrow=1
frre=-1
fsbo=0x14
fseo=0x1f9b
avsp=0x1f83
tosp=0x1f83
0xeti[0] nrow=1 offs=0
0x12ri[0] offs=0x1f9b
block_row_dump:
tab 0, row 0, @0x1f9b
tl: 5 fb: --H-FL-- lb: 0x1 cc: 1
col 0: [ 1] 61
end_of_block_dump
End dump data blocks tsn: 8 file#: 3 minblk 122 maxblk 122

使用道具 举报

回复
论坛徽章:
4
ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:442011新春纪念徽章
日期:2011-02-18 11:42:48蛋疼蛋
日期:2013-02-01 09:05:112013年新春福章
日期:2013-02-25 14:51:24
77#
发表于 2006-12-10 18:52 | 只看该作者
找到那个跟踪文件了,在oracle安装目录\admin\bdump下面。。

使用道具 举报

回复
论坛徽章:
23
生肖徽章2007版:虎
日期:2008-01-02 17:35:532010年世界杯参赛球队:日本
日期:2010-05-27 15:15:36生肖徽章2007版:虎
日期:2009-03-10 21:13:27生肖徽章2007版:虎
日期:2008-10-20 20:39:19生肖徽章2007版:虎
日期:2008-10-14 22:25:42生肖徽章2007版:虎
日期:2008-10-11 15:40:21生肖徽章2007版:虎
日期:2008-10-10 12:52:22生肖徽章2007版:虎
日期:2008-10-09 11:14:10生肖徽章2007版:虎
日期:2008-10-06 13:54:36生肖徽章2007版:虎
日期:2008-10-05 18:58:33
78#
发表于 2006-12-12 15:59 | 只看该作者
最初由 grassbell 发布
[B]2) The Transaction Header:
一共占据48bytes,包括24bytes的控制信息,和一系列的Interested Transaction Slot (ITS)。这些ITS组合在一起称为Interested Transaction List (ITL)。初始的ITL slot 数量由 INITRANS 决定(index branch block 只有1个slot)。如果有足够的剩余空间,oracle会根据需要动态的分配这些slot,直到受到空间限制或者达到了MAXTRANS。

Block header dump:  0x00c0007a
Object id on Block? Y
seg/obj: 0x806d  csc: 0x00.68d714  itc: 2  flg: O  typ: 1 - DATA
     fsl: 0  fnx: 0x0 ver: 0x01

Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0x0004.00b.00000fac  0x00801885.008c.56  --U-    1  fsc 0x0000.0068d716
0x02   0x0000.000.00000000  0x00000000.0000.00  ----    0  fsc 0x0000.00000000

24bytes的控制信息包括:
[B]Object number(seg/obj): [/B]占用4bytes,指在OBJ$中记录的segment 的 object number(0x806d=32877)

[B]Cleanout SCN(csc):[/B]  占用6bytes,最后一次 full cleanout 的scn

[B]ITL count(itc): [/B]占用1byte,ITL 的slot数量。

[B]Flag:[/B] 占用2bytes。O表示这个block在freelist 上。否则flag为"-"

[B]Block type: [/B]占用1byte。1=data; 2=index

[B]ITL freelist slot(fsl):[/B] 占用1byte。Index to the first slot on the ITL freelist

[B]Next freelist block(fnx):[/B] 占用4byte。Segment freelist中下一个block的RDBA

[B]Version:[/B] 1 byte

[B]Unused:[/B] 4bytes,用来前后兼容。


[B]每个ITL entry包括以下的内容:[/B]
[B]Transaction id(Xid)[/B]: 8bytes。其中包括rollback segment number, transaction table中的slot number等。

[B]Undo block address(Uba): [/B]8bytes。其中包括rollback segment block的DBA,sequence number等。

[B]Flags:[/B] 1nibble。
---- = transaction is active, or committed pending cleanout
C--- = transaction has been committed and locks cleaned out
-B-- = this undo record contains the undo for this ITL entry
--U- = transaction committed (maybe long ago); SCN is an upper bound
---T = transaction was still active at block cleanout SCN

[B]Locks:[/B] 3nibbles. 也就是所谓的行级锁(row-level locks)

[B]SCN or free space credit:[/B] 6bytes. 如果这个事务已经clean out,这个值就是SCN;否则,前两个字节表示由这个事务释放的此block中的空间数。 [/B]


这部分是49bytes吧

使用道具 举报

回复
论坛徽章:
23
生肖徽章2007版:虎
日期:2008-01-02 17:35:532010年世界杯参赛球队:日本
日期:2010-05-27 15:15:36生肖徽章2007版:虎
日期:2009-03-10 21:13:27生肖徽章2007版:虎
日期:2008-10-20 20:39:19生肖徽章2007版:虎
日期:2008-10-14 22:25:42生肖徽章2007版:虎
日期:2008-10-11 15:40:21生肖徽章2007版:虎
日期:2008-10-10 12:52:22生肖徽章2007版:虎
日期:2008-10-09 11:14:10生肖徽章2007版:虎
日期:2008-10-06 13:54:36生肖徽章2007版:虎
日期:2008-10-05 18:58:33
79#
发表于 2006-12-12 16:00 | 只看该作者
最初由 tanshanghua 发布
[B]找到那个跟踪文件了,在oracle安装目录\admin\bdump下面。。 [/B]


错,在udump下面

使用道具 举报

回复
论坛徽章:
23
生肖徽章2007版:虎
日期:2008-01-02 17:35:532010年世界杯参赛球队:日本
日期:2010-05-27 15:15:36生肖徽章2007版:虎
日期:2009-03-10 21:13:27生肖徽章2007版:虎
日期:2008-10-20 20:39:19生肖徽章2007版:虎
日期:2008-10-14 22:25:42生肖徽章2007版:虎
日期:2008-10-11 15:40:21生肖徽章2007版:虎
日期:2008-10-10 12:52:22生肖徽章2007版:虎
日期:2008-10-09 11:14:10生肖徽章2007版:虎
日期:2008-10-06 13:54:36生肖徽章2007版:虎
日期:2008-10-05 18:58:33
80#
发表于 2006-12-12 16:06 | 只看该作者
Data Area中的frre=-1这个是什么?代表什么意思?

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表