Oracle 学习之RMAN(十三)恢复实战--数据块修复
在很多情况下,数据库只是某个数据文件的些许数据块发生损坏。这种情况,我们当然可是使用数据库恢复或者数据文件恢复的方式来解决问题。但是有点高射炮打蚊子的感觉。幸好RMAN提供了块级别的恢复。下面我们来演示一下。
1. 创建一个表空间,大小小一点。
SQL>conn/assysdbaConnected.SQL>createtablespacetbs_blkerrdatafile'/u01/app/oracle/oradata/devdb/blkerr01.dbf'size128K;Tablespacecreated.
2. 在这个表空间上创建一个表,并且装满数据。
SQL>createtableemp_blktablespacetbs_blkerrasselect*fromscott.emp;Tablecreated.SQL>insertintoemp_blkselect*fromscott.emp;14rowscreated.SQL>/14rowscreated.。。。。SQL>insertintoemp_blkselect*fromscott.emp;insertintoemp_blkselect*fromscott.emp*ERRORatline1:ORA-01653:unabletoextendtableSYS.EMP_BLKby8intablespaceTBS_BLKERRSQL>commit;Commitcomplete.SQL>selectcount(*)fromemp_blk;COUNT(*)----------686SQL>
3. 备份该表空间或者数据文件。
RMAN>backupdatafile'/u01/app/oracle/oradata/devdb/blkerr01.dbf';Startingbackupat2015/07/0910:30:11usingchannelORA_DISK_1channelORA_DISK_1:startingfulldatafilebackupsetchannelORA_DISK_1:specifyingdatafile(s)inbackupsetinputdatafilefilenumber=00007name=/u01/app/oracle/oradata/devdb/blkerr01.dbfchannelORA_DISK_1:startingpiece1at2015/07/0910:30:11channelORA_DISK_1:finishedpiece1at2015/07/0910:30:12piecehandle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T103011_bsvq5mw9_.bkptag=TAG20150709T103011comment=NONEchannelORA_DISK_1:backupsetcomplete,elapsedtime:00:00:01Finishedbackupat2015/07/0910:30:12
4. 使用vi编辑数据文件blkerr01.dbf,对文件尾部做稍微的修改
SQL>shutdownimmediateDatabaseclosed.Databasedismounted.ORACLEinstanceshutdown.SQL>startupORACLEinstancestarted.TotalSystemGlobalArea839282688bytesFixedSize2233000bytesVariableSize553651544bytesDatabaseBuffers281018368bytesRedoBuffers2379776bytesDatabasemounted.ORA-01157:cannotidentify/lockdatafile7-seeDBWRtracefileORA-01110:datafile7:'/u01/app/oracle/oradata/devdb/blkerr01.dbf'RMAN>restoredatafile7;Startingrestoreat2015/07/0910:36:25usingtargetdatabasecontrolfileinsteadofrecoverycatalogallocatedchannel:ORA_DISK_1channelORA_DISK_1:SID=20devicetype=DISKchannelORA_DISK_1:startingdatafilebackupsetrestorechannelORA_DISK_1:specifyingdatafile(s)torestorefrombackupsetchannelORA_DISK_1:restoringdatafile00007to/u01/app/oracle/oradata/devdb/blkerr01.dbfchannelORA_DISK_1:readingfrombackuppiece/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T103011_bsvq5mw9_.bkpchannelORA_DISK_1:piecehandle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T103011_bsvq5mw9_.bkptag=TAG20150709T103011channelORA_DISK_1:restoredbackuppiece1channelORA_DISK_1:restorecomplete,elapsedtime:00:00:01Finishedrestoreat2015/07/0910:36:27RMAN>recoverdatafile7;Startingrecoverat2015/07/0910:36:40usingchannelORA_DISK_1startingmediarecoverymediarecoverycomplete,elapsedtime:00:00:00Finishedrecoverat2015/07/0910:36:41
此次修改破坏了文件的头部,发生了意外。(也可能是编辑datafile时,没有关闭数据库)我们先恢复数据文件。再次编辑文件。
此实验始终没有做成功,后续有时间再研究。
恢复的方法如下:
RMANTARGET/BLOCKRECOVERDATAFILE12BLOCK12;
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。