Download presentation
Presentation is loading. Please wait.
1
RMAN: Beginner to Advanced in 1 Hour
Arup Nanda
2
Who am I Oracle DBA for 16 years and counting
Speak at conferences, write articles, 4 books Brought up the Global Database Group at Starwood Hotels, in White Plains, NY (c) Arup Nanda
3
What’s Being Covered RMAN Basics Merge Backups Block Change Tracking
Monitoring Compression Encryption Key/Wallet Management Decisions – Image Copy or Backupset (c) Arup Nanda
4
What is it? RMAN: Recovery MANager
Oracle Enterprise Backup Utility (EBU) with Oracle7 Bugs, limitations made it infeasible RMAN – the new incarnation of EBU introduced with Oracle8 Bugs abound; DBAs still favored Hot Backup Bug free, quite usable with Oracle 8i (c) Arup Nanda
5
What was the Earlier Approach
Put the database/tablespaces/datafiles to backup mode. ALTER DATABASE BEGIN BACKUP; Copy/ftp the files to remote location ALTER DATABASE END BACKUP; The datafile headers are not updated with the newer checkpoints The datafiles are written as usual (c) Arup Nanda
6
What was the problem? Fractured block Recovery will apply more redo
More redo written during this period Recovery will apply more redo The recovery will take longer (c) Arup Nanda
7
RMAN Does not need ALTER DATABASE BEGIN BACKUP RMAN understands the structure of the data block. So it does not: need to stop the SCN update in the header generate too much redo need to apply redundant redo during recovery (c) Arup Nanda
8
RMAN Basics Executable rman in $OH/bin
Has to connect to a target database # $ORACLE_HOME/bin/rman Recovery Manager: Release … RMAN> connect target / connected to target database: ODBA112 (DBID= ) RMAN> connect target "sys/oracle as sysdba" # $ORACLE_HOME/bin/rman target=/ (c) Arup Nanda
9
Start the Backup RMAN> backup database;
The sequence of keywords (commands) is important. Giving wrong commands (or in wrong sequence) make the command fail and you can't edit (unlike SQL*Plus) RMAN> backup database; Semicolon is necessary to end a command Could be database, datafile, tablespace, archivelog all, etc. (c) Arup Nanda
10
Backup pieces (individual files)
Only Used Blocks Backup set Datafile 2 2 1 2 1 Backup pieces (individual files) Datafile 1 Since only used blocks are backed up, the backup is less than the actual database size Used block Unused block (c) Arup Nanda
11
Datafiles and Backupsets
bp1 df1 bs1 bp2 df2 bs2 bp3 df3 bs3 bp4 df4 bp5 A datafile can’t be split across backupsets Many to Many Backup Pieces Many to One Backup Sets Datafiles (c) Arup Nanda
12
Restoring RMAN> restore database; RMAN> restore tablespace USERS; RMAN> restore datafile 5; This recreates the datafiles from the different backup pieces Read and restored in parallel Recovering (applies the incremental backups and archive logs to the restored datafiles) RMAN> recover database; RMAN exclusive! (c) Arup Nanda
13
Incremental Backups RMAN checks for used blocks, so it can check if the blocks have been backed up before It can backup only the changed blocks Reducing backup size, time, I/O and CPU Level 1 – changed since Last Level 1 Level 0 – Full backup (c) Arup Nanda
14
Incremental Types Full Level1 Full Backup (all blocks) Full Backup
Initial 2 3 4 5 6 Monday 1 2 All blocks Block 2 3 4 5 6 1 All blocks Block 3 2 Tuesday 3 4 5 6 Full Level1 (c) Arup Nanda
15
Can be replaced by TABLESPACE USERS, DATAFILE 1, etc.
Incremental Levels RMAN> backup 2> database 3> ; Full Database RMAN> backup 2> incremental level 1 3> database 4> ; Incremental Level 0 indicates a full backup Can be replaced by TABLESPACE USERS, DATAFILE 1, etc. (c) Arup Nanda
16
Recovery Backup Recovery Sun (Full) Mon Tue Wed Thu Sun (Full) Mon Tue
(c) Arup Nanda
17
Cumulative Incremental
Differential Cumulative Full Backup (all blocks) Full Backup (all blocks) 1 Initial 2 3 4 5 6 Monday 1 2 Block 2 Block 2 3 4 5 6 1 Block 3 Block 2 and Block 3 2 Tuesday 3 4 5 6 (c) Arup Nanda
18
Default is Differential
Cumulative Default is Differential RMAN> backup 2> cumulative incremental level 1 3> tablespace users; Cumulative Incremental backups contain all the changes since the full backup; hence it requires only one incremental backup to be applied, speeding up recovery. (c) Arup Nanda
19
Channels Channels are akin to Parallel Query slaves
Each channel is a session that RMAN uses to backup or restore More channels, usually faster backup During backup, each channel uses a unique backupset Default is one channel (c) Arup Nanda
20
Output of Backup A channel is a session, hence SID
allocated channel: c1 channel c1: SID=128 device type=DISK allocated channel: c2 channel c2: SID=121 device type=DISK Starting backup at 06-MAY-09 channel c1: starting full datafile backup set channel c1: specifying datafile(s) in backup set input datafile file number=00001 name=C:\ORACLE\ORADATA\ARUPLAP11\SYSTEM01.DBF input datafile file number=00003 name=C:\ORACLE\ORADATA\ARUPLAP11\UNDOTBS01.DBF channel c1: starting piece 1 at 06-MAY-09 channel c2: starting full datafile backup set channel c2: specifying datafile(s) in backup set input datafile file number=00002 name=C:\ORACLE\ORADATA\ARUPLAP11\SYSAUX01.DBF input datafile file number=00004 name=C:\ORACLE\ORADATA\ARUPLAP11\USERS01.DBF channel c2: starting piece 1 at 06-MAY-09 A channel is a session, hence SID Datafiles are mentioned here (c) Arup Nanda
21
Multiple Channels RMAN> run {
2> allocate channel c1 type disk format 'c:\temp\%U.rman'; 3> allocate channel c2 type disk format 'c:\temp\%U.rman'; 4> backup database; 5> } %U creates a unique name for the file. Run "block" is enclosed in pairs of curly braces {} (c) Arup Nanda
22
Check Defaults RMAN> show all; RMAN> configure ...
Shows all the default configuration items such as number of channels, etc. RMAN> configure ... changes the items (c) Arup Nanda
23
Configure Channels RMAN> show DEVICE TYPE;
RMAN configuration parameters for database with db_unique_name ARUPLAP11 are: CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default RMAN> configure device type disk parallelism 2 backup type to backupset; ... new RMAN configuration parameters are successfully stored RMAN> configure channel 1 device type disk format 'c:\temp\%U.rman'; (c) Arup Nanda
24
NOLOGGING Nologging Operations Redo is not Generated for the Data
INSERT */+ APPEND */ INTO … SQL*Loader DIRECT=Y CREATE TABLE … NOLOGGING Redo is not Generated for the Data Metadata changes are always logged The new information doesn't get into the redo and hence not to arc logs And hence not possible to recover Incremental backs up blocks changed by NOLOGGING operations RMAN exclusive! (c) Arup Nanda
25
Block Change Tracking Incremental Backup still goes through the files to see which blocks changed Adds to time and performance Enter – Block Change Tracking To create a BCT File: ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/home/oracle/orabackup/bct_PRODB2.dbf'; Records which blocks have been changed (c) Arup Nanda
26
BCT, contd. Must be available to all instances of RAC.
Size approx 10MB per 1 TB Test: SELECT * FROM V$BLOCK_CHANGE_TRACKING; Ensure: select USED_CHANGE_TRACKING from v$backup_datafile; (c) Arup Nanda
27
Checking for Backups Lists the backups available
RMAN> list backup of database; using target database control file instead of recovery catalog List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time Full M DISK :00: MAY-09 BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG T195902 Piece Name: C:\ORACLE\PRODUCT\11.1\DB1\DATABASE\09KECC46_1_1 List of Datafiles in backup set 4 File LV Type Ckp SCN Ckp Time Name Full MAY-09 C:\ORACLE\ORADATA\ARUPLAP11\USERS01.DBF (c) Arup Nanda
28
Which Files Need Backup
RMAN> report need backup; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 1 Report of files with less than 1 redundant backups File #bkps Name C:\ORACLE\ORADATA\ARUPLAP11\SYSTEM01.DBF C:\ORACLE\ORADATA\ARUPLAP11\SYSAUX01.DBF C:\ORACLE\ORADATA\ARUPLAP11\UNDOTBS01.DBF (c) Arup Nanda
29
Obsolete (c) Arup Nanda RMAN> report obsolete;
RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 1 Report of obsolete backups and copies Type Key Completion Time Filename/Handle Backup Set MAY-09 Backup Piece MAY C:\ORACLE\PRODUCT\11.1\DB1\DATABASE\04KEBFLM_1_1 RMAN> delete obsolete; allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=123 device type=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: SID=170 device type=DISK Deleting the following obsolete backups and copies: Do you really want to delete the above objects (enter YES or NO)? yes deleted backup piece backup piece handle=C:\ORACLE\PRODUCT\11.1\DB1\DATABASE\04KEBFLM_1_1 RECID=1 STAMP= Deleted 1 objects (c) Arup Nanda
30
SHOW, LIST or REPORT List – lists backups, failures, etc.
Report – similar; but less often used Show – only config items like channels (c) Arup Nanda
31
Block Media Recovery Less likely: the entire datafile is corrupted
More likely: a specific block in a file is Why restore the entire file when only a block needs to be recovered? ORA-01578: ORACLE data block corrupted (file # 5, block # 21) ORA-01110: data file 5: 'c:\oracle\...' To restore DF# 5 Block# 21: RMAN> blockrecover datafile 5 block 21; RMAN exclusive! (c) Arup Nanda
32
Compression Compresses the backupset produced backup
as compressed backupset incremental level 1 tablespace users; Only for regular backups, not image copies Compression happens in-line; unlike O/S tools, which first need a file then compress it. RMAN exclusive! comp.rman (c) Arup Nanda
33
Validation Automatically during backup
Checks for integrity of datafiles and archived logs Detects corruptions before they get into the disks or tapes Early warning of corruptions During merge RMAN exclusive! (c) Arup Nanda
34
Image Copy Image Copy – Copies all blocks, occupied or not. Can create copies of COPY Regular RMAN Backup – Copies only used blocks Original Datafile Regular RMAN Image Copy (c) Arup Nanda
35
Can be replaced by TABLESPACE USERS, DATAFILE 1, etc.
Image Copies RMAN> backup 2> database 3> ; Regular RMAN RMAN> backup 2> as copy 3> database 4> ; Image Copy Creates a copy for each datafile Can be replaced by TABLESPACE USERS, DATAFILE 1, etc. (c) Arup Nanda
36
Recovery Scenario Current Modified Sun (Full) Mon Tue Wed Thu Full Mon
(c) Arup Nanda
37
Merged Backup Database Full Backup Incr. (c) Arup Nanda
38
Merge Backup BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG WEEKLY DATABASE; RECOVER COPY OF DATABASE WITH TAG WEEKLY; (c) Arup Nanda script r.rman c.rman
39
Image Copy Backup is simple; RMAN does not have to read the file extensively Restoring simpler – no “reconstruction” Merge Possible Compression not possible (c) Arup Nanda
40
Regular Backups Smaller Size May be Quicker Compression possible
When deciding between regular and image copy backups, take these factors into account. (c) Arup Nanda
41
Image Copies Non-conventional backups – mirror-split (must use CATALOG) Mirrored Pair Split Backed up Via RMAN CATALOG DATAFILECOPY ‘/orabcv/dbf1.dbf’ level 0; (c) Arup Nanda
42
Image Copies - Cases Partitioned Tables Option 1: Option 2:
PART1 -> Tablespace TS1, datafile dbf1 PART2 -> Tablespace TS2; datafile dbf2 SQL> alter tablespace TS1 read only; Option 1: Copy the file dbf1 to /oraback/dbf1 Catalog it in RMAN: CATALOG DATAFILECOPY ‘/oraback…’ Option 2: RMAN> BACKUP DATAFILE 235 AS COPY; (c) Arup Nanda
43
Image Copies - More Recovery from Tape to Database Directly
Backup Location Database Tape RMAN> BACKUP ... AS COPY ... RMAN> backup device type sbt copy of database; Recovery from Tape to Database Directly Backup to the tape is validated Requires MML (c) Arup Nanda
44
Displaying Seconds Issue on Command Line:
export NLS_DATE_FORMAT="mm/dd/yy hh24:mi:ss" (c) Arup Nanda
45
Validate Archivelogs To validate: Debug
backup validate archivelog all; Debug (c) Arup Nanda
46
Monitoring V$SESSION_LONGOPS
SELECT SID, SERIAL#, CONTEXT, SOFAR, TOTALWORK, ROUND(SOFAR/TOTALWORK*100,2) "% COMPLETE" FROM V$SESSION_LONGOPS WHERE OPNAME LIKE 'RMAN%' AND OPNAME NOT LIKE '%aggregate%' AND TOTALWORK != 0 AND SOFAR <> TOTALWORK (c) Arup Nanda rman_stat.sql
47
Effectiveness select device_type "Device", type,
to_char(open_time, 'mm/dd/yyyy hh24:mi:ss') "Open Time", to_char(close_time,'mm/dd/yyyy hh24:mi:ss') "Close Time", elapsed_time "Ela", effective_bytes_per_second "b/sec", filename from v$backup_async_io where close_time > sysdate - 30 order by close_time desc; (c) Arup Nanda eff.sql
48
Job Details V$RMAN_BACKUP_JOB_DETAILS records all jobs present and past Summary: Script rep1.sql Compression: script rep2.sql Past Outputs: V$RMAN_OUTPUT rep3.sql (c) Arup Nanda
49
I/O Effectiveness select io_count, ready, short_waits, long_waits, long_waits/io_count, filename from v$backup_async_io where io_count != 0 (c) Arup Nanda async.sql
50
Resource Governor You have limited CPUs and I/O resources
You don't want all the CPU to be taken by RMAN affecting the database perf You can let RMAN run longer but using less CPU Minimize Time/CPU (c) Arup Nanda
51
11g Parallel Backup Pre-11g Post-11g Backups can run in parallel
But each parallel stream picks a single file Post-11g Each file can be backed in parallel (c) Arup Nanda
52
Surviving Nightmares Controlfile is missing and you want to recover
Datafile backup is missing Two databases have the same name but your are restoring only one! Database name as Unknown Cloning the production database – on the same host! How to use extract valuable information from RMAN catalog when the controlfile is missing (c) Arup Nanda
53
Transporting Tablespaces
Transportable – on the same endianness platforms, e.g. Linux to Windows Cross-platform: RMAN> convert tablespace users 2> to platform 'HP-UX (64-bit)' 3> format= '/home/oracle/orabackup/%N_%f'; tts1.rman (c) Arup Nanda
54
Cloning (on the same host)
Check memory, space, etc. Create the new INIT.ORA Place the parameters *_convert export ORACLE_SID=CLONEDB2 Startup nomount Check Source DB is at least mounted (c) Arup Nanda
55
Cloning Contd. Put connect strings in TNSNAMES.ORA
Check MAX of Arc Logs al.sql Construct the script for cloning clone.rman Run it! (c) Arup Nanda
56
Surviving Nightmares (c) Arup Nanda
57
Missing Controlfile Autobackup: No backup: list backup of controlfile;
strings * | grep control Use restore controlfile from “…”. cont.rman (c) Arup Nanda
58
Missing Backup Datafile backup is missing Solution:
SQL> ALTER TABLESPACE … OFFLINE RMAN> RESTORE DATAFILE …; It will create an empty file RMAN> RECOVER DATAFILE …; It will roll forward the file SQL> ALTER TABLESPACE … ONLINE (c) Arup Nanda
59
Catalog, yes; Controlfile: no
The controlfile is missing; but you have the catalog. RC_DATABASE – the database select * from RC_BACKUP_CONTROLFILE_SUMMARY (c) Arup Nanda
60
Same DB Name! Two databases have the same name but your are restoring only one! Use DB_ID RMAN> SET DBID = <DBID of target>; RMAN> RESTORE CONTROLFILE; RMAN> ALTER DATABASE MOUNT; RMAN> RESTORE DATABASE; RMAN> RECOVER DATABASE; (c) Arup Nanda
61
UNKNOWN – the DB Name?! Database name as UKNOWN Sequence:
You had a database, not registered to catalog You recovered the database incompletely, with RESETLOGS You registered the “reincarnated” database to the catalog. (c) Arup Nanda
62
Security 90% of data theft at occurs from the backup; not from the database directly. Backup is more vulnerable, because: Backup tapes are outside the firewall Backup tapes are less vigilantly guarded Intrusion is often undetected Intrusion can’t be shutdown, once started (c) Arup Nanda
63
Protecting RMAN Backup
Encrypting the selective columns Using Transparent Data Encryption (TDE) Using your own encryption routines Encrypting the entire backup Using Tape Management System encryption capabilities Using RMAN’s native encryption – new in Oracle 10g R2 (c) Arup Nanda
64
Wallet SYS.ENC$ Table Encryption Key Master Key Encryption Wallet
alter system set encryption wallet open authenticated by "remnant"; (c) Arup Nanda
65
RMAN TDE Setup Make sure directory $ORACLE_BASE/admin/$ORACLE_SID/wallet exists Set the enc key password: key.sql Open the wallet: wallo.sql Close the wallet: wallc.sql (c) Arup Nanda
66
Encrypting RMAN Backups
Use the same Encryption Wallet Transparent Mode: RMAN> configure encryption for database on; RMAN> configure encryption for tablespace users on; SQL> alter system set encryption wallet open authenticated by “topSecret"; RMAN> backup tablespace users; (c) Arup Nanda
67
Restoring Enc. RMAN Backups
RMAN> restore tablespace users; Starting restore at 21-MAR-06 using channel ORA_DISK_1 ... messages ... ORA-19870: error reading backup piece /flash_area/PRODB2/BACKUPSET/2006_03_21\O1_MF_NNNDF_TAG T221325_1YR16QLT_.BKP ORA-19913: unable to decrypt backup ORA-28365: wallet is not open (c) Arup Nanda
68
RMAN Encryption without Wallet
To Backup: RMAN> set encryption on identified by “pooh" only; RMAN> backup tablespace users; To Restore: RMAN> set decryption identified by "pooh"; RMAN> restore tablespace users; (c) Arup Nanda
69
RMAN Encryption – Dual Mode
During Backup: Wallet must be open. RMAN> set encryption on identified by “pooh"; RMAN> backup tablespace users; During Restore: Either: Wallet is open OR RMAN> set decryption identified by “pooh”; (c) Arup Nanda
70
Checking Encryption Check: select tablespace_name, encrypt_in_backup
from rc_datafile; e1.sql (c) Arup Nanda
71
Shameless Plug More features described in my book
Cookbook format: e.g. How to perform a recovery when controlfile is missing (c) Arup Nanda
72
Contact: arup@proligence.com
Thank You! Questions? Contact: (c) Arup Nanda
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.