Backup and Recovery Overview.docx
《Backup and Recovery Overview.docx》由会员分享,可在线阅读,更多相关《Backup and Recovery Overview.docx(18页珍藏版)》请在冰豆网上搜索。
BackupandRecoveryOverview
BackupandRecoveryOverview
Thischapterprovidesageneraloverviewofbackupandrecoveryconcepts,thefilesinanOracledatabaserelatedtobackupandrecovery,andthetoolsavailableformakingbackupsofyourdatabase,recoveringfromdatalossorothererror,andmaintainingrecordsofyourbackups.
Thischapterincludesthefollowingtopics:
∙WhatisBackupandRecovery?
∙BackupandRecovery:
BasicConcepts
∙TheDatabaseRecoveryProcess:
BasicConcepts
∙FormsofDataRecovery
∙BackupandRecoverywithRMAN
∙MatchingFailurestoBackupandRecoveryTechniques
∙AutomaticDisk-BasedBackupandRecovery:
TheFlashRecoveryArea
∙SystemRequirementsforBackupandRecoveryMethods
∙FeatureComparisonofBackupMethods
WhatisBackupandRecovery?
Ingeneral,backupandrecoveryreferstothevariousstrategiesandproceduresinvolvedinprotectingyourdatabaseagainstdatalossandreconstructingthedatabaseafteranykindofdataloss.
PhysicalBackupsandLogicalBackups
Abackupisacopyofdatafromyourdatabasethatcanbeusedtoreconstructthatdata.Backupscanbedividedintophysicalbackupsandlogicalbackups.
Physicalbackupsarebackupsofthephysicalfilesusedinstoringandrecoveringyourdatabase,suchasdatafiles,controlfiles,andarchivedredologs.Ultimately,everyphysicalbackupisacopyoffilesstoringdatabaseinformationtosomeotherlocation,whetherondiskorsomeofflinestoragesuchastape.
Logicalbackupscontainlogicaldata(forexample,tablesorstoredprocedures)exportedfromadatabasewithanOracleexportutilityandstoredinabinaryfile,forlaterre-importingintoadatabaseusingthecorrespondingOracleimportutility..
Seealso:
OracleDatabaseUtilitiesformoredetailsaboutimportingandexportingdatausingOracleexportandimportutilities.
Physicalbackupsarethefoundationofanysoundbackupandrecoverystrategy.Logicalbackupsareausefulsupplementtophysicalbackupsinmanycircumstancesbutarenotsufficientprotectionagainstdatalosswithoutphysicalbackups.
Unlessotherwisespecified,theterm"backup"asusedinthebackupandrecoverydocumentationreferstophysicalbackups,andtobackuppartorallofyourdatabaseistotakesomekindofphyscialbackup.Thefocusinthebackupandrecoverydocumentationsetwillbealmostexclusivelyonphysicalbackups.
ErrorsandFailuresRequiringRecoveryfromBackup
WhilethereareseveraltypesofproblemthatcanhaltthenormaloperationofanOracledatabaseoraffectdatabaseI/Ooperations,onlytwotypicallyrequireDBAinterventionandmediarecovery:
mediafailure,andusererrors.
OtherfailuresmayrequireDBAinterventiontorestartthedatabase(afteraninstancefailure)orallocatemorediskspace(afterstatementfailuredueto,forinstance,afulldatafile)butthesesituationswillnotgenerallycausedatalossorrequirerecoveryfrombackup.
UserError
Usererrorsoccurwhen,eitherduetoanerrorinapplicationlogicoramanualmis-step,datainyourdatabaseischangedordeletedincorrectly.Datalossduetousererrorincludessuchmisstepsasdroppingimportanttablesordeletingorchangingthecontentsofatable.Whileusertrainingandcarefulmanagementofprivilegescanpreventmostusererrors,yourbackupstrategydetermineshowgracefullyyourecoverthelostdatawhenusererrordoescausedataloss.
MediaFailure
Amediafailureisthefailureofareadorwriteofadiskfilerequiredtorunthedatabase,duetoaphysicalproblemwiththedisksuchasaheadcrash.Anydatabasefilecanbevulnerabletoamediafailure.
Theappropriaterecoveryfromamediafailuredependsonthefilesaffectedandthetypesofbackupavailable.
OracleBackupandRecoverySolutions:
RMANandUser-ManagedBackup
Forperformingbackupandrecoverybasedonphysicalbackups,youhavetwosolutionsavailable:
∙RecoveryManager(RMAN),atool(withcommand-lineclientandEnterpriseManagerGUIinterfaces)thatintegrateswithsessionsrunningontheOracleservertoperformarangeofbackupandrecoveryactivities,aswellasmaintainingarepositoryofhistoricaldataaboutyourbackups
∙Thetraditionaluser-managedbackupandrecovery,whereyoudirectlymanagethefilesthatmakeupyourdatabasewithamixtureofhostoperatingsystemcommandsandSQL*Plusbackupandrecovery-relatedcapabilities
BothmethodsaresupportedbyOracleCorporationandarefullydocumented.RecoveryManageris,however,thepreferredsolutionfordatabasebackupandrecovery.Itcanperformthesametypesofbackupandrecoveryavailablethroughuser-managedmethodsmoreeasily,providesacommoninterfaceforbackuptasksacrossdifferenthostoperatingsystems,andoffersanumberofbackuptechniquesnotavailablethroughuser-managedmethods.
MostofthebackupandrecoverydocumentationsetwillfocusonRMAN-basedbackupandrecovery.User-managedbackupandrecoverytechniquesarecoveredinthelaterchaptersofOracleDatabaseBackupandRecoveryAdvancedUser'sGuide.
WhetheryouuseRMANoruser-managedmethods,youcansupplementyourphysicalbackupswithlogicalbackupsofschemaobjectsmadeusingdataexportutilities.Datathussavedcanlaterbeimportedtore-createthisdataafterrestoreandrecovery.However,logicalbackupsareforthemostpartbeyondthescopeofthebackupandrecoverydocumentation.
BackupandRecovery:
BasicConcepts
Thephysicalstructuresofthedatabaseandtheroleeachplaysinthedatabaserecoveryprocessarewhatdeterminetheformsofbackupandrecoveryavailablethroughuser-managedtechniquesandthroughRMAN.
PhysicalDatabaseStructuresUsedinRecoveringData
ThefilesandotherstructuresthatmakeupanOracledatabasestoredataandsafeguarditagainstpossiblefailures.ThissectionintroduceseachofthephysicalstructuresthatmakeupanOracledatabaseandtheirroleinthereconstructionofadatabasefrombackup.Thissectioncontainsthesetopics:
∙DatafilesandDataBlocks
∙RedoLogs
∙UndoSegments
∙ControlFiles
DatafilesandDataBlocks
AnOracledatabaseconsistsofoneormorelogicalstorageunitscalledtablespaces.EachtablespaceinanOracledatabaseconsistsofoneormorefilescalleddatafiles,physicalfilesunderthehostoperatingsysteminwhichthedatabaseisrunning.
Adatabase'sdataiscollectivelystoredinthedatafilesthatconstituteeachtablespaceofthedatabase.ThesimplestOracledatabasewouldhaveonetablespace,storedinonedatafile.Thedatbasemanagesthestoragespaceinthedatafilesofadatabaseinunitscalleddatablocks.Adatablockisthesmallestunitofdatausedbyadatabase.Datablocksarethesmallestunitsofstoragethatthedatabasecanuseorallocate.
Modifiedornewdataisnotwrittentodatafilesimmediately.Updatesarebufferedinmemoryandwrittentodatafilesatintervals.Ifadatabasehasnotgonethroughanormalshutdown(thatis,ifitisopen,orexitedabnormally,asinaninstancefailureoraSHUTDOWNABORT)thentherearetypicallychangesinmemorythathavenotbeenwrittentothedatafiles.Datafilesthatwererestoredfrombackup,orwerenotclosedduringaconsistentshutdown,aretypicallynotcompletelyuptodate.
Copiesofthedatafilesofadatabaseareacriticalpartofanybackup.
Seealso:
OracleDatabaseConceptsformoredetailaboutthestructureandcontentsofdatafilesanddatablocks.
RedoLogs
Redologsrecordallchangesmadetoadatabase'sdatafiles.Withacompletesetofredologsandanoldercopyofadatafile,thedatabasecanreapplythechangesrecordedintheredologstore-createthedatabaseatanypointbetweenthebackuptimeandtheendofthelastredolog.Eachtimedataischangedinthedatabase,thatchangeisrecordedintheonlineredologfirst,beforeitisappliedtothedatafiles.AnOracledatabaserequiresatleasttwoonlineredologgroups,andineachgroupthereisatleastoneonlineredologmember,anindividualredologfilewherethechangesarerecorded.
Atintervals,thedatabaserotatesthroughtheonlineredologgroups,storingchangesinthecurrentonlineredologwhilethegroupsnotinusecanbecopiedtoanarchivelocation,wheretheyarecalledarchivedredologs(or,collectively,thearchivedredolog).YoucanrunyourdatabaseinARCHIVELOGmode(inwhichthisarchivingofredologfilesisenabled)orNOARCHIVELOGmode(inwhichredologfilesaresimplyoverwritten).
Preservingthearchivedredologisamajorpartofmostbackupstrategies,astheycontainarecordofallupdatestodatafiles.Backupstrategiesofteninvolvecopyingthearchivedredologstodiskortapeforlonger-termstorage.RunninginNOARCHIVELOGmodelimitsyourdatarecoveryoptions.
Seealso:
OracleDatabaseAdministrator'sGuideformoredetailsabouttheonlineredologs,OracleDatabaseAdministrator'sGuideformoredetailsaboutarchivedredologs,and"DecidingBetweenARCHIVELOGandNOARCHIVELOGMode"foradiscussionoftheimplicationsofarchivingordiscardingyourredologfiles.
ControlFiles
Thecontrolfilecontainsacrucialrecordofthephysicalstructuresofthedatabaseandtheirstatus.Severaltypesofinformationstoredinthecontrolfilearerelatedtobackupandrecovery:
∙Databaseinformation(RESETLOGSSCNandtimestamp)
∙Tablespaceanddatafilerecords(filenames,datafilecheckpoints,read/writestatus,offlineranges)
∙Informationaboutredothreads(currentonlineredolog)
∙Logrecords(logsequencenumbers,SCNrangeineachlog)
∙ArecordofpastRMANbackups
∙Informationaboutcorruptdatafileblocks
Therecoveryprocessfordatafilesisinpartguidedbystatusinformationinthecont