码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2016-06-23 11:08:32      阅读:293      评论:0      收藏:0      [点我收藏+]

标签:oracle bbed rman

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

本文出自 “不忘初心Oracle” 博客,请务必保留此出处http://136018.blog.51cto.com/126018/1792047

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

标签:oracle bbed rman

原文地址:http://136018.blog.51cto.com/126018/1792047

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!