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

前端之家收集整理的这篇文章主要介绍了使用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

原文链接:https://www.f2er.com/oracle/213914.html

猜你在找的Oracle相关文章