本文主要是介绍Oracle 利用bbed破坏数据文件测试,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
关于bbed的安装与使用请参考:
http://blog.csdn.net/shiyu1157758655/article/details/56279479
1.创建测试表
SQL> create table test(id int,name varchar2(10));Table created.SQL> insert into test values(1,'shi');1 row created.SQL> insert into test values(2,'yu');1 row created.SQL> insert into test values(3,'yushi');1 row created.SQL> commit;Commit complete.SQL> select * from test;ID NAME
---------- ----------1 shi2 yu3 yushi
2.查看rowid对应的文件号,块号等信息
SQL> select DBMS_ROWID.ROWID_TYPE(rowid) as ROWID_TYPE ,dbms_rowid.rowid_object(rowid) as rowid_object ,DBMS_ROWID.ROWID_RELATIVE_FNO(rowid) as ROWID_RELATIVE_FNO ,DBMS_ROWID.ROWID_BLOCK_NUMBER(rowid) as ROWID_BLOCK_NUMBER,DBMS_ROWID.ROWID_ROW_NUMBER(rowid) as ROWID_ROW_NUMBER from test where rownum=1;ROWID_TYPE ROWID_OBJECT ROWID_RELATIVE_FNO ROWID_BLOCK_NUMBER ROWID_ROW_NUMBER
---------- ------------ ------------------ ------------------ ----------------1 83320 5 139 0
3.修改数据块内容
(1)定位需要修改块
cebpm:/home/oracle@cebpm>bbed parfile=bbed_parameter.txt
Password: BBED: Release 2.0.0.0.0 - Limited Production on Fri Jan 12 13:54:24 2018Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.************* !!! For Oracle Internal Use only !!! ***************BBED> info allFile# Name Size(blks)----- ---- ----------1 /data/CEBPM/datafile/o1_mf_system_dm1flxkw_.dbf 896002 /data/CEBPM/datafile/o1_mf_sysaux_dm1fnw5v_.dbf 768003 /data/CEBPM/datafile/o1_mf_undotbs1_dm1foow9_.dbf 371204 /data/CEBPM/datafile/o1_mf_users_dm1fqcrp_.dbf 6405 /data/CEBPM/datafile/test01.dbf 1280BBED> set dba 5,135DBA 0x0140008b (20971659 5,139)
(2)查看相关内容
BBED> find /c shiFile: /data/CEBPM/datafile/test01.dbf (5)Block: 139 Offsets: 8166 to 8191 Dba:0x0140008b
------------------------------------------------------------------------7368692c 010202c1 03027975 2c010202 c1020373 68690106 af65 <32 bytes per line>
(3)dump文件中内容
BBED> dump /v dba 5,139 offset 8166 count 32File: /data/CEBPM/datafile/test01.dbf (5)Block: 139 Offsets: 8166 to 8191 Dba:0x0140008b
-------------------------------------------------------7368692c 010202c1 03027975 2c010202 l shi,...?.yu,...c1020373 68690106 af65 l ?.shi..¯e<16 bytes per line>
(4)修改数据块内容
BBED> modify 500 dba 5,139
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /data/CEBPM/datafile/test01.dbf (5)
Block: 139 Offsets: 8166 to 8191 Dba:0x0140008b
------------------------------------------------------------------------
01f4692c 010202c1 03027975 2c010202 c1020373 68690106 af65
<32 bytes per line>
4.验证修改是否成功
(1) dbv 验证
cebpm:/home/oracle@cebpm>dbv file=/data/CEBPM/datafile/test01.dbf
DBVERIFY: Release 11.2.0.4.0 - Production on Fri Jan 12 14:50:38 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
DBVERIFY - Verification starting : FILE = /data/CEBPM/datafile/test01.dbf
Page 139 is marked corrupt
Corrupt block relative dba: 0x0140008b (file 5, block 139)
Bad check value found during dbv:
Data in bad block:
type: 6 format: 2 rdba: 0x0140008b
last change scn: 0x0000.001265af seq: 0x1 flg: 0x06
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x65af0601
check value in block header: 0x4c7a
computed block checksum: 0x9c72
DBVERIFY - Verification complete
Total Pages Examined : 4096
Total Pages Processed (Data) : 9
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 133
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 3953
Total Pages Marked Corrupt : 1
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 1205667 (0.1205667)
(2)rman 验证
cebpm:/home/oracle@cebpm>rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Jan 12 14:53:26 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: CEBPM (DBID=3677012495)
RMAN> backup check logical validate datafile 5;
Starting backup at 2018/01/12 14:53:45
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=48 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/data/CEBPM/datafile/test01.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5 FAILED 0 3953 4096 1205667
File Name: /data/CEBPM/datafile/test01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 1 10
Index 0 0
Other 0 133
validate found one or more corrupt blocks
See trace file /u01/app/oracle/diag/rdbms/cebpm/cebpm/trace/cebpm_ora_30610.trc for details
Finished backup at 2018/01/12 14:53:56
RMAN> exit
Recovery Manager complete.
cebpm:/home/oracle@cebpm>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Jan 12 14:54:15 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select file#,block#,blocks from v$database_block_corruption;
FILE# BLOCK# BLOCKS
---------- ---------- ----------
5 139 1
(3)直接查询验证
SQL> alter system flush buffer_cache;System altered.SQL> select * from test;
select * from test*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 5, block # 139)
ORA-01110: data file 5: '/data/CEBPM/datafile/test01.dbf'
这篇关于Oracle 利用bbed破坏数据文件测试的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!