一次坏块处理

模拟一下朋友遇到的坏块并解决下,system文件出现坏块,存在begin backup备份的数据文件。通过这个文件进行恢复

模拟环境进行begin backup 备份

[oracle@oracle10g ~]$ sqlplus / AS sysdba
 
SQL*Plus: Release 10.2.0.5.0 - Production ON Sun Nov 2 20:56:06 2014
 
Copyright (c) 1982, 2010, Oracle.  ALL Rights Reserved.
 
Connected TO an idle instance.
 
SELECT
*
ERROR at line 1:
ORA-01034: ORACLE NOT available
 
 
 
SQL> startup
ORACLE instance started.
 
Total System Global Area  599785472 bytes
Fixed SIZE                  2098112 bytes
Variable SIZE             188746816 bytes
DATABASE Buffers          402653184 bytes
Redo Buffers                6287360 bytes
DATABASE mounted.
DATABASE opened.
SQL> 
SQL> 
SQL> ALTER DATABASE BEGIN backup;
 
DATABASE altered.
 
SQL> !
 
[oracle@oracle10g oradata]$ cd orcl/
[oracle@oracle10g orcl]$ ls -l
total 3732296
-rw-r--r-- 1 oracle oinstall      18432 Jan 17  2014 bifile.bbd
-rw-r----- 1 oracle oinstall  104865792 Nov  2 20:56 big_test.dbf
-rw-r----- 1 oracle oinstall    7389184 Nov  2 20:57 control01.ctl
-rw-r----- 1 oracle oinstall    7389184 Nov  2 20:57 control02.ctl
-rw-r----- 1 oracle oinstall    7389184 Nov  2 20:57 control03.ctl
-rw-r----- 1 oracle oinstall   52436992 Nov  2 20:56 goldengate.dbf
-rw-r--r-- 1 oracle oinstall       5359 Jan 17  2014 log.bbd
-rw-r----- 1 oracle oinstall 1073750016 Nov  2 20:56 ogg_test01.dbf
-rw-r----- 1 oracle oinstall   52429312 Nov  2 20:56 redo01.log
-rw-r----- 1 oracle oinstall   52429312 Nov  2 20:56 redo02.log
-rw-r----- 1 oracle oinstall   52429312 Nov  2 20:56 redo03.log
-rw-r----- 1 oracle oinstall   52429312 Jan 17  2014 sby_redo04.log
-rw-r----- 1 oracle oinstall   52429312 Jan 17  2014 sby_redo05.log
-rw-r----- 1 oracle oinstall   52429312 Jan 17  2014 sby_redo06.log
-rw-r----- 1 oracle oinstall   52429312 Jan 17  2014 sby_redo07.log
-rw-r----- 1 oracle oinstall  471867392 Nov  2 20:56 sysaux01.dbf
-rw-r----- 1 oracle oinstall  492838912 Nov  2 20:56 system01.dbf
-rw-r----- 1 oracle oinstall   20979712 Sep 28 13:06 temp01.dbf
-rw-r----- 1 oracle oinstall  104865792 Nov  2 20:56 test01.dbf
-rw-r----- 1 oracle oinstall  104865792 Jun 16 13:19 test01.dbf.bak
-rw-r----- 1 oracle oinstall  335552512 Nov  2 20:56 undotbs01.dbf
-rw-r----- 1 oracle oinstall  671096832 Nov  2 20:56 users01.dbf
[oracle@oracle10g orcl]$ cp system01.dbf system01.dbf.bak
[oracle@oracle10g orcl]$ exit
exit

以上备份了system文件

SQL> CREATE TABLE test1 AS SELECT * FROM dba_tables;
 
TABLE created.
 
 
SQL> SELECT rowid FROM test1 WHERE rownum < 10;
 
ROWID
------------------
AAANLHAABAAAOcKAAA
AAANLHAABAAAOcKAAB
AAANLHAABAAAOcKAAC
AAANLHAABAAAOcKAAD
AAANLHAABAAAOcKAAE
AAANLHAABAAAOcKAAF
AAANLHAABAAAOcKAAG
AAANLHAABAAAOcKAAH
AAANLHAABAAAOcKAAI
 
9 ROWS selected.
 
SQL> @lookup_rowid AAANLHAABAAAOcKAAA
 
+------------------------------------------------------------------------+
| Report   : lookup_rowid.SQL                                            |
| Instance : orcl                                                        |
| USER     : SYS                                                         |
+------------------------------------------------------------------------+
 
ROWID: AAANLHAABAAAOcKAAA
Object#: 53959
RelFile#: 1
Block#: 59146
ROW#: 0
 
PL/SQL PROCEDURE successfully completed.
 
SQL> ALTER DATABASE END backup;
 
DATABASE altered.

以上创建了一张表并结束备份

使用bbed把块弄坏

BBED: Release 2.0.0.0.0 - Limited Production on Sun Nov 2 20:59:17 2014
 
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
 
************* !!! For Oracle Internal Use only !!! ***************
 
BBED> set filename '/oradata/orcl/system01.dbf'
        FILENAME        /oradata/orcl/system01.dbf
 
BBED> set mode edit
        MODE            Edit
 
BBED> CORRUPT block 59146
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
Block marked media corrupt.
 
BBED> exit
 
 
SQL> 
SQL> alter system flush buffer_cache;
 
System altered.
 
SQL> select * from test1 where rownum < 10;
select * from test1 where rownum < 10
              *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 1, block # 59146)
ORA-01110: data file 1: '/oradata/orcl/system01.dbf'

把备份的数据文件注册成datafilecopy 并进行块恢复

[oracle@oracle10g ~]$ rman target /
 
Recovery Manager: Release 10.2.0.5.0 - Production on Sun Nov 2 21:01:16 2014
 
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
 
connected to target database: ORCL (DBID=1341279948)
 
RMAN> catalog datafilecopy '/oradata/orcl/system01.dbf.bak';
 
using target database control file instead of recovery catalog
cataloged datafile copy
datafile copy filename=/oradata/orcl/system01.dbf.bak recid=1 stamp=862607075
 
RMAN> blockrecover datafile 1 block 59146;
 
Starting blockrecover at 02-NOV-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=149 devtype=DISK
 
channel ORA_DISK_1: restoring block(s) from datafile copy /oradata/orcl/system01.dbf.bak
 
starting media recovery
media recovery complete, elapsed time: 00:00:07
 
Finished blockrecover at 02-NOV-14
 
RMAN>

数据访问正常

SQL> SELECT COUNT(*) FROM test1 WHERE rownum < 10;
 
  COUNT(*)
----------
         9
此条目发表在 未分类 分类目录,贴了 , 标签。将固定链接加入收藏夹。

评论功能已关闭。