rman the oracle recovery manager (rman). objectives at the end of this module the student will...

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

Upload: mervyn-oconnor

Post on 23-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

RMANRMAN

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

Page 2: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

ObjectivesObjectives

At the end of this module the At the end of this module the student will understand the student will understand the following tasks and concepts.following tasks and concepts.

Understand the basic functionality Understand the basic functionality of the Oracle Recovery Manager.of the Oracle Recovery Manager.

Understand how to perform basic Understand how to perform basic backup and recovery operations backup and recovery operations using RMAN.using RMAN.

Page 3: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Intro to RMANIntro to RMAN Oracle Recovery ManagerOracle Recovery Manager

Backup and Restore ClientBackup and Restore Client Complete or Partial BackupsComplete or Partial Backups Full or Incremental BackupsFull or Incremental Backups Detects corrupted blocks and reports themDetects corrupted blocks and reports them Automatically tracks new tablespaces and datafilesAutomatically tracks new tablespaces and datafiles Does unused block compressionDoes unused block compression Employs binary compression for disk backupsEmploys binary compression for disk backups Can test backups without restoring themCan test backups without restoring them

Page 4: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

The RMAN The RMAN Recovery CatalogRecovery Catalog Recovery CatalogRecovery Catalog

Used to store repository recordsUsed to store repository records Stores RMAN scriptsStores RMAN scripts Can be stored in its own tablespace on Can be stored in its own tablespace on

a separate servera separate server Can use the controlfiles if a recovery Can use the controlfiles if a recovery

catalog database is not available catalog database is not available

Page 5: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Recovery Catalog Recovery Catalog OptionsOptions RMAN defaults to the NOCATALOG RMAN defaults to the NOCATALOG

connect optionconnect option Uses the target database controlfile for Uses the target database controlfile for

storing recovery metadatastoring recovery metadata Useful for simple backup and recovery Useful for simple backup and recovery

options for a single databaseoptions for a single database With the CATALOG connect option, a With the CATALOG connect option, a

Recovery Catalog may be usedRecovery Catalog may be used A Recover Catalog is a centralized recovery A Recover Catalog is a centralized recovery

metadata repositorymetadata repository Useful for simple to complex backup and Useful for simple to complex backup and

recovery options for multiple databases on recovery options for multiple databases on multiple serversmultiple servers

Page 6: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Issues with Using Issues with Using Controlfiles for RMAN Controlfiles for RMAN MetadataMetadata RMAN records will eventually “age out” RMAN records will eventually “age out”

of the control file and the records will be of the control file and the records will be reusedreused Use the CONTROLFILE_RECORD_KEEP_TIME Use the CONTROLFILE_RECORD_KEEP_TIME

init.ora parameter to control the retention init.ora parameter to control the retention period (default is 7 days)period (default is 7 days)

Rebuilding the control file will result in Rebuilding the control file will result in RMAN record lossRMAN record loss The command “alter database backup The command “alter database backup

controlfile to trace;” does not backup RMAN controlfile to trace;” does not backup RMAN recordsrecords

Use “alter database backup controlfile to Use “alter database backup controlfile to ‘<location>’;” instead to create a binary ‘<location>’;” instead to create a binary controlfile copy that maintains RMAN controlfile copy that maintains RMAN recordsrecords

Page 7: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Why Use a Recovery Why Use a Recovery Catalog?Catalog? Offers a single enterprise-wide repository Offers a single enterprise-wide repository

for maximum flexibilityfor maximum flexibility Allows the use of stored RMAN scriptsAllows the use of stored RMAN scripts Allows you to restore a database from a Allows you to restore a database from a

previous incarnation (period before previous incarnation (period before RESETLOGS)RESETLOGS)

Easier to handle the loss of a control fileEasier to handle the loss of a control file Allows creation of reports on the target Allows creation of reports on the target

database at previous points in timedatabase at previous points in time Maintains consistent RMAN channel Maintains consistent RMAN channel

configuration default valuesconfiguration default values

Page 8: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Invoking RMAN Invoking RMAN

With a recovery catalogWith a recovery catalog%ORACLE_HOME%\bin\rman TARGET / CATALOG %ORACLE_HOME%\bin\rman TARGET / CATALOG useruser//passwdpasswd@@serviceservice

