1.使用rman进行数据库全备
[oracle@rhel 2012_07_18]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jul 18 12:59:59 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: MBS (DBID=1440741932)
RMAN> backup database;
Starting backup at 18-JUL-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/home/db/oracle/oradata/mbs/MBS/datafile/o1_mf_system_80bnvf2j_.dbf
input datafile fno=00002 name=/home/db/oracle/oradata/mbs/MBS/datafile/o1_mf_undotbs1_80bnvm5g_.dbf
input datafile fno=00003 name=/home/db/oracle/oradata/mbs/MBS/datafile/o1_mf_sysaux_80bnvnr8_.dbf
input datafile fno=00004 name=/home/db/oracle/oradata/mbs/users01.dbf
input datafile fno=00005 name=/home/db/oracle/oradata/mbs/users02.dbf
channel ORA_DISK_1: starting piece 1 at 18-JUL-12
channel ORA_DISK_1: finished piece 1 at 18-JUL-12
piece handle=/home/db/oracle/recovery/MBS/backupset/2012_07_18/o1_mf_nnndf_TAG20120718T130004_80djpnlt_.bkp tag=TAG20120718T130004 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 18-JUL-12
channel ORA_DISK_1: finished piece 1 at 18-JUL-12
piece handle=/home/db/oracle/recovery/MBS/backupset/2012_07_18/o1_mf_ncsnf_TAG20120718T130004_80djpwpj_.bkp tag=TAG20120718T130004 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 18-JUL-12
RMAN> exit
2.首先模拟坏块,使用ue编辑数据文件,模拟出坏块
3. 查询表时,由于有坏块,报错:
SQL> select count(*) from test;
select count(*) from test
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 5, block # 183)
ORA-01110: data file 5: '/home/db/oracle/oradata/mbs/users02.dbf'
analyze表时也会报错:
SQL> Analyze table test validate structure cascade;
Analyze table test validate structure cascade
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 5, block # 183)
ORA-01110: data file 5: '/home/db/oracle/oradata/mbs/users02.dbf'
4. 使用DBV检测坏块
[oracle@rhel mbs]$ dbv file=users02.dbf blocksize=8192
DBVERIFY: Release 10.2.0.1.0 - Production on Wed Jul 18 13:11:26 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
DBVERIFY - Verification starting : FILE = users02.dbf
Page 183 is marked corrupt
Corrupt block relative dba: 0x014000b7 (file 5, block 183)
Bad check value found during dbv:
Data in bad block:
type: 6 format: 2 rdba: 0x014000b7
last change scn: 0x0000.00060ed3 seq: 0x2 flg: 0x04
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x0ed30602
check value in block header: 0xc263
computed block checksum: 0x27b
DBVERIFY - Verification complete
Total Pages Examined : 640
Total Pages Processed (Data) : 391
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 8
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 240
Total Pages Marked Corrupt : 1
Total Pages Influx : 0
Highest block SCN : 397035 (0.397035)
5.也可以通过rman对数据文件,数据库进行检查,查询出来后放入表 v$database_block_corruption中;
[oracle@rhel 2012_07_18]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jul 18 13:12:31 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: MBS (DBID=1440741932)
RMAN> backup validate database;
Starting backup at 18-JUL-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=143 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/home/db/oracle/oradata/mbs/MBS/datafile/o1_mf_system_80bnvf2j_.dbf
input datafile fno=00002 name=/home/db/oracle/oradata/mbs/MBS/datafile/o1_mf_undotbs1_80bnvm5g_.dbf
input datafile fno=00003 name=/home/db/oracle/oradata/mbs/MBS/datafile/o1_mf_sysaux_80bnvnr8_.dbf
input datafile fno=00004 name=/home/db/oracle/oradata/mbs/users01.dbf
input datafile fno=00005 name=/home/db/oracle/oradata/mbs/users02.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 18-JUL-12
登陆sqlplus查询v$database_block_corruption:
SQL> select * from v$database_block_corruption;
FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
5 183 1 0 CHECKSUM
6.通过rman对数据块进行修复
oracle@rhel 2012_07_18]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jul 18 13:13:33 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: MBS (DBID=1440741932)
RMAN> blockrecover datafile 5 block 183;
Starting blockrecover at 18-JUL-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=160 devtype=DISK
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00005
channel ORA_DISK_1: reading from backup piece /home/db/oracle/recovery/MBS/backupset/2012_07_18/o1_mf_nnndf_TAG20120718T130004_80djpnlt_.bkp
channel ORA_DISK_1: restored block(s) from backup piece 1
piece handle=/home/db/oracle/recovery/MBS/backupset/2012_07_18/o1_mf_nnndf_TAG20120718T130004_80djpnlt_.bkp tag=TAG20120718T130004
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:02
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished blockrecover at 18-JUL-12
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10972173/viewspace-738650/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10972173/viewspace-738650/