Michael S.

Abbey—Ntirety Technologies LLC


Not Using rman? It's time
Session S645 Michael S. Abbey Database Office Oracle Practice Ntirety LLC michael.abbey@ntirety.com Recovery Manager (rman)—the flagship of Oracle's Backup and Recovery tools for the past four releases of the server software. There was never anything wrong per se with any other of Oracle's backup solutions; suffice to say rman is THE place to be by Database 10g if not sooner. The following verbiage is going to fast-track you into the wonderful world of rman and help you avoid some of the frustrations that all too many of us have encountered. It's these frustrations that seem insurmountable; they tempt us to put off the transition to rman to a "better and more convenient time". More and more of the fancy flashback and block level change tracking capabilities are imbedded in the rman technology. Savvy DBA's would be smart to wrap their arms around rman now instead of trying to hit the ground running with an unfamiliar piece of software when disaster strikes. First let's look at some decisions and offer advice on the best practices.

Why Rman
The decision to use rman is driven by many of the following reasons: • Does not explicitly rely on any operating system commands to perform its work. Traditional online backups use the O/S copy command to get a copy of the database files from their current locations to a backup area or media. • Does not require any signaling to the database that an item is being backed up. Traditional backups involve an alter tablespace … begin backup; and alter tablespace … end backup; commands at the start and end of the backup. Alternative mechanisms are used to ensure backups are consistent and usable. • • Is more tightly integrated with the software, and therefore less prone to DBA error. Can be integrated directly with a wide assortment of tape and alternative storage

media. ______________________________________________________________________ Not Using rman—It's Time Session S645 Oracle Open World 2005

taking advantage of performance enhancing and throughput boosters introduced to all other database activities. Offers true block level incremental backups by ignoring data blocks that have never contained any data or whose contents have not changed. not the size of the database files. This metadata is especially helpful when mapping out a recovery exercise. Permits the DBA to test the recoverability of a backup without actually restoring any data. Assists the process of duplicating a database elsewhere or preparing a standby database. It gets even worse … from time-to-time. Suppose you have 30 days of rman information in your control files—guess what happens as the control files are re-created? You guessed it—bye bye metadata.Michael S. you have incorporated daily runs of the alter database backup controlfile to trace. Oracle overwrites records in its control files and. Performs integrity checks on the backed up data similar to that done when data is assembled for query result sets in SQL*Plus. As an efficient and savvy DBA. it writes metadata related to the work it is performing. ______________________________________________________________________ Not Using rman—It's Time Session S645 Oracle Open World 2005 . and for some reason all copies of your control files are unreadable. Metadata—Catalog or Nocatalog As rman interacts with the database. it is lost. Abbey—Ntirety Technologies LLC • • • • • • • • 2 Backup set piece sizes are related to the amount of activity on the database since the most recent backup. Backup and recovery performed by server sessions. Picture the following— 2AM. The quickest way to rebuild the controlfile is using fresh output from that command. Metadata about backups is automatically stored in the rman catalogue. commands into your backup arsenal. Best practice : Always use a recovery catalog with rman. if those records contain rman metadata information. That metadata is automatically stored in an instance control file. Natively spawns parallel backup and recovery processes (is using Enterprise Edition). You have redundant metadata about your backups. making the retrieval of backup details turnkey.

