ORACLE空間管理實驗8:數(shù)據(jù)塊格式分析
Jun 07, 2016 pm 03:50 PM使用DUMP 數(shù)據(jù)塊式結(jié)合BBED進(jìn)行查看。 #################### 實驗準(zhǔn)備步驟 : BYS@ bys3create table test6(aa int,bb varchar2(10)); Table created. BYS@ bys3insert into test6 values(89,'bys'); 1 row created. BYS@ bys3insert into test6 values(69,'h
使用DUMP 數(shù)據(jù)塊格式結(jié)合BBED進(jìn)行查看。####################實驗準(zhǔn)備步驟:
BYS@ bys3>create table test6(aa int,bb varchar2(10));
Table created.
BYS@ bys3>insert into test6 values(89,'bys');
1 row created.
BYS@ bys3>insert into test6 values(69,'hello');
1 row created.
BYS@ bys3>commit;
Commit complete.
BYS@ bys3>alter system checkpoint;
System altered.
BYS@ bys3>select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,aa,bb from test6;
???? FILE#???? BLOCK#???????? AA BB
---------- ---------- ---------- ----------
???????? 4??????? 477???????? 89 bys
???????? 4??????? 477???????? 69 hello
BYS@ bys3>alter system dump datafile 4 block 477;
System altered.
BYS@ bys3>select value from v$diag_info where name like 'De%';
VALUE
----------------------------------------------------------------------------------------------------
/u01/diag/rdbms/bys3/bys3/trace/bys3_ora_8109.trc
DUMP數(shù)據(jù)塊的信息解讀
Start dump data blocks tsn: 4 file#:4 minblk 477 maxblk 477
Block dump from cache:? --這段信息來自buffer cache,詳見: 詳解Buffer Header--DUMP buffer結(jié)合X$BH視圖各字段
Dump of buffer cache at level 4 for tsn=4 rdba=16777693
BH (0x22be4e74) file#: 4 rdba: 0x010001dd (4/477) class: 1 ba: 0x2286e000
? set: 3 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,0
? dbwrid: 0 obj: 23326 objn: 23326 tsn: 4 afn: 4 hint: f
? hash: [0x227e6b54,0x2a7f74ac] lru: [0x217ee3d4,0x20ff4e64]
? ckptq: [NULL] fileq: [NULL] objq: [0x217ee3ec,0x20ff4e7c] objaq: [0x217ee3f4,0x20ff4e84]
? st: XCURRENT md: NULL fpin: 'ktspbwh2: ktspfmdb' tch: 3
? flags: block_written_once redo_since_read
? LRBA: [0x0.0.0] LSCN: [0x0.0] HSCN: [0xffff.ffffffff] HSUB: [1]
? ###########################################數(shù)據(jù)塊頭部分
Block dump from disk:?? --下面的信息才是來自數(shù)據(jù)文件中的塊。
buffer tsn: 4 rdba: 0x010001dd (4/477)? --數(shù)據(jù)塊中4-8字節(jié)是RDBA--下面BBED部分可以看到
scn: 0x0000.00874dbb seq: 0x01 flg: 0x06 tail: 0x4dbb0601
frmt: 0x02 chkval: 0xeb56 type: 0x06=trans data?? --第四個字節(jié)對應(yīng)
---flg:0x01 (新建塊)0x2(數(shù)據(jù)塊延遲清洗推進(jìn)scn和seq) 0X04(設(shè)置校驗和) 0x08(臨時塊) ? ? type:0x06(表/索引塊)
--frmt:? 0x01(v7)? 0x02(v8)?? --與第三字節(jié)A2對應(yīng),表示8I以上版本
Hex dump of block: st=0, typ_found=1
Dump of memory from 0xB68A9200 to 0xB68AB200
B68A9200 0000A206 010001DD 00874DBB 06010000? [.........M......]?? ---這一行的信息可以與塊頭中的SCN TYPE之類對應(yīng)的。
B68A9210 0000EB56 00130001 00005B1E 00874DB6? [V........[...M..]
B68A9220 1FE80000 00321F02 010001D8 001A0002? [......2.........]
B68A9230 00001382 00C00B70 00070569 00002002? [....p...i.... ..]
………………………………
B68AB1D0 54415453 4D5F5355 454B5241 71780752? [STATUS_MARKER.xq]
B68AB1E0 2618100B 012C021E 46C10202 6C656805? [...&..,....F.hel]
B68AB1F0 012C6F6C 5AC10202 73796203 4DBB0601? [lo,....Z.bys...M]
##########################################下面是ITL
Block header dump:? 0x010001dd
?Object id on Block? Y
?seg/obj: 0x5b1e? csc: 0x00.874db6? itc: 2? flg: E? typ: 1 - DATA????? --數(shù)據(jù)類型是DATA。 ?
?-- seg/obj: 0x5b1e--對應(yīng)的是dba_objects.data_object_id,未TRUNCATE操作過的表data_object_id與object_id相等。格式化也就是在塊上寫入這個seg/obj:
--csc: 0x00.874db6 延遲塊清除時的SCN--查詢時、第三次提交時--三個ITL會做延遲塊清除
--flg: E?? --指用的是ASSM,如果是O表示用的是free list
--typ: 1 - DATA 事務(wù)型的數(shù)據(jù)塊(并且:數(shù)據(jù)塊頭的type:0x06),存放表和索引數(shù)據(jù)。
???? brn: 0? bdba: 0x10001d8 ver: 0x01 opc: 0?????
???? inc: 0? exflg: 0
?
?Itl?????????? Xid????????????????? Uba???????? Flag? Lck??????? Scn/Fsc
0x01?? 0x0002.01a.00001382? 0x00c00b70.0569.07? --U-??? 2? fsc 0x0000.00874dbb
0x02?? 0x0000.000.00000000? 0x00000000.0000.00? ----??? 0? fsc 0x0000.00000000
--11G默認(rèn)用快速提交,F(xiàn)lag是U,正常提交是C。
--Itl: ITL事務(wù)槽號的流水編號
--Xid:transac[X]tion identified(事務(wù)ID),由und的段號+undo的槽號+undo槽號的覆蓋次數(shù)三部分組成
--Uba:undo block address記錄了最近一次的該記錄的前鏡像(修改前的值)
--Flag:C是提交,U是快速提交,---是未提交(Flg C=Committed? U=Commit Upper Bound T=Active at CSC)
--Lck:鎖住了幾行數(shù)據(jù),對應(yīng)有幾個行鎖
--Scn/Fsc:Scn=SCN of commited TX; Fsc=Free space credit(bytes)
--這里fsc 0x0000.00874dbb是指提交的scn,這個值大于上次清除塊時的scn=csc: 0x00.874db6(此scn是這個塊中最小的SCN of commited)
--SCN WRAP:如果事務(wù)已提交并完成清洗,該字段保存事務(wù)提交SCN的SCN WRAP部分,否則該字段保存空閑預(yù)支字節(jié)數(shù)(FSC).比如刪除了一行數(shù)據(jù)10個字節(jié),在事務(wù)提前前,這10個字節(jié)就屬于fsc(即會寫到SCN WRAP),只有事務(wù)提交后,才能正式返回到空閑空間。
#################################################用戶數(shù)據(jù)頭
bdba: 0x010001dd? --當(dāng)前數(shù)據(jù)塊的DBA
data_block_dump,data header at 0xb68a9264
===============
tsiz: 0x1f98? 塊的total總可用空間 1f98--8088字節(jié)
hsiz: 0x16? --數(shù)據(jù)頭部占的字節(jié)數(shù)-不固定
pbl: 0xb68a9264
???? 76543210
flag=--------
ntab=1 ? ? ? ? ? ?? --數(shù)據(jù)塊屬于一個表, cluster表時不是1
nrow=2???????????? --行數(shù)
frre=-1 ? ? ? ? ? ? ? --The first free row entry in the row directory 要加1
fsbo=0x16 ? ???? --Free space begin offset? 叫起始空間:可以存放數(shù)據(jù)空間的起始位置(即定義了數(shù)據(jù)層中空閑空間的起始o(jì)ffset)
fseo=0x1f82???? -- Free space end offset? 叫結(jié)束空間:可以存放數(shù)據(jù)空間的結(jié)束位置(即定義了數(shù)據(jù)層中空閑空間的結(jié)束offset)插入數(shù)據(jù)從此處開始--從后往前用
avsp=0x1f6c ?? -- --Available space for new entries? 叫空閑空間:定義了數(shù)據(jù)層中空閑空間的字節(jié)數(shù)
tosp=0x1f6c ? ? -- --Total space?? 叫最終空閑空間:定義了ITL中事務(wù)提交后,數(shù)據(jù)層中空閑空間的字節(jié)數(shù)
0xe:pti[0]????? nrow=2? offs=0?? --Table directory,整個表的開始,共2行數(shù)據(jù) ,定義了該表在行索引中使用的插槽數(shù)
0x12:pri[0]???? offs=0x1f8e?? -Row index,叫行索引,定義了該塊中包含的所有行數(shù)據(jù)的位置
0x14:pri[1]???? offs=0x1f82
#######################################用戶數(shù)據(jù)
block_row_dump:
tab 0, row 0, @0x1f8e? --1個表,第1行,@0x1f8e該表在行索引中的起始插槽號 8078
tl: 10 fb: --H-FL-- lb: 0x1? cc: 2
--fb: (Flag byte)--H-FL指H(Head piece of row)F(First data piece) L(Last data piece)
--lb: 0x1 --Lock byte和上面的ITL的lck相對應(yīng),表示這行是否被lock了
col? 0: [ 2]? c1 5a?? --第一行的第一列,有兩個字符
col? 1: [ 3]? 62 79 73 --第一行的第二列,有三個字符
tab 0, row 1, @0x1f82??????? ----------使用這個轉(zhuǎn)換為十進(jìn)制在BBED以此為偏移量來查看,需要加100(ORACEL預(yù)留100字節(jié))
tl: 12 fb: --H-FL-- lb: 0x1? cc: 2
col? 0: [ 2]? c1 46
col? 1: [ 5]? 68 65 6c 6c 6f
end_of_block_dump
End dump data blocks tsn: 4 file#: 4 minblk 477 maxblk 477
最后四字節(jié)tail: 0xa3eb0601=scnBASE+flg+seq,如果不相等會報塊損壞
###################
使用BBED查看數(shù)據(jù)塊,與上一步DUMP信息進(jìn)行對應(yīng)
要節(jié)約篇幅哈哈,BBED中只講與DUMP中的對應(yīng)及一些重要字段的意義,不太重要的就要在上一步的DUMP中看了。
##########################
BBED> set file 4 block 477
??????? FILE#?????????? 4
??????? BLOCK#????????? 477
BBED> dump
?File: /u01/oradata/bys3/user01.dbf (4)
?Block: 477????????????? Offsets:??? 0 to? 511?????????? Dba:0x010001dd
------------------------------------------------------------------------
?06a20000 dd010001 bb4d8700 00000106 56eb0000 01001300 1e5b0000 b64d8700
?從BBED的第一行信息,因為大小端的問題,這里要兩位兩位倒著看。
?16進(jìn)制中兩個字符表示1bytes,所以要以2個16進(jìn)制字符為單位(1byte)來進(jìn)行轉(zhuǎn)換:
?前面的個字節(jié)是:0000 a206? 0100 01dd,可以看到和DUMP數(shù)據(jù)塊中第一行前8個字節(jié)是一樣的,
#####
BBED> map
?File: /u01/oradata/bys3/user01.dbf (4)
?Block: 477?????????????????????????????????? Dba:0x010001dd
------------------------------------------------------------
?KTB Data Block (Table/Cluster)
?struct kcbh, 20 bytes????????????????????? @0??????
?struct ktbbh, 72 bytes???????????????????? @20?????
?struct kdbh, 14 bytes????????????????????? @100????
?struct kdbt[1], 4 bytes??????????????????? @114????
?sb2 kdbr[2]??????????????????????????????? @118????
?ub1 freespace[8044]??????????????????????? @122????
?ub1 rowdata[22]??????????????????????????? @8166???
?ub4 tailchk??????????????????????????????? @8188?
##############################3
BBED> print kcbh?? ---這里面信息全部可以與DUMP中的對應(yīng)上。對應(yīng)圖中 cache layer層
struct kcbh, 20 bytes?????????????????????? @0????? ?
?? ub1 type_kcbh??????????????????????????? @0??????? 0x06? --塊類型。。。。ub4--代表:unsign bytes 4--是字節(jié)數(shù)
?? ub1 frmt_kcbh??????????????????????????? @1??????? 0xa2? --版本8I以上
?? ub1 spare1_kcbh????????????????????????? @2??????? 0x00 ?
?? ub1 spare2_kcbh????????????????????????? @3??????? 0x00
?? ub4 rdba_kcbh??????????????????????????? @4??????? 0x010001dd -DBA
?? ub4 bas_kcbh???????????????????????????? @8??????? 0x00874dbb -SCN低位
?? ub2 wrp_kcbh???????????????????????????? @12?????? 0x0000???? -SCN高位
?? ub1 seq_kcbh???????????????????????????? @14?????? 0x01??? --序號
?? ub1 flg_kcbh???????????????????????????? @15?????? 0x06 (KCBHFDLC, KCBHFCKV)
?? ub2 chkval_kcbh????????????????????????? @16?????? 0xeb56? --DUMP中chkval
?? ub2 spare3_kcbh????????????????????????? @18?????? 0x0000
BBED> print ktbbh??? ---與ITL 事務(wù)信息對應(yīng)
struct ktbbh, 72 bytes????????? @20???? ?
?? ub1 ktbbhtyp???????????????? @20?????? 0x01 (KDDBTDATA)? --塊類型
?? union ktbbhsid, 4 bytes????? @24???????? ---seg/obj:0x5b1e
????? ub4 ktbbhsg1????????????? @24?????? 0x00005b1e
????? ub4 ktbbhod1????????????? @24?????? 0x00005b1e
?? struct ktbbhcsc, 8 bytes???? @28??????? --csc: 0x00.874db6
????? ub4 kscnbas?????????????? @28?????? 0x00874db6
????? ub2 kscnwrp?????????????? @32?????? 0x0000
?? sb2 ktbbhict???????????????? @36?????? 7938? --itc: 2我這里沒對上
?? ub1 ktbbhflg???????????????? @38?????? 0x32 (NONE) --flg: E
?? ub1 ktbbhfsl???????????????? @39?????? 0x00
?? ub4 ktbbhfnx???????????????? @40?????? 0x010001d8 --bdba:
?? struct ktbbhitl[0], 24 bytes @44 --對應(yīng)事務(wù)編號Xid:0x0002.01a.00001382? ?
????? struct ktbitxid, 8 bytes? @44???? ?
???????? ub2 kxidusn??????????? @44?????? 0x0002 -usn undo segment number
???????? ub2 kxidslt??????????? @46?????? 0x001a? --事務(wù)表第幾行
???????? ub4 kxidsqn??????????? @48?????? 0x00001382 --行被重用次數(shù)
????? struct ktbituba, 8 bytes? @52? --對應(yīng)事務(wù)UBA 0x00c00b70.0569.07?? ?
???????? ub4 kubadba??????????? @52?????? 0x00c00b70 --UNDO DBA
???????? ub2 kubaseq??????????? @56?????? 0x0569? --
???????? ub1 kubarec??????????? @58?????? 0x07
????? ub2 ktbitflg????????????? @60?????? 0x2002 (KTBFUPB)
????? union _ktbitun, 2 bytes?? @62???? ?
???????? sb2 _ktbitfsc????????? @62?????? 0
???????? ub2 _ktbitwrp????????? @62?????? 0x0000
????? ub4 ktbitbas????????????? @64?????? 0x00874dbb
?? struct ktbbhitl[1], 24 bytes @68???? ?
????? struct ktbitxid, 8 bytes? @68???? ?
???????? ub2 kxidusn??????????? @68?????? 0x0000
???????? ub2 kxidslt??????????? @70?????? 0x0000
???????? ub4 kxidsqn??????????? @72?????? 0x00000000
????? struct ktbituba, 8 bytes? @76???? ?
???????? ub4 kubadba??????????? @76?????? 0x00000000
???????? ub2 kubaseq??????????? @80?????? 0x0000
???????? ub1 kubarec??????????? @82?????? 0x00
????? ub2 ktbitflg????????????? @84?????? 0x0000 (NONE)
????? union _ktbitun, 2 bytes?? @86???? ?
???????? sb2 _ktbitfsc????????? @86?????? 0
???????? ub2 _ktbitwrp????????? @86?????? 0x0000
????? ub4 ktbitbas????????????? @88?????? 0x00000000
BBED> print kdbh? --對應(yīng)的用戶數(shù)據(jù)頭
struct kdbh, 14 bytes???? @100??? ?
?? ub1 kdbhflag?????????? @100????? 0x00 (NONE)
?? sb1 kdbhntab?????????? @101????? 1? --對應(yīng)DUMP中:ntab=1
?? sb2 kdbhnrow?????????? @102????? 2 --對應(yīng)DUMP中:nrow=2
?? sb2 kdbhfrre?????????? @104???? -1 --對應(yīng)DUMP中:frre=-1
?? sb2 kdbhfsbo?????????? @106????? 22 --對應(yīng)DUMP中:fsbo=0x16
?? sb2 kdbhfseo?????????? @108????? 8066 --對應(yīng)DUMP中:fseo=0x1f82 插數(shù)據(jù)從此處開始
?? sb2 kdbhavsp?????????? @110????? 8044 --對應(yīng)DUMP中avsp=0x1f6c
?? sb2 kdbhtosp?????????? @112????? 8044 --對應(yīng)DUMP中tosp=0x1f6c
? ?
BBED> print kdbr? --對應(yīng)的行索引信息
sb2 kdbr[0]??? @118????? 8078? --對應(yīng)DUMP中0x12:pri[0]???? offs=0x1f8e
sb2 kdbr[1]??? @120????? 8066? --對應(yīng)DUMP中0x14:pri[1]???? offs=0x1f82
##########
BBED> dump offset 8166? --這里DUMP出來的是行中的具體信息? 第一行8078 第二行 8066 加100,從8166開始DUMP
?File: /u01/oradata/bys3/user01.dbf (4)
?Block: 477????????????? Offsets: 8166 to 8191?????????? Dba:0x010001dd
------------------------------------------------------------------------
?2c010202 c1460568 656c6c6f 2c010202 c15a0362 79730106 bb4d
02 c15a 03? 62 7973? 對應(yīng)的第一行的值: ?03是三個字節(jié),
col? 0: [ 2]? c1 5a
col? 1: [ 3]? 62 79 73
02 c14605? 68 656c6c6f對應(yīng)第二行的值:05是五個字節(jié)
col? 0: [ 2]? c1 46
col? 1: [ 5]? 68 65 6c 6c 6f
BBED> print tailchk??? --與DUMP中數(shù)據(jù)塊最后四個字節(jié)對應(yīng)4DBB0601,是數(shù)據(jù)塊的校驗值。
ub4 tailchk????????? @8188???? 0x4dbb0601

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

MongoDB is suitable for handling large-scale unstructured data, and Oracle is suitable for enterprise-level applications that require transaction consistency. 1.MongoDB provides flexibility and high performance, suitable for processing user behavior data. 2. Oracle is known for its stability and powerful functions and is suitable for financial systems. 3.MongoDB uses document models, and Oracle uses relational models. 4.MongoDB is suitable for social media applications, while Oracle is suitable for enterprise-level applications.

MongoDB is suitable for unstructured data and high scalability requirements, while Oracle is suitable for scenarios that require strict data consistency. 1.MongoDB flexibly stores data in different structures, suitable for social media and the Internet of Things. 2. Oracle structured data model ensures data integrity and is suitable for financial transactions. 3.MongoDB scales horizontally through shards, and Oracle scales vertically through RAC. 4.MongoDB has low maintenance costs, while Oracle has high maintenance costs but is fully supported.

Configuring WebLogic database connection on a CentOS system requires the following steps: JDK installation and environment configuration: Make sure that the server has installed a JDK that is compatible with the WebLogic version (for example, WebLogic14.1.1 usually requires JDK8). Correctly set JAVA_HOME, CLASSPATH and PATH environment variables. WebLogic installation and decompression: Download the WebLogic installation package for CentOS system from the official Oracle website and unzip it to the specified directory. WebLogic user and directory creation: Create a dedicated WebLogic user account and set a security password

Oracle views can be exported through the EXP utility: Log in to the Oracle database. Start the EXP utility, specifying the view name and export directory. Enter export parameters, including target mode, file format, and tablespace. Start exporting. Verify the export using the impdp utility.
