rman backup and recovery

Upload: prassu1

Post on 06-Jul-2018

239 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/17/2019 RMAN Backup and Recovery

    1/29

    RMANRMAN

    The Oracle Recovery Manager (RMAN)The Oracle Recovery Manager (RMAN)

  • 8/17/2019 RMAN Backup and Recovery

    2/29

    ObjectivesObjectives

    At the end of this module theAt the end of this module thestudent will understand thestudent will understand thefollowing tasks and concepts.following tasks and concepts.

      Understand the basic functionality ofUnderstand the basic functionality ofthe Oracle Recovery Manager.the Oracle Recovery Manager.

      Understand how to perform basicUnderstand how to perform basicbackup and recovery operationsbackup and recovery operations

    using RMAN.using RMAN.

  • 8/17/2019 RMAN Backup and Recovery

    3/29

    ntro to RMANntro to RMAN

     

    Oracle Recovery ManagerOracle Recovery Manager !ackup and Restore "lient!ackup and Restore "lient

    "omplete or #artial !ackups"omplete or #artial !ackups $ull or ncremental !ackups$ull or ncremental !ackups

    %etects corrupted blocks and reports them%etects corrupted blocks and reports them Automatically tracks new tablespaces and data&lesAutomatically tracks new tablespaces and data&les %oes unused block compression%oes unused block compression 'mploys binary compression for disk backups'mploys binary compression for disk backups "an test backups without restoring them"an test backups without restoring them

  • 8/17/2019 RMAN Backup and Recovery

    4/29

     (he RMAN (he RMANRecovery "atalogRecovery "atalog  Recovery "atalogRecovery "atalog

    Used to store repository recordsUsed to store repository records )tores RMAN scripts)tores RMAN scripts

    "an be stored in its own tablespace on"an be stored in its own tablespace ona separate servera separate server

    "an use the control&les if a recovery"an use the control&les if a recoverycatalog database is not availablecatalog database is not available

  • 8/17/2019 RMAN Backup and Recovery

    5/29

    Recovery "atalogRecovery "atalog

    OptionsOptions 

    RMAN defaults to the NO"A(A*O+RMAN defaults to the NO"A(A*O+connect optionconnect option Uses the target database control&le forUses the target database control&le for

    storing recovery metadatastoring recovery metadata

    Useful for simple backup and recoveryUseful for simple backup and recoveryoptions for a single databaseoptions for a single database

      ,ith the "A(A*O+ connect option- a,ith the "A(A*O+ connect option- aRecovery "atalog may be usedRecovery "atalog may be used A Recover "atalog is a centralied recoveryA Recover "atalog is a centralied recovery

    metadata repositorymetadata repository Useful for simple to comple/ backup andUseful for simple to comple/ backup and

    recovery options for multiple databases onrecovery options for multiple databases onmultiple serversmultiple servers

  • 8/17/2019 RMAN Backup and Recovery

    6/29

    ssues with Usingssues with Using"ontrol&les for RMAN"ontrol&les for RMANMetadataMetadata  RMAN records will eventually 0age out1RMAN records will eventually 0age out1

    of the control &le and the records will beof the control &le and the records will bereusedreused

    Use the "ON(RO*$*'2R'"OR%23''#2(M'Use the "ON(RO*$*'2R'"OR%23''#2(M'init.ora parameter to control the retentioninit.ora parameter to control the retentionperiod 4default is 5 days6period 4default is 5 days6

      Rebuilding the control &le will result inRebuilding the control &le will result inRMAN record lossRMAN record loss  (he command 0alter database backup (he command 0alter database backup

    control&le to trace71 does not backup RMANcontrol&le to trace71 does not backup RMANrecordsrecords

    Use 0alter database backup control&le toUse 0alter database backup control&le to89location:;71 instead to create a binary89location:;71 instead to create a binarycontrol&le copy that maintains RMAN recordscontrol&le copy that maintains RMAN records

  • 8/17/2019 RMAN Backup and Recovery

    7/29

    ,hy Use a Recovery,hy Use a Recovery

    "atalog

  • 8/17/2019 RMAN Backup and Recovery

    8/29

    nvoking RMANnvoking RMAN

      ,ith a recovery catalog,ith a recovery catalog@ORA"*'2OM'@BbinBrman (AR+'( C "A(A*O+@ORA"*'2OM'@BbinBrman (AR+'( C "A(A*O+ user user CC passwd passwdDDserviceservice

    '/ample'/ample@ORA"*'2OM'@BbinBrman (AR+'( C "A(A*O+ sysCoraEFGDorcl@ORA"*'2OM'@BbinBrman (AR+'( C "A(A*O+ sysCoraEFGDorcl

      Using the control&leUsing the control&le@ORA"*'2OM'@BbinBrman (AR+'( )H)C@ORA"*'2OM'@BbinBrman (AR+'( )H)C passwd passwdDDserviceservice

    '/ample'/ample@ORA"*'2OM'@BbinBrman (AR+'( )H)CoraEFGDorcl@ORA"*'2OM'@BbinBrman (AR+'( )H)CoraEFGDorcl

  • 8/17/2019 RMAN Backup and Recovery

    9/29

    "reating a Recovery"reating a Recovery"atalog"atalog  "reate a Recovery "atalog"reate a Recovery "atalog

     (ablespace (ablespace"R'A(' (A!*')#A"' IR'"OJ2"A(I"R'A(' (A!*')#A"' IR'"OJ2"A(I

    *O++N+*O++N+

    %A(A$*' 8"KBoracleBproductBEL.F.LBoradataBorclB%A(A$*' 8"KBoracleBproductBEL.F.LBoradataBorclB  R'"OJ2"A(.dbf )' ELLMR'"OJ2"A(.dbf )' ELLM

  • 8/17/2019 RMAN Backup and Recovery

    10/29

    "reating a Recovery "atalog"reating a Recovery "atalog

      "reate the rman schema"reate the rman schema"R'A(' U)'R rman %'N($'% !H cat"R'A(' U)'R rman %'N($'% !H cat

     ('M#ORARH (A!*')#A"' temp %'$AU*( ('M#ORARH (A!*')#A"' temp %'$AU*( (A!*')#A"' recov2cat UO(A UN*M('% ON (A!*')#A"' recov2cat UO(A UN*M('% ON

    recov2cat7recov2cat7  +rant R'"OJ'RH2"A(A*O+ to the+rant R'"OJ'RH2"A(A*O+ to the

    rman schema rmanrman schema rman+RAN( R'"OJ'RH2"A(A*O+2O,N'R (O rman7+RAN( R'"OJ'RH2"A(A*O+2O,N'R (O rman7

  • 8/17/2019 RMAN Backup and Recovery

    11/29

    "reating a Recovery"reating a Recovery"atalog"atalog  "onnect to Oracle with either )*#lus"onnect to Oracle with either )*#lus

    or RMANor RMANsPlplus rmanCcatDorclsPlplus rmanCcatDorcl

    @ORA"*'2OM'@BbinBrman (AR+'( C "A(A*O+@ORA"*'2OM'@BbinBrman (AR+'( C "A(A*O+

    rmanCcatDorclrmanCcatDorcl  Run the "R'A(' "A(A*O+ script to createRun the "R'A(' "A(A*O+ script to create

    the recovery catalogthe recovery catalog RMAN: "R'A(' "A(A*O+RMAN: "R'A(' "A(A*O+

  • 8/17/2019 RMAN Backup and Recovery

    12/29

    Jalidating the RecoveryJalidating the Recovery"atalog"atalog  "onnect into the Oracle database as rman"onnect into the Oracle database as rman

    and select from user2tablesand select from user2tablessPlplus rmanCcatDorclsPlplus rmanCcatDorcl

    )'*'"( table2name from user2tables)'*'"( table2name from user2tables

      "onnect into RMAN"onnect into RMANQORA"*'2OM'CbinCrman (AR+'( C "A(A*O+QORA"*'2OM'CbinCrman (AR+'( C "A(A*O+

    rmanCcatDorclrmanCcatDorcl Note 0connected to recovery catalog database1Note 0connected to recovery catalog database1

  • 8/17/2019 RMAN Backup and Recovery

    13/29

    "onnecting with RMAN"onnecting with RMAN

      "onnect into the target database"onnect into the target databaseusing )H)using )H)

      "onnect into the recovery catalog"onnect into the recovery catalog

    using rmanusing rman  "onnect into both the target"onnect into both the target

    database and recovery catalog usingdatabase and recovery catalog using

    bothboth@ORA"*'2OM'@BbinBrman (AR+'(@ORA"*'2OM'@BbinBrman (AR+'(

    sysCoraEFGDorcl "A(A*O+sysCoraEFGDorcl "A(A*O+rmanCcatDorclrmanCcatDorcl

  • 8/17/2019 RMAN Backup and Recovery

    14/29

    Registering a (argetRegistering a (arget%atabase in the Recovery%atabase in the Recovery

    "atalog"atalog  "onnect into RMAN"onnect into RMAN  Run register databaseRun register database  Jalidate with report schemaJalidate with report schema

  • 8/17/2019 RMAN Backup and Recovery

    15/29

    RMAN nformationRMAN nformation

       (he show command displays (he show command displaysinformation about the RMANinformation about the RMANcon&gurationcon&guration

    show all displays everythingshow all displays everything   (he list command displays (he list command displays

    information about previous backupsinformation about previous backups

    list backup displays a list of backupslist backup displays a list of backups   (he report commands creates RMAN (he report commands creates RMAN

    reports on operationsreports on operations

  • 8/17/2019 RMAN Backup and Recovery

    16/29

    RMAN "on&gurationRMAN "on&guration

      "on&gure %evices"on&gure %evices sbt device is the media managersbt device is the media manager

    JeritasJeritas

    *egato*egato *ocal disk can be used*ocal disk can be used

      "on&gure "hannels"on&gure "hannels

    Used to perform the backupsUsed to perform the backups

  • 8/17/2019 RMAN Backup and Recovery

    17/29

    "on&guring %evices"on&guring %evices

      )etup default devices)etup default devices "on&gure media manager"on&gure media manager

    "ON$+UR' %'$AU*( %'J"' (H#' (O sbt7"ON$+UR' %'$AU*( %'J"' (H#' (O sbt7

    "on&gure disk backup"on&gure disk backup"ON$+UR' %'$AU*( %'J"' (H#' (O %)37"ON$+UR' %'$AU*( %'J"' (H#' (O %)37 t can also be setup to use compressedt can also be setup to use compressed

    savesetssavesets

    "ON$+UR' %'J"' (H#' %)3 !A"3U# (H#'"ON$+UR' %'J"' (H#' %)3 !A"3U# (H#' (O "OM#R'))'% !A"3U#)'(7 (O "OM#R'))'% !A"3U#)'(7

  • 8/17/2019 RMAN Backup and Recovery

    18/29

    "on&guring "hannels"on&guring "hannels

      "hannel is the device path to the"hannel is the device path to thebackup mediabackup media

      ,ith a disk device- this is the path,ith a disk device- this is the path

    "ON$+UR' "ANN'* %'J"' (H#' %)3 $ORMA("ON$+UR' "ANN'* %'J"' (H#' %)3 $ORMA(8"KBoracleBbackupBora2df@t2s@s2s@p78"KBoracleBbackupBora2df@t2s@s2s@p7 

  • 8/17/2019 RMAN Backup and Recovery

    19/29

    "on&guring "ontrol&le"on&guring "ontrol&le!ackups!ackups  "ontrol&les can be set to auto backup"ontrol&les can be set to auto backup

    whenever a backup occurs by settingwhenever a backup occurs by settingautobackup on.autobackup on.

    "ON$+UR' "ON(RO*$*' AU(O!A"3U# on7"ON$+UR' "ON(RO*$*' AU(O!A"3U# on7

  • 8/17/2019 RMAN Backup and Recovery

    20/29

    #erforming !ackups#erforming !ackups

       (here are a number of di=erent ways (here are a number of di=erent waysto do backupsto do backups

    !A"3U# %A(A!A)'!A"3U# %A(A!A)'

    !A"3U# (A!*')#A"' 8U)'R);7!A"3U# (A!*')#A"' 8U)'R);7

    !A"3U# N"R'M'N(A* *'J'* L %A(A!A)'7!A"3U# N"R'M'N(A* *'J'* L %A(A!A)'7

    !A"3U# "URR'N( "ON(RO*$*'7!A"3U# "URR'N( "ON(RO*$*'7

  • 8/17/2019 RMAN Backup and Recovery

    21/29

    RA" !ackupsRA" !ackups

      !ackup from one node!ackup from one node  Remember to backup all archive logRemember to backup all archive log

    threads 4representing each node6 allthreads 4representing each node6 all

    should be visible from any nodeshould be visible from any node

  • 8/17/2019 RMAN Backup and Recovery

    22/29

    '/ample RMAN OSine'/ample RMAN OSine!ackup )cript!ackup )cript  ere is an e/ample for a disk>ere is an e/ample for a disk>

    based online backupKbased online backupK

    set "M%$*'T"KB('M#Brman2cmd&le.batset "M%$*'T"KB('M#Brman2cmd&le.bat

    echo shutdown immediate7 :: @"M%$*'@echo shutdown immediate7 :: @"M%$*'@

    echo startup mount7 :: @"M%$*'@echo startup mount7 :: @"M%$*'@

    echo allocate channel cE device type disk formatecho allocate channel cE device type disk format8"KBoracleBadminBmydbBbackupBmydb2U@;7 ::8"KBoracleBadminBmydbBbackupBmydb2U@;7 ::@"M%$*'@@"M%$*'@

    echo allocate channel cF device type disk formatecho allocate channel cF device type disk format8'KBoracleBadminBmydbBbackupBmydb2U@;7 ::8'KBoracleBadminBmydbBbackupBmydb2U@;7 ::@"M%$*'@@"M%$*'@

    echo backup database7 :: @"M%$*'@echo backup database7 :: @"M%$*'@

    echo alter database open- :: @"M%$*'@echo alter database open- :: @"M%$*'@

    echo e/it7 :: @"M%$*'@echo e/it7 :: @"M%$*'@

  • 8/17/2019 RMAN Backup and Recovery

    23/29

    '/ample RMAN Online'/ample RMAN Online!ackup )cript!ackup )cript

      ere is an e/ample for a disk>basedere is an e/ample for a disk>basedonline backupKonline backupK

    set "M%$*'T"KB('M#Brman2cmd&le.batset "M%$*'T"KB('M#Brman2cmd&le.batecho allocate channel cE device type disk formatecho allocate channel cE device type disk format

    8"KBoracleBadminBmydbBbackupBmydb2U @;7 :: @"M%$*'@8"KBoracleBadminBmydbBbackupBmydb2U @;7 :: @"M%$*'@

    echo allocate channel cF device type disk formatecho allocate channel cF device type disk format8'KBoracleBadminBmydbBbackupBmydb2U @;7 :: @"M%$*'@8'KBoracleBadminBmydbBbackupBmydb2U @;7 :: @"M%$*'@

    echo con&gure control&le autobackup on7 :: @"M%$*'@echo con&gure control&le autobackup on7 :: @"M%$*'@

    echo backup database plus archivelog7 :: @"M%$*'@echo backup database plus archivelog7 :: @"M%$*'@echo e/it7 :: @"M%$*'@echo e/it7 :: @"M%$*'@

    @ORA"*'2OM'@BbinBrman target mydbCpassword cmd&leT@ORA"*'2OM'@BbinBrman target mydbCpassword cmd&leT@"M%$*'@@"M%$*'@

  • 8/17/2019 RMAN Backup and Recovery

    24/29

    #erforming Restores#erforming Restores

      $irst preview the restore$irst preview the restoreR')(OR' %A(A!A)' #R'J',7R')(OR' %A(A!A)' #R'J',7

    R')(OR' (A!*')#A"' users #R'J',7R')(OR' (A!*')#A"' users #R'J',7

    R')(OR' %A(A$*' G #R'J',7R')(OR' %A(A$*' G #R'J',7

      #review allows you to see a report#review allows you to see a reportbefore the restore takes placebefore the restore takes place

  • 8/17/2019 RMAN Backup and Recovery

    25/29

    #erforming Restores#erforming Restores

      #erforming the Restore#erforming the RestoreR')(OR' %A(A!A)'7R')(OR' %A(A!A)'7

    R')(OR' (A!*')#A"' users7R')(OR' (A!*')#A"' users7

    R')(OR' %A(A$*' G7R')(OR' %A(A$*' G7

  • 8/17/2019 RMAN Backup and Recovery

    26/29

    Jalidating !ackupsJalidating !ackups

      !ackups can be validated with!ackups can be validated withrestore validaterestore validate

    R')(OR' %A(A!A)' JA*%A('7R')(OR' %A(A!A)' JA*%A('7

    R')(OR' "ON(RO*$*' JA*%A('7R')(OR' "ON(RO*$*' JA*%A('7

    R')(OR' (A!*')#A"' users JA*%A('7R')(OR' (A!*')#A"' users JA*%A('7

    R')(OR' AR"J'*O+ A** JA*%A('7R')(OR' AR"J'*O+ A** JA*%A('7

  • 8/17/2019 RMAN Backup and Recovery

    27/29

    '/ample of "omplete'/ample of "ompleteRecovery Using an RMANRecovery Using an RMAN

    Online !ackupOnline !ackup  ere is an e/ample recovery from anere is an e/ample recovery from anonline backup 4followed by an immediateonline backup 4followed by an immediatebackup6Kbackup6K

    )et ORA"*'2)%Tmydb)et ORA"*'2)%Tmydb

    @ORA"*'2OM'@BbinBrman target mydbCpassword@ORA"*'2OM'@BbinBrman target mydbCpassword

    Rman: startup nomount7Rman: startup nomount7

    Rman: set %!% T 9enter your %!%:7Rman: set %!% T 9enter your %!%:7

    Rman: restore sp&le from autobackup7Rman: restore sp&le from autobackup7

    Rman: restore control&le from autobackup7Rman: restore control&le from autobackup7

    Rman: alter database mount7Rman: alter database mount7

    Rman: restore database7Rman: restore database7

    Rman: recover database7Rman: recover database7

    Rman: alter database open resetlogs7Rman: alter database open resetlogs7

    Rman: shutdown immediate7Rman: shutdown immediate7

    Rman: startup mount7Rman: startup mount7

    Rman: backup database7Rman: backup database7Rman: PuitRman: Puit

  • 8/17/2019 RMAN Backup and Recovery

    28/29

    ReviewReview

      Name one disadvantage of using aName one disadvantage of using a"ontrol $ile to store RMAN meta>data"ontrol $ile to store RMAN meta>data

      f you have a recovery catalog- describef you have a recovery catalog- describehow you connect to RMAN and the targethow you connect to RMAN and the targetdatabasedatabase

      ,hat is the device name used for a,hat is the device name used for amedia manager

  • 8/17/2019 RMAN Backup and Recovery

    29/29

    )ummary)ummary

      RMAN "onceptsRMAN "oncepts  RMAN $unctionalityRMAN $unctionality