Oracle DUL/AUL/ODU 工具说明
2011-09-14 17:39
459 查看
假设我们的数据库遇到以下情况:
第一,没有备份;
第二,常规方法无法恢复;
第三,数据很重要,但又无法或成本太高而进行重新输入.如丢失了Oracle的System表空间,System表空间损坏到无法启动的地步,意外删除表空间或表,意外截断(Truncate)表等,
在这3中情况下,最后的方法就是通过工具直接读取数据文件里的数据,将我们的数据找回来。并且工具不需要Oracle环境的支持。
据我目前的了解,有3种工具:
(1)Oracle的内部工具是DUL(DataUnLoader)。这个需要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,也是需要购买授权。
能写出这样的软件都是牛人了,需要了解各个版本Oracleblock的详细信息。AUL和ODU的操作和OracleDUL类似。
关于DUL,MOS有说明:MOSNote72554.1
UsingDULtoRecoverfromDatabaseCorruption
第一,没有备份;
第二,常规方法无法恢复;
第三,数据很重要,但又无法或成本太高而进行重新输入.如丢失了Oracle的System表空间,System表空间损坏到无法启动的地步,意外删除表空间或表,意外截断(Truncate)表等,
在这3中情况下,最后的方法就是通过工具直接读取数据文件里的数据,将我们的数据找回来。并且工具不需要Oracle环境的支持。
据我目前的了解,有3种工具:
(1)Oracle的内部工具是DUL(DataUnLoader)。这个需要Oracle的支持。
(2)老熊写的ODU。网址:
(3)d.c.b.a(支付宝楼方鑫)写的AUL.网址:
ODU之前是免费的,现在老熊和dbsnake在维护ODU,需要购买才能使用。
d.c.b.a的AUL是用C语言写的,免费版本最大只支持2个,最大256M的datafile。如果是更大的datafile,也是需要购买授权。
能写出这样的软件都是牛人了,需要了解各个版本Oracleblock的详细信息。AUL和ODU的操作和OracleDUL类似。
关于DUL,MOS有说明:MOSNote72554.1
UsingDULtoRecoverfromDatabaseCorruption
TableOfContents
~~~~~~~~~~~~~~~~~
1.Introduction
2.UsingDUL
2.1Createanappropriateinit.dulfile
2.2Createthecontrol.dulfile
2.3Unloadtheobjectinformation
2.4InvokeDUL
2.5Rebuildthedatabase
3.Howtorebuildobjectdefinitionsthatarestoredinthedatadictionary?
4.Howtounloaddatawhenthesegmentheaderblockiscorrupted?
5.Howtounloaddatawhenthefileheaderblockiscorrupted?
6.Howtounloaddatawithoutthesystemtablespace?
7.AppendixA:Wheretofindtheexecutables?
8.References
1.Introduction
~~~~~~~~~~~~~~~
ThisdocumentistoexplainhowtouseDULratherthantogiveafull
explanationofBernard'sDataUnLoadercapabilities.
Thisdocumentisforinternaluseonlyandshouldnotbegiventocustomersat
anytime,Dulshouldalwaysbeusedbyorunderthesupervisionofasupport
analyst.
DUL(DataUnLoader)isintendedtoretrievedatafromtheOracleDatabasethat
cannotberetrievedotherwise.Thisisnotanalternativefortheexport
utilityorSQL*Loader.Thedatabasemaybecorruptedbutanindividualdata
blockusedmustbe100%correct.Duringallunloadingchecksaremadetomake
surethatblocksarenotcorruptedandbelongtothecorrectsegment.Ifa
corruptedblockisdetectedbyDUL,anerrormessageisprintedintheloader
fileandtothestandardoutput,butthiswillnotterminatetheunloadingof
thenextroworblock.
2.UsingDUL
~~~~~~~~~~~~
Firstyoumustretrievethenecessaryinformationabouttheobjectsthatexists
inthedatabase,thesestatisticswillbeloadedintotheDULdictionaryto
unloadthedatabaseobjects.
ThisinformationisretrievedfromtheUSER$,OBJ$,TAB$andCOL$tablesthat
werecreatedatdatabasecreationtime,theycanbeunloadedbasedonthefact
thatobjectnumbersarefixedforthesetablesduetotherigidnatureofsql.
bsq.DULcanfindtheinformationinthesystemtablespace,thereforthesystem
tablespacedatafile(s)mustbeincludedinthecontrolfile,ifthisdatafile(s)
isnotpresentseechapter6.
2.1Createanappropriate"init.dul"file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REMPlatformspecificparameters(NT)
REMAListofparametersforthemostcommonplatformscanbeobtainedfrom
REM 'target='_blank'>http://www.nl.oracle.com/support/dul/index.htmlosd_big_endian_flag=falseosd_dba_file_bits=10osd_c_struct_alignment=32osd_file_leader_size=1osd_word_size=32REMSizesofduldictionarycaches.IfoneoftheseistoolowstartupwillREMfail.dc_columns=2000000dc_tables=10000dc_objects=1000000dc_users=400dc_segments=100000REMLocationandfilenameofthecontrolfile,defaultvalueiscontrol.dulREMinthecurrentdirectorycontrol_file=D:\Dul\control_orcl.dulREMDatabaseblocksize,canbefoundintheinit<SID>.orafileorcanbeREMretrievedbydoing"showparameter%db_block_size%"inservermanagerREM(svrmgr23/30/l)changesthisparametertowhatevertheblocksizeisofREMthecrasheddatabase.db_block_size=4096REMCan/mustbespecifiedwhendataisneededintoexport/importformat.REMthiswillcreateafilesuitabletousebytheoracleimportutility,REMalthoughthegeneratedfileiscompletelydifferentfromatablemodeREMexportgeneratedbytheEXPutility.ItisasingletabledumpfileREMwithonlyacreatetablestructurestatementandthetabledata.REMGrants,storageclauses,triggersarenotincludedintothisdumpfile!export_mode=trueREMCompatibleparametermustbespecifiedancanbeeither6,7or8compatible=8REMThisparameterisoptionalandcanbespecifiedonplatformsthatdoREMnotsupportlongfilenames(e.g.8.3DOS)orwhenthefileformatthatREMDULuses"owner_name.table_name.ext"isnotacceptable.ThedumpfilesREMwillbesomethinglikedump001.ext,dump002.ext,etcinthiscase.file=dumpAcompletelistcanbeobtainedat 'target='_blank'>http://www.nl.oracle.com/support/DUL/ucg8.htmlsection"DULParameters"althoughthisinit.dulfilewillworkinmostcasesandcontainsallaccurateparameterstosuccesfullycompletetheunloading.2.2Createthe"control.dul"file~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Agoodknowledgeaboutthelogicaltablespaceandphysicaldatafilestructureisneededoryoucandothefollowingquerieswhenthedatabaseismounted:Oracle6,7----------->connectinternal>spoolcontrol.DUL>select*fromv$dbfile;>spooloffOracle8-------->connectinternal>spoolcontrol.DUL>selectts#,rfile#,namefromv$datafile;>spooloffEditthespoolfileandchange,ifneeded,thedatafilelocationandstripeoutunnecessaryinformationliketableheaders,feedbackline,etc...Asamplecontrolfilelookssomethinglikethis:REMOracle7controlfile1D:\DUL\DATAFILE\SYS1ORCL.DBF3D:\DUL\DATAFILE\DAT1ORCL.DBF7D:\DUL\DATAFILE\USR1ORCL.DBFREMOracle8controlfile01D:\DUL\DATAFILE\SYS1ORCL.DBF12D:\DUL\DATAFILE\USR1ORCL.DBF13D:\DUL\DATAFILE\USR2ORCL.DBF24D:\DUL\DATAFILE\DAT1ORCL.DBFNote:Eachentrycancontainapartofadatafile,thiscanbeusefulwhenyouneedtosplitdatafilesthataretoobigforDUL,sothateachpartissmallerthanforexample2GB.Forexample:REMOracle8withadatafilesplitintomultipleparts,eachpartisREMsmallerthan1GB!01D:\DUL\DATAFILE\SYS1ORCL.DBF12D:\DUL\DATAFILE\USR1ORCL.DBFstartblock1endblock100000012D:\DUL\DATAFILE\USR1ORCL.DBFstartblock1000001endblock200000012D:\DUL\DATAFILE\USR1ORCL.DBFstartblock2000001endblock25500002.3Unloadtheobjectinformation~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~StarttheDULutilitywiththeappropriateddl(DulDescriptionLanguage)script.Thereare3scriptsavailabletounloadtheUSER$,OBJ$,TAB$andCOL$tablesaccordingtothedatabaseversion.Oracle6:>dul8.exedictv6.ddlOracle7:>dul8.exedictv7.ddlOracle8:>dul8.exedictv8.ddlDataUnLoader:Release8.0.5.3.0-InternalUseOnly-onTueJun2222:19:Copyright(c)1994/1999BernardvanDuijnenAllrightsreserved.ParameteralteredSessionaltered.ParameteralteredSessionaltered.ParameteralteredSessionaltered.ParameteralteredSessionaltered..unloadingtableOBJ$2271rowsunloaded.unloadingtableTAB$245rowsunloaded.unloadingtableCOL$10489rowsunloaded.unloadingtableUSER$22rowsunloaded.unloadingtableTABPART$0rowsunloaded.unloadingtableIND$274rowsunloaded.unloadingtableICOL$514rowsunloaded.unloadingtableLOB$13rowsunloadedLifeisDULwithoutitThiswillunloadthedataoftheUSER$,OBJ$,TAB$andCOl$datadictionarytablesintoSQL*Loaderfiles,thiscannotbemanipulatedintodumpfilesoftheimportformat.Theparameterexport_mode=falseishardcodedintotheddlscriptsandcannotbechangedtothevalue"true"sincethiswillcauseDULtofailwiththeerror:.unloadingtableOBJ$DUL:Error:Column"DATAOBJ#"actualsize(2)greaterthanlengthincolumndefinition(1).............etc...............2.4InvokeDUL~~~~~~~~~~~~~~StartDULininteractivemodeoryoucanprepareascriptsthatcontainsalltheddlcommandstounloadthenecessarydatafromthedatabase.Iwilldescribeinthisdocumentthemostusedcommands,thisisnotacompletelistofpossibleparametersthatcanbespecified.Acompletelistcanbefoundathttp://www.nl.oracle.com/support/DUL/ucg8.htmlsection"DDLDescription". DUL>unloaddatabase;=>thiswillunloadtheentiredatabasetables(includessys'tablesaswell)DUL>unloaduser<username>;=>thiswillunloadallthetablesownedbythatparticullarlyuser.DUL>unloadtable<username.table_name>;=>thiswillunloadthespecifiedtableownedbythatusernameDUL>describe<owner_name.table_name>;=>willrepresentthetablecolumnswiththererelativepointerstothedatafile(s)ownedbythespecifieduser.DUL>scandatabase;=>Scansallblocksofalldatafiles.Twofilesaregenerated:1:seg.datinformationoffoundsegmentheaders(index/cluster/table)(objectid,filenumber,andblocknumber).2:ext.datinformationofcontiguoustable/clusterdatablocks.(objectid(V7),fileandblocknumberofsegmentheader(V6),filenumberandblocknumberoffirstblock,numberofblocks,numberoftables)DUL>scantables;=>Usesseg.datandext.datasinput.Scansalltablesinalldatasegments(aheaderblockandatleastonematchingextentwithatleast1table).2.5Rebuildthedatabase~~~~~~~~~~~~~~~~~~~~~~~~CreatethenewdatabaseanduseimportorSQL*LoadertorestorethedataretrievedbyDUL.Notethatwhenyouonlyunloadedthedatathattablestructures,indexation,grants,PL/SQLandtriggerswillnolongerexistinthenewdatabase.Toobtainanexactlysamecopyofthedatabaseasbeforeyouwillneedtorerunyourcreationscriptsforthetables,indexes,PL/SQL,etc.Ifyoudon'thavethesescriptsthenyouwillneedtoperformthestepsdescribedinsection3ofthisdocument.3.Howtorebuildobjectdefinitionsthatarestoredinthedatadictionary~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~YouwanttorebuildPL/SQL(packages,procedures,functionsortriggers),grants,indexes,constraintsorstorageclauses(oldtablestructure)withDUL.Thiscanbedonebutisalittlebittricky.YouneedtounloadtherelevantdatadictionarytablesusingDULandthenloadthesetablesintoahealthydatabase,besuretouseadifferentuserthansysor(system).Loadingthedatadictionarytablesofthecrasheddatabaseintothehealthydatabasedictionarycouldcorruptthehealthydatabaseaswell.Detailedexplanationtoretrieveforexamplepl/sqlpackages/procedures/functionsfromacorrupteddatabase:1)Followthestepsexplainedinthe"UsingDUL"sectionandunloadthedatadictionarytable"source$"2)Createanewuserintoahealthydatabaseandspecifythedesireddefaultandtemporarytablespace.3)Grantconnect,resource,imp_full_databasetothenewuser.4)Import/loadthetable"source$"intothenewcreatedschema:e.g.:imp80userid=newuser/passwfile=d:\dul\scott_emp.dmplog=d:\dul\impemp.txtfull=y5)Youcannowqueryfromthetable<newuser.source$>torebuildthepl/sqlprocedures/functionsfromthecorrupteddatabase.ScriptscanbefoundonWebIvtogeneratesuchPL/SQLcreationscripts.Thesamestepscanbefollowedtorecreateindexes,constraints,andstorageparametersortoregrantprivilegestotheappropiateusers.Pleasenoticethatyoualwaysneedtouseascriptofsomekindthatcanrecreatetheobjectsandincludeallthefeaturesofthecrasheddatabaseversion.Forexample:whenthecrasheddatabaseisofversion7.3.4andyouhaveseveralbitmapindexes,ifyouwoulduseascriptthatsupportsversion7.3.2orprior,thenyouwon'tbeabletorecreatethebitmapindexessuccesful!4.Howtounloaddatawhenthesegmentheaderblockiscorrupted~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~WhenDULcan'tretrievedatablockinformationonthenormalway,itcanscanthedatabasetocreateitsownsegment/extentmap.Theprocedureofscanningthedatabaseisnecessarytounloadthedatafromthedatafiles.(toillustratethisexampleIcopiedanemptyblockontopofthesegmentheaderblock)1)Createanappropiate"init.dul"(see2.1)and"control.dul"(see2.2)file.2)Unloadthetable.Thiswillfailandindicatethatthereisacorruptioninthesegmentheaderblock:DUL>unloadtablescott.emp;.unloadingtableEMPDUL:Warning:Blockisneverused,blocktypeiszeroDUL:Error:Whilecheckingtablespace6file10block2DUL:Error:Whileprocessingblockts#=6,file#=10,block#=2DUL:Error:Couldnotread/parsesegmentheader0rowsunloaded3)runthescandatabasecommand:DUL>scandatabase;tablespace0,datafile1:10239blocksscannedtablespace6,datafile10:2559blocksscanned4)IndicatetoDULthatitshoulduseitsowngeneratedextentmapratherthanthesegmentheaderinformation.DUL>altersessionsetuse_scanned_extent_map=true;ParameteralteredSessionaltered.DUL>unloadtablescott.emp;.unloadingtableEMP14rowsunloaded5.Howtounloaddatawhenthedatafileheaderblockiscorrupted~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Acorruptioninthedatafileheaderblockisalwayslistedatthemomentyouopenthedatabasethisisnotlikeaheadersegmentblockcorruption(seepoint4)wherethedatabasecanbesuccesfullyopenendandthecorruptionislistedatthemomentyoudoaqueryofatable.Dulhasnoproblemswithrecoveringfromsuchsituationsalthoughthereareotheralternativesofrecoveringfromthissituationlikepatchingthedatafileheaderblock.Theerroryouwillreceivelookssomethinglike:ORACLEinstancestarted.TotalSystemGlobalArea11739136bytesFixedSize49152bytesVariableSize7421952bytesDatabaseBuffers4194304bytesRedoBuffers73728bytesDatabasemounted.ORA-01122:databasefile10failedverificationcheckORA-01110:datafile10:'D:\DATA\TRGT\DATAFILES\JUR1TRGT.DBF'ORA-01251:UnknownFileHeaderVersionreadforfilenumber106.Howtounloaddatawithoutthesystemtablespace~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Ifdatafilesarenotavailableforthesystemtablespacetheunloadcanstillcontinuebuttheobjectinformationcan'tberetrievedfromthedatadictionarytablesUSER$,OBJ$,TAB$andCOL$.Soownername,tablenameandcolumnnameswillnotbeloadedintotheDULdictionary.IdentifyingthetablescanbeanoverwhelmingtaskandagoodknowledgeoftheRDBMSinternalsareneededhere.Firstofallyouneedagoodknowledgeofyourapplicationandit'stables.ColumntypescanbeguessedbyDUL,buttableandcolumnnameswillbelost.Anyoldsystemtablespacefromthesamedatabase(maybeweeksold)canbeagreathelp!1)Createthe"init.dul"fileandthe"control.dul"fileasexplainedinabovesteps1and2.Inthiscasethecontrolfilewillcontainallthedatafilesfromwhichyouwanttorestorebutitdoesn'trequirethesystemtablespaceinformation.2)ThenYouinvokedulandtypethefollowingcommand:DUL>scandatabase;datafile61280blocksscannedThiswillbuildtheextentandsegmentmap.Probablythedulcommandinterpreterwillbeterminatedaswell.3)reinvokethedulcommandinterpreteranddothefollowing:DataUnLoader:Release8.0.5.3.0-InternalUseOnly-onTueAug0313:33:Copyright(c)1994/1999OracleCorporation,TheNetherlands.AllrightsresLoaded4segmentsLoaded2extentsExtentmapsortedDUL>altersessionsetuse_scanned_extent_map=true;DUL>scantables;(orscanextents;)ScanningtableswithsegmentheaderOid1078fno6bno2tablenumber0UNLOADTABLET_O1078(C1NUMBER,C2UNKNOWN,C3UNKNOWN)STORAGE(TABNO0EXTENTS(FILE6BLOCK2));ColnoSeenMaxIntSzNull%C75%C100Num%NiNu%Dat%Rid%1420%0%0%100%100%0%0%24100%100%100%100%0%0%0%3480%100%100%100%0%0%50%"10""ACCOUNTING""NEWYORK""20""RESEARCH""DALLAS""30""SALES""CHICAGO""40""OPERATIONS""BOSTON"Oid1080fno6bno12tablenumber0UNLOADTABLET_O1080(C1NUMBER,C2UNKNOWN,C3UNKNOWN,C4NUMBER,C5DATE,C6NUMBER,C7NUMBER,C8NUMBER)STORAGE(TABNO0EXTENTS(FILE6BLOCK12));ColnoSeenMaxIntSzNull%C75%C100Num%NiNu%Dat%Rid%11430%0%0%100%100%0%0%21460%100%100%100%0%0%21%31490%100%100%100%0%0%0%41437%0%0%100%100%0%0%51470%0%0%0%0%100%0%61430%0%0%100%100%0%0%714271%0%0%100%100%0%0%81420%0%0%100%100%0%0%"7369""SMITH""CLERK""7902""17-DEC-1980AD00:00:00""800""""20""7499""ALLEN""SALESMAN""7698""20-FEB-1981AD00:00:00""1600""300""30""7521""WARD""SALESMAN""7698""22-FEB-1981AD00:00:00""1250""500""30""7566""JONES""MANAGER""7839""02-APR-1981AD00:00:00""2975""""20""7654""MARTIN""SALESMAN""7698""28-SEP-1981AD00:00:00""1250""1400""30"Note:itmightbebestthatyouredirecttheoutputtoalogfilesincecommandslikethe"scantables"canproducealotofoutput.OnWindowsNTyoucandothefollowingcommand:C:\>dul8>c:\temp\scan_tables.txtscantables;exit;4)Identifythelosttablesfromtheoutputofstep3;ifyoulookcarefullytotheoutputabovethenyouwillnoticethattheunloadsyntaxisalreadygivenbutthatthetablenamewillbeoftheformatt_0<objectno>andthecolumnnameswillbeoftheformatC<no>;datatypeswillnotbeanexactmatchofthedatatypeasitwasbefore.Lookespeciallyforstringslike"Oid1078fno6bno2tablenumber0"where:oid=objectid,willbeusedtounloadtheobjectfno=(data)filenumberbno=blocknumber5)Unloadtheidentifiedtableswiththe"unloadtable"command:DUL>unloadtabledept(deptnonumber(2),dnamevarchar2(14),locvarchar2(13))storage(OBJNO1078)Unloadingextent(s)oftableDEPT4rows
-------------------------------------------------------------------------------------------------------
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:151508914DBA9群:102954821聊天群:40132017(满)
--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请
相关文章推荐
- Oracle DUL/AUL/ODU 工具说明
- Oracle DUL/AUL/ODU 工具说明
- Oracle DUL/AUL/ODU 工具说明
- Oracle DUL/AUL/ODU 工具说明
- Oracle DUL/AUL/ODU 工具说明
- Oracle DUL/AUL/ODU 工具说明
- Oracle DUL/AUL/ODU 工具说明
- ORACLE DBA工具收集(Oracle DUL/AUL/ODU 恢复工具,可以脱离Oracle运行环境,直接从数据文件中读取记录)
- ORACLE恢复神器之ODU/AUL/DUL
- 数据库恢复工具:DUL、ODU和AUL
- Oracle DUL/AUL/ODU
- ORACLE dul 工具使用说明, [ID 465478.1] Note 72554.1
- oracle DUL/PRM 工具说明
- Oracle 高速批量数据加载工具sql*loader使用说明
- Oracle数据恢复工具-ODU
- Oracle DBV 工具 说明
- Oracle DBV 工具 说明
- Oracle DBA神器:PRM灾难恢复工具,Schema级别数据恢复。JAVA图形化界面版Oracle DUL
- 解决32位工具如何连接64位DB---Oracle Instant Client 使用 说明