准备:
create table t_block(id integer primary key,name varchar2(10));
insert into t_block values(1,'tcaaaa a');
insert into t_block values(2,'ad阿@奥迪');
insert into t_block values(3,'ABa$23省道');
commit;
SQL> select * from t_block;
ID NAME
---------- ----------
1 tcaaaa a
2 ad阿@奥迪
3 ABa$23省道
SQL> select rowid,dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block# from t_block;
ROWID FILE# BLOCK#
------------------ ---------- ----------
AAAXH7AAHAAOYDNAAC 7 3768525
AAAXH7AAHAAOYDNAAD 7 3768525
AAAXH7AAHAAOYDNAAE 7 3768525
RMAN> backup datafile 7;
Starting backup at 20-SEP-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=36 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=+DATA/test1/datafile/erp2013.269.861528941
channel ORA_DISK_1: starting piece 1 at 20-SEP-16
channel ORA_DISK_1: finished piece 1 at 20-SEP-16
piece handle=/u01/app/product/11.2.0/dbhome_1/dbs/01rg9vhr_1_1 tag=TAG20160920T172827 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:03:45
Finished backup at 20-SEP-16
RMAN> exit
模拟数据块损坏:
RMAN> list backup;
RMAN> blockrecover datafile 7 block 3768525 clear;
Starting recover at 20-SEP-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=52 device type=DISK
Finished recover at 20-SEP-16
RMAN>
dbv验证:
dbv file=+DATA/test1/datafile/erp2013.269.861528941 blocksize=8192 userid=system/xxx logfile=/home/oracle/dbv/erp2013.269.861528.log
查询t_block表
SQL> select * from t_block;
select * from t_block
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 7, block # 3768525)
ORA-01110: data file 7: '+DATA/test1/datafile/erp2013.269.861528941'
使用RMAN恢复:
RMAN> blockrecover datafile 7 block 3768525;
Starting recover at 20-SEP-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=36 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 00007
channel ORA_DISK_1: reading from backup piece /u01/app/product/11.2.0/dbhome_1/dbs/01rg9vhr_1_1
channel ORA_DISK_1: piece handle=/u01/app/product/11.2.0/dbhome_1/dbs/01rg9vhr_1_1 tag=TAG20160920T172827
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:03:45
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 20-SEP-16
RMAN>
查看数据
$ sqlplus sysdev/xxx
SQL*Plus: Release 11.2.0.4.0 Production on Tue Sep 20 17:51:51 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
SQL> select * from t_block;
ID NAME
---------- ----------
1 tcaaaa a
2 ad阿@奥迪
3 ABa$23省道
SQL>
恢复成功,备份很重要
create table t_block(id integer primary key,name varchar2(10));
insert into t_block values(1,'tcaaaa a');
insert into t_block values(2,'ad阿@奥迪');
insert into t_block values(3,'ABa$23省道');
commit;
SQL> select * from t_block;
ID NAME
---------- ----------
1 tcaaaa a
2 ad阿@奥迪
3 ABa$23省道
SQL> select rowid,dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block# from t_block;
ROWID FILE# BLOCK#
------------------ ---------- ----------
AAAXH7AAHAAOYDNAAC 7 3768525
AAAXH7AAHAAOYDNAAD 7 3768525
AAAXH7AAHAAOYDNAAE 7 3768525
RMAN> backup datafile 7;
Starting backup at 20-SEP-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=36 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=+DATA/test1/datafile/erp2013.269.861528941
channel ORA_DISK_1: starting piece 1 at 20-SEP-16
channel ORA_DISK_1: finished piece 1 at 20-SEP-16
piece handle=/u01/app/product/11.2.0/dbhome_1/dbs/01rg9vhr_1_1 tag=TAG20160920T172827 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:03:45
Finished backup at 20-SEP-16
RMAN> exit
模拟数据块损坏:
RMAN> list backup;
RMAN> blockrecover datafile 7 block 3768525 clear;
Starting recover at 20-SEP-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=52 device type=DISK
Finished recover at 20-SEP-16
RMAN>
dbv验证:
dbv file=+DATA/test1/datafile/erp2013.269.861528941 blocksize=8192 userid=system/xxx logfile=/home/oracle/dbv/erp2013.269.861528.log
查询t_block表
SQL> select * from t_block;
select * from t_block
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 7, block # 3768525)
ORA-01110: data file 7: '+DATA/test1/datafile/erp2013.269.861528941'
使用RMAN恢复:
RMAN> blockrecover datafile 7 block 3768525;
Starting recover at 20-SEP-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=36 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 00007
channel ORA_DISK_1: reading from backup piece /u01/app/product/11.2.0/dbhome_1/dbs/01rg9vhr_1_1
channel ORA_DISK_1: piece handle=/u01/app/product/11.2.0/dbhome_1/dbs/01rg9vhr_1_1 tag=TAG20160920T172827
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:03:45
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 20-SEP-16
RMAN>
查看数据
$ sqlplus sysdev/xxx
SQL*Plus: Release 11.2.0.4.0 Production on Tue Sep 20 17:51:51 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
SQL> select * from t_block;
ID NAME
---------- ----------
1 tcaaaa a
2 ad阿@奥迪
3 ABa$23省道
SQL>
恢复成功,备份很重要