Making UserManaged Backups.docx

上传人:b****5 文档编号:28802642 上传时间:2023-07-19 格式:DOCX 页数:34 大小:30.91KB
下载 相关 举报
Making UserManaged Backups.docx_第1页
第1页 / 共34页
Making UserManaged Backups.docx_第2页
第2页 / 共34页
Making UserManaged Backups.docx_第3页
第3页 / 共34页
Making UserManaged Backups.docx_第4页
第4页 / 共34页
Making UserManaged Backups.docx_第5页
第5页 / 共34页
点击查看更多>>
下载资源
资源描述

Making UserManaged Backups.docx

《Making UserManaged Backups.docx》由会员分享,可在线阅读,更多相关《Making UserManaged Backups.docx(34页珍藏版)》请在冰豆网上搜索。

Making UserManaged Backups.docx

MakingUserManagedBackups

MakingUser-ManagedBackups

IfyoudonotuseRecoveryManager(RMAN),thenyoucanmakebackupsofyourdatabasefileswithuser-managedmethods.

Thischaptercontainsthefollowingsections:

∙QueryingV$ViewstoObtainBackupInformation

∙MakingUser-ManagedBackupsoftheWholeDatabase

∙MakingUser-ManagedBackupsofOfflineTablespacesandDatafiles

∙MakingUser-ManagedBackupsofOnlineTablespacesandDatafiles

∙MakingUser-ManagedBackupsoftheControlFile

∙MakingUser-ManagedBackupsofArchivedRedoLogs

∙MakingUser-ManagedBackupsinSUSPENDMode

∙MakingUser-ManagedBackupstoRawDevices

∙VerifyingUser-ManagedBackups

∙MakingLogicalBackupswithOracleExportUtilities

∙MakingUser-ManagedBackupsofMiscellaneousOracleFiles

∙KeepingRecordsofCurrentandBackupDatabaseFiles

QueryingV$ViewstoObtainBackupInformation

Beforemakingabackup,youmustidentifyallthefilesinyourdatabaseanddecidewhattobackup.SeveralV$viewscanprovidethenecessaryinformation.

ListingDatabaseFilesBeforeaBackup

UseV$DATAFILE,V$LOGFILEandV$CONTROLFILEtoidentifythedatafiles,logfilesandcontrolfilesforyourdatabase.ThissameprocedureworkswhetheryounamedthesefilesmanuallyorallowedOracleManagedFilestonamethem.

Tolistdatafiles,onlineredologs,andcontrolfiles:

1.StartSQL*PlusandqueryV$DATAFILEtoobtainalistofdatafiles.Forexample,enter:

2.SQL>SELECTNAMEFROMV$DATAFILE;

3.

YoucanalsojointheV$TABLESPACEandV$DATAFILEviewstoobtainalistingofdatafilesalongwiththeirassociatedtablespaces:

SELECTt.NAME"Tablespace",f.NAME"Datafile"

FROMV$TABLESPACEt,V$DATAFILEf

WHEREt.TS#=f.TS#

ORDERBYt.NAME;

4.ObtainthefilenamesofonlineredologfilesbyqueryingtheV$LOGFILEview.Forexample,issuethefollowingquery:

5.SQL>SELECTMEMBERFROMV$LOGFILE;

6.

7.ObtainthefilenamesofthecurrentcontrolfilesbyqueryingtheV$CONTROLFILEview.Forexample,issuethefollowingquery:

8.SQL>SELECTNAMEFROMV$CONTROLFILE;

9.

Notethatyouonlyneedtobackuponecopyofamultiplexedcontrolfile.

10.IfyouplantotakeacontrolfilebackupwiththeALTERDATABASEBACKUPCONTROLFILETO'filename'statement,thensavealistofalldatafilesandonlineredologfileswiththecontrolfilebackup.Becausethecurrentdatabasestructuremaynotmatchthedatabasestructureatthetimeagivencontrolfilebackupwascreated,savingalistoffilesrecordedinthebackupcontrolfilecanaidtherecoveryprocedure.

DeterminingDatafileStatusforOnlineTablespaceBackups

Tocheckwhetheradatafileispartofacurrentonlinetablespacebackup,querytheV$BACKUPview.

