Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

Usage Guidelines

Do not forward this document to any non-Infosys mail


ID. Forwarding this document to a non-Infosys mail
ID may lead to disciplinary action against you,
including termination of employment.

Contents of this material cannot be used in any other


internal or external document without explicit
permission from E&R@infosys.com.

Copyright © 2011, Infosys 1 CONFIDENTIAL


Education and Research
We enable you to leverage knowledge anytime, anywhere!

DBA Essential Part II

ER/CORP/CRS/SE90/004 Ver. No.: 5.2 CONFIDENTIAL Copyright © 2010, Infosys Technologies Ltd.
General Guideline

© (2011) Infosys Ltd.

This document contains valuable confidential and proprietary information of Infosys. Such
confidential and proprietary information includes, amongst others, proprietary intellectual
property which can be legally protected and commercialized. Such information is furnished
herein for training purposes only. Except with the express prior written permission of Infosys,
this document and the information contained herein may not be published, disclosed, or used
for any other purpose.

Copyright © 2011, Infosys 3 CONFIDENTIAL


Confidential Information

 This Document is confidential to Infosys Limited. This document contains information


and data that Infosys considers confidential and proprietary (“Confidential
Information”).
 Confidential Information includes, but is not limited to, the following:
 Corporate and Infrastructure information about Infosys
 Infosys’ project management and quality processes
 Project experiences provided included as illustrative case studies
 Any disclosure of Confidential Information to, or use of it by a third party, will be
damaging to Infosys.
 Ownership of all Infosys Confidential Information, no matter in what media it resides,
remains with Infosys.
 Confidential information in this document shall not be disclosed, duplicated or used –
in whole or in part – for any purpose other than reading without specific written
permission of an authorized representative of Infosys.
 This document also contains third party confidential and proprietary information.
Such third party information has been included by Infosys after receiving due written
permissions and authorizations from the party/ies. Such third party confidential and
proprietary information shall not be disclosed, duplicated or used – in whole or in part
– for any purpose other than reading without specific written permission of an
authorized representative of Infosys.

Copyright © 2011, Infosys 4 CONFIDENTIAL


Learning approach
 The following are strongly suggested for a better learning and
understanding of this course:
• Noting down the key concepts in the class, explained by the educator
• Analyze all the examples / code snippets provided
• Study and understand the self study topics.
• Completion and submission of all the assignments, on time
• Completion of the self review questions in the lab guide
• Study and understand all the artifacts including the reference materials /
e-learning / supplementary materials specified
• Completion of the project (if applicable for this course) on time inclusive of
individual and group activities
• Taking part in self assessment activities
• Participation in the doubt clearing sessions

Copyright © 2011, Infosys 5 CONFIDENTIAL


Course Objectives

 Introduction to Backup and Recovery Concepts


 Introduction to RMAN
 RMAN Catalog
 RMAN based Backups
 RMAN based Recovery
 RMAN tuning

Copyright © 2011, Infosys 6 CONFIDENTIAL


Day 1 - Objectives

 Introduction to RMAN
 RMAN Architecture
 RMAN Recovery Catalog

Copyright © 2011, Infosys 7 CONFIDENTIAL


Using Oracle Recovery Manager

RMAN:
 Is a command-line client for advanced functions
 Has powerful control and scripting language
 Has a published API that enables interface with most popular
backup software
 Backs up data, control, archived log, and server parameter files
 Backs up files to disk or tape

Enterprise Manager uses Recovery Manager (RMAN) to perform


backup and recovery operations.

Copyright © 2011, Infosys 8 CONFIDENTIAL


Recovery Manager Components

Recovery Manager Enterprise


Server Session
(RMAN) manager
Target Database
(control file repository)

Options

Server Session

Auxiliary
database Channel
Channel Channel

MML

Recovery catalog
database

Disk Flash Recovery Area

Copyright © 2011, Infosys 9 CONFIDENTIAL


