使用BBED COPY命令,模拟oracle数据块的损坏

oracle里很多实验都是在特定块的损坏的情况下进行的。

常用的dd命令, 只能指定从1号块到多少个块,并不能指定一个特定的块

类似下面的命令,这是对system01.dbf第一号块作清零操作

dd if=/dev/zero of=/u01/app/oracle/oradata/orcl/system01.dbf bs=8192 count=1

如果只是对第520号块作清除操作,只清除一个特定块的话,就没办法了

这时可以使用bbed的copy命令,如拷贝2号文件的20号块到1号文件的520号块,即可模拟对特定坏的损坏操作

BBED> copy file 2 block 20 to file 1 block 520
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 520 Offsets: 0 to 511 Dba:0x00400208
------------------------------------------------------------------------
1ea20000 14008000 4f070000 00000104 8b800000 02000000 80c08300 00000000
00000000 00f80000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

<32 bytes per line>

异常关闭,再次打开就会报520号块出错的问题了

SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area 1269366784 bytes
Fixed Size 2252864 bytes
Variable Size 1040191424 bytes
Database Buffers 218103808 bytes
Redo Buffers 8818688 bytes
Database mounted.
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-01578: ORACLE data block corrupted (file # 1,block # 520)
ORA-01110: data file 1: '/u01/app/oracle/oradata/orcl/system01.dbf'
Process ID: 1961
Session ID: 1 Serial number: 5


SQL> exit

如何恢复呢,如果有备份,可以使用blockrecover datafile 1 block 520;命令来恢复指定数据文件的指定块

RMAN> blockrecover datafile 1 block 520;

Starting recover at 23-JUN-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00001
channel ORA_DISK_1: reading from backup piece /home/oracle/ora-datafile1.bak
channel ORA_DISK_1: piece handle=/home/oracle/ora-datafile1.bak tag=TAG20160623T020307
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 23-JUN-16

RMAN> alter database open;

database opened

RMAN> exit

相关文章

文章浏览阅读773次,点赞6次,收藏9次。【代码】c# json字符...
文章浏览阅读8.7k次,点赞2次,收藏17次。此现象一般定位到远...
文章浏览阅读2.8k次。mysql脚本转化为oracle脚本_mysql建表语...
文章浏览阅读2.2k次。cx_Oracle报错:cx_Oracle DatabaseErr...
文章浏览阅读1.1k次,点赞38次,收藏35次。本文深入探讨了Or...
文章浏览阅读1.5k次。默认自动收集统计信息的时间为晚上10点...