Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Oracle Recovery Manager (RMAN)

Similar presentations


Presentation on theme: "The Oracle Recovery Manager (RMAN)"— Presentation transcript:

1 The Oracle Recovery Manager (RMAN)

2 Objectives At the end of this module the student will understand the following tasks and concepts. Understand the basic functionality of the Oracle Recovery Manager. Understand how to perform basic backup and recovery operations using RMAN.

3 Intro to RMAN Oracle Recovery Manager Backup and Restore Client
Complete or Partial Backups Full or Incremental Backups Detects corrupted blocks and reports them Automatically tracks new tablespaces and datafiles Does unused block compression Employs binary compression for disk backups Can test backups without restoring them RMAN is a client side backup and restore utility that works in conjunction with the Oracle database engine and performs a number of different types of backups including the following: Complete backups backup all of the data in the database. Partial backups are used to only backup a part of the database such as a tablespace or just a datafile. A full backup saves the entire contents of the object being backed up. An incremental backup only backs up the data that has changed since the last backup. Can compress the data in order to save space on disk.

4 The RMAN Recovery Catalog
Used to store repository records Stores RMAN scripts Can be stored in its own tablespace on a separate server Can use the controlfiles if a recovery catalog database is not available

5 Recovery Catalog Options
RMAN defaults to the NOCATALOG connect option Uses the target database controlfile for storing recovery metadata Useful for simple backup and recovery options for a single database With the CATALOG connect option, a Recovery Catalog may be used A Recover Catalog is a centralized recovery metadata repository Useful for simple to complex backup and recovery options for multiple databases on multiple servers

6 Issues with Using Controlfiles for RMAN Metadata
RMAN records will eventually “age out” of the control file and the records will be reused Use the CONTROLFILE_RECORD_KEEP_TIME init.ora parameter to control the retention period (default is 7 days) Rebuilding the control file will result in RMAN record loss The command “alter database backup controlfile to trace;” does not backup RMAN records Use “alter database backup controlfile to ‘<location>’;” instead to create a binary controlfile copy that maintains RMAN records

7 Why Use a Recovery Catalog?
Offers a single enterprise-wide repository for maximum flexibility Allows the use of stored RMAN scripts Allows you to restore a database from a previous incarnation (period before RESETLOGS) Easier to handle the loss of a control file Allows creation of reports on the target database at previous points in time Maintains consistent RMAN channel configuration default values

8 Invoking RMAN With a recovery catalog Using the controlfile Example
%ORACLE_HOME%\bin\rman TARGET / CATALOG Example %ORACLE_HOME%\bin\rman TARGET / CATALOG Using the controlfile %ORACLE_HOME%\bin\rman TARGET %ORACLE_HOME%\bin\rman TARGET

9 Creating a Recovery Catalog
Create a Recovery Catalog Tablespace CREATE TABLESPACE "RECOV_CAT" LOGGING DATAFILE ‘C:\oracle\product\10.2.0\oradata\orcl\ RECOV_CAT.dbf' SIZE 100M

10 Creating a Recovery Catalog
Create the rman schema CREATE USER rman IDENTIFIED BY cat TEMPORARY TABLESPACE temp DEFAULT TABLESPACE recov_cat QUOTA UNLIMITED ON recov_cat; Grant RECOVERY_CATALOG to the rman schema rman GRANT RECOVERY_CATALOG_OWNER TO rman;

11 Creating a Recovery Catalog
Connect to Oracle with either SQLPlus or RMAN sqlplus %ORACLE_HOME%\bin\rman TARGET / CATALOG Run the CREATE CATALOG script to create the recovery catalog RMAN> CREATE CATALOG The recovery catalog can be created from within rman itself. Use the CREATE CATALOG command. C:\%ORACLE_HOME%\bin\rman TARGET / CATALOG Recovery Manager: Release Production Copyright (c) 1995, 2004, Oracle. All rights reserved. connected to target database: ORCL (DBID= ) connected to recovery catalog database recovery catalog is not installed RMAN> CREATE CATALOG; recovery catalog created You can also use the CREATE CATALOG command with the TABLESPACE qualifier. RMAN> CREATE CATALOG TABLESPACE 'RECOV_CAT'; RMAN>

12 Validating the Recovery Catalog
Connect into the Oracle database as rman and select from user_tables sqlplus SELECT table_name from user_tables Connect into RMAN $ORACLE_HOME/bin/rman TARGET / CATALOG Note “connected to recovery catalog database” C:\ sqlplus SQL*Plus: Release Production on Sun Jun 20 08:55: Copyright (c) 1982, 2004, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release Production With the Partitioning, OLAP and Data Mining options SQL> SELECT table_name FROM user_tables; TABLE_NAME RCVER FB TSATT TS CKP DBINC CONF NODE DB RSR XAL C:\ $ORACLE_HOME/bin/rman TARGET / CATALOG Recovery Manager: Release Production Copyright (c) 1995, 2004, Oracle. All rights reserved. connected to target database: ORCL (DBID= ) connected to recovery catalog database RMAN>

