zoukankan      html  css  js  c++  java
  • 使用dul恢复数据(转载)

    背景: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

  • 相关阅读:
    Laravel中Contracts的理解和使用
    laravel 服务容器的用法
    linux 安装go环境
    权限设计-系统登录用户权限设计
    Laravel 中使用 JWT 认证的 Restful API
    使用laravel-wechat微信支付
    composer查看全局配置
    如何在 Laravel 项目中处理 Excel 文件
    laravel各种请求类
    Centos创建用户并授权
  • 原文地址:https://www.cnblogs.com/wuhenke/p/1984007.html
Copyright © 2011-2022 走看看