没有RMAN备份如何执行Oracle块恢复block recover

如果自己搞不定可以找诗檀软件专业ORACLE数据库修复团队成员帮您恢复!

诗檀软件专业数据库修复团队

服务热线 : 13764045638    QQ号:47079569    邮箱:[email protected]

 

没有RMAN备份执行块恢复

仅使用基于OS的热备份,没有RMAN备份执行块多媒体恢复是可能的,为此,我们需要编目热备份文件到RMAN 储存库,作为文件的镜像副本使用,并使用BLOCKRECOVER命令从映像副本只恢复损坏的块,为了测试它,创建一个表,并插入一个行。

SQL>
create
table tbl_corrupt_test (id number);
Table created.

SQL>
insert into
tbl_corrupt_test values(1);
1 row created.

SQL> commit;
Commit complete.

获取tbl_corrupt_test表存在的文件名,并制成它的热备份,如下:

SQL>
select
segment_name, a.tablespace_name, b.name
from
dba_segments a, v$datafile b
where
a.header_file=b.file# and a.segment_name=’tbl_corrupt_test’;

SEGMENT_NAME     TABLESPACE_NAME NAME
—————  ————— ———————————–
tbl_corrupt_test users
/u01/oracle/product/10.2.0/db_1/oradata/newdb/users01.dbf

SQL>
alter
tablespace users begin backup;
Tablespace altered.

SQL>
host
cp /u01/oracle/product/10.2.0/db_1/oradata/newdb/users01.dbf
/u01/oracle/product/10.2.0/db_1/oradata/newdb/users01_backup.dbf

SQL>
alter
tablespace users end backup;
Tablespace altered.

现在使用上节中提到的技术损坏表(数据文件) ,如下:

SQL>
select
header_block from dba_segments
where
segment_name=’tbl_corrupt_test’;

HEADER_BLOCK
————
59

[oracle@localhost admin]$ dd
of=/u01/oracle/product/10.2.0/
db_1/oradata/newdb/users01.dbf
bs=8192 conv=notrunc seek=60 <<EOF
> corruption
> EOF
0+1 records in
0+1 records out

测试损坏如下:

SQL>
alter
system flush buffer_cache;

System altered.

SQL>
select * from
tbl_corrupt_test;
select * from tbl_corrupt_test
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 4, block # 60)
ORA-01110: data file 4:
‘/u01/oracle/product/10.2.0/db_1/oradata/newdb/users01.dbf’
SQL>

连接到RMAN,尝试恢复数据库块,如下:

RMAN> blockrecover datafile 4 block 60;

RMAN-00571: ===========================================================
RMAN-00569: =============== error message stack follows ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of blockrecover command at 03/09/2010 03:36:13
RMAN-06026: some targets not found – aborting restore
RMAN-06023: no backup or copy of datafile 4 found to restore

接下来, 使用catalog 命令存储在线备份文件到RMAN存储库,使其作为一个映像副本:

RMAN> catalog datafilecopy
‘/u01/oracle/product/10.2.0/db_1/oradata/newdb/users01_backup.dbf’;

cataloged datafile copy
datafile copy
filename=/u01/oracle/product/10.2.0/db_1/oradata/newdb/users01_backup.dbf
recid=1 stamp=713158624

尝试恢复数据块:

RMAN> blockrecover datafile 4 block 60;
<……output trimmed ……>
<……output trimmed ……>
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished blockrecover at 09-MAR-10
RMAN> exit

块已恢复,现在,查询表:

SQL> select * from tbl_corrupt_test;

ID
———-
1
SQL>

这就对了!使用os命令采用的热备份文件恢复了损坏的数据块。


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *