[20171122]恢復資料檔案塊頭5.txt
[20171122]恢復資料檔案塊頭5.txt
--//前幾天做了恢復資料檔案塊頭,透過備份檔案直接取出檔案塊頭,覆蓋原來的資料塊,然後修復.
--//今天測試使用image copy來恢復.也是直接使用直接取出檔案塊頭覆蓋原來的資料塊.
1.環境:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
2.建立測試環境:
CREATE TABLESPACE TEA DATAFILE
'/mnt/ramdisk/book/tea01.dbf' SIZE 40M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
create table t1 tablespace tea as select rownum id ,lpad('A',32,'A') name from dual connect by level<=1e5;
--//建立rman備份:
backup as copy database format '/home/oracle/backup/%b';
--//注:這是我個人主張的備份方式設定filesperset=1,可惜我們團隊一直不建議使用.這樣備份檔案顯得太多了.實際上這樣做與我後面的恢復有關.
create table t2 tablespace tea as select rownum id ,lpad('B',32,'B') name from dual connect by level<=1e5;
--//建立大小5M的表。注:說明一點,我是先做資料庫備份,再建立t2表.
--//破壞資料檔案頭,注:資料檔案頭在資料檔案的第2塊.第1塊OS頭.
update t2 set name=lpad('C',32,'C') where id <=5;
alter system checkpoint;
alter system checkpoint;
alter system checkpoint;
rollback ;
update t2 set name=lpad('D',32,'D') where id between 5 and 9;
commit ;
alter database datafile 6 offline ;
$ dd if=/dev/zero of=/mnt/ramdisk/book/tea01.dbf count=1 bs=8192 conv=notrunc seek=1
1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 3.8338e-05 seconds, 214 MB/s
2. 使用image copy恢復:
--//image copy 就簡單了,因為一一對應.第一塊就是檔案頭.
RMAN> list datafilecopy 30;
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
30 6 A 2017-11-22 11:28:12 13279859806 2017-11-22 11:28:12
Name: /home/oracle/backup/tea01.dbf
Tag: TAG20171122T112746
--//透過dd ,還是bbed都是很相對簡單.僅僅測試使用bbed.
--//dd if=/home/oracle/backup/tea01.dbf skip=1 of=/mnt/ramdisk/book/tea01.dbf seek=1 count=1 bs=8192 conv=notrunc
3.dbv 與rman檢查:
RMAN> validate datafile 6;
Starting validate at 2017-11-22 11:37:15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
RMAN-06169: could not read file header for datafile 6 error reason 7
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of validate command at 11/22/2017 11:37:15
RMAN-06056: could not access datafile 6
$ dbv file=/mnt/ramdisk/book/tea01.dbf
DBVERIFY: Release 11.2.0.4.0 - Production on Wed Nov 22 11:39:20 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
DBVERIFY - Verification starting : FILE = /mnt/ramdisk/book/tea01.dbf
Page 1 is marked corrupt
Corrupt block relative dba: 0x00000001 (file 0, block 1)
Completely zero block found during dbv:
Page 2 is marked corrupt
Corrupt block relative dba: 0x00000002 (file 0, block 2)
Bad header found during dbv:
Data in bad block:
type: 29 format: 2 rdba: 0x01800002
last change scn: 0x0003.178a94ee seq: 0x2 flg: 0x04
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x94ee1d02
check value in block header: 0xb859
computed block checksum: 0x0
Page 3 is marked corrupt
Corrupt block relative dba: 0x00000003 (file 0, block 3)
Bad header found during dbv:
Data in bad block:
type: 30 format: 2 rdba: 0x01800003
last change scn: 0x0003.178a94ee seq: 0x1 flg: 0x04
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x94ee1e01
check value in block header: 0x5952
computed block checksum: 0x0
--//一旦檔案頭損壞,檢查根本不能透過.
RMAN> recover datafile 6 block 1;
Starting recover at 2017-11-22 11:49:34
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 2017-11-22 11:49:34
RMAN> blockrecover datafile 6 block 1;
Starting recover at 2017-11-22 11:51:31
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 2017-11-22 11:51:31
--//看上去ok實際上什麼也沒做.也就是檔案頭損壞,這樣不行:
BBED> dump /v offset 0 filename '/mnt/ramdisk/book/tea01.dbf' block 1
File: /mnt/ramdisk/book/tea01.dbf (6)
Block: 1 Offsets: 0 to 63 Dba:0x01800001
-----------------------------------------------------------------------------------------------------------
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l ................................
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l ................................
<32 bytes per line>
--//依舊還是0000.
4.恢復:
BBED> map filename '/home/oracle/backup/tea01.dbf' block 1
File: /home/oracle/backup/tea01.dbf (206)
Block: 1 Dba:0x33800001
------------------------------------------------------------
Data File Header
struct kcvfh, 860 bytes @0
ub4 tailchk @8188
--//OK image copy block 1確實檔案頭.
BBED> help copy
COPY [ DBA | FILE | FILENAME | BLOCK ] TO [ DBA | FILE | FILENAME | BLOCK ]
BBED> copy filename '/home/oracle/backup/tea01.dbf' block 1 to filename '/mnt/ramdisk/book/tea01.dbf' block 1
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /mnt/ramdisk/book/tea01.dbf (6)
Block: 1 Offsets: 0 to 63 Dba:0x01800001
------------------------------------------------------------------------------------------------------------------------------------------------
0ba20000 01008001 00000000 00000104 dfb50000 00000000 0004200b 6e21b74f 424f4f4b 00000000 bdb00000 00140000 00200000 06000300 00000000 00000000
<64 bytes per line>
--//唯獨要記住一點操作前要看看offset是否是0,不要可能可能從某個中間位置開始copy.
BBED> show offset
OFFSET 0
BBED> dump /v offset 0 filename '/mnt/ramdisk/book/tea01.dbf' block 1
File: /mnt/ramdisk/book/tea01.dbf (6)
Block: 1 Offsets: 0 to 63 Dba:0x01800001
-----------------------------------------------------------------------------------------------------------
0ba20000 01008001 00000000 00000104 dfb50000 00000000 0004200b 6e21b74f l .......................... .n!.O
424f4f4b 00000000 bdb00000 00140000 00200000 06000300 00000000 00000000 l BOOK............. ..............
<32 bytes per line>
--//ok已經寫入.
SCOTT@book> alter database datafile 6 online ;
alter database datafile 6 online
*
ERROR at line 1:
ORA-01113: file 6 needs media recovery
ORA-01110: data file 6: '/mnt/ramdisk/book/tea01.dbf'
RMAN> recover datafile 6;
Starting recover at 2017-11-22 11:45:16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=94 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=106 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=119 device type=DISK
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 2017-11-22 11:45:17
SCOTT@book> alter database datafile 6 online ;
Database altered.
SCOTT@book> column name format a40
SCOTT@book> select * from t2 where id between 1 and 9;
ID NAME
---------- ----------------------------------------
1 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
2 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
3 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
4 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
5 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
6 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
7 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
8 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
9 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
9 rows selected.
--//OK現在恢復正常了.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2147607/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- rman恢復資料檔案-----塊折斷
- 恢復資料,資料塊恢復
- [20171114]恢復資料檔案塊頭2.txt
- 資料檔案壞塊的製造和恢復
- [20171115]恢復資料檔案塊頭3補充.txt
- [20171115]恢復資料檔案塊頭4補充.txt
- bbed 與檔案頭恢復
- 【資料庫資料恢復】Oracle資料庫檔案出現壞塊報錯的資料恢復案例資料庫資料恢復Oracle
- 資料恢復-電腦管家檔案恢復工具資料恢復
- rman恢復資料檔案 恢復表空間
- 恢復之重建資料檔案
- 【資料庫資料恢復】透過恢復NDF檔案修復資料庫的資料恢復過程資料庫資料恢復
- rman 恢復資料塊
- rman恢復資料塊
- RMAN恢復案例:無恢復目錄,丟失全部資料檔案、控制檔案、日誌檔案恢復
- RMAN恢復案例:丟失全部資料檔案恢復
- 使用blockrecover 對有壞塊的資料檔案進行恢復BloC
- 資料檔案誤刪--但有資料檔案的copy恢復
- 恢復之還原資料檔案
- 資料檔案丟失的恢復
- [ORACLE ASM] AMDU 恢復資料檔案OracleASM
- 新增資料檔案與恢復cf
- Bak檔案恢復到資料庫資料庫
- 資料檔案丟失如何恢復
- 【資料庫資料恢復】MongoDB資料庫檔案損壞的資料恢復案例資料庫資料恢復MongoDB
- rman備份恢復-rman恢復資料檔案測試
- rman恢復時跳過資料檔案,進行恢復
- oracle實驗記錄 (恢復,備份-含壞塊資料檔案)Oracle
- 資料塊恢復例項
- 備份與恢復--重建控制檔案後資料檔案損壞的恢復
- 【伺服器資料恢復】ZFS檔案系統下RAIDZ多塊硬碟離線的資料恢復案例伺服器資料恢復AI硬碟
- 資料恢復新姿勢——通過ibd和frm檔案恢復資料資料恢復
- 恢復案例:歸檔模式下丟失全部資料檔案的恢復模式
- system資料檔案頭損壞修復
- Oracle備份與恢復【丟失資料檔案的恢復】Oracle
- RMAN恢復案例:丟失非系統資料檔案恢復
- RM 刪除資料檔案恢復操作
- 電腦檔案丟失資料恢復資料恢復