- 浏览: 301842 次
最新评论
-
com_xpp:
思创工作一年小结 -
aijuans1:
思创
思创工作一年小结 -
mixer_a:
一切都是对象
JavaScript 也可以面向对象 -
dyllove98:
不错,面向对象就容易阅读和理解
JavaScript 也可以面向对象 -
spyker:
楼主男人女人?
舞蹈和编程的一点乱想
Oracle DUL/AUL/ODU 工具说明
假设我们的数据库遇到以下情况:
第一,没有备份;
第二,常规方法无法恢复;
第三,数据很重要, 但又无法或成本太高而进行重新输入. 如丢失了Oracle的System表空间, System表空间损坏到无法启动的地步, 意外删除表空间或表, 意外截断(Truncate)表等,
在这3中情况下, 最后的方法就是通过工具直接读取数据文件里的数据,将我们的数据找回来。并且工具不需要Oracle 环境的支持。
据我目前的了解,有3种工具:
(1)Oracle 的内部工具是DUL(Data UnLoader)。 这个需要Oracle 的支持。
(2)老熊写的ODU。 网址:http://www.oracleodu.com/en/
(3)d.c.b.a (支付宝 楼方鑫)写的AUL. 网址:http://www.anysql.net/download
ODU 之前是免费的, 现在老熊和dbsnake 在维护ODU,需要购买才能使用。
d.c.b.a的AUL 是用C 语言写的, 免费版本最大只支持2个,最大256M的datafile。 如果是更大的datafile,也是需要购买授权。
能写出这样的软件都是牛人了,需要了解各个版本Oracle block的详细信息。 AUL 和 ODU的操作和Oracle DUL 类似。
关于DUL,MOS 有说明: MOS Note 72554.1
Using DUL to Recover fromDatabase Corruption
Table Of Contents
~~~~~~~~~~~~~~~~~
1. Introduction
2. Using DUL
2.1 Create an appropriate init.dul file
2.2 Create the control.dul file
2.3 Unload the object information
2.4 Invoke DUL
2.5 Rebuild the database
3. How to rebuild object definitions that are stored in the data dictionary ?
4. How to unload data when the segment header block is corrupted ?
5. How to unload data when the file header block is corrupted ?
6. How to unload data without the system tablespace ?
7. Appendix A : Where to find the executables ?
8. References
1. Introduction
~~~~~~~~~~~~~~~
This document is to explain how to use DUL rather than to give a full
explanation of Bernard's Data UnLoader capabilities.
This document is for internal use only and should not be given to customers at
any time, Dul should always be used by or under the supervision of a support
analyst.
DUL (Data UnLoader) is intended to retrieve data from the Oracle Database that
cannot be retrieved otherwise. This is not an alternative for the export
utility or SQL*Loader. The database may be corrupted but an individual data
block used must be 100% correct. During all unloading checks are made to make
sure that blocks are not corrupted and belong to the correct segment. If a
corrupted block is detected by DUL, an error message is printed in the loader
file and to the standard output, but this will not terminate the unloading of
the next row or block.
2. Using DUL
~~~~~~~~~~~~
First you must retrieve the necessary information about the objects that exists
in the database, these statistics will be loaded into the DUL dictionary to
unload the database objects.
This information is retrieved from the USER$, OBJ$, TAB$ and COL$ tables that
were created at database creation time, they can be unloaded based on the fact
that object numbers are fixed for these tables due to the rigid nature of sql.
bsq. DUL can find the information in the system tablespace, therefor the system
tablespace datafile(s) must be included in the control file, if this datafile(s)
is not present see chapter 6.
2.1 Create an appropriate "init.dul" file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM Platform specific parameters (NT)
REM A List of parameters for the most common platforms can be obtained from
REM http://www.nl.oracle.com/support/dul/index.html
osd_big_endian_flag=false
osd_dba_file_bits=10
osd_c_struct_alignment=32
osd_file_leader_size=1
osd_word_size = 32
REM Sizes of dul dictionary caches. If one of these is too low startup will
REM fail.
dc_columns=2000000
dc_tables=10000
dc_objects=1000000
dc_users=400
dc_segments=100000
REM Location and filename of the control file, default value is control.dul
REM in the current directory
control_file = D:\Dul\control_orcl.dul
REM Database blocksize, can be found in the init<SID>.ora file or can be
REM retrieved by doing "show parameter %db_block_size%" in server manager
REM (svrmgr23/30/l) changes this parameter to whatever the block size is of
REM the crashed database.
db_block_size=4096
REM Can/must be specified when data is needed into export/import format.
REM this will create a file suitable to use by the oracle import utility,
REM although the generated file is completely different from a table mode
REM export generated by the EXP utility. It is a single table dump file
REM with only a create table structure statement and the table data.
REM Grants, storage clauses, triggers are not included into this dump file !
export_mode=true
REM Compatible parameter must be specified an can be either 6, 7 or 8
compatible=8
REM This parameter is optional and can be specified on platforms that do
REM not support long file names (e.g. 8.3 DOS) or when the file format that
REM DUL uses "owner_name.table_name.ext" is not acceptable. The dump files
REM will be something like dump001.ext, dump002.ext, etc in this case.
file = dump
A complete list can be obtained at http://www.nl.oracle.com/support/DUL/ucg8.
html section "DUL Parameters" although this init.dul file will work in most
cases and contains all accurate parameters to succesfully complete the
unloading.
2.2 Create the "control.dul" file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A good knowledge about the logical tablespace and physical datafile
structure is needed or you can do the following queries when the database
is mounted :
Oracle 6, 7
-----------
> connect internal
> spool control.DUL
> select * from v$dbfile;
> spool off
Oracle 8
--------
> connect internal
> spool control.DUL
> select ts#, rfile#, name from v$datafile;
> spool off
Edit the spool file and change, if needed, the datafile location and stripe
out unnecessary information like table headers, feedback line, etc...
A sample control file looks something like this :
REM Oracle7 control file
1 D:\DUL\DATAFILE\SYS1ORCL.DBF
3 D:\DUL\DATAFILE\DAT1ORCL.DBF
7 D:\DUL\DATAFILE\USR1ORCL.DBF
REM Oracle8 control file
0 1 D:\DUL\DATAFILE\SYS1ORCL.DBF
1 2 D:\DUL\DATAFILE\USR1ORCL.DBF
1 3 D:\DUL\DATAFILE\USR2ORCL.DBF
2 4 D:\DUL\DATAFILE\DAT1ORCL.DBF
Note : Each entry can contain a part of a datafile, this can be useful when
you need to split datafiles that are too big for DUL, so that each
part is smaller than for example 2GB. For example :
REM Oracle8 with a datafile split into multiple parts, each part is
REM smaller than 1GB !
0 1 D:\DUL\DATAFILE\SYS1ORCL.DBF
1 2 D:\DUL\DATAFILE\USR1ORCL.DBF startblock 1 endblock 1000000
1 2 D:\DUL\DATAFILE\USR1ORCL.DBF startblock 1000001 endblock 2000000
1 2 D:\DUL\DATAFILE\USR1ORCL.DBF startblock 2000001 endblock 2550000
2.3 Unload the object information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Start the DUL utility with the appropriate ddl (Dul Description Language)
script. There are 3 scripts available to unload the USER$, OBJ$, TAB$ and
COL$ tables according to the database version.
Oracle6 :> dul8.exe dictv6.ddl
Oracle7 :> dul8.exe dictv7.ddl
Oracle8 :> dul8.exe dictv8.ddl
Data UnLoader: Release 8.0.5.3.0 - Internal Use Only - on Tue Jun 22 22:19:
Copyright (c) 1994/1999 Bernard van Duijnen All rights reserved.
Parameter altered
Session altered.
Parameter altered
Session altered.
Parameter altered
Session altered.
Parameter altered
Session altered.
. unloading table OBJ$ 2271 rows unloaded
. unloading table TAB$ 245 rows unloaded
. unloading table COL$ 10489 rows unloaded
. unloading table USER$ 22 rows unloaded
. unloading table TABPART$ 0 rows unloaded
. unloading table IND$ 274 rows unloaded
. unloading table ICOL$ 514 rows unloaded
. unloading table LOB$ 13 rows unloaded
Life is DUL without it
This will unload the data of the USER$, OBJ$, TAB$ and COl$ data dictionary
tables into SQL*Loader files , this can not be manipulated into dump files
of the import format. The parameter export_mode = false is hardcoded into
the ddl scripts and can not be changed to the value "true" since this will
cause DUL to fail with the error:
. unloading table OBJ$
DUL: Error: Column "DATAOBJ#" actual size(2) greater than length in column
definition(1)
.............etc...............
2.4 Invoke DUL
~~~~~~~~~~~~~~
Start DUL in interactive mode or you can prepare a scripts that contains all
the ddl commands to unload the necessary data from the database. I will
describe in this document the most used commands, this is not a complete list
of possible parameters that can be specified. A complete list can be found at
http://www.nl.oracle.com/support/DUL/ucg8.html section "DDL Description".
DUL> unload database;
=> this will unload the entire database tables(includes sys'tables as well)
DUL> unload user <username>;
=> this will unload all the tables owned by that particullarly user.
DUL> unload table <username.table_name>;
=> this will unload the specified table owned by that username
DUL> describe <owner_name.table_name>;
=> will represent the table columns with there relative pointers to the
datafile(s) owned by the specified user.
DUL> scan database;
=> Scans all blocks of all data files.
Two files are generated:
1: seg.dat information of found segment headers (index/cluster/table)
(object id, file number, and block number).
2: ext.dat information of contiguous table/cluster data blocks.
(object id(V7), file and block number of segment header (V6),
file number and block number of first block,
number of blocks, number of tables)
DUL> scan tables;
=> Uses seg.dat and ext.dat as input.
Scans all tables in all data segments (a header block and at least one
matching extent with at least 1 table).
2.5 Rebuild the database
~~~~~~~~~~~~~~~~~~~~~~~~
Create the new database and use import or SQL*Loader to restore the data
retrieved by DUL. Note that when you only unloaded the data that table
structures, indexation, grants, PL/SQL and triggers will no longer exist in
the new database. To obtain an exactly same copy of the database as before
you will need to rerun your creation scripts for the tables, indexes, PL/SQL,
etc.
If you don't have these scripts then you will need to perform the steps
described in section 3 of this document.
3. How to rebuild object definitions that are stored in the data dictionary
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You want to rebuild PL/SQL(packages, procedures, functions or triggers), grants,
indexes, constraints or storage clauses(old table structure) with DUL. This can
be done but is a little bit tricky. You need to unload the relevant data
dictionary tables using DUL and then load these tables into a healthy database,
be sure to use a different user than sys or (system). Loading the data
dictionary tables of the crashed database into the healthy database dictionary
could corrupt the healthy database as well.
Detailed explanation to retrieve for example pl/sql packages / procedures /
functions from a corrupted database :
1) Follow the steps explained in the "Using DUL" section and unload the data
dictionary table "source$"
2) Create a new user into a healthy database and specify the desired default
and temporary tablespace.
3) Grant connect, resource, imp_full_database to the new user.
4) Import/load the table "source$" into the new created schema:
e.g.: imp80 userid=newuser/passw file=d:\dul\scott_emp.dmp
log=d:\dul\impemp.txt full=y
5) You can now query from the table <newuser.source$> to rebuild the pl/sql
procedures/functions from the corrupted database. Scripts can be found on
WebIv to generate such PL/SQL creation scripts.
The same steps can be followed to recreate indexes, constraints, and storage
parameters or to regrant privileges to the appropiate users. Please notice that
you always need to use a script of some kind that can recreate the objects and
include all the features of the crashed database version. For example : when
the crashed database is of version 7.3.4 and you have several bitmap indexes,
if you would use a script that supports version 7.3.2 or prior, then you won't
be able to recreate the bitmap indexes succesful !
4. How to unload data when the segment header block is corrupted
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When DUL can't retrieve data block information on the normal way, it can scan
the database to create its own segment/extent map. The procedure of scanning
the database is necessary to unload the data from the datafiles.
(to illustrate this example I copied an empty block ontop of the segment header
block)
1) Create an appropiate "init.dul" (see 2.1) and "control.dul" (see 2.2) file.
2) Unload the table. This will fail and indicate that there is a corruption in
the segment header block:
DUL> unload table scott.emp;
. unloading table EMP
DUL: Warning: Block is never used, block type is zero
DUL: Error: While checking tablespace 6 file 10 block 2
DUL: Error: While processing block ts#=6, file#=10, block#=2
DUL: Error: Could not read/parse segment header
0 rows unloaded
3) run the scan database command :
DUL> scan database;
tablespace 0, data file 1: 10239 blocks scanned
tablespace 6, data file 10: 2559 blocks scanned
4) Indicate to DUL that it should use its own generated extent map rather than
the segment header information.
DUL> alter session set use_scanned_extent_map = true;
Parameter altered
Session altered.
DUL> unload table scott.emp;
. unloading table EMP 14 rows unloaded
5. How to unload data when the datafile header block is corrupted
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A corruption in the datafile header block is always listed at the moment you
open the database this is not like a header segment block corruption (see point
4) where the database can be succesfully openend and the corruption is listed
at the moment you do a query of a table. Dul has no problems with recovering
from such situations although there are other alternatives of recovering from
this situation like patching the datafile header block.
The error you will receive looks something like :
ORACLE instance started.
Total System Global Area 11739136 bytes
Fixed Size 49152 bytes
Variable Size 7421952 bytes
Database Buffers 4194304 bytes
Redo Buffers 73728 bytes
Database mounted.
ORA-01122: database file 10 failed verification check
ORA-01110: data file 10: 'D:\DATA\TRGT\DATAFILES\JUR1TRGT.DBF'
ORA-01251: Unknown File Header Version read for file number 10
6. How to unload data without the system tablespace
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If datafiles are not available for the system tablespace the unload can still
continue but the object information can't be retrieved from the data dictionary
tables USER$, OBJ$, TAB$ and COL$. So ownername, tablename and columnnames will
not be loaded into the DUL dictionary. Identifying the tables can be an
overwhelming task and a good knowledge of the RDBMS internals are needed here.
First of all you need a good knowledge of your application and it's tables.
Column types can be guessed by DUL, but table and column names will be lost.
Any old system tablespace from the same database (may be weeks old) can be a
great help !
1) Create the "init.dul" file and the "control.dul" file as explained in above
steps 1 and 2. In this case the control file will contain all the datafiles
from which you want to restore but it doesn't require the system tablespace
information.
2) Then You invoke dul and type the following command :
DUL> scan database;
data file 6 1280 blocks scanned
This will build the extent and segment map. Probably the dul command
interpreter will be terminated as well.
3) reinvoke the dul command interpreter and do the following :
Data UnLoader: Release 8.0.5.3.0 - Internal Use Only - on Tue Aug 03 13:33:
Copyright (c) 1994/1999 Oracle Corporation, The Netherlands. All rights res
Loaded 4 segments
Loaded 2 extents
Extent map sorted
DUL> alter session set use_scanned_extent_map = true;
DUL> scan tables; (or scan extents;)
Scanning tables with segment header
Oid 1078 fno 6 bno 2 table number 0
UNLOAD TABLE T_O1078 ( C1 NUMBER, C2 UNKNOWN, C3 UNKNOWN )
STORAGE ( TABNO 0 EXTENTS( FILE 6 BLOCK 2));
Colno Seen MaxIntSz Null% C75% C100 Num% NiNu% Dat% Rid%
1 4 2 0% 0% 0% 100% 100% 0% 0%
2 4 10 0% 100% 100% 100% 0% 0% 0%
3 4 8 0% 100% 100% 100% 0% 0% 50%
"10" "ACCOUNTING" "NEW YORK"
"20" "RESEARCH" "DALLAS"
"30" "SALES" "CHICAGO"
"40" "OPERATIONS" "BOSTON"
Oid 1080 fno 6 bno 12 table number 0
UNLOAD TABLE T_O1080 ( C1 NUMBER, C2 UNKNOWN, C3 UNKNOWN, C4 NUMBER,
C5 DATE, C6 NUMBER, C7 NUMBER, C8 NUMBER )
STORAGE ( TABNO 0 EXTENTS( FILE 6 BLOCK 12));
Colno Seen MaxIntSz Null% C75% C100 Num% NiNu% Dat% Rid%
1 14 3 0% 0% 0% 100% 100% 0% 0%
2 14 6 0% 100% 100% 100% 0% 0% 21%
3 14 9 0% 100% 100% 100% 0% 0% 0%
4 14 3 7% 0% 0% 100% 100% 0% 0%
5 14 7 0% 0% 0% 0% 0% 100% 0%
6 14 3 0% 0% 0% 100% 100% 0% 0%
7 14 2 71% 0% 0% 100% 100% 0% 0%
8 14 2 0% 0% 0% 100% 100% 0% 0%
"7369" "SMITH" "CLERK" "7902" "17-DEC-1980 AD 00:00:00" "800" "" "20"
"7499" "ALLEN" "SALESMAN" "7698" "20-FEB-1981 AD 00:00:00" "1600" "300" "30"
"7521" "WARD" "SALESMAN" "7698" "22-FEB-1981 AD 00:00:00" "1250" "500" "30"
"7566" "JONES" "MANAGER" "7839" "02-APR-1981 AD 00:00:00" "2975" "" "20"
"7654" "MARTIN" "SALESMAN" "7698" "28-SEP-1981 AD 00:00:00" "1250" "1400" "30"
Note : it might be best that you redirect the output to a logfile since
commands like the "scan tables" can produce a lot of output.
On Windows NT you can do the following command :
C:\> dul8 > c:\temp\scan_tables.txt
scan tables;
exit;
4) Identify the lost tables from the output of step 3; if you look carefully to
the output above then you will notice that the unload syntax is already given
but that the table name will be of the format t_0<objectno> and the column
names will be of the format C<no>; datatypes will not be an exact match of
the datatype as it was before.
Look especially for strings like "Oid 1078 fno 6 bno 2 table number 0" where:
oid = object id, will be used to unload the object
fno = (data)file number
bno = block number
5) Unload the identified tables with the "unload table" command :
DUL> unload table dept (deptno number(2), dname varchar2(14),
loc varchar2(13)) storage (OBJNO 1078)
Unloading extent(s) of table DEPT 4 rows
-------------------------------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
Weibo: http://weibo.com/tianlesoftware
Email: dvd.dba@gmail.com
DBA1 群:62697716(满); DBA2 群:62697977(满)DBA3 群:62697850(满)
DBA 超级群:63306533(满); DBA4 群:83829929(满) DBA5群: 142216823(满)
DBA6 群:158654907(满) DBA7 群:69087192(满)DBA8 群:172855474
DBA 超级群2:151508914 DBA9群:102954821 聊天 群:40132017(满)
--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请
相关推荐
PRM-DUL可以脱离Oracle数据库软件实例的存在直接读取Oracle数据文件datafile中的行数据和LOB等大对象。 当你的数据库因为ORA-00600/ORA-07445或其他ORA-报错,或丢失关键的system表空间数据文件,或ASM diskgroup...
aul dul odu打包 ODU全称为Oracle Database Unloader,是由OracleODU开发的类似于Oracle的DUL(Oracle内部著名的数据库恢复工具)的一款恢复软件,用于直接从Oracle数据库的数据文件中获取表数据
Oracle DUL,全称为DataUnmarshaller Utility,是一款由Oracle公司开发的专业数据恢复工具。它主要用于从损坏或崩溃的数据库中恢复数据,是Oracle数据库系统的重要补充工具。DUL数据抽取工具的源码对于深入理解...
"Oracle恢复工具DUL"正是一款专为解决这类问题而设计的专业工具,尤其适用于Windows操作系统环境。 DUL,全称为Data Unloader for Oracle,是由Reltio公司开发的一款开源工具,主要用于Oracle数据库的数据提取、...
PRM-DUL Oracle数据库恢复工具(简称PRM-DUL)是一款专为Oracle数据救援而研发的企业级工具。可在多个操作平台(AIX/HPUX/SOLARIS/Linux/Windows)使用并支持对Oracle 9i/10g/11g/12c各版本数据库的数据救援工作。...
Oracle DUL全称Oracle Data Unloader,泛指作为Oracle数据库文件的数据导出工具,可以在Oracle数据库无法正常启动的情况下对数据文件进行扫描和数据导出。 除了Oracle内部使用服务程序外,市面上还有可选择的第三方...
Oracle DUL,全称为Data Recovery Utility,是Oracle数据库系统中的一款强大的数据恢复工具。它主要用于处理数据库的物理层恢复,特别是在遇到数据文件损坏、误删除或其他严重问题时,DUL能够帮助数据库管理员进行...
然而DUL并非一个商业工具,这个工具仅在Oracle内部流通,但是逐渐的,DUL也开始流入民间,被一些资深Oracle工程师所使用。 随着数据库版本的变化,DUL工具也在逐渐升级之中,对应Oracle8 / Oracle8i / Oracle9i / ...
Oracle DUL工具,全称Database Utility Library,是Oracle数据库领域中的一款强大工具,主要用于数据库的恢复、备份以及数据迁移等任务。它由Parnassus Data公司开发,为数据库管理员提供了一种高效、灵活的方式来...
Oracle DUL工具,全称Data Utility for Oracle,是Oracle数据库恢复领域的一款重要工具,尤其在数据丢失或遇到坏块问题,且没有可用备份时,它成为拯救数据的最后防线。这款工具适用于Oracle数据库的8i和9i版本,...
2、oracle的odu软件 odu_309_win32.zip 3、aul6_final.zip可在windows运行,aul6_linux64.zip没有测试 aul6_final.zip aul6_linux64.zip 4、tomcoding的dul软件,只在linux64位运行 mydul_pe_test_linux.zip
ODU全称为Oracle Database Unloader,是类似于Oracle的DUL的软件,用于直接从Oracle数据库的数据文件中获取表数据。在各种原因造成的数据库不能打开时,用于抢救数据,最大限度地减少数据丢失。 ODU有什么功能特点...
Oracle Data Unloader(DUL)是Oracle数据库管理工具的一个组件,用于高效地导出大量数据。这个源代码可能包含了用于批量卸载Oracle数据库表数据到文件的程序逻辑。OracleBlock.java很可能是源代码中的关键部分,它...
PRM-DUL Oracle数据库恢复工具,一款专为Oracle数据救援而研发的企业级工具。可在多个操作平台(AIX/HPUX/SOLARIS/Linux/Windows)使用并支持对Oracle 9i/10g/11g/12c各版本数据库的数据救援工作。软件基于JAVA 开发...
PRM可以再无备份的情况下恢复被truncated掉的表,也可以恢复无法打开的Oracle数据库(Alter database open... PRM是图形化增强版的Oracle DUL工具,同时具备很多Oracle DUL不具备的特性。 而且PRM无需学任何新命令。
PRM-DUL可以脱离Oracle数据库软件实例的存在直接读取Oracle数据文件datafile中的行数据和LOB等大对象。 当你的数据库因为ORA-00600/ORA-07445或其他ORA-报错,或丢失关键的system表空间数据文件,或ASM diskgroup...
ODU全称为Oracle Database Unloader,是由OracleODU开发的类似于Oracle的DUL的一款恢复软件,用于直接从Oracle数据库的数据文件中获取表数据。,win2008, window10 下面可以用。
Oracle DUL,全称为Data Recovery Utility,是由Oracle公司开发的一款强大的数据恢复工具,主要用于处理数据库中的数据丢失或误删除问题。这款工具对于DBA(数据库管理员)来说是至关重要的,因为它能够在不影响生产...
DUL是Oracle数据库的一种第三方恢复工具,用于处理复杂的数据库恢复任务,如恢复单个对象或特定时间点的数据。在本例中,它用于恢复误删除的表`account.al_bill_dtl`。 2. **HACMP for AIX**: HACMP是IBM开发的...