sitemap

RSS地图

收藏本站

设为首页

Oracle研究中心

当前位置:Oracle研究中心 > 产品DBA > Oracle BBED >

【学习笔记】Oracle BBED工具使用案例 BBED修改ASM中块的详细步骤

时间:2016-10-27 10:38   来源:Oracle研究中心   作者:HTZ   点击:

天萃荷净 Oracle研究中心学习笔记:分享一篇关于Oracle工具BBED使用的文章,该文章包含使用Oracle BBED工具如何修改ASM中块的详细步骤。
下面的方法,只是用于测试ASM环境中修改特定的块,请误在生产环境直接操作。

1,测试环境

oracleplus.net> select * from v$version where rownum<3;

BANNER
—————————————————————-
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 – 64bi
PL/SQL Release 10.2.0.5.0 – Production

oracleplus.net> !lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 4.8 (Tikanga)
Release: 4.8
Codename: Tikanga

2,创建表空间与测试表

oracleplus.net> drop tablespace htz including contents;
Tablespace dropped.
SQL> create tablespace htz datafile ‘+DATA_S’ size 10m;
Tablespace created.
SQL> create table scott.htz tablespace htz as select * from dba_objects;
Table created.
oracleplus.net> @extent.sql
sEnter value for owner: cott
Enter value for segment_name: htz
Enter value for tablespace_name:
BLOCK
EXTENT_ID BEGIN_END BLOCKS BYTES(KB)
——— ————————- ——— ———
0 9~16 8 64
1 17~24 8 64
2 25~32 8 64
3 33~40 8 64
4 41~48 8 64
5 49~56 8 64
6 57~64 8 64
7 65~72 8 64
8 73~80 8 64
9 81~88 8 64
10 89~96 8 64
11 97~104 8 64
12 105~112 8 64
13 113~120 8 64
14 121~128 8 64
15 129~136 8 64
16 137~264 128 1024
17 265~392 128 1024
18 393~520 128 1024
19 521~648 128 1024
20 649~776 128 1024

3,bbed处理ASM中的块

这里选择106块中的23号记录用于测试,将object_id从7389更改为1235
oracleplus.net> select rowid,object_id,dbms_rowid.rowid_row_number(rowid) from scott.htz where dbms_rowid.rowid_block_number(rowid)=106;

ROWID OBJECT_ID DBMS_ROWID.ROWID_ROW_NUMBER(ROWID)
—————— ———- ———————————-
AAAMpWAAFAAAABqAAA 7366 0
AAAMpWAAFAAAABqAAB 7367 1
AAAMpWAAFAAAABqAAC 7368 2
AAAMpWAAFAAAABqAAD 7369 3
AAAMpWAAFAAAABqAAE 7370 4
AAAMpWAAFAAAABqAAF 7371 5
AAAMpWAAFAAAABqAAG 7372 6
AAAMpWAAFAAAABqAAH 7373 7
AAAMpWAAFAAAABqAAI 7374 8
AAAMpWAAFAAAABqAAJ 7375 9
AAAMpWAAFAAAABqAAK 7376 10
AAAMpWAAFAAAABqAAL 7377 11
AAAMpWAAFAAAABqAAM 7378 12
AAAMpWAAFAAAABqAAN 7379 13
AAAMpWAAFAAAABqAAO 7380 14
AAAMpWAAFAAAABqAAP 7381 15
AAAMpWAAFAAAABqAAQ 7382 16
AAAMpWAAFAAAABqAAR 7383 17
AAAMpWAAFAAAABqAAS 7384 18
AAAMpWAAFAAAABqAAT 7385 19
AAAMpWAAFAAAABqAAU 7386 20
AAAMpWAAFAAAABqAAV 7387 21
AAAMpWAAFAAAABqAAW 7388 22
AAAMpWAAFAAAABqAAX 7389 23

这里我们选择将7389更改为1234


oracleplus.net> col name for a60
oracleplus.net> select name from v$dbfile;

NAME
————————————————————
+DATA_E/asm10g/datafile/users.259.853148557
+DATA_E/asm10g/datafile/sysaux.257.853148557
+DATA_E/asm10g/datafile/undotbs1.258.853148557
+DATA_E/asm10g/datafile/system.256.853148557
+DATA_S/asm10g/datafile/htz.260.853238891


