Understanding RMAN
Rman Backups:
============
SYSBACKUP PRIVILEGE : Introduced in oracle 12c database
===================
• New system privileges introduced is SYSBACKUP
• Granted to users who need to perform backup and recovery operations.
• A user with the SYSBACKUP privilege will be restricted to allow only backup and recovery operations.
• This permission can also be granted to a local user account in a PDB
eg:
RMAN> connect target /
connected to target database: CDBTST (DBID=1036753271)
RMAN> connect target '"xyz as sysbackup"';
target database Password:
connected to target database: CDBTST (DBID=1036753271)
RMAN:
====
a RMAN (Recovery Manager)
RMAN is a centralised backup restore and recovery utility across the enterprise database;
If we configure RMAN there will be minimal DBA intervention during restore and recovery
We can configure RMAN in CATALOG mode and NO CATALOG mode
Oracle stringly recomends to configure RMAN in catalog mode
In No catalog mode information about the configuration parameters and backup sets will be stored in the reusable section of the target database control file
we can save the backup information using the control_file_record_keep_time
Invocation of every RMAN backup command produces backup sets which are nothing but collection of backup pieces which are nothing but physical files
We can take full/differential/incremental using RMAN
In case of incremental backups RMAN takes the backup of only modified blocks
RMAN backup is a content copy
In order to minimize the backup time we can define multiple channels
A channel is a communication path from catalog database to target database
No of channel depends on number of CPUS
If a server is a uni processor and we have defined channels of 3 then there will be no use
we can clone the database using duplicate database
we can create stand by database using RMAN
To minimize the incremental backup time oracle has introduced block chnage tacking
Once we enable BCT then it will initiate CTWR(change Track writer)
Using RMAN we can take compressed backups
Using catalog database we can retain the information about the backups until we donot delet explicitly
In catalog database we can create stored scripts and the scripts can be reused for any number of target databases
Steps to configure CATALOG database:
====================================
Identify a least utilised server running on any paltform
create a suitable database for catalog
create a seperate tablespace to hold the rman database
create a seperate user and grant connect,resource,recovery_catalog_owner
connect to RMAN utility and execute "create catalog"
Now execute register database
Working on RMAN configuration:
===========================
RMAN on its own capable of taking the backups in to disk based on archive dest value
But it cannot directly push the backup pieces to the tape until the intervention of third party MML layer like TIVOLI?VERITAS/LEGATO/OSB
From 10g oracle introduced OSB(oracle secure backup ) to minimise tyhe MML intervention to tape libraris
Incase of TIVOLI TSM administrator is going to install teh TSM software and its going to configure TDPO.opt file on all the target database TDPO
Once the tdpo agenr is installed and configured on the target databases it is the responsibility of the dba to modify the RMAN scripts to point to the TDPO.opt file location
CONFIGURE RETENTION POLICY TO REDUNDANCY 2
This above parameter explain us that it will maintain 2 copies of backup pieces, but this is not a good practice to use
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 31 DAYS
CONFIGURE BACKUP OPTIMIZATION ON
CONFIGURE DEFAULT DEVICE TO DISK
CONFIGURE CONTROLFILE AUTOBACKUP ON
CONFIGURE DEVICE TYPE DISK PARALLELISM
RMAN COMMANDS:
==============
RMAN > LIST BACKUP;
RMAN > SHOW ALL;
RMAN > REPORT NEED BACKUP; Using the report command,we can get information about RMAN backups which correspond to current retention policy.
RMAN > BACKUP DATABASE;
RMAN > REPORT SCHEMA;// To get information about datafiles of a database according to a specific point in time, use the following:
report schema at time sysdate-1';
report schema at scn=554962;
report schema at sequence 3 thread 1;
RMAN SCRIPT:
==========
run
{
allocate channel t1 device type disk;
allocate channel t2 device type disk;
allocate channel t3 device type disk;
allocate channel t4 device type disk;
backup archivelog all delete all input //In this case RMAN backs up only one copy of each log sequence number in these directories, and then deletes all copies of any log that it backed up from the archiving destinations.
sql 'alter system switch logfile';
release channel t1;
release channel t2;
release channel t3;
release channel t4;
}
Useful commands
===============
backup database plus archivelog all delete all input;
crosscheck archivelog all;
backup incremental level 0 database;
backup incremental level 1 database;
backup as compressed backupset database;
crosscheck backup
delete obsolete
Backup strategy
Types of Incremental backup
1) Cumulative
- Which includes all block changes since the most recent level 0 backup
2) Differential
- Which includes only blocks changed since the most recent incremental backup. Incremental backups are differential by default.
Making Incremental Backup
- It captures the block level changes to the database after incremental or full backups
- By generally incremental is smaller and faster than full backup and Recovery with incremental backups is faster than using redo logs alone.
- In this incremental backup starting is “Level 0” Which is same as a full backup but it ll set a backup strategy.
- In “Level 1” backup which contains only blocks changed after a previous incremental backup , if our current database or parent database incarnation doesn’t have the “Level 0” backup we would directly proceed for “Level 1” then it ll take automatically “Level 0”
Typical Backup Options
1)Format => Backup format ‘%U_%d_%t_%s_%p’
Here %U=Unique name ,%d=database name,%t=backup set time stamp,%s=backup set number,%p=backup piece number
2)TAG => BACKUP TAG 'weekly_full_db_bkup' DATABASE MAXSETSIZE 10M;
We are allocating the name of rman Backup if we don't mention the tag by default the rman allocates the name using date and time
We can implement three kinds of backup strategies
1) Level 0 or full backup - Monthly once
2) Level 1 Cumulative - Weekly Once
3) Level 1 Differential - Daily Once
RMAN> backup format 'Dh_%U_%d_%t_%s_%p'Tag 'Incre_backup_1' incremental level 1 database;
RMAN > backup format 'Dh_%U_%d_%t_%s_%p' Tag 'Incre_culMul' incremental level 1 cumulative database;
Note: if we are going to take level 0 or Full backup a thumb rule is to take a new backup when the data of 50% has been changed. We can observe also by using this query
SQL> SELECT FILE#, INCREMENTAL_LEVEL, COMPLETION_TIME, BLOCKS, DATAFILE_BLOCKS FROM V$BACKUP_DATAFILE WHERE INCREMENTAL_LEVEL > 0 AND BLOCKS / DATAFILE_BLOCKS > .5 ORDER BY COMPLETION_TIME;
FUll DB crash:
=============
RMAN > backup database;
RMAN > sql ' alter system switch logfile';
Now remove CRD files
RMAN > shut abort
RMAN > startup nomount;
RMAN > restore controlfile;
RMAN> sql 'alter database mount';
RMAN > restore database;
RMAN> recover database;
RMAN > sql ' alter database open resetlogs';
RMAn > list incarnation;
Comments
Post a Comment