similar in structure to any other instance but playing a special role in one's disaster recovery toolset. Table 1 outlines the most common plus' and minus' of choosing locations for a recovery catalog instance. the following decisions have to be made prior to creation. Some companies have multiple servers licensed for Oracle and can implement the bullet-proof backup solution for their catalog instance—the physical standby. run your catalog instance on the same server as production with a physical standby in the same location as production's. one selects a location accessible from all sites. or do it yourself. Where Should it Reside Initially. "Recovey catalog" is a fancy way of saying database. Create admin directories to accommodate trace files and archived redo Make an initialization parameter file from an existing instance. Abbey—Ntirety Technologies LLC 3 The Catalog Instance Fortunately.Michael S. Often licensing constraints determine the recovery catalog location. this is nothing other than a standard Oracle database. one considers storing the catalog instance on a separate server. In a situation where the catalog is going to serve a handful of databases. edit to suit the catalog instance memory structures and file locations Ensure UNDO_MANAGEMENT = AUTO and UNDO_TABLESPACE = UNDOTBS are set in the init file Create data directories to accommodate the infrastructure to support the catalog instance ______________________________________________________________________ Not Using rman—It's Time Session S645 Oracle Open World 2005 . Location Same server + No SQL*Net involved in backups Loss of catalog at same time as production Resources required to perform catalog backups Memory required for catalog SGA Easy implementation of production-ready backup routines More frequent accessibility to secondary storage device(s) like tape Different server Immune from production server License costs outages Production shielded from catalog Failure could result in loss of instance resource requirements transactions in 1 archived redo log Best practice : If possible. it is just that. Setup Checklist The following checklist outlines the steps involved in fast-tracking you to rman nirvana. Whether you use the database configuration assistance.

and create the catalog Register the target database in the catalog Repeat for as many databases that need to be backed up 4 The following few sections present code to accomplish some of the tasks in the above checklist.rdo') size 50m. '{location}/{SID}/log2_g1. group 2 ('{location}/{SID}/log1_g2. group 3 ('{location}/{SID}/log1_g3. Abbey—Ntirety Technologies LLC Create the database using scripts similar to those shown next Create the catalog user's tablespace Create the catalog user. and tweak its environment to permit owning a catalog schema Create a tnsnames.rdo') size 50m.ora entry for the catalog instance Ensure the catalog instance is accessible via SQL*Net Set the ORACLE_SID to point at the production database Connect to rman.rdo'.Michael S.dbf' size 1024m extent management local uniform size 10m undo tablespace undotbs datafile '{location}/{SID}/undotbs01.rdo') size 50m datafile '{location}/{SID}/system01. '{location}/{SID}/log2_g3. '{location}/{SID}/log2_g2.rdo'.dbf' size 300m autoextend on next 100m maxsize 2001m default temporary tablespace loc_temp tempfile '{location}/{SID}/loc_temp01.dbf' size 300m autoextend on next 100m maxsize 2001m extent management local sysaux datafile '{location}/{SID}/sysaux01. Administration Scripts conn / as sysdba set echo off @?/rdbms/admin/catalog ______________________________________________________________________ Not Using rman—It's Time Session S645 Oracle Open World 2005 . Create Database set echo on sqlbl on startup nomount create database rcat controlfile reuse maxlogfiles 16 maxlogmembers 4 maxdatafiles 16384 maxinstances 2 maxloghistory 2048 character set we8iso8859p1 logfile group 1 ('{location}/{SID}/log1_g1.rdo'.dbf' size 1024m The text in red is where you would substitute your site-specific directory names and chosebn ORACLE_SID.

grant recovery_catalog_owner to rman.ip.instance. On each server that needs to access the rman catalog instance. create user rman identified by rman temporary tablespace loc_temp default tablespace rman quota unlimited on rman. proceed to the $ORACLE_HOME/network/admin directory where the target database resides and make an entry in its tnsnames.sql conn / as sysdba @?/rdbms/admin/utlrp 5 The Catalog Owner's Tablespace create tablespace rman datafile '{location}/{SID}/rman01.plb @?/rdbms/admin/dbmsdefr @?/rdbms/admin/prvtdefr.resource to rman.plb @?/rdbms/admin/catqueue @?/rdbms/admin/dbmsaqad @?/rdbms/admin/prvtaqad.plb connect system/manager @?/rdbms/admin/catdbsyn @?/sqlplus/admin/pupbld.address)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = rcat ) ) ) ______________________________________________________________________ Not Using rman—It's Time Session S645 Oracle Open World 2005 . grant connect.ora referring to the recovery catalog instance.plb @?/rdbms/admin/catcr @?/rdbms/admin/prvtcr.plb @?/rdbms/admin/dbmssql @?/rdbms/admin/prvtsql. this section applies. Abbey—Ntirety Technologies LLC @?/rdbms/admin/catproc @?/rdbms/admin/catrep @?/rdbms/admin/catexp @?/rdbms/admin/catldr @?/rdbms/admin/dbmsutil @?/rdbms/admin/prvtutil. SQL*Net Considerations If the rman catalog is to be accessed from anywhere not local to the server upon which it resides.Michael S.dbf' size 200m extent management local autoallocate segment space management auto. This resembles something like: rcat = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rman.

