Top Banner

of 22

RMAN(Script Overview)

Jul 05, 2018

Download

Documents

raaji
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/16/2019 RMAN(Script Overview)

    1/22

    Introduction to Recovery Manager 1. Recovery Manager (RMAN) is an Oracleutility that can back up, restore, and

    recover database files. he product is a feature of theOracle database server and does not

    re!uire separate installation. Recovery Manager is a client"server application that uses

    database server sessions to perfor# backup and recovery.

    About Recovery Manager (RMAN)

    Recovery Manager (RMAN) is an Oracle utility that can back up, restore, and recover

    database files. he product is a feature of the Oracle database server and does not re!uire

    separate installation.

    Recovery Manager is a client"server application that uses database server sessions to

     perfor# backup and recovery. $t stores #etadata about its operations in the control file of

    the target database and, optionally, in a recovery catalog sche#a in an Oracle database.

    %ou can invoke RMAN as a co##and&line e'ecutable fro# the operating syste# pro#pt

    or use so#e RMAN features through the nterprise Manager *$.

    Why Use RMAN?

    Most production database syste#s i#pose stringent re!uire#ents on backup and recovery.

    As a +A in charge of backup and recovery, you #ust-

    • Manage the complexity of backup and recovery operations

    • Minimize the possibility of human error

    • Make backups scalable and reliable

    • Utilize all available media hardware

    • Make backups proportional to the size of transactional changes,not to the size of database

  • 8/16/2019 RMAN(Script Overview)

    2/22

    • Make recovery time proportional to the amount of data recovered

    %ou have to basic #ethods for perfor#ing these backup and recovery tasks on an Oracle

    release /.0 or higher database-

    • Using operating system commands to perform backup and restoreoperations, and SQL or SQL!lus statements to perform recovery

    • Using "ecovery Manager for backup, restore, and recovery

    Note :-

    "M#$ was introduced in %racle release &'( and is not compatible with

    %racle databases prior to release &'('

    hy use one #ethod rather than the other2 As illustrated in 3igure 1&1, RMAN uses

    server sessions to perfor# backup and recovery operations and stores #etadata in a

    repository. RMAN auto#ates backup and recovery, hereas the useranaged #ethod

    re!uires you to keep track of all database files and backups. 3or e'a#ple, instead of

    re!uiring you to locate backups for each datafile, copy the# to the correct place using

    operating syste# co##ands, and choose hich logs to apply, RMAN #anages these tasks

    auto#atically.

    he advantage of using RMAN is especially true if you use Oracle Managed 3iles. hen

    you let Oracle na#e and #anage your datafiles, control files, and online redo logs, the

    syste# beco#es easier to use. On the other hand, it #ay be harder for you to keep track of 

    the filena#es of the various database files because you have not na#ed the# yourself.

    RMAN users do not suffer fro# this proble# because RMAN handles all record keeping.

    Figure 1-1 Comparison of RMAN Automated and User-Managed Procedures

    http://docs.oracle.com/cd/B10501_01/server.920/a96566/rcmintro.htm#452884http://docs.oracle.com/cd/B10501_01/server.920/a96566/rcmintro.htm#452884

  • 8/16/2019 RMAN(Script Overview)

    3/22

    Overview of the RMAN Environent

    he RMAN environ#ent consists of the utilities and databases that play a role in a backup

    and recovery strategy. A typical RMAN setup utili4es the folloing-

    • "M#$ executable

    •  )arget database

    • "ecovery catalog database

    • Media management software

    Of these co#ponents, only the RMAN e'ecutable and target database are re!uired.RMAN auto#atically stores its #etadata in the target database control file, so the recovery

    catalog database is optional. Nevertheless, #aintaining a recovery catalog is strongly

    encouraged. $f you create a catalog on a separate #achine, and if the production #achine

    fails co#pletely, then you have all the restore and recovery infor#ation you need in the

    catalog.

    About the RMAN E!ecutab"e

    he RMAN e'ecutable is auto#atically included ith the Oracle softare installation. $ts

    location is platfor#&specific and is typically located in the sa#e place as the other Oracle

    e'ecutables. On *ni' syste#s, for e'a#ple, the RMAN e'ecutable is located

    in $ORACLE_HOME/bin.

  • 8/16/2019 RMAN(Script Overview)

    4/22

    o start the e'ecutable, si#ply enter the filena#e on the co##and line. 3or e'a#ple, on a

    *N$5 syste#, enter-

    % rman

    About the #arget $atabase

    he target database is the database that RMAN is backing up, restoring, or recovering.

    %ou can use a single recovery catalog in con6unction ith #ultiple target databases. 3or

    e'a#ple, assu#e that your data center contains 10 databases of varying si4es. %ou can use

    a single recovery catalog located in a different data center to #anage the #etadata fro# all

    of these databases.

    About the RMAN Re%ository

    he RMAN repository is a set of #etadata that RMAN uses to store infor#ation about the

    target database and its backup and recovery operations. A#ong other things, RMAN

    stores infor#ation about-

    • *ackup sets and pieces

    • +mage copies including archived redo logs-

    • !roxy copies

    •  )he target database schema

    • !ersistent con.guration settings

    %ou can access this #etadata by issuing LIST, REPORT, and SHOW co##ands in the RMAN

    interface, or by using SELECT state#ents on the catalog vies (only if you use a recovery

    catalog). 3igure 1&7illustrates ho RMAN issues lists and reports.

    http://docs.oracle.com/cd/B10501_01/server.920/a96566/rcmintro.htm#453325http://docs.oracle.com/cd/B10501_01/server.920/a96566/rcmintro.htm#453325

  • 8/16/2019 RMAN(Script Overview)

    5/22

    Figure 1-2 RMAN Lists and Reports

    %ou can either create a recovery catalog in hich to store the repository, or let RMAN

    store the repository e'clusively in the target database control file. 3igure 1&8 depicts

    RMAN using a recovery catalog.

    Figure 1-3 RMAN with ptiona! Reco"er# Cata!og 

    http://docs.oracle.com/cd/B10501_01/server.920/a96566/rcmintro.htm#453284http://docs.oracle.com/cd/B10501_01/server.920/a96566/rcmintro.htm#453284

  • 8/16/2019 RMAN(Script Overview)

    6/22

    Comparison Between RMAN and User-Managed Methods $- 

    Recovery Manager User&Managed Method

    *ses a #edia #anage#ent A9$ so that RMAN

    orks sea#lessly ith third&party #edia

    #anage#ent softare. More than 70 vendorssupport the A9$.

    +oes not have support of a published A9$.

    hen backing up online files, RMAN rereadsfractured data blocks to get a consistent read. %ou

    do not need to place online tablespaces in backup#ode hen perfor#ing backups.

    Re!uires placing online tablespaces in backup#ode before backing the# up, and then taking

    the tablespaces out of this #ode after the backupis co#plete. :erious database perfor#ance and#anageability proble#s can occur if you neglect

    to take tablespaces out of backup #ode after an

    online backup is co#plete.

    9erfor#s incre#ental backups, hich back up

    only those data blocks that changed after a previous backup. %ou can recover the database

    using incre#ental backups, hich #eans that youcan recover aNOARCHIVELOG database. ;oever,

    you can only take incre#ental backups of

    a NOARCHIVELOG database after a consistent

    shutdon.

    acks up all blocks, not 6ust the changed blocks.

    +oes not allo you to recovera NOARCHIVELOGdatabase.

  • 8/16/2019 RMAN(Script Overview)

    7/22

    Recovery Manager User&Managed Method

    O#its never&used blocks fro# datafile backups sothat only data blocks that have been ritten to are

    included in a backup.

    $ncludes all data blocks, regardless of hetherthey contain data.

    *ses the repository to report on crucial

    infor#ation, including-

    • +atabase sche#a at a specified ti#e

    hich files need a backup

    • hich files have not had a backup in a

    specified nu#ber of days

    • hich backups can be deleted because

    they are redundant or cannot be used for

    recovery

  • 8/16/2019 RMAN(Script Overview)

    8/22

    Recovery Manager User&Managed Method

    then issuing operating syste# co##ands in parallel.

    ests hether files can be backed up or restored

    ithout actually perfor#ing the backup or restore.

    Re!uires you to actually restore backup files

     before you can perfor# a trial recovery of the

     backups.

    9erfor#s archived log failover auto#atically. $f

    RMAN discovers a corrupt or #issing log duringa backup, then it considers all logs and log copies

    listed in the repository as alternative candidates

    for the backup.

  • 8/16/2019 RMAN(Script Overview)

    9/22

    efore getting into the configr! co##and, lets first take a look at our default settings by

    using the show co##and-RMAN" SHOW ALL;

    RMAN configra#ion aram!#!r ar!&CON'IG(RE RETENTION POLIC) TO RE*(N*ANC) +, - .!fa#CON'IG(RE 0AC1(P OPTIMI2ATION O'', - .!fa#CON'IG(RE *E'A(LT *EVICE T)PE TO *IS1, - .!fa#CON'IG(RE CONTROL'ILE A(TO0AC1(P O'', - .!fa#CON'IG(RE CONTROL'ILE A(TO0AC1(P 'ORMAT 'OR *EVICE T)PE *IS1 TO 3%'3, - .!fa#CON'IG(RE *EVICE T)PE *IS1 PARALLELISM +, - .!fa#CON'IG(RE *ATA'ILE 0AC1(P COPIES 'OR *EVICE T)PE *IS1 TO +, - .!fa#CON'IG(RE ARCHIVELOG 0AC1(P COPIES 'OR *EVICE T)PE *IS1 TO +, - .!fa#CON'IG(RE MA4SETSI2E TO (NLIMITE*, - .!fa#CON'IG(RE SNAPSHOT CONTROL'ILE NAME TO3/5+/a/orac!/ro.c#/+56765/.b/nacf_TARG*06f3, - .!fa#

    3ro# the above listing, you can see that the RMAN allos you to set default values forso#e of the folloing-

    • he default retention policy. his deter#ines hich backups and copies are

    eligible for deletion because they are no longer needed.

    • urning ON and O33 backup opti#i4ation. ackup opti#i4ation eli#inates

    duplicate backups of identical datafiles (like those associated ith a read&

    only tablespace) and archived redo logs.

    • A default device type for RMAN 6obs, (disk or tape [sbt])

    • he default for auto#ated backups of the control file to ON or O33. %ou can

    also control the default for#at of the control file backup output files and the

    default device on hich to create these backups.

    • he nu#ber of channels (for paralleli4ation) that are auto#atically allocated

    hen perfor#ing auto#ated backup and recovery"restore 6obs.

    • A tablespace e'clusion policy to configure specific tablespaces to be

    e'cluded during full database backup operations. $f there are no tablespacee'clusion policies defined, nothing ill be displayed by the 8o9

    a co##and.

    • he #a'i#u# si4e for any given backup piece and the si4e of any backup set

    hen perfor#ing auto#ated backups.

  • 8/16/2019 RMAN(Script Overview)

    10/22

    • he default filena#e for the snapshot controlfile.

    his article ill provide detailed infor#ation on all of these RMAN configuration

     para#eters and ho they can be defined.

    Using Substitution Variables

    RMAN can #ake use of substitution variables in creating for#at strings to generate

    filena#es. ithout due care, non&uni!ue filena#es can be generated and, under certain

    circu#stances, this can cause backup data to be overritten and therefore lost. :o becareful@ this is not a bug ith Oracle, but rather a usage error.

    Format Description

    %specifies the backup piece number  ithin the backup set. his value starts at 1 for each

     backup set and is incre#ented by 1 as each backup piece is created.

    %

    specifies the backup set number . his nu#ber is a counter in the control file that is

    incre#ented for each backup set. he counter value starts at 1 and is uni!ue for the lifeti#eof the control file. $f you restore a backup control file, then duplicate values can result. Also,

    initiali4es the counter back to 1.

    %. specifies the database na#e.

    %n

    specifies the database name, padded on the right ith ' characters to a total length of /

    characters. 3or e'a#ple, if 9RO+1 is the database na#e, then 9RO+1''' is the paddeddatabase na#e.

    %#

    specifies the backup set timestamp, hich is a B&byte value derived as the nu#ber of

    seconds elapsed since a fi'ed reference ti#e. he co#bination of Cs and Ct can be used tofor# a uni!ue na#e for the backup set.

    %specifies an /&character na#e constituted by co#pressed representations of the backup set

    nu#ber and the ti#e the backup set as created.

    %c

    (Oracle/i or higher) & specifies the copy nu#ber of the backup piece ithin a set of

    duple'ed backup pieces. $f you did not issue the set duple' co##and, then this variable ill be 1 for regular backup sets and 0 for pro'y copies. $f you issued set duple', the variable

    identifies the copy nu#ber- 1, 7, 8, or B.

    %(

    (Oracle/i or higher) & specifies a convenient shorthand for CuDCpDCc that guarantees

    uni!ueness in generated backup filena#es. $f you do not specify a for#at, RMAN uses C* by default. C* is the default in Oracle/i.

  • 8/16/2019 RMAN(Script Overview)

    11/22

    Using the  configure  Comman to Clear Values

    efore discussing each of the RMAN configuration para#eters in detail, lets first take a

    look at ho to clear values. (:etting these configuration para#eters to their default values)

    >ike setting an RMAN configuration para#eter, you use the configr! co##and, but ill

    use the clear option.

    o set the MA4SETSI2E para#eter back to its default value of *N>$M$+-

    RMAN" configure maxsetsize clear;;ere is a list of co##ands that clear several RMAN settings back to their default values-RMAN" CONFIG!" !"#"N#ION $OLIC% CL"A!;RMAN" CONFIG!" &AC'$ O$#I(I)A#ION CL"A!;RMAN" CONFIG!" *"FAL# *"+IC" #%$" CL"A!;RMAN" CONFIG!" CON#!OLFIL" A#O&AC'$ CL"A!;RMAN" CONFIG!" CON#!OLFIL" A#O&AC'$ FO!(A# FO! *"+IC" #%$" *IS' CL"A!;RMAN" CONFIG!" CON#!OLFIL" A#O&AC'$ FO!(A# FO! *"+IC" #%$" S CL"A!;RMAN" CONFIG!" *"+IC" #%$" *IS' CL"A!;RMAN" CONFIG!" *A#AFIL" &AC'$ CO$I"S FO! *"+IC" #%$" *IS' CL"A!;RMAN" CONFIG!" *A#AFIL" &AC'$ CO$I"S FO! *"+IC" #%$" S CL"A!;RMAN" CONFIG!" A!CHI+"LOG &AC'$ CO$I"S FO! *"+IC" #%$" *IS' CL"A!;RMAN" CONFIG!" A!CHI+"LOG &AC'$ CO$I"S FO! *"+IC" #%$" S CL"A!;RMAN" CONFIG!" CHANN"L *"+IC" #%$" *IS' CL"A!;RMAN" CONFIG!" CHANN"L *"+IC" #%$" S CL"A!;RMAN" CONFIG!" (A,S"#SI)" CL"A!;RMAN" CONFIG!" SNA$SHO# CON#!OLFIL" NA(" CL"A!;RMAN" - CONFIG!" ",CL*" FO! #A&L"S$AC" S"!S.!"A*.#&S;

    R!"!N"#ON $O%#C&

    *sed to control ho long RMAN ill keep backups. his can be configured by the

    Enu#berE of backups taken, or by the nu#bers of EdaysE to keep. ;ere is an e'a#ple of

     both-CONFIG!" !"#"N#ION $OLIC% #O !"*N*ANC% /;

    CONFIG!" !"#"N#ION $OLIC% #O !"CO+"!% WIN*OW OF 0 *A%S;

  • 8/16/2019 RMAN(Script Overview)

    12/22

     Note that hen configuring a retention policy, RMAN ill not cause backups to be

    auto#atically deleted. he retention policy ill, hoever, #ark backups as O:O>

    that have fallen outside the retention period. RMAN co##ands like EREPORT O0SOLETEE

    and E*ELETE O0SOLETEE ill ork ith these obsolete backups.

    $f back up your database infre!uently, you probably ill prefer a redundancy policy that is

    stated in ter#s of nu#ber of backups rather than backups later than n days old. $n this

    case, you ould use the re1un1anc2 para#eter as follos-

    RMAN" CONFIG!" !"#"N#ION $OLIC% #O !"*N*ANC% 0;

    3inally, if you do not ant to use a retention policy, si#ply use-RMAN" CONFIG!" !"#"N#ION $OLIC% #O NON";

    'AC(U$ O$"#M#)A"#ON

    *sed to enable or disable backup opti#i4ation. ackup file opti#i4ation can assist in

    reducing the space used to backup the database. hen perfor#ing an RMAN backup, a

    check is done on the file before backup to see if the file already e'ists in a backupset ith

    the sa#e infor#ation- (dbid, checkpoint, and resetlogs data).

    3or archive logs, the sa#e file #eans the sa#e dbid, thread, se!uence, and resetlogs data.$f the +> $N9* option is used, RMAN deletes all the files that ould have been

     backed up, even hen the file is not included due to file opti#i4ation.

    he to possible values for backup opti#i4ation is ON and O33 as shon in the

    folloing e'a#ple synta'-

    CONFIG!" &AC'$ O$#I(I)A#ION OFF;

    CONFIG!" &AC'$ O$#I(I)A#ION ON;

    *se caution hen enabling backup opti#i4ation if you use a #edia #anager that has an

    e'piration policy. he #edia #anager can e'pire tapes containing backups (using its

    #edia control softare), and RMAN ill not #ake ne backups because of opti#i4ation.

    One ay to protect fro# this is to run

  • 8/16/2019 RMAN(Script Overview)

    13/22

    e'a#ple, consider perfor#ing a backup ith opti#i4ation enabled and a retention period

    of 8 days. RMAN ill only co#pare the datafile ith backup sets ithin the 8 day period

    & even if the datafile it is about to backup hasnt changed ithin that 8 days.

    D!FAU%" D!V#C! "&$!

  • 8/16/2019 RMAN(Script Overview)

    14/22

    CONFIG!" CON#!OLFIL" A#O&AC'$ OFF;

    hen the 3$> A*OA and the :93$> (if the database as started ith

    an :93$>) to the sa#e backup piece. After the 3$> A*OA

  • 8/16/2019 RMAN(Script Overview)

    15/22

    docu#ented (above). hen 3$> A*OA and :93$>, (if the database as started ith an spfile), are includedauto#atically hen datafile 1 is backed up.

  • 8/16/2019 RMAN(Script Overview)

    16/22

    >>$:M to 7 or even 17.

    DA"A'AS! +an ARC,#V!%O-. 'AC(U$ CO$#!S

    :pecifies the nu#ber of copies of each backup set for +AA3$> (both datafiles and

    control files) or ARO files on the specified device type, fro# 1 (default) to B. $f 

    duple'ing is specified in the 0AC1(P co##and or in a SET 0AC1(P COPIES co##and, then

    the CON'IG(RE setting is overridden.

  • 8/16/2019 RMAN(Script Overview)

    17/22

    ;ere is the general synta'-

      ?ARCHIVELOG> *ATA'ILE@

      0AC1(P COPIES 'OR *EVICE  T)PE .!ic!S!cifi!r  TO in#!g!r,

    NO"!* 

  • 8/16/2019 RMAN(Script Overview)

    18/22

    aocO!ran.Li# / S!cifi! con#ro o#ion for #8! /  / aoca#!. c8ann! / 

  • 8/16/2019 RMAN(Script Overview)

    19/22

    RMAN" CONFIG!" CHANN"L 6 *"+IC" #%$" *IS' FO!(A#78ora3ac4u568rman8O!A9/:83ac4u5.13.1.S.s.$.5.#.t7 (A,$I"C"SI)" 6:/9 operations. he RA para#eter

    specifies units of bytes"second. est to find a value that i#proves perfor#ance of your

    !ueries hile still letting RMAN co#plete the backup in a reasonable a#ount of ti#e. Note

    that RATE is not designed to increase backup throughput, but to decrease backup throughputso that #ore disk bandidth is available for other database operations.

    NO"!* he

  • 8/16/2019 RMAN(Script Overview)

    20/22

    database device configuration. $t is not necessary to specify configuration infor#ation for

    au'iliary channels unless they re!uire different para#eters fro# the target channels.

    NO"!* 3or generic channels of a specified device type, a ne co##and erases previous

    settings for this device type. Assu#e that you run these co##ands-CONFIG!" CHANN"L *"+IC" #%$" s3t (A,$I"C"SI)" 6G;CONFIG!" CHANN"L *"+IC" #%$" s3t !A#" 6B::';

    he second co##and erases the MA59$

  • 8/16/2019 RMAN(Script Overview)

    21/22

    docu#entation states that it li#its the si4e of a backup set, it see#s to place li#its on the

    datafile si4es & even though $ a# using backup sets and not i#age copies. 3or e'a#ple, $

    have set MA5::$ to H00# and atte#pted to backup a database, only to get the error-

    RMAN:5+Q& .a#afi! or .a#afi!coB arg!r #8an SETSI2E& fi!- +/+5/a/ora.a#a/TARG*0/!r5+6.bf

    he file (users01.dbf) is larger than H00M but the backupset is considerably s#aller thanthat (there is very little data in there at present). he Oracle docu#entation states that

    MA5::$ li#its the si4e of the backupsets, NO the si4e of the datafiles hich can be

     backed&up. All $ can say, is that Oracle states that this is e'pected behavior, and $ think it isa bug in the docu#entation.

    $f you ant to set the value backup to its default, use-

    RMAN" CONFIG!" (A,S"#SI)" CL"A!;

    SNA$S,O" CON"RO%F#%!

    A snapshot control file is created by RMAN during the backup process that serves as a

     point&in&ti#e copy of the database control file. his ill ensure that that backups being

    taken is consistent to a given point in ti#e. 3or e'a#ple, if you add a datafile ortablespace to a database after the backup has started, (assu#ing an online backup and

     before the backup has ended), that datafile and"or tablespace ill not be included in the

     backup. $t is so#eti#es re!uired that the location and na#e of the snapshot control file be

    changed fro# its default.

    o set the snapshot control file to a different location (and na#e) use the folloing-

    RMAN" CONFIG!" SNA$SHO# CON#!OLFIL" NA(" #O78ora3ac4u58rman8O!A9/:8scontrolfile?ctl7;

    NO"!* he default value for the snapshot control file na#e is platfor#&specific anddependent on the Oracle ho#e. 3or e'a#ple, the default on so#e *N$5 syste#

    is/.b/nacf_6f. $f you clear the control file na#e, and you change the Oracle ho#e,

    then the default location of the snapshot control file changes as ell.

  • 8/16/2019 RMAN(Script Overview)

    22/22