RMAN Architecture contd.

 RMAN implements a type of Server Managed recovery or SMR.


 RMAN is an application that makes client connection to the Oracle
database to access internal backup and recovery packages.
 It turns the user commands into Remote Procedure Calls(RPC) to
be executed on the database.
 RMAN utility is made of two pieces: executable file and the
recover.bsq.
 The recover.bsq file is the library file from which the executable file
extracts code for creating PL/SQL calls to the target.

Copyright © 2011, Infosys 10 CONFIDENTIAL


RMAN Architecture contd.

 RMAN makes a client connection to the target database and two


server processes are spawned.
 The primary process is used to make calls to packages in the SYS
schema in order to perform the backup and recovery operations.
 This process also coordinates the work of the channel processes
during backups and restores.
 The secondary or shadow process polls any long-running
transactions in RMAN and logs the information internally.
 This information is available in the view V$SESSION_LONGOPS.

Copyright © 2011, Infosys 11 CONFIDENTIAL


RMAN Architecture contd.

 The primary process has access to two packages in the SYS


schema.
 The packages are hard coded into the oracle software libraries.
Hence RMAN can connect to the target database in any of the
startup stages.
 DBMS_RCVMAN
 DBMS_BACKUP_RESTORE

Copyright © 2011, Infosys 12 CONFIDENTIAL


RMAN Repository
 The RMAN repository is the collection of metadata about the target
databases that RMAN uses for backup, recovery, and
maintenance.
 RMAN always stores this information in records in the control file.
 Types of Records in the Control File:
 Circular Reuse Records
– CONTROL_FILE_RECORD_KEEP_TIME parameter.
 Noncircular Reuse Records
 You can also create a recovery catalog, an external Oracle
database in which to store this information. The control file has
finite space for records of backup activities, while a recovery
catalog can store a much longer history.
 The recovery catalog's version of the RMAN repository is
maintained solely by RMAN.
Copyright © 2011, Infosys 13 CONFIDENTIAL
Snapshot Control File

 This snapshot control file ensures that RMAN has a consistent view
of the control file.
 The snapshot control file exists in ORACLE_HOME/dbs directory.
 It has the default name of format SNCF<Oracle_SID>.ORA
 To modify the location and the format of the snapshot control file
the command is:

CONFIGURE SNAPSHOT CONTROLFILE NAME TO


‘<location\file_name>’;

Copyright © 2011, Infosys 14 CONFIDENTIAL


Configuring Your Database for Backup
and Recovery Operations
 Operate the database in ARCHIVELOG mode.
Archiver
(ARCn)

Online redo Archived


log files redo log files

 Configure the Flash Recovery Area

Archived Control file Datafile


redo log files backups backups

Copyright © 2011, Infosys 15 CONFIDENTIAL


Configuring ARCHIVELOG Mode

 Perform the following steps to place the database in


ARCHIVELOG mode:

 Using Enterprise Manager:


1. Select the “ARCHIVELOG Mode” check box.
2. Click Apply. The database can be set to ARCHIVELOG mode only
from the MOUNT state.
3. Click Yes when asked whether you want to restart the database.

 Using SQL commands:


1. Place the database in MOUNT mode.
2. Issue the ALTER DATABASE ARCHIVELOG MODE command
3. Open the database

Copyright © 2011, Infosys 16 CONFIDENTIAL


Using a Flash Recovery Area

 The Flash Recovery Area provides a centralized location for control


file backups, archived redo logs, flashback logs, and database
backups.
 The Flash Recovery Area can be defined as a directory, file
system, or ASM disk group.
 A single Flash Recovery Area can be shared by more than one
database.
 Using the Flash Recovery Area for recovery-related files has the
following benefits:
 Simplifies the location of database backups.
 Automatically manages the disk space allocated for recovery files.

Copyright © 2011, Infosys 17 CONFIDENTIAL


Defining a Flash Recovery Area

 The Flash Recovery Area is defined by setting the following