oracleplus.net> alter system flush buffer_cache;

System altered.
这里将内存中的数据刷出到数据文件中

3.2 查询数据文件106块对应ASM中的块

oracleplus.net> @asm_extent_by_datafileblock.sql
Enter value for block: 106
Enter value for file_number: 260
Enter value for file_type: datafile
Enter value for filename:

DISK_NUMBER EXTENT EXTENT EXTENT
DISK_NMAE NUMBER BEGIN_BLOCK DISK_BLOCK END_BLOCK TOTAL_AU BEGIN_BLOCK END_BLOCK
————————- ——- ———— ———- ———— ———- ———– ———-
0.VOL9 227 29056 29162 29184 1 0 128

[oracle@www.htz.pw sql]$sh ./asm_find_asmlib_disk_by_kfed.sh
ASMLIB disk name: /dev/oracleasm/disks/VOL1
ASM disk name:
Device path: /dev/sdc1
ASMLIB disk name: /dev/oracleasm/disks/VOL2
ASM disk name:
Device path: /dev/sdc2
ASMLIB disk name: /dev/oracleasm/disks/VOL3
ASM disk name:
Device path: /dev/sdc3
ASMLIB disk name: /dev/oracleasm/disks/VOL5
ASM disk name:
Device path: /dev/sdc5
ASMLIB disk name: /dev/oracleasm/disks/VOL6
ASM disk name:
Device path: /dev/sdc6
ASMLIB disk name: /dev/oracleasm/disks/VOL7
ASM disk name:
Device path: /dev/sdc7
ASMLIB disk name: /dev/oracleasm/disks/VOL8
ASM disk name:
Device path: /dev/sdc8
ASMLIB disk name: /dev/oracleasm/disks/VOL9
ASM disk name:
Device path: /dev/sdc9
下面是验证数据块是否正确
oracleplus.net> !dd if=/dev/sdc9 skip=29162 bs=8192 count=1 |od -Ad -tx1|more
1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 2.5e-05 seconds, 328 MB/s
0000000 06 a2 00 00 6a 00 40 01 b3 0f 06 00 00 00 02 00
0000016 00 00 00 00 01 00 00 00 4c ca 00 00 87 0f 06 00
0000032 00 00 00 00 03 00 32 00 69 00 40 01 ff ff 00 00
0000048 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00
0000064 87 0f 06 00 00 00 00 00 00 00 00 00 00 00 00 00
0000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

这里就是代表
6a 00 40 01rdba地址
3.3 将asm中的块dd到文件系统
在dd出来的时候,需要将数据文件offline,或者是表空间offline,防止数据的修改等。
oracleplus.net> alter tablespace htz offline;

Tablespace altered.
[oracle@www.htz.pw sql]$rm /tmp/106
[oracle@www.htz.pw sql]$dd if=/dev/sdc9 of=/tmp/106 skip=29162 bs=8192 count=1
1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 0.000128 seconds, 64.0 MB/s
[oracle@www.htz.pw sql]$ls -l /tmp/106
-rw-r–r– 1 oracle dba 8192 Jul 18 11:01 /tmp/106

3.4 bbed修改数据

[oracle@www.htz.pw sql]$bbed

Password:

BBED: Release 2.0.0.0.0 – Limited Production on Fri Jul 18 10:28:31 2014

Copyright (c) 1982, 2007, Oracle. All rights reserved.

************* !!! For Oracle Internal Use only !!! ***************

BBED> set filename ‘/tmp/106’;
FILENAME /tmp/106

BBED> set blocksize 8192
BLOCKSIZE 8192
这里一步相当的重要,不部bbed会识别出来是512,不知道是什么原因。并且在使用很多命令后,都要重新配置blocksize,另外还需要注意的是使用了set blocksize 后,使用undo,reverse都是不能回退到原来的值,不知道是什么原因,所以在修改前最好多做一次备份。
BBED> x /rcccnnc *kdbr[23]
rowdata[4854] @6051
————-
flag@6051: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@6052: 0x00
cols@6053: 13

col 0[3] @6054: SYS
col 1[13] @6058: KUPC$_JOBINFO
col 2[0] @6072: *NULL*
col 3[3] @6073: 7389
col 4[0] @6077: *NULL*
col 5[9] @6078: TYPE BODY
col 6[7] @6088: xn….(
col 7[7] @6096: xn….(
col 8[19] @6104: 2010-04-20:08:27:39
col 9[5] @6124: VALID
col 10[1] @6130: N
col 11[1] @6132: N
col 12[1] @6134: N
BBED> set count 16 blocksize 8192
COUNT 16
BLOCKSIZE 8192


BBED> set count 16 blocksize 8192
COUNT 16
BLOCKSIZE 8192

BBED> set offset 6073
OFFSET 6073

BBED> dump
File: /tmp/106 (0)
Block: 1 Offsets: 6073 to 6088 Dba:0x00000000
————————————————————————
03c24a5a ff095459 50452042 4f445907

<32 bytes per line>

BBED> set mode edit
MODE Edit

BBED> set blocksize 8192
BLOCKSIZE 8192
这个值的计算可以通过select dump(1234,’16’)from dual来计算得到
BBED> modify /x c20d23
File: /tmp/106 (0)
Block: 1 Offsets: 6074 to 6089 Dba:0x00000000
————————————————————————
c20d23ff 09545950 4520424f 44590778

<32 bytes per line>

BBED> x /rcccnnc *kdbr[23]
rowdata[4854] @6051
————-
flag@6051: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@6052: 0x00
cols@6053: 13

col 0[3] @6054: SYS
col 1[13] @6058: KUPC$_JOBINFO
col 2[0] @6072: *NULL*
col 3[3] @6073: 1234
col 4[0] @6077: *NULL*
col 5[9] @6078: TYPE BODY
col 6[7] @6088: xn….(
col 7[7] @6096: xn….(
col 8[19] @6104: 2010-04-20:08:27:39
col 9[5] @6124: VALID
col 10[1] @6130: N
col 11[1] @6132: N
col 12[1] @6134: N

下面2步是取消checksum,可以不用修改的。
BBED> modify /x 0000 offset 16
File: /tmp/106 (0)
Block: 1 Offsets: 16 to 31 Dba:0x00000000
————————————————————————
00000000 01000000 57ca0000 6ffe0600

<32 bytes per line>

BBED> modify /x 00 offset 15
File: /tmp/106 (0)
Block: 1 Offsets: 15 to 30 Dba:0x00000000
————————————————————————
00000000 00010000 0057ca00 006ffe06

<32 bytes per line>

3.5 将修改的块复制到ASM盘中

oracleplus.net> !dd if=/tmp/106 of=/dev/sdc9 seek=29162 bs=8192 count=1 conv=notrunc
1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 3e-05 seconds, 273 MB/s
这里千万要记住conv=notrunc不然的话,你后面的整个数据就88了。

4 验证数据

oracleplus.net> alter tablespace htz online;

Tablespace altered.


oracleplus.net> select rowid,object_id,dbms_rowid.rowid_row_number(rowhttp://www.oracleplus.netid) from scott.htz where rowid=’AAAMpXAAFAAAABqAAX’;

ROWID OBJECT_ID DBMS_ROWID.ROWID_ROW_NUMBER(ROWID)
—————— ———- ———————————-
AAAMpXAAFAAAABqAAX 1234 23
如果是offline数据文件,需要使用recover datafile ,后才能正常online。

整个实验结束
本文固定链接: http://www.htz.pw/2014/07/18/bbed%e4%bf%ae%e6%94%b9asm%e4%b8%ad%e7%9a%84%e5%9d%97.html | 认真就输

--------------------------------------ORACLE-DBA----------------------------------------

最权威、专业的Oracle案例资源汇总之【学习笔记】Oracle BBED工具使用案例 BBED修改ASM中块的详细步骤

本文由大师惜分飞原创分享,网址:http://www.oracleplus.net/arch/1082.html

Oracle研究中心

关键词:

Oracle bbed官方使用手册

使用Oracle bbed如何修复ASM中的块