rman恢復資料檔案-----塊折斷
這幾天重新複習了一下rman備份與恢復,感覺要學的東西實在是太多,
模擬了一下實驗,將實驗過程記錄下來,以便日後查閱。
試驗目的
rman功能很強大,10g以後可以通過rman對某個損壞資料檔案的具體塊做恢復。
試驗環境
OS: redhat linuxas4
DB: oracle10g r2
試驗步驟
1:在sxit使用者下建立一個表cc,往表裡插入資料,並提交。
SQL> select count(*) from sxit.cc;
COUNT(*)
----------
449480
2:根據 dba_data_files 檢視和 all_tables 檢視檢視sxit使用者下所建立的表cc 屬於哪個資料檔案。
3:以nocatalog方式連線到資料庫中,用rman工具進行資料庫全備
[oracle@catalog ~]$ export PATH=$ORACLE_HOME/binATH:.
[oracle@catalog ~]$ rman target / nocatalog
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jul 15 17:58:25 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORA10HHA (DBID=3339398398)
using target database control file instead of recovery catalog
RMAN> backup database;
備份後,預設就在閃回區生成一個備份集檔案。
4:用 shutdown immediate命令關閉資料庫
5:將sxit使用者下cc表所屬的資料檔案下載到本地xp系統上,並通過 ultraedit 工具編輯 資料檔案users01.dbf 中的內容,模擬資料塊損壞。
注意:不要編輯資料檔案的頭部前八個位元組。(資料庫啟動的時候,會檢查控制檔案和資料檔案頭部,如果不一致資料庫就會打不開)
然後儲存,重新上傳到原始目錄下。
6:再次查詢cc表,發現表無法訪問,並報塊折斷錯誤提示。
SQL> select count(*) from sxit.CC;
select count(*) from sxit.CC
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 4, block # 1600)
ORA-01110: data file 4: '/home/oracle/oradata/ora10hha/users01.dbf'
7:在作業系統層面驗證資料是否有損壞。
[oracle@catalog ora10hha]$ dbv file='/home/oracle/oradata/ora10hha/users01.dbf'
DBVERIFY: Release 10.2.0.1.0 - Production on Fri Jul 15 17:52:25 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
DBVERIFY - Verification starting : FILE = /home/oracle/oradata/ora10hha/users01.dbf
Page 359 is marked corrupt
Corrupt block relative dba: 0x01000167 (file 4, block 359)
Bad check value found during dbv:
Data in bad block:
type: 6 format: 2 rdba: 0x01000167
last change scn: 0x0000.000ea3fd seq: 0x4c flg: 0x04
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0xa3fd064c
check value in block header: 0x59b1
computed block checksum: 0x7981
Page 1600 is marked corrupt
Corrupt block relative dba: 0x01000640 (file 4, block 1600)
Bad check value found during dbv:
Data in bad block:
type: 6 format: 2 rdba: 0x01000640
last change scn: 0x0000.000ff474 seq: 0x1 flg: 0x04
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0xf4740601
check value in block header: 0xf984
computed block checksum: 0x9871
DBVERIFY - Verification complete
Total Pages Examined : 16320
Total Pages Processed (Data) : 15470
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 14
Total Pages Failing (Index): 0
Total Pages Processed (Other): 238
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 596
Total Pages Marked Corrupt : 2
Total Pages Influx : 0
Highest block SCN : 1310735 (0.1310735)
[oracle@catalog ora10hha]$
從執行結果可以看出,第4號資料檔案的第359個塊和第1600個塊有損壞。
也可以從rman中進行資料庫塊是否有損壞
[oracle@catalog ~]$ rman target / nocatalog
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jul 15 17:58:25 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORA10HHA (DBID=3339398398)
using target database control file instead of recovery catalog
RMAN> backup validate database;
Starting backup at 15-JUL-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=153 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00005 name=/home/oracle/oradata/ora10hha/cata.dbf
input datafile fno=00001 name=/home/oracle/oradata/ora10hha/system01.dbf
input datafile fno=00002 name=/home/oracle/oradata/ora10hha/undotbs01.dbf
input datafile fno=00003 name=/home/oracle/oradata/ora10hha/sysaux01.dbf
input datafile fno=00004 name=/home/oracle/oradata/ora10hha/users01.dbf
input datafile fno=00006 name=/home/oracle/oradata/ora10hha/tz.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:16
Finished backup at 15-JUL-11
然後在以下檢視中有記錄:
select * from v$database_block_corruption
結果見附件中。
8:用rman恢復對應的資料塊。
如果不用rman備份資料檔案的話,那麼在恢復資料的時候,就需要將這個資料檔案全部拷貝過去,然後進行
恢復。如果碰到上百個G的大資料檔案,為了幾個損壞的塊進行恢復需要耗費很久的時間。
但是如果使用rman工具,就可以對單個的資料檔案塊進行恢復,很方便。
[oracle@catalog ~]$ rman target / nocatalog
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jul 15 17:58:25 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORA10HHA (DBID=3339398398)
using target database control file instead of recovery catalog
RMAN> blockrecover datafile 4 block 359;
Starting blockrecover at 15-JUL-11
using channel ORA_DISK_1
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00004
channel ORA_DISK_1: reading from backup piece /home/oracle/flash_recovery_area/ORA10HHA/backupset/2011_07_15/o1_mf_nnndf_TAG20110715T163759_71zz37r4_.bkp
channel ORA_DISK_1: restored block(s) from backup piece 1
piece handle=/home/oracle/flash_recovery_area/ORA10HHA/backupset/2011_07_15/o1_mf_nnndf_TAG20110715T163759_71zz37r4_.bkp tag=TAG20110715T163759
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:27
starting media recovery
media recovery complete, elapsed time: 00:00:04
Finished blockrecover at 15-JUL-11
RMAN> blockrecover datafile 4 block 1600;
Starting blockrecover at 15-JUL-11
using channel ORA_DISK_1
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00004
channel ORA_DISK_1: reading from backup piece /home/oracle/flash_recovery_area/ORA10HHA/backupset/2011_07_15/o1_mf_nnndf_TAG20110715T163759_71zz37r4_.bkp
channel ORA_DISK_1: restored block(s) from backup piece 1
piece handle=/home/oracle/flash_recovery_area/ORA10HHA/backupset/2011_07_15/o1_mf_nnndf_TAG20110715T163759_71zz37r4_.bkp tag=TAG20110715T163759
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:35
starting media recovery
media recovery complete, elapsed time: 00:00:04
Finished blockrecover at 15-JUL-11
RMAN>
9:恢復以後,然後檢視cc表,可以訪問。
SQL> select count(*) from sxit.cc;
COUNT(*)
----------
449480
SQL>

