Home > Database > Mysql Tutorial > 使用DUMP数据块与BBED查看BLOCK对比数据库修改时的SCN

使用DUMP数据块与BBED查看BLOCK对比数据库修改时的SCN

WBOY
Release: 2016-06-07 15:22:12
Original
1179 people have browsed it

实验思路: 先在数据库中对bys.a表的一行进行更新,查出此行对应的FILE# BLOCK# 然后DUMP此FILE# BLOCK#,查看SCN信息 使用BBED DUMP此FILE# BLOCK#,查看SCN信息 1.在数据库中对 bys.a表的一行进行更新,记录此行的ROWID。 19:55:13 BYS@ bys3select * from

实验思路:
先在数据库中对bys.a表的一行进行更新,查出此行对应的FILE# BLOCK#
然后DUMP此FILE# BLOCK#,查看SCN信息
使用BBED DUMP此FILE# BLOCK#,查看SCN信息

1.在数据库中对 bys.a表的一行进行更新,记录此行的ROWID。

19:55:13 BYS@ bys3>select * from a;
B
----------
55
7
3
19:55:15 BYS@ bys3>update a set b=0 where b=7;
1 row updated.
19:55:38 BYS@ bys3>commit;
Commit complete.
19:55:40 BYS@ bys3>select rowid,b from a; ---COMMIT的时间是19:55:40
ROWID B
------------------ ----------
AAAFOzAAEAAAACSAAA 55
AAAFOzAAEAAAACZAAA 0
AAAFOzAAEAAAACbAAA 3
19:57:15 BYS@ bys3>col object_name for a10
20:01:04 BYS@ bys3>select a.rowid,a.object_id,a.file_id,a.block_id,a.row_id,b.object_name,b from (select rowid,dbms_rowid.rowid_object(rowid) object_id,dbms_rowid.rowid_relative_fno(rowid) file_id,dbms_rowid.rowid_block_number(rowid) block_id,dbms_rowid.rowid_row_number(rowid) row_id,b from bys.a) a,dba_objects b where a.object_id=b.object_id; ---如使用此语句,只需要修改标红出的表名,字段名即可。
ROWID OBJECT_ID FILE_ID BLOCK_ID ROW_ID OBJECT_NAM B
------------------ ---------- ---------- ---------- ---------- ---------- ----------
AAAFOzAAEAAAACbAAA 21427 4 155 0 A 3
AAAFOzAAEAAAACZAAA 21427 4 153 0 A 0
AAAFOzAAEAAAACSAAA 21427 4 146 0 A 55
通过上面的语句可以查询出update a set b=0 where b=7;修改数据块是:file#4,block#153
###################################################################

2.使用DUMP file#4,block#153数据块来查看此块相关信息---主要是修改时的SCN

20:01:36 BYS@ bys3>alter system dump datafile 4 block 153;
System altered.
查看TRACE文件位置方法有三个:
select value from v$diag_info where name like 'Default%';
SYS用户执行:oradebug setmypid; oradebug tracefile_name
或者直接在user_dump_dest目录中使用 ls -alt 找最近生成的文件
20:05:32 BYS@ bys3>col name for a10
20:05:40 BYS@ bys3>col value for a50
20:05:49 BYS@ bys3>select * from v$diag_info where name like 'Default%';
INST_ID NAME VALUE
---------- ---------- --------------------------------------------------
1 Default Tr /u01/app/oracle/product/11.2.0/dbhome_1/log/diag/r
ace File dbms/bys3/bys3/trace/bys3_ora_17341.trc

