[20150513]人为破坏数据块.txt

[20150513]人为破坏数据块.txt

--演示的目的,参考链接:
http://www.askmaclean.com/archives/oracle-make-block-physical-corruption.html

--不要在生产系统测试!!!!!

1.建立测试环境:

SCOTT@test> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- ----------------------------------------------------------------
x86_64/Linux 2.4.xx            10.2.0.4.0     Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

SCOTT@test> create table depty as select * from dept ;
Table created.

SCOTT@test> select rowid,depty.* from depty ;
ROWID                    DEPTNO DNAME          LOC
------------------ ------------ -------------- -------------
AAAPbxAAEAAAAUkAAA           10 ACCOUNTING     NEW YORK
AAAPbxAAEAAAAUkAAB           20 RESEARCH       DALLAS
AAAPbxAAEAAAAUkAAC           30 SALES          CHICAGO
AAAPbxAAEAAAAUkAAD           40 OPERATIONS     BOSTON

SCOTT@test> @ &r/lookup_rowid AAAPbxAAEAAAAUkAAA
      OBJECT         FILE        BLOCK          ROW DBA                  TEXT
------------ ------------ ------------ ------------ -------------------- ----------------------------------------
       63217            4         1316            0 4,1316               alter system dump datafile 4 block 1316

--保证脏块写盘.
SCOTT@test> alter system checkpoint;
System altered.

--安全需要备份数据文件.
RMAN> backup datafile 4 format '/tmp/users_%u' ;
Starting backup at 2015-05-13 12:02:58
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=/mnt/ramdisk/test/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-05-13 12:02:59
channel ORA_DISK_1: finished piece 1 at 2015-05-13 12:03:00
piece handle=/tmp/users_01q6r3rj tag=TAG20150513T120259 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-05-13 12:03:00

2.开始测试:

SCOTT@test> alter system flush buffer_cache;
System altered.

RMAN> BLOCKRECOVER DATAFILE 4 BLOCK 1316 clear;

Starting blockrecover at 2015-05-13 12:07:46
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=147 devtype=DISK
Finished blockrecover at 2015-05-13 12:07:46

SCOTT@test> select rowid,depty.* from depty ;
select rowid,depty.* from depty
                          *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 4, block # 1316)
ORA-01110: data file 4: '/mnt/ramdisk/test/users01.dbf'

RMAN> BLOCKRECOVER DATAFILE 4 BLOCK 1316 ;

Starting blockrecover at 2015-05-13 12:08:51
using channel ORA_DISK_1

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00004
channel ORA_DISK_1: reading from backup piece /tmp/users_01q6r3rj
channel ORA_DISK_1: restored block(s) from backup piece 1
piece handle=/tmp/users_01q6r3rj tag=TAG20150513T120259
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:02

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished blockrecover at 2015-05-13 12:08:54

==补充说明,10g不支持如下格式:
RMAN> recover datafile 4 block 1316 ;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "block": expecting one of: "archivelog, auxiliary, allow, check, comma, delete, from, high, noredo, noparallel, parallel, ;, skip, test, until, undo"
RMAN-01007: at line 1 column 20 file: standard input

RMAN> recover datafile 4 block 1316 clear;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "block": expecting one of: "archivelog, auxiliary, allow, check, comma, delete, from, high, noredo, noparallel, parallel, ;, skip, test, until, undo"
RMAN-01007: at line 1 column 20 file: standard input
================

SCOTT@test> select rowid,depty.* from depty ;

ROWID                    DEPTNO DNAME          LOC
------------------ ------------ -------------- -------------
AAAPbxAAEAAAAUkAAA           10 ACCOUNTING     NEW YORK
AAAPbxAAEAAAAUkAAB           20 RESEARCH       DALLAS
AAAPbxAAEAAAAUkAAC           30 SALES          CHICAGO
AAAPbxAAEAAAAUkAAD           40 OPERATIONS     BOSTON

--数据恢复.

== >
补充一点:11g才可以使用如下,10g不行!在11g下做的测试,省略许多步骤:

RMAN> RECOVER DATAFILE 4 BLOCK 1523 clear;

Starting recover at 2015-05-13 15:14:09
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
Finished recover at 2015-05-13 15:14:10

 

RMAN> RECOVER corruption list;

Starting recover at 2015-05-13 15:15:52
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00004
channel ORA_DISK_1: reading from backup piece /tmp/users_3gq6rf0g
channel ORA_DISK_1: piece handle=/tmp/users_3gq6rf0g tag=TAG20150513T151319
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 2015-05-13 15:16:00