initialization parameters:
 DB_RECOVERY_FILE_DEST_SIZE: Sets the disk limit, expressed in
bytes
 DB_RECOVERY_FILE_DEST: Sets the location for the Flash Recovery
Area
 These parameters are dynamic and can be altered or disabled.
 When the Flash Recovery Area is configured,
LOG_ARCHIVE_DEST_10 is automatically set to the Flash
Recovery Area location.
 The archiver background process creates archived redo log files in
the Flash Recovery Area and in other configured
LOG_ARCHIVE_DEST_n locations

Copyright © 2011, Infosys 18 CONFIDENTIAL


Flash Recovery Area Space Usage

 Configure the retention policy to the minimum value appropriate for


your database.
 Back up the archive log files regularly and delete the files upon
completion of the backup.
 Use the RMAN REPORT OBSOLETE and DELETE OBSOLETE
commands to remove backups and file copies that are not required.

Several views are available to help you manage the FRA. They are as
follows:
 DBA_OUTSTANDING_ALERTS
 V$RECOVERY_FILE_DEST
 V$FLASH_RECOVERY_AREA_USAGE

Copyright © 2011, Infosys 19 CONFIDENTIAL


Configure Backup Settings

 Types of RMAN Backups


 Consistent and Inconsistent
 Full and Incremental
 Image Copies
 Backup Sets and Backup Pieces
 RMAN Backup Destinations
 Allocating channels for Backup
 Configure Backup Optimization

Copyright © 2011, Infosys CONFIDENTIAL


Education and Research
We enable you to leverage knowledge anytime, anywhere!

RMAN Catalog

ER/CORP/CRS/SE90/004 Ver. No.: 5.2 CONFIDENTIAL Copyright © 2010, Infosys Technologies Ltd.
RMAN Metadata

 Using Control file for RMAN Metadata


 Default mode
 Simplifies the administration (Ex: For single database
backups)
 Using RMAN catalog for Metadata
 Recommended for administering more than one
database backup and recovery
 Backup is maintained in a separate database
 RMAN scripts are also stored

Copyright © 2011, Infosys CONFIDENTIAL


RMAN Repository Data Storage:
Comparison of Options
Control file: Recovery catalog:
 Simpler administration  Replicates control file data
 Default  Has room for more data
 Can service many targets
 Can store RMAN scripts

Metadata
Backup set list
Image copy list
.
.
.

Copyright © 2011, Infosys 23 CONFIDENTIAL


Create and Configure Recovery Catalog

 Configure the Recovery catalog database


 Create the Recovery catalog owner
 Create the Recovery catalog

Copyright © 2011, Infosys CONFIDENTIAL


Create and Configure Recovery Catalog ctd

 Step 1: Create a tablespace for Recovery catalog


owner
 Step 2: Create a user as Recovery Catalog Owner
and grant recovery_catalog_owner role to this user
 Step 3: Create the Recovery Catalog

 (Use manual mode and Enterprise manager)

Copyright © 2011, Infosys CONFIDENTIAL


Managing the Recovery Catalog

 Registering a Database
 RMAN> register database;
 Changing the DBID of a Database
 Unregistering a Database
 Resynchronize the Recovery Catalog
 Create and Use RMAN Stored Scripts

Copyright © 2011, Infosys CONFIDENTIAL


Managing the Recovery Catalog ctd..

 Backing up the Recovery catalog


 Recovering from the loss of a Recovery Catalog
 Recovery Catalog operations

Copyright © 2011, Infosys CONFIDENTIAL


Registering and Unregistering the
Database
 RMAN> register database;

 RMAN> unregister database;

Copyright © 2011, Infosys 28 CONFIDENTIAL


Changing the DBID of the database

 Shutdown immediate (Clean shutdown)


 Startup in MOUNT mode
 In command mode run nid command
 $>nid target=system/syspass@dbname
 When prompted for changing the dbid, provide ‘y’
 Database will be shutdown
 Startup in mount mode
 Open with RESETLOGS option

