使用dul恢復資料(轉載)

weixin_34391854發表於2011-03-14

背景:windows2000上的9201庫,一個檔案損壞,沒有備份,需要用dul抽取資料。

操作步驟:

首先建立2個配置檔案:init.dul 和 control.dul
init.dul 是dul工具的引數檔案,dul啟動的時候要讀取這些引數進行配置。
control.dul 記錄所有資料檔案的位置和編號,dul要通過這個檔案找到資料檔案。

init.dul的內容(不同情況不同版本的庫內容不一樣):
osd_big_endian_flag=false
osd_dba_file_bits=10
osd_c_struct_alignment=32
osd_file_leader_size=1
osd_word_size=32

control_file=Y:DUL20070115_contentinfocontrol.dul
db_block_size=8192
compatible=9


這裡的db_block_size引數要和要恢復的表空間塊大小一致。compatible引數要和資料庫的compatible引數一致,9i的庫要設成9。

control.dul檔案的內容用如下sql生成:
select ts#, rfile#, name from v$datafile;
將查詢出來的內容複製到control.dul檔案中即可。
0 1 Y:ORADATASYSTEM01.DBF
1 2 Y:ORADATAUNDOTBS01.DBF
3 3 Y:ORADATADRSYS01.DBF
4 4 Y:ORADATAINDX01.DBF
5 5 Y:ORADATATOOLS01.DBF
6 6 Y:ORADATAUSERS01.DBF
7 7 Y:ORADATAMDB.ORA
9 8 Y:ORADATAXSDBTEST.ORA
10 9 Y:ORADATATEST.ORA
11 10 Y:ORADATABBS.ORA
8 11 Y:ORADATAXSDB.ORA
13 12 Y:ORADATAGBMDB.ORA

這2個配置檔案要和dul.exe在同一個目錄下。建立好之後就可以dul了。

直接在cmd中敲dul進入dul。
進入dul以後,先執行bootstrap命令。這是建立部分資料字典:OBJ$ TAB$ COL$ USER$
因為oracle的資料塊中儲存的是純資料,也就是不包含欄位名,表名這些資訊,這些資訊是存放到資料字典中的。
所以dul要先從資料字典中讀出這些資訊,按照資料字典中的名稱以及表的物理資訊到資料檔案中找到對應的表。

這是dul日誌的一部分,表的物理資訊都記錄在tab$中,dul通過這些資訊就能找到表的資料:
unload table TAB$( OBJ# number, DATAOBJ# number,
TS# number, FILE# number, BLOCK# number,

建立好資料字典之後,就可以dul了,有幾種模式,比較常用的是按表dul和按使用者dul。
unload table usera.tablea;
unload user usera;

自己的感受:有了dul,介質損壞不再可怕,dba不再擔心下崗,生活也變的美好,公雞也會下蛋了。呵呵!

以下是本次資料恢復時dul的日誌,包括了bootstrap和unload user 的過程:

DUL version 9.2.1.5 with 64-bits i/o

Init.dul parameter settings:
ALLOW_TRAILER_MISMATCH = FALSE
ALLOW_DBA_MISMATCH = FALSE
ASCII2EBCDIC = FALSE
BUFFER = 65536
COMPATIBLE = 9
CONTROL_FILE = Y:DUL20070115control.dul
DB_BLOCK_SIZE = 8192
DC_COLUMNS = 100000
DC_FILES = 1022
DC_OBJECTS = 40000
DC_TABLES = 10000
DC_USERS = 1000
DC_SEGMENTS = 10000
DC_EXTENTS = 10000
CACHE_HEADER_DUMP_LEVEL = 2
TX_HEADER_DUMP_LEVEL = 1
DATA_HEADER_DUMP_LEVEL = 1
ROWDATA_DUMP_LEVEL = 2
EXPORT_MODE = true
FILE = dump
FILE_SIZE_IN_MB =
LDR_ENCLOSE_CHAR = "
LDR_PHYS_REC_SIZE = 0
LOGFILE = dul.log
MAX_OPEN_FILES = 8
OSD_BIG_ENDIAN_FLAG = false
OSD_DBA_FILE_BITS = 10
OSD_FILE_LEADER_SIZE = 1
OSD_C_STRUCT_ALIGNMENT = 32
OSD_WORD_SIZE = 32
PARSE_HEX_ESCAPES = FALSE
USE_SCANNED_EXTENT_MAP = FALSE
TRACE_FLAGS = 0
WARN_RECREATE_FILES = TRUE
WRITABLE_DATA_FILES = FALSE

Entries from control file Y:DUL20070115control.dul:
0 1 Y:ORADATASYSTEM01.DBF startblock 1 block size 8192 (off512=16)
1 2 Y:ORADATAUNDOTBS01.DBF startblock 1 block size 8192 (off512=16)
3 3 Y:ORADATADRSYS01.DBF startblock 1 block size 8192 (off512=16)
4 4 Y:ORADATAINDX01.DBF startblock 1 block size 8192 (off512=16)
5 5 Y:ORADATATOOLS01.DBF startblock 1 block size 8192 (off512=16)
6 6 Y:ORADATAUSERS01.DBF startblock 1 block size 8192 (off512=16)
7 7 Y:ORADATAMDB.ORA startblock 1 block size 8192 (off512=16)
9 8 Y:ORADATAXSDBTEST.ORA startblock 1 block size 8192 (off512=16)
10 9 Y:ORADATATEST.ORA startblock 1 block size 8192 (off512=16)
11 10 Y:ORADATABBS.ORA startblock 1 block size 8192 (off512=16)
8 11 Y:ORADATAXSDB.ORA startblock 1 block size 8192 (off512=16)
13 12 Y:ORADATAGBMDB.ORA startblock 1 block size 8192 (off512=16)

DUL> bootstrap;
Scanning SYSTEM tablespace to locate compatibility segment ...
tablespace 0, data file 1: 319999 blocks scanned
Loaded 1355 entries from EXT.dat
Sorted 1355 entries
Loaded 1051 entries from SEG.dat
Loaded 1 entries from COMPATSEG.dat
Compatibility segment found at file = 1, block = 417
database version 9 bootstrap$ at file 1, block 377
. unloading table BOOTSTRAP$ 57 rows unloaded
Loaded 57 entries from BOOTSTRAP.dat
Parsing Bootstrap$ contents
Generating dict.ddl for version 9
OBJ$: segobjno 18, file 1
TAB$: segobjno 2, tabno 1, file 1
COL$: segobjno 2, tabno 5, file 1
USER$: segobjno 10, tabno 1, file 1
Running generated file "@dict.ddl" to unload the dictionary tables
REM DDL Script to unload the dictionary cache for DUL

REM force the settings to get the expected DUL self readable format
alter session set profile DUL_READABLE_FORMAT;

unload table OBJ$( OBJ# number, DATAOBJ# number, OWNER# number,
NAME varchar2(30), NAMESPACE ignore, SUBNAME varchar2(30),
TYPE# number)
storage( segobjno 18 file 1);
. unloading table OBJ$ 28155 rows unloaded

unload table TAB$( OBJ# number, DATAOBJ# number,
TS# number, FILE# number, BLOCK# number,
BOBJ# number, TAB# number, COLS number, CLUCOLS number,
PCTFREE$ ignore, PCTUSED$ ignore, INITRANS ignore, MAXTRANS ignore,
FLAGS ignore, AUDIT$ ignore, ROWCNT ignore, BLKCNT ignore,
EMPCNT ignore, AVGSPC ignore, CHNCNT ignore, AVGRLN ignore,
AVGSPC_FLB ignore, FLBCNT ignore,
ANALYZETIME ignore, SAMPLESIZE ignore,
DEGREE ignore, INSTANCES ignore,
INTCOLS ignore, KERNELCOLS ignore, PROPERTY number)
cluster C_OBJ#(OBJ#)
storage ( segobjno 2 tabno 1 file 1);
. unloading table TAB$ 1010 rows unloaded

unload table COL$ ( OBJ# number, COL# number , SEGCOL# number,
SEGCOLLENGTH ignore, OFFSET ignore, NAME char(30),
TYPE# number, LENGTH number, FIXEDSTORAGE ignore,
PRECISION# ignore, SCALE ignore, NULL$ ignore, DEFLENGTH ignore,
DEFAULT$ ignore, INTCOL# number, PROPERTY number)
cluster C_OBJ#(OBJ#)
storage(segobjno 2 tabno 5 file 1);
. unloading table COL$ 34136 rows unloaded

unload table USER$( USER# number, NAME varchar2(30))
cluster C_USER#(USER#)
storage( segobjno 10 tabno 1 file 1);
. unloading table USER$ 45 rows unloaded


REM restore the user settings
alter session set profile USER;
REM load the files into the cache
reload;
Loaded 45 entries from USER.dat
Loaded 28155 entries from OBJ.dat
Loaded 1010 entries from TAB.dat
Loaded 34136 entries from COL.dat
Loaded 1051 entries from SEG.dat
Loaded 1355 entries from EXT.dat
Sorted 1355 entries
Loaded 1 entries from COMPATSEG.dat
Loaded 57 entries from BOOTSTRAP.dat
DUL: Warning: Recreating file "dict.ddl"
Generating dict.ddl for version 9
OBJ$: segobjno 18, file 1
TAB$: segobjno 2, tabno 1, file 1
COL$: segobjno 2, tabno 5, file 1
USER$: segobjno 10, tabno 1, file 1
TABPART$: segobjno 230, file 1
TABCOMPART$: segobjno 249, file 1
TABSUBPART$: segobjno 240, file 1
IND$: segobjno 2, tabno 3, file 1
ICOL$: segobjno 2, tabno 4, file 1
LOB$: segobjno 2, tabno 6, file 1
Running generated file "@dict.ddl" to unload the dictionary tables
REM DDL Script to unload the dictionary cache for DUL

REM force the settings to get the expected DUL self readable format
alter session set profile DUL_READABLE_FORMAT;

unload table OBJ$( OBJ# number, DATAOBJ# number, OWNER# number,
NAME varchar2(30), NAMESPACE ignore, SUBNAME varchar2(30),
TYPE# number)
storage( segobjno 18 file 1);
. unloading table OBJ$
DUL: Warning: Recreating file "OBJ.ctl"
28155 rows unloaded

unload table TAB$( OBJ# number, DATAOBJ# number,
TS# number, FILE# number, BLOCK# number,
BOBJ# number, TAB# number, COLS number, CLUCOLS number,
PCTFREE$ ignore, PCTUSED$ ignore, INITRANS ignore, MAXTRANS ignore,
FLAGS ignore, AUDIT$ ignore, ROWCNT ignore, BLKCNT ignore,
EMPCNT ignore, AVGSPC ignore, CHNCNT ignore, AVGRLN ignore,
AVGSPC_FLB ignore, FLBCNT ignore,
ANALYZETIME ignore, SAMPLESIZE ignore,
DEGREE ignore, INSTANCES ignore,
INTCOLS ignore, KERNELCOLS ignore, PROPERTY number)
cluster C_OBJ#(OBJ#)
storage ( segobjno 2 tabno 1 file 1);
. unloading table TAB$
DUL: Warning: Recreating file "TAB.ctl"
1010 rows unloaded

unload table COL$ ( OBJ# number, COL# number , SEGCOL# number,
SEGCOLLENGTH ignore, OFFSET ignore, NAME char(30),
TYPE# number, LENGTH number, FIXEDSTORAGE ignore,
PRECISION# ignore, SCALE ignore, NULL$ ignore, DEFLENGTH ignore,
DEFAULT$ ignore, INTCOL# number, PROPERTY number)
cluster C_OBJ#(OBJ#)
storage(segobjno 2 tabno 5 file 1);
. unloading table COL$
DUL: Warning: Recreating file "COL.ctl"
34136 rows unloaded

unload table USER$( USER# number, NAME varchar2(30))
cluster C_USER#(USER#)
storage( segobjno 10 tabno 1 file 1);
. unloading table USER$
DUL: Warning: Recreating file "USER.ctl"
45 rows unloaded

unload table TABPART$( OBJ# number, DATAOBJ# number, BO# number,
PART# number, HIBOUNDLEN ignore, SPARE3 ignore,
TS# number, FILE# number, BLOCK# number)
storage( segobjno 230 file 1);
. unloading table TABPART$ 37 rows unloaded

unload table TABCOMPART$( OBJ# number, DATAOBJ# ignore, BO# number,
PART# number)
storage( segobjno 249 file 1);
. unloading table TABCOMPART$ 0 rows unloaded

unload table TABSUBPART$( OBJ# number, DATAOBJ# number, POBJ# number,
SUBPART# number, FLAGS ignore,
TS# number, FILE# number, BLOCK# number)
storage( segobjno 240 file 1);
. unloading table TABSUBPART$ 0 rows unloaded

unload table IND$( BO# number, OBJ# number,
DATAOBJ# number, TS# number, FILE# number, BLOCK# number,
INDMETHOD# ignore, COLS number, PCTFREE$ ignore, INITRANS ignore,
MAXTRANS ignore, PCTTHRESH$ ignore,
TYPE# number, FLAGS ignore, PROPERTY number)
cluster C_OBJ#(BO#)
storage ( segobjno 2 tabno 3 file 1);
. unloading table IND$ 1120 rows unloaded

unload table ICOL$( BO# number, OBJ# number, COL# number, POS# number)
cluster C_OBJ#(BO#)
storage ( segobjno 2 tabno 4 file 1);
. unloading table ICOL$ 1707 rows unloaded

unload table LOB$( OBJ# number, COL# number, INTCOL# ignore,
lobj# number, part# ignore, ind# number,
ts# number, file# number, block# number)
cluster C_OBJ#(OBJ#)
storage ( segobjno 2 tabno 6 file 1);
. unloading table LOB$ 76 rows unloaded


REM restore the user settings
alter session set profile USER;
REM load the files into the cache
reload;
Loaded 45 entries from USER.dat
Loaded 28155 entries from OBJ.dat
Loaded 1010 entries from TAB.dat
Loaded 34136 entries from COL.dat
Loaded 1051 entries from SEG.dat
Loaded 1355 entries from EXT.dat
Sorted 1355 entries
Loaded 37 entries from TABPART.dat
Loaded 0 entries from TABCOMPART.dat
Loaded 0 entries from TABSUBPART.dat
Loaded 1120 entries from IND.dat
Loaded 76 entries from LOB.dat
Loaded 1707 entries from ICOL.dat
Loaded 1 entries from COMPATSEG.dat
Loaded 57 entries from BOOTSTRAP.dat
DUL> unload user gbmdb
2 ;
About to unload GBMDB's tables ...
. unloading table C_XYQUOTATION_CHANGE_BAK 1 row unloaded
. unloading table C_BANK 2038 rows unloaded
. unloading table C_BEHALF 11182 rows unloaded
. unloading table C_CLASS 10 rows unloaded
. unloading table C_FSUPPLIER 28 rows unloaded
. unloading table C_FSUPPLIER_REGION 39 rows unloaded
. unloading table C_MEMB 2012 rows unloaded
. unloading table C_MEMBER_SUPPLIER 77 rows unloaded
. unloading table C_MPLATE 830 rows unloaded
. unloading table C_NODE 34 rows unloaded
. unloading table C_ORDER_DEL 350 rows unloaded
. unloading table C_ORDER_DEL_LOG 0 rows unloaded
. unloading table C_PRODUCT 9171 rows unloaded
. unloading table C_PRODUCT_CONTROL 10286 rows unloaded
. unloading table C_QUOTAS_LOG 15583 rows unloaded
. unloading table C_QUOTATION 272017 rows unloaded
. unloading table C_QUOTATIONS 484517 rows unloaded
. unloading table C_QUOTATION_LOG 7589 rows unloaded
. unloading table C_REGION 60 rows unloaded
. unloading table C_SUPPLIER 173 rows unloaded
. unloading table C_CONSIGN 863 rows unloaded
. unloading table C_XYORDER_DEL 1473 rows unloaded
. unloading table C_XYORDER_DEL_LOG 6 rows unloaded
. unloading table C_XYQUOTATION 13400 rows unloaded
. unloading table C_XYQUOTATIONS 54504 rows unloaded
. unloading table C_XYQUOTATIONS_CHANGE 35482 rows unloaded
. unloading table C_XYQUOTATION_CHANGE 12670 rows unloaded
. unloading table C_XYQUOTATION_CHANGE_LOG 161 rows unloaded
. unloading table C_XYQUOTATION_LOG 9 rows unloaded
. unloading table PLAN_TABLE 0 rows unloaded
. unloading table MQUOTAS 1068 rows unloaded
. unloading table AMQUOTAS 331 rows unloaded
. unloading table MQUOTASOPR 3240 rows unloaded
. unloading table CHARG_RULE 0 rows unloaded
. unloading table CODETYPE 16 rows unloaded
. unloading table CODEITEM 129 rows unloaded
. unloading table C_TO 1016 rows unloaded
. unloading table MEMB 2012 rows unloaded
. unloading table ROLE 10 rows unloaded
. unloading table USERINFO 132 rows unloaded
. unloading table ROLERESOLIST 160 rows unloaded
. unloading table P_DIRECTOR 51 rows unloaded
. unloading table USERROLELIST 139 rows unloaded
. unloading table DIRECTOR_MEMB 1143 rows unloaded
. unloading table C_QUOTATIONS_BAK 39 rows unloaded
. unloading table C_XYQUOTATION_BAK 5964 rows unloaded
. unloading table C_XYORDER_DEL_BAK 23 rows unloaded
. unloading table MLOG$_MQUOTAS 0 rows unloaded
DUL: Error: Skipping temporary table RUPD$_MQUOTAS
. unloading table DELI_PRODUCT_VALUE 12861 rows unloaded
. unloading table OUT_USERINFO 76 rows unloaded
. unloading table PRE_MQUOTAS 715 rows unloaded
. unloading table NOTICE 79 rows unloaded
. unloading table NEWS 29 rows unloaded
. unloading table MQUOTAS_BAK 2425 rows unloaded
. unloading table ADVICE 11 rows unloaded
. unloading table DELI_PRODUCT 12854 rows unloaded
. unloading table MLOG$_DELI_PRODUCT_VALUE 39165 rows unloaded
DUL: Error: Skipping temporary table RUPD$_DELI_PRODUCT_VALUE
. unloading table REPORTCDT 4 rows unloaded
. unloading table DELIREGION 6 rows unloaded
. unloading table C_TAX 1299 rows unloaded
. unloading table SUPPLY_GOODS 190 rows unloaded
. unloading table REQUIRE_GOODS 2266 rows unloaded
. unloading table PROVINCE_CITY 31 rows unloaded
. unloading table DP 2442 rows unloaded
. unloading table ZC_PERM 251134 rows unloaded
. unloading table ZC_PERMS 497100 rows unloaded
. unloading table MLOG$_C_PRODUCT 69545 rows unloaded
DUL: Error: Skipping temporary table RUPD$_C_PRODUCT
. unloading table MLOG$_C_PRODUCT_CONTROL 32548 rows unloaded
DUL: Error: Skipping temporary table RUPD$_C_PRODUCT_CONTROL
. unloading table C_DELI_PRODUCT 10286 rows unloaded
. unloading table MLOG$_C_XYQUOTATIONS 47462 rows unloaded
DUL: Error: Skipping temporary table RUPD$_C_XYQUOTATIONS
. unloading table MLOG$_C_QUOTATION 715709 rows unloaded
DUL: Error: Skipping temporary table RUPD$_C_QUOTATION
. unloading table MLOG$_MEMB 9562 rows unloaded
DUL: Error: Skipping temporary table RUPD$_MEMB
. unloading table DELI_PRODUCT_BAK 5012 rows unloaded
. unloading table MLOG$_AMQUOTAS 522 rows unloaded
DUL: Error: Skipping temporary table RUPD$_AMQUOTAS
. unloading table MEMB_BAK 2011 rows unloaded
. unloading table PERMST2 107621 rows unloaded
. unloading table BUDGET_B 4120 rows unloaded
. unloading table LOG_ZC_PERMS 1160838 rows unloaded
. unloading table LOG_ZC_PERM 397771 rows unloaded
. unloading table PERMST 107614 rows unloaded
. unloading table BUDGET_B_CITY 3785 rows unloaded
. unloading table BUDGET_S 0 rows unloaded
. unloading table BUDGET_S_CITY 0 rows unloaded
. unloading table B_FORECAST 27 rows unloaded
. unloading table COLUMNINFO 6 rows unloaded
Preparing lob metadata from lob index
. unloading (index organized) table LOB030127eb 0 rows unloaded
Loaded 0 entries from LOB030127eb.dat
Sorted 0 entries
. unloading table CONTENTINFO
DUL: Error: Column CONTENT of type CLOB cannot be unloaded in export_mode
DUL: Warning: Column will be ignored
42 rows unloaded
. unloading table BO 164 rows unloaded
. unloading table SOO 103 rows unloaded
. unloading table SO 102 rows unloaded
. unloading table C_QUOTALO 617 rows unloaded
. unloading table C_QUOTATION_BAK 91 rows unloaded
. unloading table C_QUOTAS 1068 rows unloaded
. unloading table TEST_QUO 404195 rows unloaded
. unloading table TBAG 405649 rows unloaded
. unloading table BBAG 405635 rows unloaded
. unloading table TTBAG 75721 rows unloaded
DUL> exit

Life is DUL without it

相關文章