13 Connecting with RMAN Connect into the target database using SYS
Connect into the recovery catalog using rman Connect into both the target database and recovery catalog using both %ORACLE_HOME%\bin\rman TARGET CATALOG C:\ $ORACLE_HOME\bin\rman TARGET CATALOG Recovery Manager: Release Production Copyright (c) 1995, 2004, Oracle. All rights reserved. connected to target database: ORCL (DBID= ) connected to recovery catalog database RMAN>

14 Registering a Target Database in the Recovery Catalog
Connect into RMAN Run register database Validate with report schema RMAN> register database; database registered in recovery catalog starting full resync of recovery catalog full resync complete RMAN> report schema; Report of database schema File K-bytes Tablespace RB segs Datafile Name SYSTEM YES C:\oracle\product\10.1.0\oradata\orcl\system01.dbf UNDOTBS YES C:\\oracle\product\10.1.0\oradata\orcl\undotbs01.dbf SYSAUX NO C:\oracle\product\10.1.0\oradata\orcl\sysaux01.dbf USERS NO C:\oracle\product\10.1.0\oradata\orcl\users01.dbf EXAMPLE NO C:\\oracle\product\10.1.0\oradata\orcl\example01.dbf RECOV_CAT NO C:\oracle\product\10.1.0\oradata\orcl\RECOV_CAT.dbf RMAN>

15 RMAN Information The show command displays information about the RMAN configuration show all – displays everything The list command displays information about previous backups list backup – displays a list of backups The report commands creates RMAN reports on operations RMAN> show all; RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE MAXSETSIZE TO UNLIMITED; # default CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘C:\oracle\product\10.1.0\db_1\dbs\snapcf_orcl.f'; # default

16 RMAN Configuration Configure Devices Configure Channels
sbt device is the media manager Veritas Legato Local disk can be used Configure Channels Used to perform the backups

17 Configuring Devices Setup default devices Configure media manager
CONFIGURE DEFAULT DEVICE TYPE TO sbt; Configure disk backup CONFIGURE DEFAULT DEVICE TYPE TO DISK; It can also be setup to use compressed savesets CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET;

18 Configuring Channels Channel is the device path to the backup media
With a disk device, this is the path CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘C:\oracle\backup\ora_df%t_s%s_s%p';

19 Configuring Controlfile Backups
Controlfiles can be set to auto backup whenever a backup occurs by setting autobackup on. CONFIGURE CONTROLFILE AUTOBACKUP on;

20 Performing Backups There are a number of different ways to do backups
BACKUP DATABASE BACKUP TABLESPACE ‘USERS’; BACKUP INCREMENTAL LEVEL 0 DATABASE; BACKUP CURRENT CONTROLFILE; C:\ %ORACLE_HOME%\bin\rman TARGET CATALOG Recovery Manager: Release Production Copyright (c) 1995, 2004, Oracle. All rights reserved. connected to target database: ORCL (DBID= ) connected to recovery catalog database RMAN> backup database; Starting backup at 20-JUN-04 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=256 devtype=DISK channel ORA_DISK_1: starting compressed full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=C:\oracle\product\10.1.0\oradata\orcl\system01.dbf input datafile fno=00003 name=C:\oracle\product\10.1.0\oradata\orcl\sysaux01.dbf input datafile fno=00005 name=C:\oracle\product\10.1.0\oradata\orcl\example01.dbf input datafile fno=00006 name=C:\oracle\product\10.1.0\oradata\orcl\RECOV_CAT.dbf input datafile fno=00002 name=C:\oracle\product\10.1.0\oradata\orcl\undotbs01.dbf input datafile fno=00004 name=C:\oracle\product\10.1.0\oradata\orcl\users01.dbf channel ORA_DISK_1: starting piece 1 at 20-JUN-04 channel ORA_DISK_1: finished piece 1 at 20-JUN-04 piece handle=C:\oracle\backup\ora_df _s3_s1 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:02:35 including current controlfile in backupset including current SPFILE in backupset piece handle=C:\oracle\backup\ora_df _s4_s1 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04 Finished backup at 20-JUN-04 RMAN> MAN> BACKUP TABLESPACE 'USERS'; using channel ORA_DISK_1 piece handle=C:\oracle\backup\ora_df _s5_s1 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

21 RAC Backups Backup from one node
Remember to backup all archive log threads (representing each node) – all should be visible from any node