rman.jpg
模擬了一下實驗,將實驗過程記錄下來,以便日後查閱。
試驗目的
rman功能很強大,10g以後可以通過rman對某個損壞資料檔案的具體塊做恢復。
試驗環境
OS: redhat linuxas4
DB: oracle10g r2
試驗步驟
1:在sxit使用者下建立一個表cc,往表裡插入資料,並提交。
SQL> select count(*) from sxit.cc;
COUNT(*)
----------
449480
2:根據 dba_data_files 檢視和 all_tables 檢視檢視sxit使用者下所建立的表cc 屬於哪個資料檔案。
3:以nocatalog方式連線到資料庫中,用rman工具進行資料庫全備
[oracle@catalog ~]$ export PATH=$ORACLE_HOME/binATH:.
[oracle@catalog ~]$ rman target / nocatalog
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jul 15 17:58:25 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORA10HHA (DBID=3339398398)
using target database control file instead of recovery catalog
RMAN> backup database;
備份後,預設就在閃回區生成一個備份集檔案。
4:用 shutdown immediate命令關閉資料庫
5:將sxit使用者下cc表所屬的資料檔案下載到本地xp系統上,並通過 ultraedit 工具編輯 資料檔案users01.dbf 中的內容,模擬資料塊損壞。
注意:不要編輯資料檔案的頭部前八個位元組。(資料庫啟動的時候,會檢查控制檔案和資料檔案頭部,如果不一致資料庫就會打不開)
然後儲存,重新上傳到原始目錄下。
6:再次查詢cc表,發現表無法訪問,並報塊折斷錯誤提示。
SQL> select count(*) from sxit.CC;
select count(*) from sxit.CC
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 4, block # 1600)
ORA-01110: data file 4: '/home/oracle/oradata/ora10hha/users01.dbf'
7:在作業系統層面驗證資料是否有損壞。
[oracle@catalog ora10hha]$ dbv file='/home/oracle/oradata/ora10hha/users01.dbf'
DBVERIFY: Release 10.2.0.1.0 - Production on Fri Jul 15 17:52:25 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
DBVERIFY - Verification starting : FILE = /home/oracle/oradata/ora10hha/users01.dbf
Page 359 is marked corrupt
Corrupt block relative dba: 0x01000167 (file 4, block 359)
Bad check value found during dbv:
Data in bad block:
type: 6 format: 2 rdba: 0x01000167
last change scn: 0x0000.000ea3fd seq: 0x4c flg: 0x04
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0xa3fd064c
check value in block header: 0x59b1
computed block checksum: 0x7981
Page 1600 is marked corrupt
Corrupt block relative dba: 0x01000640 (file 4, block 1600)
Bad check value found during dbv:
Data in bad block:
type: 6 format: 2 rdba: 0x01000640
last change scn: 0x0000.000ff474 seq: 0x1 flg: 0x04
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0xf4740601
check value in block header: 0xf984
computed block checksum: 0x9871
DBVERIFY - Verification complete
Total Pages Examined : 16320
Total Pages Processed (Data) : 15470
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 14
Total Pages Failing (Index): 0
Total Pages Processed (Other): 238
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 596
Total Pages Marked Corrupt : 2
Total Pages Influx : 0
Highest block SCN : 1310735 (0.1310735)
[oracle@catalog ora10hha]$
從執行結果可以看出,第4號資料檔案的第359個塊和第1600個塊有損壞。
也可以從rman中進行資料庫塊是否有損壞
[oracle@catalog ~]$ rman target / nocatalog
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jul 15 17:58:25 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORA10HHA (DBID=3339398398)
using target database control file instead of recovery catalog
RMAN> backup validate database;
Starting backup at 15-JUL-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=153 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00005 name=/home/oracle/oradata/ora10hha/cata.dbf
input datafile fno=00001 name=/home/oracle/oradata/ora10hha/system01.dbf
input datafile fno=00002 name=/home/oracle/oradata/ora10hha/undotbs01.dbf
input datafile fno=00003 name=/home/oracle/oradata/ora10hha/sysaux01.dbf
input datafile fno=00004 name=/home/oracle/oradata/ora10hha/users01.dbf
input datafile fno=00006 name=/home/oracle/oradata/ora10hha/tz.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:16
Finished backup at 15-JUL-11
然後在以下檢視中有記錄:
select * from v$database_block_corruption
結果見附件中。
8:用rman恢復對應的資料塊。
如果不用rman備份資料檔案的話,那麼在恢復資料的時候,就需要將這個資料檔案全部拷貝過去,然後進行
恢復。如果碰到上百個G的大資料檔案,為了幾個損壞的塊進行恢復需要耗費很久的時間。
但是如果使用rman工具,就可以對單個的資料檔案塊進行恢復,很方便。
[oracle@catalog ~]$ rman target / nocatalog
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jul 15 17:58:25 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORA10HHA (DBID=3339398398)
using target database control file instead of recovery catalog
RMAN> blockrecover datafile 4 block 359;
Starting blockrecover at 15-JUL-11
using channel ORA_DISK_1
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00004
channel ORA_DISK_1: reading from backup piece /home/oracle/flash_recovery_area/ORA10HHA/backupset/2011_07_15/o1_mf_nnndf_TAG20110715T163759_71zz37r4_.bkp
channel ORA_DISK_1: restored block(s) from backup piece 1
piece handle=/home/oracle/flash_recovery_area/ORA10HHA/backupset/2011_07_15/o1_mf_nnndf_TAG20110715T163759_71zz37r4_.bkp tag=TAG20110715T163759
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:27
starting media recovery
media recovery complete, elapsed time: 00:00:04
Finished blockrecover at 15-JUL-11
RMAN> blockrecover datafile 4 block 1600;
Starting blockrecover at 15-JUL-11
using channel ORA_DISK_1
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00004
channel ORA_DISK_1: reading from backup piece /home/oracle/flash_recovery_area/ORA10HHA/backupset/2011_07_15/o1_mf_nnndf_TAG20110715T163759_71zz37r4_.bkp
channel ORA_DISK_1: restored block(s) from backup piece 1
piece handle=/home/oracle/flash_recovery_area/ORA10HHA/backupset/2011_07_15/o1_mf_nnndf_TAG20110715T163759_71zz37r4_.bkp tag=TAG20110715T163759
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:35
starting media recovery
media recovery complete, elapsed time: 00:00:04
Finished blockrecover at 15-JUL-11
RMAN>
9:恢復以後,然後檢視cc表,可以訪問。
SQL> select count(*) from sxit.cc;
COUNT(*)
----------
449480
SQL>

rman.jpg
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24862808/viewspace-708140/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- RMAN備份恢復典型案例——資料檔案存在壞快
- 12 使用RMAN備份和恢復檔案
- 【資料庫資料恢復】Oracle資料庫檔案出現壞塊報錯的資料恢復案例資料庫資料恢復Oracle
- 【資料庫資料恢復】透過恢復NDF檔案修復資料庫的資料恢復過程資料庫資料恢復
- rman恢復控制檔案的一個小錯誤
- 【RMAN】如果控制檔案損壞那麼如何恢復?恢復控制檔案的方式有哪幾種?
- 資料恢復新姿勢——通過ibd和frm檔案恢復資料資料恢復
- 【伺服器資料恢復】StorNext檔案系統資料恢復案例伺服器資料恢復
- 【伺服器資料恢復】ZFS檔案系統下RAIDZ多塊硬碟離線的資料恢復案例伺服器資料恢復AI硬碟
- 【資料庫資料恢復】MongoDB資料庫檔案損壞的資料恢復案例資料庫資料恢復MongoDB
- 【儲存資料恢復】WAFL檔案系統下raid資料恢復案例資料恢復AI
- 【Vsan資料恢復】斷電導致Vsan分散式儲存虛擬磁碟檔案丟失的資料恢復案例資料恢復分散式
- 【伺服器資料恢復】意外斷電導致FreeNAS中UFS2檔案系統故障的資料恢復伺服器資料恢復
- RMAN增量恢復
- Oracle單個資料檔案損壞,在Rman命令裡設定表空間、資料檔案offline方式來恢復最方便Oracle
- 電腦檔案丟失資料恢復資料恢復
- 【資料庫資料恢復】Sql Server資料庫檔案丟失的資料恢復過程資料庫資料恢復SQLServer
- MSSQL資料庫資料恢復案例:ndf檔案大小變為0KB恢復資料SQL資料庫資料恢復
- 【北亞資料恢復】MongoDB資料遷移檔案丟失的MongoDB資料恢復案例資料恢復MongoDB
- 【資料庫資料恢復】mdb_catalog.wt檔案丟失的MongoDB資料恢復案例資料庫資料恢復MongoDB
- 【資料庫資料恢復】EXT3檔案系統下MYSQL資料庫恢復案例資料庫資料恢復MySql
- 【伺服器資料恢復】xfs檔案系統資料丟失的資料恢復案例伺服器資料恢復
- 資料庫資料恢復-SQL SERVER資料庫檔案大小變為“0”的資料恢復方案資料庫資料恢復SQLServer
- Linux伺服器資料恢復案例;ocfs2檔案系統資料恢復Linux伺服器資料恢復
- Oracle 之利用BBED修改資料塊SCN----沒有備份資料檔案的資料恢復Oracle資料恢復
- mysql通過frm、idb檔案恢復資料MySql
- SQL SEVER 缺少LOG檔案資料庫恢復SQL資料庫
- 怎樣恢復Mac檔案及資料夾資料?BackupLoupe for mac(資料恢復備份助手)3.5.4Mac資料恢復
- RMAN備份恢復典型案例——資料庫卡頓資料庫
- RMAN恢復實踐
- 資料庫資料恢復—MongoDB資料庫檔案丟失,啟動報錯的資料恢復案例資料庫資料恢復MongoDB
- 【伺服器資料恢復】reiserfs檔案系統下RAID5資料恢復案例伺服器資料恢復AI
- 【伺服器資料恢復】ZFS檔案系統下伺服器資料恢復案例伺服器資料恢復
- 【伺服器資料恢復】異常斷電導致虛擬機器檔案丟失不能啟動的資料恢復案例伺服器資料恢復虛擬機
- 伺服器資料恢復-ext3檔案系統下oracle資料庫資料恢復案例伺服器資料恢復Oracle資料庫
- RMAN恢復之RMAN-06555處理
- RMAN修復壞塊
- 同名檔案替換怎麼恢復,恢復同名檔案
- 【伺服器資料恢復】VMware虛擬機器磁碟檔案恢復案例伺服器資料恢復虛擬機