recovery catalog created RMAN> register database. Abbey—Ntirety Technologies LLC 6 The listener.. There is no need to have a separate script to backup this catalog. Note : If possible. .. database registered in recovery catalog starting full resync of recovery catalog full resync complete RMAN> This is run once for each database that is destined to be backed up using the just-created catalog.1. The following suggestions should get you on the right track: 1. This resembles: (SID_DESC = (ORACLE_HOME = /fully/pathed/location/of/$ORACLE_HOME) (SID_NAME = rcat) ) Registering Database(s) in Catalog All that is left is to register databases in the recovery catalog as follows: rman target / catalog rman/rman@rcat … … Recovery Manager: Release 10. Whatever operating system you are using.0. then CONN_STR=nocatalog else CONN_STR="catalog rman/rman@rcat" fi . All rights reserved. when invoking rman. ______________________________________________________________________ Not Using rman—It's Time Session S645 Oracle Open World 2005 . connected to target database: RM1 (DBID=3810339942) connected to recovery catalog database recovery catalog is not installed RMAN> create catalog.. Backing up the Catalog Database The catalog instance is backed up using rman itself as well as Oracle Data Pump. Do a nocatalog backup. build the rman connection string dynamically as follows: if [ "$ORACLE_SID" = "rcat" ].. use the nocatalog construct. run your catalog instance on the same server as production with a physical standby in the same location as production's.. 2004.Production Copyright (c) 1995.ora where the catalog resides needs an entry to intercept request connections to the catalog. rman target / "$CONN_STR" .Michael S. Oracle Corporation..4 .

Rman Backup Script And now. change archivelog all crosscheck. ~oracle/.profile > /dev/null 2>&1 export export export export export export export export export ORACLE_SID=$1 LEVEL=$2 BACKUP_BASE=$3 ARCH_BASE=$4 PATH=$ORACLE_HOME/bin:$PATH:/usr/sbin TIMESTAMP=`date +'%Y%m%d'` BACKUP_DIR=${BACKUP_BASE}/${ORACLE_SID} ARCH_DIR=${ARCH_BASE}/${ORACLE_SID} LOGFILE=${BACKUP_DIR}/rman-level${LEVEL}-${TIMESTAMP}. There are many ways to do this scripting. Write two data pump exports: • FULL=Y CONTENT=METADATA_ONLY gets the infrastructure of the catalog instance • FULL=Y 3. the fun begins. some additional considerations for recovery testing. All that is left for this discussion is the backup script itself. EOF rman target / catalog rman/rman@rcat > ${LOGFILE} <<.log unset LD_PRELOAD unset TWO_TASK unset LD_LIBRARY_PATH cd $HOME/working $ORACLE_HOME/bin/sqlplus / <<. Generate the code to recreate the instance control file. but this is what we started with and have been most successful with implementing: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #!/bin/ksh SCRIPT=1 . export SCRIPT . this can be easily edited to become a CREATE DATABASE script.EOF sql 'alter system archive log current'. can derail the best intentions to get started with rman. these errors. if not forewarned. I will delve into incremental backup levels.Michael S." command then get a copy of the most recent file in USER_DUMP_DEST to use if and when required. If you are able to attend the presentation at Open World. allocate channel for maintenance type disk. and issue the "alter database backup controlfile to trace. ______________________________________________________________________ Not Using rman—It's Time Session S645 Oracle Open World 2005 . Enter SQL*Plus as sysdba. Abbey—Ntirety Technologies LLC 7 2.EOF alter system switch logfile. and look at a handful of common errors.