从DUMP信息中查出修改时SCN为:scn: 0x0000.00197b75 ---详见下面的TRACE文件具体信息
转换为SCN为:
20:19:17 BYS@ bys3>select to_number('197b75','xxxxxxxxx') from dual;
TO_NUMBER('197B75','XXXXXXXXX')
-------------------------------
1670005
20:19:38 BYS@ bys3>select scn_to_timestamp(1670005) from dual; --把SCN转换为时间,验证此SCN与UPDATE语句提交时的相符。
SCN_TO_TIMESTAMP(1670005)
---------------------------------------------------------------------------
29-NOV-13 07.55.39.000000000 PM
查看bys3_ora_17341.trc中的详细信息如下:===截取块头部分信息:
Start dump data blocks tsn: 4 file#:4 minblk 153 maxblk 153
Block dump from cache:
Dump of buffer cache at level 4 for tsn=4 rdba=16777369
BH (0x22bfad14) file#: 4 rdba: 0x01000099 (4/153) class: 1 ba: 0x22b9e000
set: 3 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,0
dbwrid: 0 obj: 21427 objn: 21427 tsn: 4 afn: 4 hint: f
hash: [0x22bfba7c,0x2879bdd8] lru: [0x22bfaea4,0x22bfac10]
ckptq: [NULL] fileq: [NULL] objq: [0x22bfaebc,0x25040784] objaq: [0x22bfbba8,0x22bfb9f0]
st: XCURRENT md: NULL fpin: 'kdswh01: kdstgr' tch: 6
flags: block_written_once redo_since_read
LRBA: [0x0.0.0] LSCN: [0x0.0] HSCN: [0xffff.ffffffff] HSUB: [1]
BH (0x22bfb9f8) file#: 4 rdba: 0x01000099 (4/153) class: 1 ba: 0x22bbc000
set: 3 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,0
dbwrid: 0 obj: 21427 objn: 21427 tsn: 4 afn: 4 hint: f
hash: [0x2879bdd8,0x22bfad98] lru: [0x22bfacec,0x217e4bb8]
lru-flags: hot_buffer
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: CR md: NULL fpin: 'kdswh01: kdstgr' tch: 0
cr: [scn: 0x0.197b72],[xid: 0x0.0.0],[uba: 0x0.0.0],[cls: 0x0.197b72],[sfl: 0x0],[lc: 0x0.14da6c]
flags: only_sequential_access
Block dump from disk:
buffer tsn: 4 rdba: 0x01000099 (4/153)
scn: 0x0000.00197b75 seq: 0x02 flg: 0x06 tail: 0x7b750602
frmt: 0x02 chkval: 0xe52c type: 0x06=trans data
Hex dump of block: st=0, typ_found=1
Dump of memory from 0xB6C41600 to 0xB6C43600
##########################################################3

3.使用BBED 查看file#4,block#153数据块中的SCN信息

[oracle@bys3 ~]$ cat par.bbd
blocksize=8192
listfile=bbedfile.txt
mode=edit
[oracle@bys3 ~]$ cat bbedfile.txt
1 /u01/oradata/bys3/system01.dbf 524288000
2 /u01/oradata/bys3/sysaux01.dbf 340787200
3 /u01/oradata/bys3/undotbs01.dbf 209715200
4 /u01/oradata/bys3/user01.dbf 52428800
[oracle@bys3 ~]$ bbed parfile=par.bbd
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Fri Nov 29 20:22:10 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> set file 4 block 153
FILE# 4
BLOCK# 153
BBED> map
File: /u01/oradata/bys3/user01.dbf (4)
Block: 153 Dba:0x01000099
------------------------------------------------------------
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[660] @118
ub1 freespace[719] @1438
ub1 rowdata[6031] @2157
ub4 tailchk @8188
BBED> print kcbh
struct kcbh, 20 bytes @0
ub1 type_kcbh @0 0x06
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0x00
ub1 spare2_kcbh @3 0x00
ub4 rdba_kcbh @4 0x01000099
ub4 bas_kcbh @8 0x00197b75 ---从名字就比较好看出是scn wrap和scn base
ub2 wrp_kcbh @12 0x0000
ub1 seq_kcbh @14 0x02
ub1 flg_kcbh @15 0x06 (KCBHFDLC, KCBHFCKV)
ub2 chkval_kcbh @16 0xe52c
ub2 spare3_kcbh @18 0x0000
下面两行对应的就是SCN的scn wrap 高16位-2byte和scn base 低32位-4byte 详见:http://blog.csdn.net/q947817003/article/details/11590983
ub4 bas_kcbh @8 0x00197b75
ub2 wrp_kcbh @12 0x0000
scn计算方法:SCN=(SCN_WRP * 4294967296) + SCN_BAS
所以此数据块上的SCN就是:0x0000.00197b75 --对应十进制SCN:1670005 对应时间:29-NOV-13 07.55.39.000000000 PM
这个SCN的值与在数据库中使用DUMP file#4,block#153数据块信息得出的SCN是一致的。此处的SCN:0x0000.00197b75转换为十进制SCN及转换为时间详见上一步DUMP时的转换,不详细写出了。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template