您的位置:首页 > 数据库 > Oracle

Oracle OMF--------Tablespace creation is a snap with Oracle Managed Files

2009-06-17 14:26 651 查看
Oracle9iintroducesanewfeaturethatsimplifiestablespacecreation.Thisnewfeature,OracleManagedFiles(OMF),makeslifeeasierforOracleDBAsbyremovingthetediumfromcreatingandmanagingOracledatafiles.

BeforeOMF,OracleDBAshadtotakeseveralmanualstepsbeforeaddingadatafile.Asimpleexampleofthesestepsfollows,butnotethatyoumustknowthelocationofthedirectorythatcontainstheOracledatafiles:

createtablespace
users_02
add
'c:/oracle/oradata/diogenes/users02.dbf'
size
20m;

Inthisexample,youmustknowthefollowinginformationtocreateanewtablespace:

Theproperfilelocation

Theproperfilename

Theproperfilesize

PriortoOMF,youneededtoexecutequeriestogetthefilenamesandfilelocations,interrogatingthedba_data_filesviewtofindtheappropriatelocationforanewdatafile,asshowninListingA..

ListingA


SQL>selectfile_namefromdba_data_files;

FILE_NAME

------------------------------------------------
C:/ORACLE/ORADATA/DIOGENES/SYSTEM01.DBF
C:/ORACLE/ORADATA/DIOGENES/UNDOTBS01.DBF
C:/ORACLE/ORADATA/DIOGENES/CWMLITE01.DBF
C:/ORACLE/ORADATA/DIOGENES/DRSYS01.DBF
C:/ORACLE/ORADATA/DIOGENES/EXAMPLE01.DBF
C:/ORACLE/ORADATA/DIOGENES/INDX01.DBF
C:/ORACLE/ORADATA/DIOGENES/TOOLS01.DBF
C:/ORACLE/ORADATA/DIOGENES/USERS01.DBF
C:/ORACLE/ORADATA/DIOGENES/16K_TS.DBF

Usingtheoutputofthepreviousquery,theC:/Oracle/Oradata/DiogenesdirectoryistheproperlocationtoaddanewOracledatafile.

Viewingtablespaceinformationwasalsocumbersome.Youhadtowriteaquerytojoindba_tablespaceswithdba_data_filestogetthefilesizes,asshowninListingB.

ListingB


columnfile_nameformata40
columntablespaceformata15
columnbytesformat999,999,999

select
file_name,
t.tablespace_nametablespace,
bytes
from
dba_data_filesd,
dba_tablespacest
where
t.tablespace_name=d.tablespace_name;

TheoutputisshowninListingC.

ListingC



FILE_NAMETABLESPACEBYTES

-------------------------------------------------------------------

C:/ORACLE/ORADATA/DIOGENES/SYSTEM01.DBFSYSTEM340,787,200

C:/ORACLE/ORADATA/DIOGENES/UNDOTBS01.DBFUNDOTBS209,715,200

C:/ORACLE/ORADATA/DIOGENES/CWMLITE01.DBFCWMLITE20,971,520

C:/ORACLE/ORADATA/DIOGENES/DRSYS01.DBFDRSYS20,971,520

C:/ORACLE/ORADATA/DIOGENES/EXAMPLE01.DBFEXAMPLE159,907,840

C:/ORACLE/ORADATA/DIOGENES/INDX01.DBFINDX26,214,400

C:/ORACLE/ORADATA/DIOGENES/TOOLS01.DBFTOOLS10,485,760

C:/ORACLE/ORADATA/DIOGENES/USERS01.DBFUSERS26,214,400

C:/ORACLE/ORADATA/DIOGENES/16K_TS.DBFTS_16K10,485,760

OracleCorporationrecognizedthatthiswasalotofworkjusttoaddadatafile,soitdevelopedOMFtoreducethecomplexityinvolvedinspecifyingallthedetailedfileinformation.SomeofthebenefitsofOMFare:

EasierOraclefilemanagement—AllfilesareplacedintotheproperOSdirectory.

Easierthird-partyapplicationintegration—Third-partyappsdon’thavetobeawareofOS-specificenvironments.

ReductionofOraclefilemanagementerrors—Noriskofhumanerror.

EnforcementofOptimalFlexibleArchitecture(OFA)standards—OMFwillcomplywiththeOFAstandardsforfilenameandfilelocations.

Defaultfilesizes—OMFallowsfilestohavestandard,uniformsizes.

Filesizeandnamingstandards

BeforeOMFappeared,OracleDBAscouldcreatedatafileswithanynametheychose.Whilethefilesuffixwasnormally.dbf,theOracleDBAwasfreetocreateanytypeoffilenamedesired.Forexample,thefollowingisasillybutlegitimateOraclecommand:

createtablespace
new_ts
datafile
c:/windows/ProgramFiles/autoexec.bat’
size
300m;

Aswecanseefromthisexample,allowingthedevelopertochoosefilenamesandlocationscanhavedisastrouseffects.WhenusingOMF,filestypicallyhaveadefaultsizeof100MBandarenamedusingaformatmaskforthefilename.

ListingDpresentstheformatmaskthatOMFuseswhencreatingnewdatafiles.

ListingD


u%isaunique8digitcode,
g%isthelogfilegroupnumber,
%tisthetablespacename:

Controlfilesora_%u.ctl
RedoLogFilesora_%g_%u.log
Datafilesora_%t_%u.dbf
TemporaryDatafilesora_%t_%u.tmp

WithOMF,tablespacecreationsyntaxissimplified,anditbecomeseasytoallocateanewtablespace:

SQL>createtablespacenew_ts;
Tablespacecreated.

