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 恢復資料塊
- rman恢復資料塊
- rman備份恢復-rman恢復資料檔案測試
- rman恢復資料檔案 恢復表空間
- RMAN恢復案例:丟失全部資料檔案恢復
- RMAN blockrecover命令恢復資料塊BloC
- rman恢復時跳過資料檔案,進行恢復
- RMAN恢復 執行重要檔案RMAN恢復
- RMAN恢復案例:無恢復目錄,丟失全部資料檔案、控制檔案、日誌檔案恢復
- RMAN恢復案例:丟失非系統資料檔案恢復
- RMAN完全恢復丟失的資料檔案
- rman 恢復---歸檔丟失and資料檔案損壞
- rman恢復--歸檔模式有備份,丟失資料檔案的恢復模式
- rman恢復--歸檔模式無備份,丟失資料檔案的恢復模式
- RMAN恢復控制檔案
- 利用RMAN修復資料檔案中的壞塊
- 恢復資料,資料塊恢復
- RMAN資料庫恢復 之歸檔模式有(無)備份-丟失資料檔案的恢復資料庫模式
- 誤刪除資料檔案、控制檔案的非RMAN恢復方法
- RMAN恢復 執行不重要檔案的RMAN恢復
- 使用rman恢復控制檔案
- rman恢復資料庫--用備份的控制檔案資料庫
- rman恢復--丟失控制檔案的恢復
- 資料檔案壞塊的製造和恢復
- RMAN恢復表空間,資料檔案,歸檔檔案,控制檔案等介紹
- 無歸檔日誌恢復rman資料
- oracle RMAN 非歸檔資料庫恢復Oracle資料庫
- 【管理篇備份恢復】rman恢復測試(一) 表空間資料檔案
- RMAN備份恢復典型案例——資料檔案存在壞快
- 非系統資料檔案損壞,rman備份恢復
- 利用rman做資料檔案丟失的恢復實驗
- 【資料庫資料恢復】Oracle資料庫檔案出現壞塊報錯的資料恢復案例資料庫資料恢復Oracle
- RMAN恢復資料庫資料庫
- rman備份-(1) 利用備份級恢復資料檔案和控制檔案
- RMAN備份恢復之控制檔案的恢復(三)
- RMAN備份恢復之控制檔案的恢復(二)
- RMAN備份恢復之控制檔案的恢復(一)
- RMAN_部分資料檔案丟失或者損壞的恢復