Oracle Dump 分析学习总结
生活随笔
收集整理的這篇文章主要介紹了
Oracle Dump 分析学习总结
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
簡(jiǎn)單分析dump出來的oracle數(shù)據(jù)塊
一.dump數(shù)據(jù)塊
oracle的rowid中包含著這條數(shù)據(jù)對(duì)象號(hào),數(shù)據(jù)文件號(hào),數(shù)據(jù)文件中的塊號(hào)以及塊中的行號(hào),并且這些都
可以通過dbms_rowid這個(gè)包轉(zhuǎn)成具體的數(shù)字出來
?
SQL> select dbms_rowid.ROWID_RELATIVE_FNO(rowid) as file#,dbms_rowid.ROWID_BLOCK_NUMBER
(rowid) as block#,dbms_rowid.ROWID_ROW_NUMBER(rowid) as row#,a.* from paololiu.test1 a;?
?
? ? ?FILE# ? ? BLOCK# ? ?ROW# AAA ? BBB
---------- ---------- ---------- ----- --------------------------------------------------
?6 ?131 ? ? ? 0 abc ? abc
?6 ?131 ? ? ? 1 111 ? 111
?6 ?131 ? ? ? 2 ab12 ?ab12
?
可以看tset1表中的三條記錄都在第6號(hào)文件的131號(hào)塊上,并分別在這個(gè)塊的第0,1,2行上。
通過dump命令就可以把這整個(gè)塊都dump出來的:
?
SQL> alter system dump datafile 6 block 131;
?
System altered.
?
dump出來的文件在user_dump_dest參數(shù)設(shè)定的目錄內(nèi),以_ora_.trc為格式的名字。其中spid指當(dāng)前sid
所對(duì)應(yīng)的操作系統(tǒng)的進(jìn)程號(hào),可以通過以下語(yǔ)句獲得:
?
SQL> select p.spid from v$session s,v$process p where s.paddr=p.addr and s.sid in (select?
userenv('sid') from dual);
?
SPID
------------------------
2413
?
通過vi就可以打開剛才dump出來的trc文件了,在最下面就可以看到那三條記錄了
?
block_row_dump:
tab 0, row 0, @0x1f8b
tl: 13 fb: --H-FL-- lb: 0x1 ?cc: 2
col ?0: [ 5] ?61 62 63 20 20
col ?1: [ 3] ?61 62 63
tab 0, row 1, @0x1f7e
tl: 13 fb: --H-FL-- lb: 0x1 ?cc: 2
col ?0: [ 5] ?31 31 31 20 20
col ?1: [ 3] ?31 31 31
tab 0, row 2, @0x1f70
tl: 14 fb: --H-FL-- lb: 0x1 ?cc: 2
col ?0: [ 5] ?61 62 31 32 20
col ?1: [ 4] ?61 62 31 32
end_of_block_dump
?
另外同樣也可以通過dump函數(shù)來獲得這些二進(jìn)制文件的值(前面trc文件顯示的是16進(jìn)制的,這里顯示的
是10進(jìn)制的):
?
SQL> select a.*,dump(aaa) as dump1,dump(bbb) as dump2 from test1 a;
?
AAA ? BBB DUMP1 ?DUMP2
----- ---------- -------------------------------- --------------------------------
abc ? abc Typ=96 Len=5: 97,98,99,32,32 ?Typ=1 Len=3: 97,98,99
111 ? 111 Typ=96 Len=5: 49,49,49,32,32 ?Typ=1 Len=3: 49,49,49
ab12 ?ab12 Typ=96 Len=5: 97,98,49,50,32 ?Typ=1 Len=4: 97,98,49,50
?
二.分析dump出來的數(shù)值
?
剛才那張表的數(shù)據(jù)結(jié)構(gòu)如下:
SQL> desc test1;
?Name ? Null? ? ?Type
?----------------------------------------- -------- ----------------------------
?AAA ? ?CHAR(5)
?BBB ? ?VARCHAR2(50)
?
這里可以看到typ=96代表char類型,而typ=1代表varchar2類型。后面的數(shù)值則對(duì)應(yīng)的是ascii表的值,
其中97是a,98是b,99是c,49是1,50是2。還有可以看到char類型后面還有一些32則對(duì)應(yīng)的是空格,填充
剩余字符串長(zhǎng)度。
?
這里顯示的是字符串,而數(shù)值型就相對(duì)比較復(fù)雜了
?
1.數(shù)值:123456
SQL> select dump(123456) as dump1 from dual;
?
DUMP1
--------------------------------
Typ=2 Len=4: 195,13,35,57
?
195-193=2
193是個(gè)常數(shù)值,第一位的數(shù)字195去減193得到一個(gè)指數(shù)值2
13-1=12,12*100^2=120000
35-1=34,34*100^1=3400
57-1=56,56*100^0=56
這里-1前面的就是dump出來的后面幾位的值,依次分別是13,35,57,用他們減掉一個(gè)常數(shù)值1以后再依次
乘以100的遞減指數(shù)倍
?
sum=120000+3400+56=123456
再將它們相加就可以得到原來的值了
?
?
?
2.數(shù)值:123456.789
SQL> select dump(123456.789) as dump1 from dual;
?
DUMP1
--------------------------------
Typ=2 Len=6: 195,13,35,57,79,91
?
其實(shí)小數(shù)的算法和前面的整數(shù)一樣的:
a.用第一位195減掉193得到指數(shù)值
195-194=2
?
b.后面幾位分別乘以相對(duì)應(yīng)的100的遞減的指數(shù)倍
13-1=12;12*100^2=120000
35-1=34;34*100^1=3400
57-1=56;56*100^0=56
79-1=78;78*100^-1=0.78
91-1=90;90*100^-2=0.09
?
c.最后相加
120000+3400+56+0.78+0.9=123456.789
?
?
3.數(shù)值:-98765.4321
SQL> select dump(-98765.4321) as dump1 from dual;
?
DUMP1
------------------------------------------------------------
Typ=2 Len=7: 60,92,14,36,58,80,102
?
負(fù)數(shù)的算法和前面的正數(shù)差不多,只是幾個(gè)常數(shù)需要換一下
a.指數(shù)算法稍有區(qū)別:用常數(shù)62減去第一位等到指數(shù)值
62-60=2
?
b.后面的是減去常數(shù)101后再乘以100的遞減指數(shù)倍
92-101=-9;-9*100^2=-90000
14-101=-87;-87*100^1=-8700
36-101=-65;-65*100^0=-65
58-101=-43;-43*100^-1=-0.43
80-101=-21;-21*100^-2=-0.0021
最后一位102放棄
?
c.相加后得到相應(yīng)的數(shù)值:
-90000-8700-65-0.43-0.0021=-98765.4321
========
DUMP塊的分析
Dump file C:\oracle\admin\ORCL\udump\ORA03560.TRCThu Mar 12 15:45:29 2009
ORACLE V8.1.7.0.0 - Production vsnsta=0
vsnsql=e vsnxtr=3
Windows 2000 Version 5.1 Service Pack 2, CPU type 586
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
With the Partitioning option
JServer Release 8.1.7.0.0 - Production
Windows 2000 Version 5.1 Service Pack 2, CPU type 586
Instance name: orcl
Redo thread mounted by this instance: 1
Oracle process number: 16
Windows thread id: 3560, image: ORACLE.EXE
*** 2009-03-12 15:45:29.687
*** SESSION ID:(17.1166) 2009-03-12 15:45:29.671
Start dump data blocks tsn: 0 file#: 1 minblk 60446 maxblk 60446
buffer tsn: 0 rdba: 0x0040ec1e (1/60446)
-- tsn 是表空間號(hào) ?rdba是相對(duì)數(shù)據(jù)地址(轉(zhuǎn)成二進(jìn)制 前十位是相對(duì)文件號(hào),后22位是數(shù)據(jù)塊號(hào))
scn: 0x0000.0008d355 seq: 0x03 flg: 0x04 tail: 0xd3550603
--SCN為SCN Base=0008,SCN Wrap=d355,seq:scn的變化序列
--尾區(qū)版本號(hào)為tail: 0xd3550603(tail=SCN Wrap: d355 ?+ type: 0x06+ seq: 0x03)
frmt: 0x02 chkval: 0x3f39 type: 0x06=trans data
-- frmt: 0x02 代表該BLOC是UNDO BLOCK?
--flg:標(biāo)識(shí): ? 0x01 ?new block ?- zeroed ?data area
? ? ? ? ? ? ? ? 0x02 ?delayed logging change advanced ?scn/seq
? ? ? ? ? ? ? ? 0x04 ?check value saved -block xor's to zero
? ? ? ? ? ? ? ? 0x08 ?temporary block
?
Block header dump: ?0x0040ec1e
?Object id on Block? Y
?seg/obj: 0x60f7 ?csc: 0x00.8d355 ?itc: 1 ?flg: O ?typ: 1 - DATA
? ? ?fsl: 0 ?fnx: 0x0 ver: 0x01
? ? ?
?---seg/obj 對(duì)象ID值?
?--csc(SCN at last Block CleanOut): 0x00.8d355表示最后一次塊清除(Block CleanOut)時(shí)候的SCN
?--itc 表示Number of itl slots ?對(duì)應(yīng)v$transaction 中的XINDUSN
?
?
?Itl ? ? ? ? ? Xid ? ? ? ? ? ? ? ? ?Uba ? ? ? ? Flag ?Lck ? ? ? ?Scn/Fsc
0x01 ? xid: ?0x0001.022.00000389 ? ?uba: 0x008012f0.0186.16 ?---- ? ?3 ?fsc 0x0000.00000000
---xid = XINDUSN+ XINSLOT+XIDSQN V$transaction中的字段)
--uba = 0x008012f0.UBASQN.UBAREC 前面的一個(gè)16進(jìn)制數(shù)可以用來計(jì)算得到UBAFILE,UBABLK
--DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE(TO_NUMBER('0x008012f0','XXXXXXXXXX'))
--dbms_utility.data_block_address_block(to_number('0x008012f0','xxxxxxxx'))?
--Lck 應(yīng)該是鎖定的行數(shù)
data_block_dump
===============
tsiz: 0xfb8
hsiz: 0x18
pbl: 0x0e4c6c44
bdba: 0x0040ec1e
flag=-----------
ntab=1
nrow=3
frre=-1
fsbo=0x18
fseo=0xe4a
avsp=0xee9
tosp=0xee9
0xe:pti[0] nrow=3 offs=0
0x12:pri[0] offs=0xec3
0x14:pri[1] offs=0xe88
0x16:pri[2] offs=0xe4a
block_row_dump:
tab 0, row 0, @0xec3
tl: 62 fb: --H-FL-- lb: 0x1 cc: 4
col ?0: [10] ?50 73 79 63 68 6f 6c 6f 67 79
col ?1: [14] ?49 72 65 6e 65 20 46 72 69 65 64 6d 61 6e
col ?2: [15] ?46 75 6c 74 6f 6e 20 48 61 6c 6c 20 31 33 33
col ?3: [16] ?77 61 eb 56 a4 95 4d 5d a1 25 72 a5 e8 21 8d 5d
tab 0, row 1, @0xe88
tl: 59 fb: --H-FL-- lb: 0x1 cc: 4
col ?0: [ 7] ?48 69 73 74 6f 72 79
col ?1: [11] ?4a 6f 68 6e 20 57 68 61 6c 65 6e
col ?2: [18] ?41 70 70 6c 65 67 61 74 65 20 48 61 6c 6c 20 31 34 32
col ?3: [16] ?1c 69 7d a9 4c 0c 45 a9 9f bb de 31 79 77 29 76
tab 0, row 2, @0xe4a
tl: 62 fb: --H-FL-- lb: 0x1 cc: 4
col ?0: [ 7] ?45 6e 67 6c 69 73 68
col ?1: [13] ?4c 79 6e 6e 20 53 61 75 6e 64 65 72 73
col ?2: [19] ?42 72 65 61 6b 73 74 6f 6e 65 20 48 61 6c 6c 20 32 30 35
col ?3: [16] ?26 1d a8 2e d8 c1 41 ed ad 73 6a 31 4d 51 76 94
end_of_block_dump
End dump data blocks tsn: 0 file#: 1 minblk 60446 maxblk 60446
========
ORACLE SYSTEMDUMP分析
? ?某日一數(shù)據(jù)庫(kù)已經(jīng)hang住不動(dòng)了,數(shù)據(jù)庫(kù)的版本是oracle 12.1.0.1.發(fā)現(xiàn)通過sqlplus正常的連接已經(jīng)無法使用了.
整個(gè)實(shí)例hang住了,如下
[oracle@rac1 ~]$ sqlplus /nolog
SQL*Plus: Release 12.1.0.1.0 Production on Sun Jul 20 01:41:11 2014
Copyright (c) 1982, 2013, Oracle. ?All rights reserved.
SQL> conn / as sysdba;
connect命令hang住,無法正常連接
查看alert.log發(fā)現(xiàn)很長(zhǎng)時(shí)間內(nèi)沒有日志拋出了.
Fri Jul 18 09:11:45 2014
Warning: VKTM detected a time drift.
Time drifts can result in an unexpected behavior such as time-outs. Please check trace file?
for more details.
Fri Jul 18 10:14:33 2014
Warning: VKTM detected a time drift.
Time drifts can result in an unexpected behavior such as time-outs. Please check trace file?
for more details.
Fri Jul 18 13:00:46 2014
Thread 1 advanced to log sequence 42 (LGWR switch)
? Current log# 2 seq# 42 mem# 0: +DATA/tt/redo02.log
Fri Jul 18 15:22:20 2014
Active Session History (ASH) performed an emergency flush. This may mean that ASH is?
undersized. If emergency flushes are a recurring issue, you may consider increasing ASH?
size by setting the value of _ASH_SIZE to a sufficiently large value. Currently, ASH size?
is 4194304 bytes. Both ASH size and the total number of emergency flushes since instance?
startup can be monitored by running the following query:
?select total_size,awr_flush_emergency_count from v$ash_info;
Fri Jul 18 22:00:03 2014
?
[oracle@rac1 trace]$ date
Fri Jul 18 23:47:48 CST 2014
?
還好sqlplus提供了一個(gè)prelim選項(xiàng)可以連接實(shí)例
[oracle@rac1 ~]$ sqlplus -prelim / as sysdba;
SQL*Plus: Release 12.1.0.1.0 Production on Sun Jul 20 01:48:37 2014
Copyright (c) 1982, 2013, Oracle. ?All rights reserved.
SQL>
?
對(duì)系統(tǒng)進(jìn)行兩次systemdump 266。
[oracle@rac1 ~]$ sqlplus -prelim / as sysdba;
SQL*Plus: Release 12.1.0.1.0 Production on Sun Jul 20 01:48:37 2014
Copyright (c) 1982, 2013, Oracle. ?All rights reserved.
SQL> oradebug setmypid;
Statement processed.
SQL> oradebug dump systemdump 266;
等待90秒
SQL> oradebug dump systemdump 266;
?
[oracle@localhost ~]$ awk -f ass109.awk tt1_ora_2806.trc
Starting Systemstate 1
....................................................................
Starting Systemstate 2
...................................................................
Ass.Awk Version 1.0.9 - Processing tt1_ora_2806.trc
System State 1
~~~~~~~~~~~~~~~~
1: ? ? ? ? ? ? ? ? ? ??
51: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
52: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
53: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
54: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
55: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
56: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
57: 0: waiting for 'Streams AQ: qmn coordinator idle wait'?
58: 0: waiting for 'cursor: pin S' ? ? ?
? ? ?Cmd: Select
59: 0: waiting for 'Streams AQ: qmn slave idle wait'?
60: 0: waiting for 'SQL*Net message from client'?
61: 0: waiting for 'gc freelist' ? ? ? ?
? ? ?Cmd: Select
62: 0: waiting for 'REPL Capture/Apply: RAC AQ qmn coordinator'?
63: 2: waited for 'Streams AQ: waiting for time management or cleanup tasks'?
64: 0: waiting for 'Streams AQ: load balancer idle'?
69: 0: waiting for 'Space Manager: slave idle wait'?
70: 0: waiting for 'gc freelist' ? ? ? ?
? ? ?Cmd: Select
71: 0: waiting for 'gc freelist' ? ? ? ?
? ? ?Cmd: Select
74: 0: waiting for 'gc freelist' ? ? ? ?
Blockers
~~~~~~~~
? ? ? ? Above is a list of all the processes. If they are waiting for a resource
? ? ? ? then it will be given in square brackets. Below is a summary of the
? ? ? ? waited upon resources, together with the holder of that resource.
? ? ? ? Notes:
? ? ? ? ~~~~~
? ? ? ? ?o A process id of '???' implies that the holder was not found in the
? ? ? ? ? ?systemstate.
? ? ? ? ? ? ? ? ? ? Resource Holder State
? ? ? ? Latch sent-location: ? ???? Blocker
Object Names
~~~~~~~~~~~~
Latch sent-location: ? ? ? ? ? ? ? ? ?last post sent-location: kji.h LINE:
在使用了awk腳本分析后,發(fā)現(xiàn)沒有很明顯的阻塞,看來先只能提SR了.
========
總結(jié)
以上是生活随笔為你收集整理的Oracle Dump 分析学习总结的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 图解Oracle 12c 手动建库
- 下一篇: 图解RadASM使用初步