ExampleExample%ORACLE_HOME%\bin\rman TARGET / CATALOG sys/ora123@orcl%ORACLE_HOME%\bin\rman TARGET / CATALOG sys/ora123@orcl

Using the controlfileUsing the controlfile%ORACLE_HOME%\bin\rman TARGET SYS/%ORACLE_HOME%\bin\rman TARGET SYS/passwdpasswd@@serviceservice

ExampleExample%ORACLE_HOME%\bin\rman TARGET SYS/ora123@orcl%ORACLE_HOME%\bin\rman TARGET SYS/ora123@orcl

Page 9: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Creating a Recovery Creating a Recovery CatalogCatalog Create a Recovery Catalog Create a Recovery Catalog

TablespaceTablespaceCREATE TABLESPACE "RECOV_CAT" CREATE TABLESPACE "RECOV_CAT" LOGGING LOGGING DATAFILE ‘C:\oracle\product\10.2.0\oradata\orcl\DATAFILE ‘C:\oracle\product\10.2.0\oradata\orcl\ RECOV_CAT.dbf' SIZE 100MRECOV_CAT.dbf' SIZE 100M

Page 10: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Creating a Recovery CatalogCreating a Recovery Catalog

Create the rman schemaCreate the rman schemaCREATE USER rman IDENTIFIED BY cat CREATE USER rman IDENTIFIED BY cat

TEMPORARY TABLESPACE temp DEFAULT TEMPORARY TABLESPACE temp DEFAULT TABLESPACE recov_cat QUOTA UNLIMITED ON TABLESPACE recov_cat QUOTA UNLIMITED ON recov_cat; recov_cat;

Grant RECOVERY_CATALOG to the Grant RECOVERY_CATALOG to the rman schema rmanrman schema rmanGRANT RECOVERY_CATALOG_OWNER TO rman; GRANT RECOVERY_CATALOG_OWNER TO rman;

Page 11: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Creating a Recovery Creating a Recovery CatalogCatalog Connect to Oracle with either Connect to Oracle with either

SQLPlus or RMANSQLPlus or RMANsqlplus rman/cat@orclsqlplus rman/cat@orcl%ORACLE_HOME%\bin\rman TARGET / CATALOG %ORACLE_HOME%\bin\rman TARGET / CATALOG

rman/cat@orclrman/cat@orcl

Run the CREATE CATALOG script to create Run the CREATE CATALOG script to create the recovery catalogthe recovery catalog RMAN> CREATE CATALOGRMAN> CREATE CATALOG

Page 12: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Validating the Recovery Validating the Recovery CatalogCatalog Connect into the Oracle database as rman Connect into the Oracle database as rman

and select from user_tablesand select from user_tablessqlplus rman/cat@orclsqlplus rman/cat@orclSELECT table_name from user_tablesSELECT table_name from user_tables

Connect into RMANConnect into RMAN$ORACLE_HOME/bin/rman TARGET / CATALOG $ORACLE_HOME/bin/rman TARGET / CATALOG

rman/cat@orclrman/cat@orcl Note “connected to recovery catalog database”Note “connected to recovery catalog database”

Page 13: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Connecting with RMANConnecting with RMAN

Connect into the target database Connect into the target database using SYSusing SYS

Connect into the recovery catalog Connect into the recovery catalog using rmanusing rman

Connect into both the target Connect into both the target database and recovery catalog using database and recovery catalog using bothboth%ORACLE_HOME%\bin\rman TARGET %ORACLE_HOME%\bin\rman TARGET

sys/ora123@orcl CATALOG sys/ora123@orcl CATALOG rman/cat@orclrman/cat@orcl

Page 14: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Registering a Target Registering a Target Database in the Recovery Database in the Recovery CatalogCatalog Connect into RMANConnect into RMAN Run register databaseRun register database Validate with report schemaValidate with report schema

Page 15: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

RMAN InformationRMAN Information

The show command displays The show command displays information about the RMAN information about the RMAN configurationconfiguration show all – displays everythingshow all – displays everything

The list command displays The list command displays information about previous backupsinformation about previous backups list backup – displays a list of backupslist backup – displays a list of backups

The report commands creates RMAN The report commands creates RMAN reports on operationsreports on operations

Page 16: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