Thisviewisusefulonlyforuser-managedonlinetablespacebackups,becauseneitherRMANbackupsnorofflinetablespacebackupsrequirethedatafilesofatablespacetobeinbackupmode.

TheV$BACKUPviewismostusefulwhenthedatabaseisopen.Itisalsousefulimmediatelyafteraninstancefailurebecauseitshowsthebackupstatusofthefilesatthetimeofthefailure.Usethisinformationtodeterminewhetheryouhaveleftanytablespacesinbackupmode.

V$BACKUPisnotusefulifthecontrolfilecurrentlyinuseisarestoredbackuporanewcontrolfilecreatedafterthemediafailureoccurred.Arestoredorre-createdcontrolfiledoesnotcontaintheinformationthedatabaseneedstopopulateV$BACKUPaccurately.Also,ifyouhaverestoredabackupofafile,thisfile'sSTATUSinV$BACKUPreflectsthebackupstatusoftheolderversionofthefile,notthemostcurrentversion.Thus,thisviewcancontainmisleadingdataaboutrestoredfiles.

Forexample,thefollowingquerydisplayswhichdatafilesarecurrentlyincludedinatablespacethathasbeenplacedinbackupmode:

SELECTt.nameAS"TB_NAME",d.file#as"DF#",d.nameAS"DF_NAME",b.status

FROMV$DATAFILEd,V$TABLESPACEt,V$BACKUPb

WHEREd.TS#=t.TS#

ANDb.FILE#=d.FILE#

ANDb.STATUS='ACTIVE'

/

ThefollowingsampleoutputshowsthatthetoolsanduserstablespacescurrentlyhaveACTIVEstatus:

TB_NAMEDF#DF_NAMESTATUS

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

TOOLS7/oracle/oradata/trgt/tools01.dbfACTIVE

USERS8/oracle/oradata/trgt/users01.dbfACTIVE

 

IntheSTATUScolumn,NOTACTIVEindicatesthatthefileisnotcurrentlyinbackupmode(thatis,youhavenotexecutedtheALTERTABLESPACE...BEGINBACKUPorALTERDATABASEBEGINBACKUPstatement),whereasACTIVEindicatesthatthefileiscurrentlyinbackupmode.

MakingUser-ManagedBackupsoftheWholeDatabase

YoucanmakeawholedatabasebackupofallfilesinadatabaseafterthedatabasehasbeenshutdownwiththeNORMAL,IMMEDIATE,orTRANSACTIONALoptions.AwholedatabasebackuptakenwhilethedatabaseisopenorafteraninstancefailureorSHUTDOWNABORTisinconsistent.Insuchcases,thefilesareinconsistentwithrespecttothecheckpointSCN.

YoucanmakeawholedatabasebackupifadatabaseisoperatingineitherARCHIVELOGorNOARCHIVELOGmode.IfyourunthedatabaseinNOARCHIVELOGmode,however,thebackupmustbeconsistent;thatis,youmustshutdownthedatabasecleanlybeforethebackup.

ThesetofbackupfilesthatresultsfromaconsistentwholedatabasebackupisconsistentbecauseallfilesarecheckpointedtothesameSCN.Youcanrestoretheconsistentdatabasebackupwithoutfurtherrecovery.Afterrestoringthebackupfiles,youcanperformadditionalrecoverystepstorecoverthedatabasetoamorecurrenttimeifthedatabaseisoperatedinARCHIVELOGmode.Also,youcantakeinconsistentwholedatabasebackupsifyourdatabaseisinARCHIVELOGmode.

Controlfilesplayacrucialroleindatabaserestoreandrecovery.FordatabasesrunninginARCHIVELOGmode,OracleCorporationrecommendsthatyoubackupcontrolfileswiththeALTERDATABASEBACKUPCONTROLFILETO'filename'statement.

SeeAlso:

"MakingUser-ManagedBackupsoftheControlFile"formoreinformationaboutbackingupcontrolfiles

MakingConsistentWholeDatabaseBackups

Thissectiondescribeshowtobackupthedatabasewithanoperatingsystemutility.

Tomakeaconsistentwholedatabasebackup:

