本文主要是介绍Oracle 恢复坏块方法(ORA-01578)—RMAN恢复,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
之前我们测试过利用bbed跳过坏块进行恢复,但是这种方法却会丢失部分数据,那么有什么办法可以确保数据不会被丢失呢?
如果在坏块之前,有rman备份,可以使用rman的备份来进行恢复,确保数据不会被丢失。
1.创建测试表
SQL> conn test/test
Connected.
SQL> create table test as select * from all_objects;Table created.SQL> select count(*) from test;COUNT(*)
----------80440
2.对数据库进行rman备份
cebpm:/data/backup/cebpm/fullback@cebpm>rman target /Recovery Manager: Release 11.2.0.4.0 - Production on Mon Jan 15 09:24:50 2018Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.connected to target database: CEBPM (DBID=3677012495)RMAN> backup database format '/data/backup/cebpm/fullback/cebpm';Starting backup at 2018/01/15 09:25:17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 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=00001 name=/data/CEBPM/datafile/o1_mf_system_dm1flxkw_.dbf
input datafile file number=00002 name=/data/CEBPM/datafile/o1_mf_sysaux_dm1fnw5v_.dbf
input datafile file number=00005 name=/data/CEBPM/datafile/test01.dbf
input datafile file number=00003 name=/data/CEBPM/datafile/undotbs01.dbf
input datafile file number=00004 name=/data/CEBPM/datafile/o1_mf_users_dm1fqcrp_.dbf
channel ORA_DISK_1: starting piece 1 at 2018/01/15 09:25:21
channel ORA_DISK_1: finished piece 1 at 2018/01/15 09:27:07
piece handle=/data/backup/cebpm/fullback/cebpm tag=TAG20180115T092520 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:46
Finished backup at 2018/01/15 09:27:07Starting Control File and SPFILE Autobackup at 2018/01/15 09:27:09
piece handle=/data/backup/cebpm/ctlbackup/control_c-3677012495-20180115-01 comment=NONE
Finished Control File and SPFILE Autobackup at 2018/01/15 09:27:12
3.利用bbed破坏数据
具体可参考:
http://blog.csdn.net/shiyu1157758655/article/details/79043618
4.验证坏块
cebpm:/home/oracle@cebpm>dbv file=/data/CEBPM/datafile/test01.dbf DBVERIFY: Release 11.2.0.4.0 - Production on Mon Jan 15 09:33:09 2018Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.DBVERIFY - Verification starting : FILE = /data/CEBPM/datafile/test01.dbf
Page 131 is marked corrupt
Corrupt block relative dba: 0x01400083 (file 5, block 131)
Bad check value found during dbv:
Data in bad block:type: 6 format: 2 rdba: 0x01400083last change scn: 0x0000.0012dad3 seq: 0x2 flg: 0x04spare1: 0x0 spare2: 0x0 spare3: 0x0consistency value in tail: 0xdad30602check value in block header: 0x4fe7computed block checksum: 0x33c4DBVERIFY - Verification completeTotal Pages Examined : 16384
Total Pages Processed (Data) : 1149
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 155
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 15079
Total Pages Marked Corrupt : 1
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 1235718 (0.1235718)
SQL> select count(*) from test;
select count(*) from test*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 5, block # 131)
ORA-01110: data file 5: '/data/CEBPM/datafile/test01.dbf'
5.使用rman进行恢复
cebpm:/home/oracle@cebpm>rman target /Recovery Manager: Release 11.2.0.4.0 - Production on Mon Jan 15 09:34:48 2018Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.connected to target database: CEBPM (DBID=3677012495)RMAN> blockrecover datafile 5 block 131;Starting recover at 2018/01/15 09:37:00
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
searching flashback logs for block images until SCN 1235817
finished flashback log search, restored 1 blocksstarting media recovery
media recovery complete, elapsed time: 00:00:03Finished recover at 2018/01/15 09:37:10
6.检测坏块是否被修复
cebpm:/home/oracle@cebpm>dbv file=/data/CEBPM/datafile/test01.dbf DBVERIFY: Release 11.2.0.4.0 - Production on Mon Jan 15 09:38:42 2018Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.DBVERIFY - Verification starting : FILE = /data/CEBPM/datafile/test01.dbfDBVERIFY - Verification completeTotal Pages Examined : 16384
Total Pages Processed (Data) : 1150
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 155
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 15079
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 1235718 (0.1235718)
RMAN> backup check logical validate datafile 5;Starting backup at 2018/01/15 09:38:24
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/data/CEBPM/datafile/test01.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5 OK 0 15079 16384 1235718 File Name: /data/CEBPM/datafile/test01.dbfBlock Type Blocks Failing Blocks Processed---------- -------------- ----------------Data 0 1150 Index 0 0 Other 0 155 Finished backup at 2018/01/15 09:38:26
7.验证数据是否正确
SQL> conn test/test
Connected.
SQL> select count(*) from test;COUNT(*)
----------80440
由上可知数据已经完全恢复,不存在丢失数据的情况。
这篇关于Oracle 恢复坏块方法(ORA-01578)—RMAN恢复的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!