NowthatthebenefitsofOMFareapparent,I’llexaminetheprocessforinstallingandusingit.TouseOMF,youmustsetthedb_create_file_destparameter.Oncethisisset,OMFisinstalledandtablespacecreationbecomessupereasy:

SQL>altersystemsetdb_create_file_dest=’c:/oracle/oradata/diogenes/;

Systemaltered.

SQL>createtablespacetest;

Tablespacecreated.

NowI’lllookatthefilename,directoryname,andsizeforthefilethatwascreatedasaresultofthiscommandinListingE.

ListingE


FILE_NAMETABLESPACEBYTES

-----------------------------------------------------------------------------

C:/ORACLE/ORADATA/DIOGENES/ORA_TEST_YNJ2K200.DBFTEST104,857,600

ListingEshowsthatOMFcreatedthefileasfollows:

Filelocation—C:/Oracle/Oradata/Diogenes

Filename—Ora_test_ynj2k200.dbf

Filesize—100MB

NotethattheOMFdefaultfilesizeis100MB,andthefilesizecan’tbeoverriddenatthecommandline.YoucanspecifythefilesizeonlyifyoubypassOMFandspecifythefilenameandlocationinthedatafileclause.

OracleenhancedtheOracle9ialertlogtodisplaymessagesabouttablespacecreationanddatafilecreation.Toseethealertlog,youmustgototheBackground_dump_destinationdirectory.YougetthelocationofthisdirectorybyissuingthecommandinListingF.

ListingF


SQL>showparameterbackground_dump

NAMETYPEVALUE

-----------------------------------------------------------------------------

background_dump_deststringC:/oracle/admin/diogenes/bdump

Nowthatyouknowthelocationofthealertlog,gotothatdirectoryandissueadircommandtoseethealertlogfile,namedDiogenesALRT.LOG(FigureA).

FigureA
ThelocationoftheOraclealertlog
Whenyoucheckthelastfewlinesofthealertlog,you’llseethatOracle9ihasloggedtheOMFoperations,andyouhaveafullaudittrainofthechange,asshowninListingG.

ListingG


WedJul3112:02:302002

ALTERSYSTEMSETdb_create_file_dest='c:/oracle/oradata/diogenes'SCOPE=BOTH;
WedJul3112:02:422002
createtablespacetest
WedJul3112:02:472002
CreatedOraclemanagedfileC:/ORACLE/ORADATA/DIOGENES/ORA_TEST_YNJ2K200.DBF
Completed:createtablespacetest
WedJul3112:08:262002
droptablespacetest
WedJul3112:08:262002
DeletedOraclemanagedfileC:/ORACLE/ORADATA/DIOGENES/ORA_TEST_YNJ2K200.DBF
Completed:droptablespacetest

UsingOMFwithonlineredologs

Oracle9ialsoletsyouuseOMFwithonlineredologfiles.Thisfeatureisespeciallyusefulbecauseitremovesthetediumfrommultiplexingandsizingtheredologs.Youdothisbysettingthedb_create_online_log_dest_1throughdb_create_online_log_dest_5parameters.Theone-through-fivenotationallowsyoutospecifyuptofivemultiplexedcopiesoftheonlineredologfile.

Becausetheredologsareallocatedatdatabasecreationtime,theseparametersmustbesetintheinit.orafilepriortocreatingthedatabase.Whenmultiplexing,youalsoneedtosegregatetheonlineredologsontoseparatedisksasprotectionagainstdiskfailure.InthisUNIXexample,themountpointsu01,u02,u03,andu04allmaptodifferentdiskspindles.

UsingOMFfortheredologsrequiresseveralparameters.Here’sasampleinit.orafileforOracle9iOMFforredologs:

db_create_online_log_dest_1=‘/u01/oracle/oradata/diogenes’
db_create_online_log_dest_2=‘/u02/oracle/oradata/diogenes’
db_create_online_log_dest_3=‘/u03/oracle/oradata/diogenes’
db_create_online_log_dest_4=‘/u04/oracle/oradata/diogenes’

UsingOMFforredologsgreatlysimplifiesthesyntaxyouneedtocreateanewdatabase.BeforeOMF,youhadtospecifythesizeandlocationoftheredologsatdatabasecreationtime,asshowninListingH.

ListingH


createdatabase
"diogenes"
maxinstances1
maxlogfiles16
maxloghistory226
maxlogmembers2
maxdatafiles30
noarchivelog
characterset"US7ASCII"
SETTIME_ZONE='PST';
datafile
'c:/oracle/oradata/system01.dbf'size246M
logfile
group1'c:/oracle/oradata/log01.dbf'size50K,
group2'c:/oracle/oradata/log02.dbf'size50K,
group3'c:/oracle/oradata/log03.dbf'size50K

;

Now,OMFtakescareofthedetails,anddatabasecreationissimple,asshowninListingI

ListingI


createdatabase
"diogenes"
maxinstances1
maxlogfiles16
maxloghistory226
maxlogmembers2
maxdatafiles30
noarchivelog
characterset"US7ASCII"
SETTIME_ZONE='PST';
datafile
'c:/oracle/oradata/system01.dbf'size246M
logfile
group1,
group2,
group3

;

Whodoesn’tlikeOMF?

OMFisquitepopularinlargeOracle9ishopsthathandlehundredsoftablespacesanddatafiles.OMFisalsopopularforvendor-basedapplicationsbecausevendorinstallscriptscanbesenttoallOraclecustomers,nomatterwhattheirspecificfileconfiguration.ThedownsidetoOMFisthatseasoneddatabaseprofessionalsdon’tliketouseuniformfilesizesandobtusefilenames.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: