The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.
-
Upload
david-kilgore -
Category
Documents
-
view
223 -
download
1
Transcript of The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.
![Page 1: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/1.jpg)
The What, How and Whyof ORACLE RMAN
Maxym KharchenkoCentral Florida ORACLE Users Group
June 2009
![Page 2: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/2.jpg)
Who am I
Maxym Kharchenko, [email protected]
a Scorpio …
Used to be database internals developer Anyone else heard about: dbVista/Raima/Birdstep/RDM?
Have known RMAN since release 8 … closely …
ORACLE Certified Master … RMAN was a big part of the exam … shh …
![Page 3: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/3.jpg)
What is it that DBA does ?
DBA is someone, who …
Keeps the database running …“If your program doesn’t stop producing 10 Gb of archived logs
every minute, the system will die in 30 minutes … Just FYI …”
… Reasonably fast …“You might think of using WHERE clause in that SQL” …
Protects the data …“How many tables did you say your script drop by mistake?”
… and keeps it reasonably secure“Sorry, the CEO asked NOT to make his salary world viewable” …
Etc etc etc
![Page 4: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/4.jpg)
Recover that data OR die!All DBA responsibilities are important
But NONE is as important as …
Be able to recover data when necessary !
People might (reasonably) tolerate:
System slowness Lack of security Even downtime …
But … if you lose production data and CANNOT recover it you are really, really screwed !
Nobody will care about the reasons One strike and you are out!
![Page 5: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/5.jpg)
ORACLE Backup and Recovery are NOT for the average Joe …
Let’s face it – ORACLE backups and recoveries are complex …
Making a mistake is easy … if you do NOT understand what you are doing … … and sometimes even
if you do …
Successful database recovery test means: A guaranteed future recovery
?
-- Backup data filesGet tbs list/exclude not needed FOR i IN ‘all tablespaces’ DO ALTER tablespace $I BEGIN BACKUP; Get the list of tbs files Copy tbs files ALTER TABLESPACE $I END BACKUP;DONE-- Backup archived logsGet the list of ARC destinationsCopy archived logs
How to perform a ‘disaster’ recovery
10 11 12 1391 2 3 4 5 6 7 8
Backup Backup Backup
![Page 6: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/6.jpg)
Why DBAs make mistakes (with backups) ?
There are 2 major reasons:
Junior DBAs the problem is complexity You need to know a lot and experience a lot Some things will only come with experience
It is EASY to make a mistake if you don’t know enough …
Senior DBAs the problem is that the process is too mundane Repeating the same 40 operations over and over is boring People tend to optimize the work and skip the unnecessary steps Documentation is often ignored
It is even EASIER to make a mistake if you know too much …
![Page 7: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/7.jpg)
Coming of ‘R-man’
To recover the data in all cases … guaranteed, you need to:
Know it all Remember everything
The (sad) conclusion is:
No human will be able to do it …
That is why, we need a ROBOT
![Page 8: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/8.jpg)
The WHAT of RMAN
![Page 9: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/9.jpg)
RMAN Makes Things Simple
1backup full database plus archivelog;
ALTER DATABASE BEGIN BACKUP;Get the list of database files(optional) Exclude read only/unneededCopy database filesCheck that copy is successfulALTER DATABASE END BACKUP;ALTER SYSTEM SWITCH ARCHIVE LOG CURRENT;Get the list of ARC destinationsCopy archived logsCheck that copy is successfulALTER DATABASE BACKUP CONTROLFILE TO …;Copy controlfileCopy parameter/spfile/password fileCheck that copy is successful
![Page 10: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/10.jpg)
RMAN is a Detail Junkie
2EXECUTES:
• Every single step in the procedure …
• … Including implied (‘switch that log’) …
REMEMBERS:
• What backups to keep, remove …
• Special cases (i.e. KEEP FOREVER)
KEEPS TRACK AND VALIDATES:
• Is my data recoverable from backups ?
• Are my backups ‘good’ ?
ADVISES AND MAKES DECISIONS:
• What to backup ?
• How to recover ?
![Page 11: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/11.jpg)
RMAN has Advanced Tools
3Incremental Backups
Compressed Backups
Encrypted Backups
Block Recovery
Backup Flow Control
Etc …
![Page 12: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/12.jpg)
RMAN Manages Binary Metadata
4B
acku
p R
epos
itory
(”M
etad
ata”
)
DB Copy
Standby DB
Create ‘test’ copy of DB excluding
historical data
Create logical standby database
DB (“Data”)
Lab_main TBS
Create a “pluggable” copy of tbs “Lab_main”
As of 1 am yesterday
![Page 13: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/13.jpg)
The HOW of RMAN
![Page 14: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/14.jpg)
RMAN configuration in a nutshell
Target Database
Backup Repository
Recovery Catalog
AuxiliaryDatabase
Disk
Tape
Disk TapeAND
Disk TapeTHEN
AUX Output location
RMAN
Channels
Auxiliary Channels
![Page 15: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/15.jpg)
RMAN backup – Data Copies
Cataloging external copy
A
BA
B
Recovery from copy
A
B
A
B
RMAN Backup as copy
A
B
A
B
Copy switch
A
B
![Page 16: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/16.jpg)
RMAN backup – BackupsetsBackup as backupset
B2B1 B3
A2A1 A3B3A1 A3
B1A2 B2
Recovery from backupset
B2B1 B3
A2A1 A3B3A1 A3
B1A2 B2Full backup and recovery will be slower
1. Backups can be smaller:
• Incremental, Compressed
2. (some) Backups can be faster:
• Incremental with B.C.T.
3. (some) Recoveries can be faster:
• Incremental vs. ARC
4. (some) Backup operations can be optimized
• Zero block, UNDO optimization
5. System can be less affected
• Native RMAN, MINIMIZE LOAD
6. Can backup directly to “tape”
![Page 17: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/17.jpg)
How to be IncrementalFull
Sunday
Monday
Tuesday
Wednesday
Thursday
10 5 10 5
IncrementalSunday (level 0)
Mon (1)
Tue (1)
Wed (1)
Thu (1)
1511 8
Incremental cumulativeSunday (level 0)
Mon (1c)
Tue (1c)
Thu (1c)
Wed (1c)
1311 7
Incrementally updatedSunday (copy/level 0)
Mon (1)+Monday (copy/level 0)=
Tue (1)
Tuesday (copy/level 0)= +12 6
![Page 18: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/18.jpg)
Speeding Up Incremental Backups
Incremental backup - Regular
1 2 3 4 5 6 7 8 9 10 11 12BackupRepositoryDatafile 5
Incremental backup – with block change tracking
1 2 3 4 5 6 7 8 9 10 11 12BackupRepository
4
10
Datafile 5
B.C.T log
![Page 19: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/19.jpg)
RMAN – Making a BackupRMAN> run { allocate channel ch1 type sbt parms 'ENV=(TDPO_OPTFILE=/opt/tsm/tdpo.opt)' rate=100M allocate channel ch2 type sbt parms 'ENV=(TDPO_OPTFILE=/opt/tsm/tdpo.opt)' rate=100M;
backup incremental level 0 database format '%d_s%s_p%p_%T.bkpdf'; backup archivelog all format '%d_s%s_p%p_%T.bkpal';
delete noprompt archivelog all until time "sysdate-2/24";
backup current controlfile format '%d_s%s_p%p_%T.bkpcf';
release channel ch1; release channel ch2;}
RMAN> backup incremental level 0 database plus archivelog;
![Page 20: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/20.jpg)
RMAN – The Beauty of Stored Parameters
RMAN> show all;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;CONFIGURE BACKUP OPTIMIZATION ON;CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';CONFIGURE CONTROLFILE AUTOBACKUP ON;CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO 'autocf_%d_%F';CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 2 BACKUP TYPE TO BACKUPSET;CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'ENV=(TDPO_OPTFILE=/opt/tsm/tdpo.opt)' FORMAT '%d_s%s_p%p_%T.bkpset';CONFIGURE CHANNEL 1 TYPE 'SBT_TAPE' RATE 100M;CONFIGURE CHANNEL 2 TYPE 'SBT_TAPE' RATE 100M;
![Page 21: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/21.jpg)
Disk or Tape ?RMAN> backup device type DISK full database plus archivelog;
RMAN> backup device type SBT full database plus archivelog;
Sunday:RMAN> backup device type SBT incremental level 0 database plus archivelog;
Monday:RMAN> backup device type DISK incremental level 1 database;RMAN> backup device type SBT archivelog all;
RMAN> backup incremental level 0 database plus archivelog;RMAN> backup recovery area;
![Page 22: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/22.jpg)
RMAN - Recovering Your Dataset dbid 2226857552; startup force nomount restore spfile from autobackup;
shutdown immediatestartup nomountrestore controlfile from autobackup;alter database mount;
# (optional): catalog start with '…';# Find latest available SCN, i.e. from v$archived_logrestore database until scn 1234567;recover database until scn 1234567; alter database open resetlogs;
RMAN> restore spfile from '/ora05/flash/DEV10/autobackup/ 2008_12_21/o1_mf_s_674071460_4nxlvpdk_.bkp';
RMAN> restore controlfile from autobackup db_recovery_file_dest='/ora05/flash' db_name='orcl';
![Page 23: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/23.jpg)
Block Recovery# First of all - find which blocks are corrupted
1. Alert log2. RMAN> backup validate check logical datafile N; SQL> SELECT * FROM v$database_block_corruption;3. RMAN> backup check logical datafile N;4. UNIX> dbv data_file
# Then, repair it like this:RMAN> blockrecover datafile X block Y;
# Or, like this:RMAN> blockrecover corruption list;
![Page 24: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/24.jpg)
RMAN – How to Maintain Backups
Remove/Create
Database
Repository
“Tape”
Recovery Window
Database
Repository
“Tape”
Flash Recovery Area
Database
Repository
“Tape”
Flash Recovery Area + TDP
Database
Repository
“Tape”
![Page 25: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/25.jpg)
FRA Sizing Considerations
Remove/Create
Database
Repository
“Tape”
Flash Recovery Area
Database
Repository
“Tape”
![Page 26: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/26.jpg)
FRA – How Large ?FRA size depends on:
Size and volatility of FRA components
Backup Retention
Backup Method
FRA Components
Level 0 Level 1 Flashback Archivelog
FRA: How backup method can affect size
Database
FRA: Disk
FRA: Disk THEN Tape
FRA: Level 0 - TAPE, Level 1 - DISK
FRA: Compressed backups
![Page 27: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/27.jpg)
Is your database recoverable ?
RMAN> report need backup database;RMAN> report unrecoverable database;
RMAN> restore database preview;RMAN> recover database test;
RMAN> crosscheck backup;RMAN> crosscheck copy;
RMAN> list backup of database summary;RMAN> list backup of database by file;
RMAN> backup incremental level 0 check logical database;SQL> SELECT * FROM v$database_block_corruption;
RMAN> restore database validate check logical;SQL> SELECT * FROM v$database_block_corruption;
![Page 28: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/28.jpg)
RMAN - Managing Your Binary Metadata
duplicate target database to testdb skip tablespace tbs1 until time ‘sysdate-1’ logfile group 1 (‘/testdb/redo01.arc’) size 100M reuse, group 2 (‘/testdb/redo01.arc’) size 100M reuse;
transport tablespace lab tablespace destination '/tbs' auxiliary destination '/aux' until time 'sysdate-1';
recover tablespace users, tools auxiliary destination '/aux' until time 'sysdate-1';
Bac
kup
Rep
osito
ry (
”Met
adat
a”)
DB
TTS TBS
Aux DB(“Copy”)
Aux DB
Dup
licat
e
TTS TBS
Aux DB
Transport
TSPITR
![Page 29: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/29.jpg)
RMAN Extras
Database command console
ASM data manager
Datafile platform conversion
Script processor
![Page 30: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/30.jpg)
The WHY of RMAN
![Page 31: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/31.jpg)
Why use RMAN?RMAN utility:
Can simplify many backup and recovery operations Performing them faster and, in many cases, better than ‘regular’
backup tools Let’s you do some cool things with ORACLE Helps avoid mistakes
But most importantly, RMAN allows a DBA to be LAZY (in a good way)
And spend your valuable time on other cool things in ORACLE Because, let’s admit it … backups ARE …
… boring … ;-)
![Page 32: The What, How and Why of ORACLE RMAN Maxym Kharchenko Central Florida ORACLE Users Group June 2009.](https://reader033.fdocuments.net/reader033/viewer/2022061304/5513bc5455034653298b4768/html5/thumbnails/32.jpg)
Any Questions ?