Copyright © 2011, Infosys 29 CONFIDENTIAL


Cataloging additional backup files

 Check the manual backup locations


 Connect to RMAN and use Catalog start with option
 $> rman target/catalog rman/rman@dbname;
 RMAN> catalog start with ‘backup path’;
 To use backups from flash recovery area
 RMAN> catalog recovery area noprompt;
 Resync the Recovery Catalog
 RMAN>resync catalog;

Copyright © 2011, Infosys 30 CONFIDENTIAL


Virtual Private Catalog

 Virtual Private Catalog separates the recovery


catalog into distinct catalogs virtually using views
and synonyms
 Creating and Managing Virtual Private Catalog
 Granting Permissions for VPC owners
 VPC operations

Copyright © 2011, Infosys CONFIDENTIAL


Creation of VPC

 Create an RMAN based catalog


 Grant recovery_catalog_owner to VPC owner
 Grant register to VPC owner
 Create virtual catalog
 Register database
 Use virtual catalog

Copyright © 2011, Infosys 32 CONFIDENTIAL


Create and Use RMAN Stored Scripts

 Created and stored scripts are available to any RMAN


client that can connect to the target database and uses
the recovery catalog.
 Types of RMAN stored scripts:
– Local Scripts: These are associated with only the target
database to which RMAN is connected when the script is
created
– Global Scripts: Theses scripts can be executed against
any database which are registered in the recovery catalog

Copyright © 2011, Infosys CONFIDENTIAL


Creating RMAN Stored Scripts

 Creating a local RMAN script:


CREATE SCRIPT scr_name
{
<RMAN commands>
}

 Creating a global RMAN script:


CREATE GLOBAL SCRIPT scr_name
{
<RMAN commands>
}

 Creating a RMAN script from a text file:


CREATE SCRIPT scr_name FROM FILE 'f_name';

Copyright © 2011, Infosys CONFIDENTIAL


Executing RMAN Stored Scripts

 Executing a RMAN script:

RUN { EXECUTE SCRIPT scr_name


; }

 Executing a global RMAN script:

RUN { EXECUTE GLOBAL SCRIPT scr_name


; }

Copyright © 2011, Infosys CONFIDENTIAL


Displaying RMAN Stored Script
Information
 Displaying a RMAN script:

PRINT [GLOBAL] SCRIPT script_name;

 Sending the contents of a RMAN script to a file:


PRINT [GLOBAL] SCRIPT script_name
TO FILE 'file_name';

 Displaying the names of defined RMAN scripts:

LIST [GLOBAL] SCRIPT NAMES;

Copyright © 2011, Infosys CONFIDENTIAL


Updating and Deleting RMAN Stored
Scripts
 Updating a RMAN script:

REPLACE [GLOBAL] SCRIPT scr_name


{
<RMAN commands> ;
}

 Updating a RMAN script from a file:


REPLACE [GLOBAL] SCRIPT script_name
FROM FILE 'file_name';

 Deleting a RMAN script:


DELETE SCRIPT script_name;

Copyright © 2011, Infosys CONFIDENTIAL


Summary

 User Managed Recovery


 Introduction to RMAN
 RMAN Catalog
 Virtual Private Catalog

Copyright © 2011, Infosys 38 CONFIDENTIAL


Thank You

“The contents of this document are proprietary and confidential to Infosys Ltd. and may not be disclosed
in whole or in part at any time, to any third party without the prior written consent of
Infosys Ltd.”

“© 2008 Infosys Ltd. All rights reserved. Copyright in the whole and any part of this document belongs to
Infosys Ltd. This work may not be used, sold, transferred, adapted, abridged, copied or reproduced in
whole or in part, in any manner or form, or in any media, without the prior written consent of Infosys Ltd.”

Copyright © 2011, Infosys 39 CONFIDENTIAL

You might also like