1.Ifthedatabaseisopen,useSQL*PlustoshutdownthedatabasewiththeNORMAL,IMMEDIATE,orTRANSACTIONALoptions.

2.UseanoperatingsystemutilitytomakebackupsofalldatafilesaswellasallcontrolfilesspecifiedbytheCONTROL_FILESparameteroftheinitializationparameterfile.Also,backuptheinitializationparameterfileandotherOracleproductinitializationfiles.Tofindthesefiles,doasearchfor*.orastartinginyourOraclehomedirectoryandrecursivelysearchallofitssubdirectories.

Forexample,youcanbackupthedatafiles,controlfilesandarchivedlogsto/disk2/backupasfollows:

%cp$ORACLE_HOME/oradata/trgt/*.dbf/disk2/backup

%cp$ORACLE_HOME/oradata/trgt/arch/*/disk2/backup/arch

3.Restartthedatabase.Forexample,enter:

4.SQL>STARTUP

SeeAlso:

OracleDatabaseAdministrator'sGuideformoreinformationonstartingupandshuttingdownadatabase

MakingUser-ManagedBackupsofOfflineTablespacesandDatafiles

Youcanbackupallorsomeofthedatafilesofanindividualtablespacewhilethetablespaceisoffline.Allothertablespacesofthedatabasecanremainopenandavailableforsystemwideuse.YoumusthavetheDBAprivilegeorhavetheMANAGETABLESPACEsystemprivilegetotaketablespacesofflineandonline.

Notethefollowingguidelineswhenbackingupofflinetablespaces:

∙YoucannotofflinetheSYSTEMtablespaceoratablespacewithactiverollbacksegments.Thefollowingprocedurecannotbeusedforsuchtablespaces.

∙AssumethatatableisintablespacePrimaryanditsindexisintablespaceIndex.TakingtablespaceIndexofflinewhileleavingtablespacePrimaryonlinecancauseerrorswhenDMLisissuedagainsttheindexedtableslocatedinPrimary.TheproblemonlymanifestswhentheaccessmethodchosenbytheoptimizerneedstoaccesstheindexesintheIndextablespace.

Tobackupofflinetablespaces:

1.Beforebeginningabackupofatablespace,identifythetablespace'sdatafilesbyqueryingtheDBA_DATA_FILESview.Forexample,assumethatyouwanttobackuptheuserstablespace.EnterthefollowinginSQL*Plus:

2.SELECTTABLESPACE_NAME,FILE_NAME

3.FROMSYS.DBA_DATA_FILES

4.WHERETABLESPACE_NAME='USERS';

5.

6.TABLESPACE_NAMEFILE_NAME

7.---------------------------------------------------------------

8.USERS/oracle/oradata/trgt/users01.dbf

9.

Inthisexample,/oracle/oradata/trgt/users01.dbfisafullyspecifiedfilenamecorrespondingtothedatafileintheuserstablespace.

10.Takethetablespaceofflineusingnormalpriorityifpossiblebecauseitguaranteesthatyoucansubsequentlybringthetablespaceonlinewithouthavingtorecoverit.Forexample:

11.SQL>ALTERTABLESPACEusersOFFLINENORMAL;

12.

13.Backuptheofflinedatafiles.Forexample:

14.%cp/oracle/oradata/trgt/users01.dbf/d2/users01_`date"+%m_%d_%y"`.dbf

15.

16.Bringthetablespaceonline.Forexample:

17.ALTERTABLESPACEusersONLINE;

Note:

Ifyoutookthetablespaceofflineusingtemporaryorimmediatepriority,thenyoucannotbringthetablespaceonlineunlessyouperformtablespacerecovery.

18.Archivetheunarchivedredologssothattheredorequiredtorecoverthetablespacebackupisarchived.Forexample,enter:

19.ALTERSYSTEMARCHIVELOGCURRENT;

MakingUser-ManagedBackupsofOnlineTablespacesandDatafiles

Youcanbackupalloronlyspecificdatafilesofanonlinetablespacewhilethedatabaseisopen.Theprocedurediffersdependingonwhethertheonlinetablespaceisread/writeorread-only.

Note:

Youshouldnotbackuptemporarytablespaces.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1