rman – the pocket knife of a dba
TRANSCRIPT
![Page 1: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/1.jpg)
RMAN – The Pocket Knife of a DBA
■ Presenter: Anton Els Session Details:
@aelsnz
![Page 2: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/2.jpg)
Introduction
■ Vice President Product Development ■ NZOUG Committee (VP) ■ Working with Oracle database since version 7 ■ Interests Include:
▪ Linux, Docker, Oracle Databases, Oracle Backup and Recovery
■ Qualifications: ▪ Oracle Database 11g Certified Master
▪ Oracle 8i, 9i, 10g and 11g OCP
▪ Solaris 10 SCSA and Red Hat 5 RHCSA
▪ B.Sc. Mathematical Sciences and B.Sc. Hons Informatics
■ Presented at Collaborate, NZOUG and db tech showcase
2
Anton Els -‐ @aelsnz
![Page 3: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/3.jpg)
Where do I come from….
3
![Page 4: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/4.jpg)
Who do I work for – Dbvisit Software Limited
■ Software Development Company ■ HQ in New Zealand
▪ US subsidiary and office in Czech Republic ■ Database Replication is our playground! ■ Worldwide leader in DR solutions for Oracle Standard Edition ■ Used in 110+ countries! ■ Product Engineers with “real world” DBA Experience ■ Regular presenters at OOW, Collaborate and NZOUG ■ Passionate about Oracle Technology
4
![Page 5: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/5.jpg)
Agenda
■ What is RMAN, and some history ■ The RMAN environment ■ Recovery Catalog vs. Controlfile ■ Backupset vs. Image Copy ■ Backup, Restore and Recover commands ■ Incremental Backups ■ Advanced options ■ 12c… how great are those new features! ■ Recovery Advisor ■ Reporting monitoring tips
![Page 6: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/6.jpg)
What is RMAN?
■ Oracle Recovery Manager – RMAN ■ I see it as a “safety net” for DBAs
■ Helps you to be prepared for disasters
▪ Natural
▪ Human
▪ Hardware
■ Even if you have a standby database you still need backups! ▪ What-if:
— Both primary / standby is lost
— Logical corruption replicates through to your standby
![Page 7: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/7.jpg)
RMAN helps you protect what is important
■ Database Files
■ Archive Logs
■ Control Files
■ Server Parameter Files
Do not forget about Oracle So9ware and Opera=ng System!
![Page 8: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/8.jpg)
A bit of RMAN History
■ “Traditional backup and recovery”
▪ using BEGIN / END backup commands alter tablespace … begin backup;-> copy files somewherealter tablespace … end backup;
■ RMAN introduced in Oracle 8-8.1.7 ▪ Support open / mounted database backups
▪ Incremental backup support (only modified blocks)
▪ Corrupt block detection
▪ Recovery catalog
▪ Support disk and tape backups
![Page 9: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/9.jpg)
A bit of RMAN History
■ Improved in 9i ▪ Block media recovery
▪ Backup of spfile
▪ Improved controlfile auto backup
▪ FORCE option in the delete command
▪ Introduction of the DBNEWID
![Page 10: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/10.jpg)
A bit of RMAN History
■ Key improvements in Oracle 10g ▪ Improved reporting
▪ Backup Compression (backup sets) (10.1)
▪ Backup Encryption (10.2)
▪ Unused Block Compression (10.2)
▪ Using incremental backup to roll a
standby database forward (10.2)
![Page 11: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/11.jpg)
A bit of RMAN History
■ Key Improvements in 11g ▪ Fast Incremental Backups (block change tracking)
▪ Data Recovery Advisor
▪ Network-Aware Duplication
▪ Automatic Block Repair (11.2)
▪ Duplicate without target database connection (11.2)
![Page 12: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/12.jpg)
A bit of RMAN History
■ Key Improvements in 12c ▪ SQL Commands in RMAN !!!
▪ Table Recovery (Auxiliary instance used)
▪ Improved Active Duplication (backup sets)
▪ Network-Enabled Restore (restore datafile from standby or primary)
▪ Improved multisection backup options (Incremental Backups and
Image Copies)
▪ Fast Standby database synchronization (Using Services)
▪ Multi-tenancy support
▪ Cross-Platform Backup/Restore
![Page 13: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/13.jpg)
A bit of RMAN History
■ Key Improvements in 12c ▪ SQL Commands in RMAN !!!
▪ Table Recovery (Auxiliary instance used)
▪ Improved Active Duplication (backup sets)
▪ Network-Enabled Restore (restore datafile from standby or primary)
▪ Improved multisection backup options (Incremental Backups and
Image Copies)
▪ Fast Standby database synchronization (Using Services)
▪ Multi-tenancy support
▪ Cross-Platform Backup/Restore
![Page 14: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/14.jpg)
Archivelog vs. No-Archivelog Mode
■ No-Archivelog Mode:
▪ Only Cold backups — Database is shutdown when performing backup – downtime!!
▪ Other … kind of backup methods include: — export/import
— datapump
![Page 15: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/15.jpg)
Archivelog vs. No-Archivelog Mode
■ Archivelog Mode
▪ Online Redo logs are archived
following a log switch
▪ Required for Online Backups
— No Downtime
▪ Note: Does require extra disk space!
▪ Make sure you have sufficient redo log groups
SQL> connect / as sysdbaSQL> archive log list;SQL> select log_mode from v$database;SQL> show parameter recoverySQL> shutdown immediate;SQL> startup mountSQL> alter database archivelog;SQL> shutdown immediate;SQL> startupSQL> archive log listSQL> select log_mode from v$database;
![Page 16: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/16.jpg)
Start from a good base
![Page 17: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/17.jpg)
The RMAN Environment ■ The “rman” command: rman nocatalog target /Argument Value Description-----------------------------------------------------------------------------target quoted-string connect-string for target database
catalog quoted-string connect-string for recovery catalogauxiliary quoted-string connect-string for auxiliary databasenocatalog none if specified, then no recovery catalogcmdfile quoted-string name of input command filelog quoted-string name of output message log filetrace quoted-string name of output debugging message log fileappend none if specified, log is opened in append modedebug optional-args activate debuggingmsgno none show RMAN-nnnn prefix for all messagessend quoted-string send a command to the media managerpipe string building block for pipe namesscript string name of catalog script to executeusing list of args arguments for rman variablestimeout integer number of seconds to wait for pipe input
checksyntax none check the command file for syntax errors-----------------------------------------------------------------------------Both single and double quotes (' or ") are accepted for a quoted-string.Quotes are not required unless the string contains embedded white-space.
TIP – on Unix use “oraenv” oracle@dbvlin103[/home/oracle]: . oraenv ORACLE_SID = [oracle] ? proddb The Oracle base remains unchanged with value /u01/app/oracle oracle@dbvlin103[/home/oracle]: env | grep ORA ORACLE_SID=proddb ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/12.1.0/db_1
![Page 18: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/18.jpg)
The RMAN Environment ■ What is “kind of” wrong with example below?
RMAN> backup datafile 1;
Starting backup at 03-OCT-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=261 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/PRODDB/DATAFILE/system.260.858601171
channel ORA_DISK_1: starting piece 1 at 03-OCT-14
channel ORA_DISK_1: finished piece 1 at 03-OCT-14
…
…
Finished backup at 03-OCT-14
![Page 19: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/19.jpg)
Why make things difficult? BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21 Full 683.20M DISK 00:00:06 03-OCT-14
BP Key: 21 Status: AVAILABLE Compressed: NO Tag: TAG20141003T174234
Piece Name: /u02/backups/rman/proddb/15pk56ka_1_1
List of Datafiles in backup set 21
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 2785085 03-OCT-14 +DATA/PRODDB/DATAFILE/system.260.858601171
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
25 Full 683.20M DISK 00:00:14 03-OCT-14
BP Key: 25 Status: AVAILABLE Compressed: NO Tag: TAG20141003T174952
Piece Name: /u02/backups/rman/proddb/19pk5721_1_1
List of Datafiles in backup set 25
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 2785924 03-OCT-14 +DATA/PRODDB/DATAFILE/system.260.858601171
![Page 20: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/20.jpg)
Make it easier! – set NLS_DATE_FORMAT
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
21 Full 683.20M DISK 00:00:06 03/10/2014:17:42:40
BP Key: 21 Status: AVAILABLE Compressed: NO Tag: TAG20141003T174234
Piece Name: /u02/backups/rman/proddb/15pk56ka_1_1
List of Datafiles in backup set 21
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
1 Full 2785085 03/10/2014:17:42:34 +DATA/PRODDB/DATAFILE/system.260.858601171
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
25 Full 683.20M DISK 00:00:14 03/10/2014:17:50:07
BP Key: 25 Status: AVAILABLE Compressed: NO Tag: TAG20141003T174952
Piece Name: /u02/backups/rman/proddb/19pk5721_1_1
List of Datafiles in backup set 25
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
1 Full 2785924 03/10/2014:17:49:53 +DATA/PRODDB/DATAFILE/system.260.858601171
NLS_DATE_FORMAT="dd/mm/yyyy:hh24:mi:ss"
![Page 21: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/21.jpg)
The Default Configuration RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PRODDB are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/backups/rman/proddb/cfc_%F';
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 1;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u02/backups/rman/proddb/%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/12.1.0/db_1/dbs/snapcf_proddb.f'; # default
![Page 22: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/22.jpg)
The Default Configuration RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PRODDB are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/backups/rman/proddb/cfc_%F';
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 1;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u02/backups/rman/proddb/%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/12.1.0/db_1/dbs/snapcf_proddb.f'; # default
![Page 23: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/23.jpg)
Recovery Catalog vs. Controlfile ■ Which one is the correct one to use….
■ Advantages or reasons to consider a Recovery Catalog:
▪ More backup history can be stored ▪ Multiple databases ▪ When using Standby Databases ▪ When looking at using centralized stored scripts ▪ Monitoring ▪ Reporting
■ Using the Controlfile, keep in mind: ▪ CONTROLFILE_RECORD_KEEP_TIME
![Page 24: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/24.jpg)
![Page 25: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/25.jpg)
Backup Sets and Image Copies ■ Backup Set
▪ Default option
▪ Logical container ▪ Can contain one or more files ▪ Proprietary RMAN format ▪ Can be compressed ▪ Physical files on disk – called backup pieces
■ Image Copies ▪ Powerful… but not as widely used
▪ Bit-by-Bit copy of the original file (They are Exactly the same!)
▪ Can be updated with incremental backups
▪ Can easily be switched to, reducing recovery time!!
![Page 26: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/26.jpg)
Example using Backup Set RMAN> run{ backup as compressed backupset filesperset 10 database format '/u02/backups/rman/proddb/db-%U';
backup as compressed backupset filesperset 30 archivelog all format '/u02/backups/rman/proddb/arc-%U';
backup current controlfile format '/u02/backups/rman/proddb/ctl-%d-%I'; }
Starting backup at 04/10/2014:21:46:45using channel ORA_DISK_1channel ORA_DISK_1: starting compressed full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00003 name=+DATA/PRODDB/DATAFILE/sysaux.294.858601125input datafile file number=00001 name=+DATA/PRODDB/DATAFILE/system.260.858601171input datafile file number=00006 name=+DATA/PRODDB/DATAFILE/users.259.858601227input datafile file number=00005 name=+DATA/PRODDB/DATAFILE/data.263.859037565input datafile file number=00004 name=+DATA/PRODDB/DATAFILE/undotbs1.258.858601227channel ORA_DISK_1: starting piece 1 at 04/10/2014:21:46:46channel ORA_DISK_1: finished piece 1 at 04/10/2014:21:48:21piece handle=/u02/backups/rman/proddb/db-1spk89a6_1_1 tag=FULLDBBKP comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:01:35Finished backup at 04/10/2014:21:48:21……
1
2
![Page 27: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/27.jpg)
Example using Backup Copy RMAN> run
{ backup as copy database TAG 'FRA_DBCOPY'; }
Note: This example run on 3 Node 11.2.0.4 RAC database with sufficient space in FRA to keep a copy of the database.
Starting backup at 04/10/2014:21:48:44allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=20 instance=DEV1 device type=DISKchannel ORA_DISK_1: starting datafile copyinput datafile file number=00002 name=+DATA/dev/datafile/sysaux.275.858702333output file name=+FRA/dev/datafile/sysaux.2874.860104127 tag=FRA_DBCOPY RECID=1 STAMP=860104162channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45…
RMAN> list copy of database;
List of Datafile Copies=======================
Key File S Completion Time Ckp SCN Ckp Time------- ---- - ------------------- ---------- -------------------2 1 A 04/10/2014:21:50:05 48308543 04/10/2014:21:49:30 Name: +FRA/dev/datafile/system.2757.860104173 Tag: FRA_DBCOPY
1 2 A 04/10/2014:21:49:22 48308515 04/10/2014:21:48:45 Name: +FRA/dev/datafile/sysaux.2874.860104127 Tag: FRA_DBCOPY
1
2
3
![Page 28: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/28.jpg)
Restoring is easy… if you have good backups
Restore one datafile
RMAN> alter database datafile 5 offline;
RMAN> restore datafile 5;
RMAN> recover datafile 5;
RMAN> alter database datafile 5 online;
Restore and recover database
RMAN> startup nomount;
RMAN> set dbid 598649033
RMAN> restore controlfile from '/u02/backups/rman/proddb/ctl-PRODDB-598649033';
RMAN> alter database mount;
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open resetlogs;
![Page 29: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/29.jpg)
But what about Image Copies?
Switch to datafile copy
RMAN> alter database datafile 5 offline;
RMAN> switch datafile 5 to copy;
RMAN> recover datafile 5;
RMAN> alter database datafile 5 online;
Switch database to Image Copies
RMAN> startup mount;
RMAN> list copy of database;
RMAN> switch database to copy;
RMAN> recover database;
If complete recovery:
RMAN> alter database open;
If incomplete recovery:
RMAN> alter database open resetlogs;
![Page 30: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/30.jpg)
Move database from file system to ASM
30
DEMO
![Page 31: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/31.jpg)
![Page 32: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/32.jpg)
Remember control files… (continue from Demo)
■ Start database in nomount ■ Restore “copy” the controlfile into ASM: RMAN> restore controlfile to '+DATA' from '/u02/oracle/oradata1/DEV2/control01.ctl';
■ Update spfile ASMCMD> find +DATA/DEV2/ *…+DATA/DEV2/CONTROLFILE/current.281.887984443…
SQL> alter system set control_files='+DATA/DEV2/CONTROLFILE/current.281.887984443' scope=spfile; ■ Enable OMF and recovery area in ASM SQL> alter system set db_create_file_dest='+DATA' scope=spfile;SQL> alter system set db_recovery_file_dest='+FRA’ scope=spfile;
![Page 33: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/33.jpg)
RMAN Channels
■ The RMAN Client does not: ▪ Perform backups, restores or recovery operations!
■ Database Server sessions perform this work ▪ Linux – Server process ▪ Windows – Thread within database service
■ Two Supported Device Types: ▪ DISK ▪ SBT (Tape Based Backups)
![Page 34: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/34.jpg)
RMAN Channels - 3 Key Phases
■ Read Phase ■ Copy Phase (processing phase)
■ Write Phase
• Valida=on • Compression • Encryp=on
![Page 35: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/35.jpg)
Incremental Backups ■ 1st Step - Full Level 0 Backup
rman> backup … incremental level 0 database …
■ Two types of Incremental Backups: ▪ Cumulative rman> backup … incremental level 1 cumulative
database …
▪ Differential (default) rman> backup … incremental level 1
database …
Mon Tue Wed Thu Fri
FULL
|-‐-‐-‐-‐-‐>
|-‐-‐-‐-‐-‐-‐ -‐-‐-‐-‐-‐-‐>
|-‐-‐-‐-‐-‐-‐ -‐-‐-‐-‐-‐-‐-‐-‐ -‐-‐-‐-‐-‐-‐>
|-‐-‐-‐-‐-‐-‐ -‐-‐-‐-‐-‐-‐-‐-‐ -‐-‐-‐-‐-‐-‐-‐-‐ -‐-‐-‐-‐-‐-‐>
Mon Tue Wed Thu Fri
FULL
|-‐-‐-‐-‐-‐>
-‐-‐-‐-‐-‐-‐-‐-‐ |-‐-‐-‐-‐-‐>
-‐-‐-‐-‐-‐-‐-‐-‐ -‐-‐-‐-‐-‐-‐-‐-‐ |-‐-‐-‐-‐-‐>
-‐-‐-‐-‐-‐-‐-‐-‐ -‐-‐-‐-‐-‐-‐-‐-‐ -‐-‐-‐-‐-‐-‐-‐-‐ |-‐-‐-‐-‐-‐>
![Page 36: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/36.jpg)
Two Advanced Options (of many)
■ Updating Image Copies using Incremental Backups ▪ Create Backup:
rman> backup as copy incremental level 0 database format
'/u02/oracle/oradata2/DEV2/%N-%f.dbf' TAG=‘inc_bkp_copy';
rman> backup incremental level 1
for recover of copy with tag 'inc_bkp_copy’ database;
▪ Apply incremental backup to image copy:
rman> recover copy of database with tag ’ inc_bkp_copy';
![Page 37: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/37.jpg)
Recover Image Copy using Incremental Backup
37
DEMO
![Page 38: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/38.jpg)
![Page 39: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/39.jpg)
Two Advanced Options (of many)
■ Block Change Tracking (10g+ and EE only) ▪ Default location DB_CREATE_FILE_DEST (OMF File)
▪ Minimum 10M (grows in 10M chunks)
▪ Enable: sql> alter database enable block change tracking;
sql> alter database enable block change tracking
using file ‘/u01/oradata/blck-tracking’;
▪ Disable: sql> alter database disable block change tracking;
![Page 40: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/40.jpg)
12c… how great are those new features!
■ Four New Features that stood out for me:
▪ SQL Commands in RMAN
▪ Table Recovery
▪ Network-Enabled Restore / Recovery
▪ Rolling forward / synchronizing a Standby Database - Using Services
![Page 41: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/41.jpg)
12c – SQL Commands in RMAN
No more: rman> sql ‘alter system switch logfile’;
Now: rman> alter system switch logfile;
RMAN> create table test (id number);Statement processed
RMAN> select * from test;no rows selected
RMAN> begin2> for c1 in 1..20 loop3> insert into test values (c1);4> end loop;5> end;6> /
Statement processed
RMAN> select count(1) from test;
COUNT(1)---------- 20
RMAN> rollback;
Statement processed
RMAN> drop table test purge;
Statement processed
![Page 42: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/42.jpg)
12c – Table Recovery Pre-requisites: ■ Backups must be available
■ Target database must be:
▪ open Read / Write and in archivelog mode
Things to take into account ■ An Auxiliary Instance
■ Tablespace containing table is restored
■ Datapump used for table export/import
■ Disable table import using: NOTABLEIMPORT keyword
■ Make sure you have sufficient storage – auxiliary instance
![Page 43: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/43.jpg)
Restore Table using RMAN (12c)
43
DEMO
![Page 44: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/44.jpg)
44
![Page 45: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/45.jpg)
12c – Network-Enabled Restore/Recovery
■ Restore a datafile from a Primary / Standby ■ Using Services ■ Configure and Test Networking:
▪ listener.ora ▪ tnsnames.ora
■ SECTIONSIZE, encryption, compressed backupsets can be used ■ Improved restore | recover datafile Commands
rman> restore datafile n from service <service>;
rman> recover datafile n from service <service>;
![Page 46: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/46.jpg)
12c – Network-Enabled Restore/Recovery RMAN> alter database datafile 5 offline;Statement processed
RMAN> restore datafile 5 from service proddb_dr;Starting restore at 07/10/2014:13:06:28using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: using network backup set from service proddb_drchannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00005 to +DATA/PRODDB/DATAFILE/data.304.860260051channel ORA_DISK_1: restore complete, elapsed time: 00:00:03Finished restore at 07/10/2014:13:06:32
RMAN> recover datafile 5;Starting recover at 07/10/2014:13:06:39using channel ORA_DISK_1starting media recoverymedia recovery complete, elapsed time: 00:00:01Finished recover at 07/10/2014:13:06:40
RMAN> alter database datafile 5 online;Statement processed
![Page 47: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/47.jpg)
12c – Rolling Forward / Sync a Standby Database
Quick and easy recovery from: ■ Unrecoverable archive log gaps
■ No-logging operations
When using this method • Standby = Target
• Primary = Auxiliary
Behind the scenes: ■ Standby database “current SCN” is obtained
■ Primary database incremental backup from this SCN
■ Incremental backup copied across network and applied to standby
![Page 48: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/48.jpg)
12c – Rolling Forward / Sync a Standby Database Example: (executed from standby server)
rman> connect target /
rman> connect auxiliary sys/<syspassword>@<your_primary_db_service>
rman> recover database from service <your_primary_db_service>
using compressed backupset;
Important last step ▪ Recreate the standby controlfile
— Required as standby controlfile SCN lower than datafile SCN
— Update datafile and tempfile names if required
![Page 49: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/49.jpg)
Tip - Don’t forget about Data Recovery Advisor
■ Introduced in Oracle 11g ■ Three key commands:
rman> LIST failure
rman> ADVISE failure
rman> REPAIR failure
■ Not available when using Multi-tenancy - CDB/PDB
▪ Expected in 12.2
![Page 50: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/50.jpg)
Reporting and Monitoring
■ Using RMAN: ▪ LIST command ▪ REPORT command
■ Using Database Queries: ▪ Monitor current running jobs:
— v$session
— v$session_longops
▪ Monitoring history: — v$rman_backup_job_details
— v$rman_output
![Page 51: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/51.jpg)
Reporting and Monitoring
SELECT command_id, status, start_time, end_time, time_taken_display, input_type, output_device_type, input_bytes_display, output_bytes_display, output_bytes_per_sec_displayfrom v$rman_backup_job_detailswhere start_time > (sysdate-5)order by start_time;
Rman> list backup;Rman> list copy;Rman> list copy of database;Rman> list copy of datafile n;Rman> report schema;Rman> report need backup;Rman> report obsolete;
![Page 52: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/52.jpg)
RMAN is easy!
Start with the basics before making things too complex: ■ set NLS_DATE_FORMAT ■ SHOW ALL ■ CONFIGURE ■ BACKUP DATABASE ■ RESTORE | RECOVER DATABASE ■ RESTORE | RECOVER DATAFILE
Don’t forget about the VALIDATE options!!
![Page 53: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/53.jpg)
Recommended Reading
• Oracle Online Documentation
• Oracle Database 12c Backup and Recovery Survival Guide
• RMAN Recipes for Oracle Database 11g, A Problem-Solution Approach
• Dbvisit Blog – http://blog.dbvisit.com
![Page 54: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/54.jpg)
■ Change Control is there for a reason!
■
■ Document your Backup and Recovery procedures!!!
But most important!
![Page 55: RMAN – The Pocket Knife of a DBA](https://reader034.vdocuments.mx/reader034/viewer/2022042513/589fc76d1a28ab91398b6047/html5/thumbnails/55.jpg)
Questions?
Presented By: Anton Els Company: Dbvisit Software Limited Email: [email protected] Twitter: @aelsnz Blog: http://blog.dbvisit.com/author/anton-els/