Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

RMAN of Oracle Learning (XIII) recovery-data Block repair

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In many cases, the database is only a few blocks of a data file corrupted. In this case, of course, we can use database recovery or data file recovery to solve the problem. But it feels like an anti-aircraft gun hitting mosquitoes. Fortunately, RMAN provides block-level recovery. Let's demonstrate it.

1. Create a tablespace, a little bit smaller.

SQL > conn / as sysdbaConnected.SQL > create tablespace tbs_blkerr datafile'/ u01 created.

two。 Create a table on this tablespace and fill it with data.

SQL > create table emp_blk tablespace tbs_blkerr as select * from scott.emp;Table created.SQL > insert into emp_blk select * from scott.emp;14 rows created.SQL > / 14 rows created. SQL > insert into emp_blk select * from scott.emp;insert into emp_blk select * from scott.emp*ERROR at line 1:ORA-01653: unable to extend table SYS.EMP_BLK by 8 in tablespace TBS_BLKERRSQL > commit;Commit complete.SQL > select count (*) from emp_blk; COUNT (*)-686SQL >

3. Back up the tablespace or data file.

RMAN > backup datafile'/ u01ActionAccording to oradata, devdbUnixblkerr01.dbf' Starting backup at 2015-07-09 10:30:11using channel ORA_DISK_1channel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile (s) in backup setinput datafile file number=00007 name=/u01/app/oracle/oradata/devdb/blkerr01.dbfchannel ORA_DISK_1: starting piece 1 at 2015-07-09 10:30:11channel ORA_DISK_1: finished piece 1 at 2015-07-09 10:30:12piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/ 2015_07_09/o1_mf_nnndf_TAG20150709T103011_bsvq5mw9_.bkp tag=TAG20150709T103011 comment=NONEchannel ORA_DISK_1: backup set complete Elapsed time: 00:00:01Finished backup at 2015-07-09 10:30:12

4. Use vi to edit the data file blkerr01.dbf, and make slight changes to the end of the file

SQL > shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL > startupORACLE instance started.Total System Global Area 839282688 bytesFixed Size 2233000 bytesVariable Size 553651544 bytesDatabase Buffers 281018368 bytesRedo Buffers 2379776 bytesDatabase mounted.ORA-01157: cannot identify/lock datafile 7-see DBWR trace fileORA-01110: datafile 7:'/ u01/app/oracle/oradata/devdb/blkerr01.dbf'RMAN > restore datafile 7 Starting restore at 2015-07-09 10:36:25using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=20 device type=DISKchannel ORA_DISK_1: starting datafile backupset restorechannel ORA_DISK_1: specifying datafile (s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00007 to / u01/app/oracle/oradata/devdb/blkerr01.dbfchannel ORA_DISK_1: reading from backup piece / u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09 / o1_mf_nnndf_TAG20150709T103011_bsvq5mw9_.bkpchannel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T103011_bsvq5mw9_.bkp tag=TAG20150709T103011channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete Elapsed time: 00:00:01Finished restore at 2015-07-09 10:36:27RMAN > recover datafile 7 Starting recover at 2015-07-09 10:36:40using channel ORA_DISK_1starting media recoverymedia recovery complete, elapsed time: 00:00:00Finished recover at 2015-07-09 10:36:41

This modification damaged the header of the file and an accident occurred. (it is also possible that the database was not closed when editing datafile.) Let's restore the data file first. Edit the file again.

This experiment has never been successful, and we will have time to study it later.

The recovery method is as follows:

RMAN TARGET / BLOCKRECOVER DATAFILE 12 BLOCK 12

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report