[20210128]拼接資料塊.txt

lfree發表於2021-01-28

[20210128]拼接資料塊.txt

--//昨天測試[20210126]探究oracle記憶體分配4.txt,連結http://blog.itpub.net/267265/viewspace-2753605/
--//使用X$KSMMEM檢視,實際上該檢視可以看到共享記憶體段的全部資訊,這樣利用這個檢視應該可以看到資料塊的資訊.
--//測試使用它拼接資料塊看看.

1.環境:
SYS@book> @ ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.測試:
SCOTT@book> select rowid,dept.* from dept;

ROWID                  DEPTNO DNAME          LOC
------------------ ---------- -------------- -------------
AAAVRCAAEAAAACHAAA         10 ACCOUNTING     NEW YORK
AAAVRCAAEAAAACHAAB         20 RESEARCH       DALLAS
AAAVRCAAEAAAACHAAC         30 SALES          CHICAGO
AAAVRCAAEAAAACHAAD         40 OPERATIONS     BOSTON

SCOTT@book> @ rowid AAAVRCAAEAAAACHAAB
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     87106          4        135          1  0x1000087           4,135                alter system dump datafile 4 block 135 ;

SYS@book> set verify off
SYS@book> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         1 0000000084D25320          4        135          1 data block         xcur                1          0          0          0          0          0 0000000074B6E000 00               DEPT

--//BA=0000000074B6E000.
--//8192 = 0x2000
--//0x0000000074B6E000+0x2000 = 1958150144 = 0x74b70000

--//說明一點,如果KSMMMVAL全部是0,該檢視顯示:
SYS@book> SELECT * FROM X$KSMMEM where addr=hextoraw('0000000074B6E1A0');
ADDR                   INDX    INST_ID KSMMMVAL
---------------- ---------- ---------- ----------------
0000000074B6E1A0   43441204          1 00

set head off
set feedback off
spool 4_135.txt
SELECT KSMMMVAL FROM X$KSMMEM WHERE addr >= hextoraw('0000000074B6E000') and  addr< hextoraw('0000000074B70000') and rownum<=1024;
spool off

--//感覺有點慢,加入rownum<=1024快一點點.僅僅等於可以使用內部索引.

3. 嘗試觀察:

$ sed 's/^00$/00000000/' 4_135.txt | tail -1
8F1706014B524F59

BBED> dump /v offset 8184
 File: /mnt/ramdisk/book/users01.dbf (4)
 Block: 135                               Offsets: 8184 to 8191                            Dba:0x01000087
-----------------------------------------------------------------------------------------------------------
 594f524b 0106178f                                                       l YORK....

--//1行8個位元組,注意看由於CPU的大小頭問題,完成是顛倒過來的.麻煩的是8個位元組顛倒.od -t x8可以實現顛倒.

$ sed 's/^00$/0000000000000000/' 4_135.txt | xxd -r -p | od -t x8 | cut -c9-| xxd -r -p | xxd -c 16 -g 2 | tail
0001f60: 6574 2f55 524c 436c 6173 734c 6f61 6465  et/URLClassLoade
0001f70: 7224 3402 c102 ff02 c11e 0778 7108 180c  r$4.?.?.xq...
0001f80: 2e12 0778 7108 180c 2e12 0778 7108 180c  ...xq......xq...
0001f90: 2e12 02c1 02ff ff02 c149 ff02 c107 04c3  ...?.罥.?.?
0001fa0: 2c00 0302 c129 0a4f 5045 5241 5449 4f4e  ,...?.OPERATION
0001fb0: 5306 424f 5354 4f4e 2c00 0302 c11f 0553  S.BOSTON,...?.S
0001fc0: 414c 4553 0743 4849 4341 474f 2c00 0302  ALES.CHICAGO,...
0001fd0: c115 0852 4553 4541 5243 4806 4441 4c4c  ?.RESEARCH.DALL
0001fe0: 4153 2c02 0302 c10b 0a41 4343 4f55 4e54  AS,...?.ACCOUNT
0001ff0: 494e 4708 4e45 5720 594f 524b 0106 178f  ING.NEW YORK....

$ xxd -c16 -g 2 -s 1105920 -l 8192 /mnt/ramdisk/book/users01.dbf | tail
010ff60: 6574 2f55 524c 436c 6173 734c 6f61 6465  et/URLClassLoade
010ff70: 7224 3402 c102 ff02 c11e 0778 7108 180c  r$4.?.?.xq...
010ff80: 2e12 0778 7108 180c 2e12 0778 7108 180c  ...xq......xq...
010ff90: 2e12 02c1 02ff ff02 c149 ff02 c107 04c3  ...?.罥.?.?
010ffa0: 2c00 0302 c129 0a4f 5045 5241 5449 4f4e  ,...?.OPERATION
010ffb0: 5306 424f 5354 4f4e 2c00 0302 c11f 0553  S.BOSTON,...?.S
010ffc0: 414c 4553 0743 4849 4341 474f 2c00 0302  ALES.CHICAGO,...
010ffd0: c115 0852 4553 4541 5243 4806 4441 4c4c  ?.RESEARCH.DALL
010ffe0: 4153 2c02 0302 c10b 0a41 4343 4f55 4e54  AS,...?.ACCOUNT
010fff0: 494e 4708 4e45 5720 594f 524b 0106 178f  ING.NEW YORK....

--//上下對比完全一致.

$ diff <(sed 's/^00$/0000000000000000/' 4_135.txt | xxd -r -p | od -t x8 | cut -c9-| xxd -r -p | xxd -c 16 -g 2 | cut -c9-) <(xxd -c16 -g 2 -s 1105920 -l 8192 /mnt/ramdisk/book/users01.dbf| cut -c9- )

--//純粹無聊,就算練習一些bash shell程式設計吧^_^.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2754182/,如需轉載,請註明出處,否則將追究法律責任。

相關文章