22 Example RMAN Offline Backup Script
Here is an example for a disk-based online backup: set CMDFILE=C:\TEMP\rman_cmdfile.bat echo shutdown immediate; >> %CMDFILE% echo startup mount; >> %CMDFILE% echo allocate channel c1 device type disk format ‘C:\oracle\admin\mydb\backup\mydb_U%’; >> %CMDFILE% echo allocate channel c2 device type disk format ‘E:\oracle\admin\mydb\backup\mydb_U%’; >> %CMDFILE% echo backup database; >> %CMDFILE% echo alter database open, >> %CMDFILE% echo exit; >> %CMDFILE% %ORACLE_HOME%\bin\rman target mydb/password cmdfile=%CMDFILE%

23 Example RMAN Online Backup Script
Here is an example for a disk-based online backup: set CMDFILE=C:\TEMP\rman_cmdfile.bat echo allocate channel c1 device type disk format ‘C:\oracle\admin\mydb\backup\mydb_U %’; >> %CMDFILE% echo allocate channel c2 device type disk format ‘E:\oracle\admin\mydb\backup\mydb_U %’; >> %CMDFILE% echo configure controlfile autobackup on; >> %CMDFILE% echo backup database plus archivelog; >> %CMDFILE% echo exit; >> %CMDFILE% %ORACLE_HOME%\bin\rman target mydb/password cmdfile=%CMDFILE%

24 Performing Restores First preview the restore
RESTORE DATABASE PREVIEW; RESTORE TABLESPACE users PREVIEW; RESTORE DATAFILE 3 PREVIEW; Preview allows you to see a report before the restore takes place RMAN> restore database preview; Starting restore at 20-JUN-04 using channel ORA_DISK_1 List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time Full M DISK :02: JUN-04 BP Key: 56 Status: AVAILABLE Compressed: NO Tag: TAG T093416 Piece Name: C:\oracle\backup\ora_df _s3_s1 List of Datafiles in backup set 52 File LV Type Ckp SCN Ckp Time Name Full JUN-04 C:\oracle\product\10.1.0\oradata\orcl\system01.dbf Full JUN-04 C:\oracle\product\10.1.0\oradata\orcl\undotbs01.dbf Full JUN-04 C:\oracle\product\10.1.0\oradata\orcl\sysaux01.dbf Full JUN-04 C:\oracle\product\10.1.0\oradata\orcl\example01.dbf Full JUN-04 C:\oracle\product\10.1.0\oradata\orcl\RECOV_CAT.dbf Full 1M DISK :00: JUN-04 BP Key: 73 Status: AVAILABLE Compressed: NO Tag: TAG T095115 Piece Name: C:\oracle\backup\ora_df _s5_s1 List of Datafiles in backup set 70 Full JUN-04 C:\oracle\product\10.1.0\oradata\orcl\users01.dbf Finished restore at 20-JUN-04 RMAN> restore database preview summary; List of Backups =============== Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag B F A DISK JUN NO TAG T093416 B F A DISK JUN NO TAG T095115 RMAN>

25 Performing Restores Performing the Restore RESTORE DATABASE;
RESTORE TABLESPACE users; RESTORE DATAFILE 3;

26 Validating Backups Backups can be validated with restore validate
RESTORE DATABASE VALIDATE; RESTORE CONTROLFILE VALIDATE; RESTORE TABLESPACE users VALIDATE; RESTORE ARCHIVELOG ALL VALIDATE; RMAN> restore database validate; Starting restore at 20-JUN-04 using channel ORA_DISK_1 channel ORA_DISK_1: starting validation of datafile backupset channel ORA_DISK_1: restored backup piece 1 piece handle=C:\oracle\backup\ora_df _s3_s1 tag=TAG T093416 channel ORA_DISK_1: validation complete piece handle=C:\oracle\backup\ora_df _s5_s1 tag=TAG T095115 Finished restore at 20-JUN-04 RMAN>

27 Example of Complete Recovery Using an RMAN Online Backup
Here is an example recovery from an online backup (followed by an immediate backup): Set ORACLE_SID=mydb %ORACLE_HOME%\bin\rman target mydb/password Rman> startup nomount; Rman> set DBID = <enter your DBID>; Rman> restore spfile from autobackup; Rman> restore controlfile from autobackup; Rman> alter database mount; Rman> restore database; Rman> recover database; Rman> alter database open resetlogs; Rman> shutdown immediate; Rman> startup mount; Rman> backup database; Rman> quit

28 Review Name one disadvantage of using a Control File to store RMAN meta-data If you have a recovery catalog, describe how you connect to RMAN and the target database What is the device name used for a media manager? What keywords are used to designate devices to be used for backups?

29 Summary RMAN Concepts RMAN Functionality


Download ppt "The Oracle Recovery Manager (RMAN)"

Similar presentations


Ads by Google