The start of the famous "run" block. and accepting inline commands until the subsequent EOF. let's discuss some notable lines. They are used to help establish S/S file name uniqueness for each backup set piece. A stake in the ground. sql 'alter system archive log current'. and "%U" are included. Another log file switch. Checks for existence of archived redo logs in the instance-specified location. 1 3 5 7-10 12-16 18-20 25 28 29 30 31 32 33 34-35 Line Notes 36 37 38 39-40 41-42 The magic causing the script to run in the korn shell Used in a lot of cases by . } EOF Now. backup current controlfile for standby format '${BACKUP_DIR}/%d_SCF_%U. The "%d". "%s". Create a standby controlfile.profile "error-free" by suppressing stdout and stderr. backup incremental level ${LEVEL} (database). We want these 3 unset (if running 9i or 10g) and LD_LIBRARY_PATH left alone if running 8i. Invoke rman using a catalog. where the database is backed up to the appropriate device. Channel allocation. Notice how the channel is defined using some of the environment variables that were set in the script.. copy current controlfile to '${BACKUP_DIR}/${ORACLE_SID}_level${LEVEL}_${TIMESTAMP}_control01. A manual backup of the control file. If controlfile autobackup is turned on. archive redo log-wise. run { allocate channel ch1 type disk format '${BACKUP_DIR}/%d_level${LEVEL}_${TIMESTAMP}_%s_U%U. Ingest command-line parameters and set some environment variables. release channel ch1. Size of each backups et piece is set to 2000Mb. Expand on some variables set by command-line parameters. ______________________________________________________________________ Not Using rman—It's Time Session S645 Oracle Open World 2005 . sending output to the specified logfile. using the line numbers in the above. done inside rman.Michael S. The finish of backup log switch. resync catalog.. would be type 'SBT_TAPE' with appropriate ENV parameters for writing directly to tape. nothing is redundant nothing is redundant nothing is redundant nothing is redundant. unlike the first. Keep the running of . set limit channel ch1 kbytes=2000000. Allocation of disk channel for the ensuing maintenance activity. Abbey—Ntirety Technologies LLC 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 8 delete noprompt expired archivelog all. this is redundant. in the backup world. their meaning specific things to rman.bak'. This is the point in the redo stream where the rman backup commences. but hey . They are marked AVAILABLE or EXPIRED depending on the success or failure of the check on disk for their existence.profile to suppress screen I/O.bak'. The heart of the script. Catalog records of archived redo logs that were found to be expired are wiped from the rman repository.bak'.

" In March 2005. using the same ORACLE_SID and the same directory structures 2. The accompanying PowerPoint presentation will discuss: • • • • • • • Incremental backup levels Controlfile autobackup Recovery testing 1. Abbey—Ntirety Technologies LLC 44 A catalog resync is not required. once you get started. Michael joined Ntirety LLC. but why not!. Abbey is a frequent presenter at technical events in North America and Europe. He is responsible for service delivery in the Oracle practice.Michael S. Michael was re-elected to the Board in the 2002 election process. an Oracle and SQL Server services company in Eastern Massachusetts. Like most technies. the complete functionality of the rman product and the bells and whistles of an rman environment will jump out at you and you will get deeper into the tool's functionality. infrastruture setup. We have discussed instance creation. A ______________________________________________________________________ Not Using rman—It's Time Session S645 Oracle Open World 2005 . the most recent being "Oracle10/g/ Database: A Beginner's Guide. having served on the board of directors of the IOUG from 1992 until 2000. catalog instance backup. He has accumulated an avid following in the Oracle user group community. 9 Wrapup The material presented in this paper can fast track your move to rman. and presented a sample rman backup script with discussion. using a different ORACLE_SID with a different directory structure Catalog cleanup Retention policies and their enforcement Cleanup on disk and tape Validating backups Michael S. Michael is co-author of 13 successful works in the Oracle Press series.

Sign up to vote on this title
UsefulNot useful