SCOTT@test> select rowid,depty.* from depty ;
ROWID                  DEPTNO DNAME          LOC
------------------ ---------- -------------- -------------
AABKCeAAEAAAAXzAAA         10 ACCOUNTING     NEW YORK
AABKCeAAEAAAAXzAAB         20 RESEARCH       DALLAS1
AABKCeAAEAAAAXzAAC         30 SALES          CHICAGO
AABKCeAAEAAAAXzAAD         40 OPERATIONS     BOSTON
AABKCeAAEAAAAXzAAE         50 MARKETING      LONDON

时间: 2024-10-23 18:19:43

[20150513]人为破坏数据块.txt的相关文章

[20150929]检查数据块.txt

[20150929]检查数据块.txt --一般检查数据库的块是否存在损坏,使用dbv程序.例子: $ dbv file=/u01/app/oracle11g/oradata/test/system01.dbf DBVERIFY: Release 11.2.0.3.0 - Production on Tue Sep 29 07:48:28 2015 Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserv

[20150612]使用bvi查看数据块.txt

[20150612]使用bvi查看数据块.txt --编写一个简单的脚本实现bvi查看数据块,主要我现在喜欢使用bbed查看,而修改选择bvi. --通过例子来说明: SCOTT@test> select rowid,dept.* from dept ; ROWID                    DEPTNO DNAME          LOC ------------------ ------------ -------------- ------------- AABJVUAAEA

[20161129]转储内存的内容还原成数据块.txt

[20161129]转储内存的内容还原成数据块.txt --昨天在做1128PAGETABLE SEGMENT HEADER损坏恢复,链接http://blog.itpub.net/267265/viewspace-2129195/ --在做还原成数据块时思路很乱,当时是一边做一边想,希望能找到好的方法,今天自己在重复做一次. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER --

[20160531]windows下bbed修复corrupt数据块

[20160531]windows下bbed修复corrupt数据块.txt --昨天别人的问题,使用windows下的bbed修复corrupt数据块报错.我自己也重复测试看看: --bbed在windows的安装看: http://blog.itpub.net/267265/viewspace-2109019/ 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER --------

[20150522]bbed与数据块检查和.txt

[20150522]bbed与数据块检查和.txt --我现在基本拿bbed学习,基本是拿bbed查看,而使用bvi修改数据.我感觉这种方便1写. --实际上使用bbed的好处就是修改数据块检查和不一致,而使用bbed修改很简单仅仅需要执行sum apply就ok了. --对比dbv与bbed确定检查和位置. 1.建立测试环境: SCOTT@test> @ &r/ver1 PORT_STRING                    VERSION        BANNER -------

[20150527]bbed与数据块检查和2.txt

[20150527]bbed与数据块检查和2.txt http://blog.itpub.net/267265/viewspace-1666781/ --我现在基本拿bbed学习,基本是拿bbed查看,而使用bvi修改数据.我感觉这种方便1写. --实际上使用bbed的好处就是修改数据块检查和不一致,而使用bbed修改很简单仅仅需要执行sum apply就ok了. --对比dbv与bbed确定检查和位置. --实际上既然检查和在16,17字节,只要清零,加上dbv就很容易确定要修改的内容. 1.

[20121115]关于oracle数据文件的第1块.txt

[20121115]关于oracle数据文件的第1块.txt 每个数据文件的第一个块(block 0)是OS block header,在数据库中查询不到信息,记录的是OS信息,以及文件大小的等信息.今天做一些简单的研究. SQL> select * from v$version where rownum BANNER -------------------------------------------------------------------------------- Oracle D

[20170611]关于数据块地址的计算.txt

[20170611]关于数据块地址的计算.txt --//如果数据库出现一些问题,会在alert或者跟踪文件,或者屏幕出现一些错误提示.例如: ORA-00600: internal error code, arguments: [2662], [3], [392066208], [3], [392066212], [4194825], [], [], [], [], [], [] ORA-600 [2662] [a] [b] {c} [d] [e] Arg [a] Current SCN WR

[20160831]关于数据块Checksum.txt

[20160831]关于数据块Checksum.txt --以前我学习bbed时做过一些测试,将'AAAA'替换成'BBBB',你可以发现数据块的Checksum并没有发生变化,当时并没有仔细探究, --现在想起来计算Checksum算法应该相对简单,就是做异或操作. --比如上面的字符'AAAA'如果2个字符按位做异或操作,变成00000000,这个正好巧合,如果修改成'CCCC',做相同的异或操作结果 --也是00000000. --如果按照这个推测修改为'CDCD',这样做异或操作的结果也