RMAN ConfigurationRMAN Configuration

Configure DevicesConfigure Devices sbt device is the media managersbt device is the media manager

VeritasVeritas LegatoLegato

Local disk can be usedLocal disk can be used Configure ChannelsConfigure Channels

Used to perform the backupsUsed to perform the backups

Page 17: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Configuring DevicesConfiguring Devices

Setup default devicesSetup default devices Configure media managerConfigure media manager

CONFIGURE DEFAULT DEVICE TYPE TO sbt; CONFIGURE DEFAULT DEVICE TYPE TO sbt; Configure disk backupConfigure disk backup

CONFIGURE DEFAULT DEVICE TYPE TO DISK;CONFIGURE DEFAULT DEVICE TYPE TO DISK; It can also be setup to use compressed It can also be setup to use compressed

savesetssavesetsCONFIGURE DEVICE TYPE DISK BACKUP TYPE CONFIGURE DEVICE TYPE DISK BACKUP TYPE

TO COMPRESSED BACKUPSET; TO COMPRESSED BACKUPSET;

Page 18: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Configuring ChannelsConfiguring Channels

Channel is the device path to the Channel is the device path to the backup mediabackup media

With a disk device, this is the pathWith a disk device, this is the pathCONFIGURE CHANNEL DEVICE TYPE DISK FORMAT CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT

‘C:\oracle\backup\ora_df%t_s%s_s%p';‘C:\oracle\backup\ora_df%t_s%s_s%p';

Page 19: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Configuring Controlfile Configuring Controlfile BackupsBackups Controlfiles can be set to auto Controlfiles can be set to auto

backup whenever a backup occurs by backup whenever a backup occurs by setting autobackup on.setting autobackup on.

CONFIGURE CONTROLFILE AUTOBACKUP on;CONFIGURE CONTROLFILE AUTOBACKUP on;

Page 20: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Performing BackupsPerforming Backups

There are a number of different ways There are a number of different ways to do backupsto do backups

BACKUP DATABASEBACKUP DATABASEBACKUP TABLESPACE ‘USERS’;BACKUP TABLESPACE ‘USERS’;BACKUP INCREMENTAL LEVEL 0 DATABASE; BACKUP INCREMENTAL LEVEL 0 DATABASE; BACKUP CURRENT CONTROLFILE;BACKUP CURRENT CONTROLFILE;

Page 21: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

RAC BackupsRAC Backups

Backup from one nodeBackup from one node Remember to backup all archive log Remember to backup all archive log

threads (representing each node) – threads (representing each node) – all should be visible from any nodeall should be visible from any node

Page 22: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Example RMAN Offline Example RMAN Offline Backup ScriptBackup Script Here is an example for a disk-Here is an example for a disk-

based online backup:based online backup:

set CMDFILE=C:\TEMP\rman_cmdfile.batset CMDFILE=C:\TEMP\rman_cmdfile.batecho shutdown immediate; >> %CMDFILE%echo shutdown immediate; >> %CMDFILE%echo startup mount; >> %CMDFILE%echo startup mount; >> %CMDFILE%echo allocate channel c1 device type disk format ‘C:\echo allocate channel c1 device type disk format ‘C:\

oracle\admin\mydb\backup\mydb_U%’; >> %CMDFILEoracle\admin\mydb\backup\mydb_U%’; >> %CMDFILE%%

echo allocate channel c2 device type disk format ‘E:\echo allocate channel c2 device type disk format ‘E:\oracle\admin\mydb\backup\mydb_U%’; >> %CMDFILEoracle\admin\mydb\backup\mydb_U%’; >> %CMDFILE%%

echo backup database; >> %CMDFILE%echo backup database; >> %CMDFILE%echo alter database open, >> %CMDFILE%echo alter database open, >> %CMDFILE%echo exit; >> %CMDFILE% echo exit; >> %CMDFILE% %ORACLE_HOME%\bin\rman target mydb/password %ORACLE_HOME%\bin\rman target mydb/password

cmdfile=%CMDFILE%cmdfile=%CMDFILE%

Page 23: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Example RMAN Online Example RMAN Online Backup ScriptBackup Script

Here is an example for a disk-based Here is an example for a disk-based online backup:online backup:

set CMDFILE=C:\TEMP\rman_cmdfile.batset CMDFILE=C:\TEMP\rman_cmdfile.batecho allocate channel c1 device type disk format ‘C:\oracle\echo allocate channel c1 device type disk format ‘C:\oracle\

admin\mydb\backup\mydb_U %’; >> %CMDFILE%admin\mydb\backup\mydb_U %’; >> %CMDFILE%echo allocate channel c2 device type disk format ‘E:\oracle\echo allocate channel c2 device type disk format ‘E:\oracle\

admin\mydb\backup\mydb_U %’; >> %CMDFILE%admin\mydb\backup\mydb_U %’; >> %CMDFILE%echo configure controlfile autobackup on; >> %CMDFILE%echo configure controlfile autobackup on; >> %CMDFILE%echo backup database plus archivelog; >> %CMDFILE%echo backup database plus archivelog; >> %CMDFILE%echo exit; >> %CMDFILE%echo exit; >> %CMDFILE%%ORACLE_HOME%\bin\rman target mydb/password cmdfile=%ORACLE_HOME%\bin\rman target mydb/password cmdfile=

%CMDFILE%%CMDFILE%

Page 24: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Performing RestoresPerforming Restores

First preview the restoreFirst preview the restoreRESTORE DATABASE PREVIEW;RESTORE DATABASE PREVIEW;RESTORE TABLESPACE users PREVIEW; RESTORE TABLESPACE users PREVIEW; RESTORE DATAFILE 3 PREVIEW; RESTORE DATAFILE 3 PREVIEW;

Preview allows you to see a report Preview allows you to see a report before the restore takes placebefore the restore takes place

Page 25: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Performing RestoresPerforming Restores

Performing the RestorePerforming the RestoreRESTORE DATABASE;RESTORE DATABASE;RESTORE TABLESPACE users; RESTORE TABLESPACE users; RESTORE DATAFILE 3;RESTORE DATAFILE 3;

Page 26: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Validating BackupsValidating Backups

Backups can be validated with Backups can be validated with restore validaterestore validate

RESTORE DATABASE VALIDATE;RESTORE DATABASE VALIDATE;RESTORE CONTROLFILE VALIDATE; RESTORE CONTROLFILE VALIDATE; RESTORE TABLESPACE users VALIDATE; RESTORE TABLESPACE users VALIDATE; RESTORE ARCHIVELOG ALL VALIDATE; RESTORE ARCHIVELOG ALL VALIDATE;

Page 27: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

Example of Complete Example of Complete Recovery Using an RMAN Recovery Using an RMAN Online BackupOnline Backup Here is an example recovery from an Here is an example recovery from an

online backup (followed by an immediate online backup (followed by an immediate backup):backup):

Set ORACLE_SID=mydbSet ORACLE_SID=mydb%ORACLE_HOME%\bin\rman target mydb/password%ORACLE_HOME%\bin\rman target mydb/passwordRman> startup nomount;Rman> startup nomount;Rman> set DBID = <enter your DBID>;Rman> set DBID = <enter your DBID>;Rman> restore spfile from autobackup;Rman> restore spfile from autobackup;Rman> restore controlfile from autobackup;Rman> restore controlfile from autobackup;Rman> alter database mount;Rman> alter database mount;Rman> restore database;Rman> restore database;Rman> recover database;Rman> recover database;Rman> alter database open resetlogs;Rman> alter database open resetlogs;Rman> shutdown immediate;Rman> shutdown immediate;Rman> startup mount;Rman> startup mount;Rman> backup database;Rman> backup database;Rman> quitRman> quit

Page 28: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

ReviewReview

Name one disadvantage of using a Name one disadvantage of using a Control File to store RMAN meta-dataControl File to store RMAN meta-data

If you have a recovery catalog, describe If you have a recovery catalog, describe how you connect to RMAN and the target how you connect to RMAN and the target databasedatabase

What is the device name used for a What is the device name used for a media manager?media manager?

What keywords are used to designate What keywords are used to designate devices to be used for backups?devices to be used for backups?

Page 29: RMAN The Oracle Recovery Manager (RMAN). Objectives At the end of this module the student will understand the following tasks and concepts. Understand

SummarySummary

RMAN ConceptsRMAN Concepts RMAN FunctionalityRMAN Functionality