Thursday, July 23, 2020

ORACLE RMAN(RECOVERY MANAGER) COMPONENTS AND CONFIGURATIONS

ORACLE RMAN(RECOVERY MANAGER) COMPONENTS AND CONFIGURATIONS:  

RMAN:
             Rman or Oracle Recovery Manager introduced in oracle 8i,oracle proprietary software client or utility similar to sqlplus used to perform backups,restores,recoveries and other Database operations,Rman takes backup only usedblocks in entire database blocklevel backup,it performs block level backup parallelism,Rman is the utility to take backups and restore oracle recommends,Rman is faster it takes block level backups,Rman is faster because we can initiative parallesism,validate your database using Rman detect block corruption,Rman will repair the database block corruption for you validating backup,incremental backup,recovery catalog.and it is a platform independent tool.
            Rman stores backup metadata inforamtion in the database ,use control file to hold backup metadata information catalog, also using remote repsitory catalog schema database it is a online backup tool its a special feature does block backup with incremental concept,metadata is the control file data stores the information into different database on server,Multi destination backups like tapes,Archive log mode is must to use Rman. Rman utility comes with oracle binaries,no special installation orlicence required for using Rman at command prompt just type rman,it defaults connects to database environmental variables defined, Rman utility can be used only when Database is atleast mount stage,Rman is used while the database is UP and running and have a very little performance impact is backup is running .

COMPONENTS OF RMAN
------------------------------------
RMAN PROMPT
TARGET DATABASE
RECOVERY CATALOG
AUXILAR DATABASE-->clone DB connection target clone
MEDIA MANAGEMENT LAYER-->RMAN and third party tools (net backup)
RMAN CHANNELS---> back up is speed 

FULL BACKUP-----> ENTIRE DATABASE BACKUP (RMAN FULL BACKUP IS EQUAL TO HOT BACKUP  CANNOT APPLY INCREMENTAL BACKUP ON FULL BACKUP)
              

INCREMENTAL BACKUP----> LEVEL 0--->FULL DB BACKUP--> Full Db backup takes bakup of the used blocks( we can restore Db level0)

  |----> LEVEL 1--->BACKUP CHANGES ONLY FROM LAST LEVEL 0 BACKUP--->Takes Backup of only the changed blocks from last backup,Rman will know which block will be changed block header SCN number backup only changed block  taken by referrring data block header for updated SCN (we can recover DB applying archives and open database)

RECOVERY IN TWO PARTS----->RESTORE--->LEVEL 0
                                              |--->RECOVERY--> LEVEL 1

CONFIGURATIONS OF RMAN
-----------------------------------------
To connect using rman
----------------------
$rman target/

To Display the configuration of RMAN.
------------------------------------
rman>show all;


Configuring Device Type - Tape / Disk
----------------------- --------------
For Tape: Tivoli manager (IBM)

rman>Configure default device type to sbt;

For Disk : Default
-------------------
rman>Configure default device type to disk;

Configuring Channels with Parallelism Option - EE
---------------------------------------------
Multiple backupsets can run with parallel option.

Depends on number of cores, can increase the performance of the backup using multiple channels.

$mkdir -p /orabackup/prod/rman/stream1
$mkdir -p /orabackup/prod/rman/stream2

rman>Configure device type disk parallelism 2;
rman>CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/orabackup/prod/rman/stream1/backup%U';
rman>CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/orabackup/prod/rman/stream2/backup%U';

Maximum Piece Size
------------------
Limit the backup piece size 
rman>CONFIGURE CHANNEL  DEVICE TYPE DISK MAXPIECESIZE 1000m;


Optimization
------------
oracle skips the files that are already backedup by enabling optimization.

rman>configure backup optimization on;


Control file autobackup
-----------------------
Control file holds data and control information of database
 as well metadata of backup information.

On every backup event, the control has to get backed up. Enable autobackup.
With control file - includes spfile also

rman>configure controlfile autobackup on;

rman>configure controlfile autobackup off;


rman>CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/orabackup/prod/rman/%F';

Eg:
Output :
--------
Starting Control File and SPFILE Autobackup at 23-JUL-20
piece handle=/orabackup/prod/rman/c-369100151-20171110-00 comment=NONE
Finished Control File and SPFILE Autobackup at 23-JUL-20


Retention Policy - default 1 day
----------------
is defined , how to long to hold the backups ..
Once retention value reached, the backup files will expire.

rman>CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;


Snapshot controlfile
---------------------
rman>CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/orabackup/prod/rman/snapcf_prod.f';

To update the recovery catalog to get sync for consistent , will have a snapshot controlfile.


Backup sets / Backup Pieces
---------------------------

RMAN can also store its backups in an RMAN-specific format called a backup set.

A backup set is a collection of files called backup pieces, each of which may contain the backup of one or several database files.


retention
optimization
control on , path/loc
snapshot
parallelism
channels 
maxpiecesize
disk/tape
---------------------------------------------
How to have a backup using rman?

rman target/
rman>backup database plus archivelog;

Only datafiles
rman>backup database;

only archivelog files
rman>backup archivelog all;

Image backup - same as dbf format
rman>backup as copy database;

list of backup files
rman>list backup;
rman>list backup summary;






Error : scenario:
----------------
ORA-19625: error identifying file /archives/prod/1_986936449_51.arc
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory

in case : 
archive log missing , cannot continue backup.

for that , use crosscheck command . will validate the existing archives and mark has expired for
those missing archives in control file. so next backup will skip those missing archives found expired.

rman>crosscheck archivelog all;
rman>backup database plus archivelog;

For backups 
rman>crosscheck backup;

Error : Scenario:-
-----------------
ORA-19502: write error on file "/orabackup/prod/rman/stream2/backup0kth1k51_1_1", block number 51456 (block size=8192)
ORA-27072: File I/O error

Verify the physical file system space on /orabackup
$df -h
if 100% 
remove old files using

Step1 : rman>report obsolete;
will list all files that are expired/obsolete;
Step2 : rman>delete obsolete;
will delete those listed obsolete files.

If those files not listed and not part of the same database.
then delete using rm -rf * from /orbackup/prod/rman/stream1
1. cd /orabackup/prod/rman/stream1
2. ls -ltrh
3. $rm -rf *


Compressed backup
-----------------
rman>BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG;

Validate the db
RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL;

Skip those archives missing,and free up space on archive location while 
backup.
----------------------------------------------------
RMAN>backup archivelog all delete input skip inaccessible;

/archives - 100%
Take a archive log backup,and resume space by deleteing those backedup archives.

move -/archives - /orabackup (1-10 -old ls -ltr)
backup - delete - space resumed
/orabackup-/archives (1-10) - free already
crosscheck
backup - delete

Connect - RMAN
Backup and Recovery
Configuration
retention policy
controlfile auto
path - controlfile
parallelism - faster
channels
optimization - to skip
snapshot -
maxpiece size

Backup sets - specific format
Backup pieces - files
backup database plus archivelog
crosscheck - validate
delete obsolete
report obsolete

Incremental - Level0 - level 1 | Cummulative
Difference - delete obsolete | delete expired
compressed

Backup Strategy - Explain ?
--------------------------
Incremental backup - Block Level - only changes.

Two types of incremental backup.
    Level 0 - Full incremental backup
    Level 1
        Differential incremental backup.
        Cummulative Backup

Full Incremental - Level 0 Backup -is the full complete
 base backup taken normally on peak off hours.


RMAN>BACKUP INCREMENTAL LEVEL 0 DATABASE;

Level - 1

Differential Backup
-----------------
Sunday – full backup Including all archivelogs – this is a base backup.
Up on this – all changes made will be backedup on every day since last
 incremental backup.

RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;

Cummulative – Including all Previous Changes from
base backup (Level 0) on Sunday.
----------

RMAN>BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;

So we can use next incremental backup for recovery , if previous level 1 backups are lost.
Its the best backup. If no redundancy.

But still, having multiple reduncies in terms tapes/disks. Will
recommend differential.

Crosscheck
---------

we have archives ,... while backup if archives are missing ? can we continue
 the backup?
What happens ?
 The backup fails.
How to continue ?...

ORA-19625: error identifying file /archives/prod/1_998901437_22.arc

RMAN> crosscheck archivelog all;
Crosscheck command validates archives physically exists and updates control
 file repository the file status.
So while rman backup , will verify the catalog and skip those files are
expired(marked) which are physically not exists.

rman>backup archivelog all;
But recommended to continue with full backup in this situation.

every 2/4 hrs will have archive log backup.


Difference between delete obsolete and delete expired?
------------------------------------------------------

Obsolete? : out of retention period. physically files exists and files are
 out retention.

Expired : physically not exists and marked has expired in catalog.

rman>report obsolete;
rman>delete obsolete;

rman>delete expired backup;
will delete records from catalog those expird.


Note:
Level 0 - Full Incremental Backup - Complete
1TB
Level 1
Differential -- Only changes from last incremental
Mon - 1GB -
Tues - 0.5G
Wed - 0.25G -
Only those changes - the difference
Cummulative - best - including previous changes on top of base backup
Mon - 1G
Tues - 1G+0.5G - lost
Wed = 1G+0.5+0.25G - can retain from wed backup of Tues
which includes previous changes as it is cummulative

Space and time

Real time , we use only differential if redundancy managed with additional tape and storage backup.
If tape backup of tuesday with differential and lost disk backup
Can we retain from tape

/orabackup - rman - tues -
once done
will have tape backup



Note:
------
rman>backup archivelog all delete input skip inaccessible;

difference delete obsolete and expired

based on retention, the backup files get expired but physically exists
those need to be deleted
as backup policy , retention 7 days if incremental
after 7 days - expired
need to clean up space to resume
use obsolete

Recoveries
----------
Recover - Lost datafile
-----------------------

    users will not be able to write in users datafile (scott/hr-eg)

Make sure - we have full DB backup - last night including - archives.
as we lost - keep offline datafile.
@09 last night
rman>backup database plus archivelog;
@next day at 03PM - lost datafile
$rm users01.dbf
SQL> alter database datafile '/oradata/prod/users01.dbf' offline;

rman target/
RMAN>restore datafile '/oradata/prod/users01.dbf';
rman>recover datafile '/oradata/prod/users01.dbf';
will recover changes from last night 09 till today 03pm from
archives.

SQL> alter database datafile '/oradata/prod/users01.dbf' online;

---------------------------------------------------

inconsistent Recovery - If no archives.
    Timebased
        using SCN number(v$database)


As you would expect, RMAN allows incomplete recovery to a specified time,
 SCN or sequence number:

$rman target/
$rman>run {
 shutdown abort;
 startup mount;
 set until sequence 21;
 restore database;
 recover database; #media recovery from archiveslogs
 alter database open resetlogs;
}

-----------------------------------
Whole database recovery
-----------------------

If the controlfiles and online redo logs are still present a whole database
 recovery can be achieved by running the following script:
rman target/
rman>
run { shutdown abort
# use abort if this fails
 startup mount;
 restore database;
 recover database;
alter database open;
}

Note: Using run{} block ,we can execute multiple commands in rman.
-------------------------------------
Difference between delete obsolete and delete expired


Delete Obsolete - will delete, where the files physical exists and out of
 retention period.
rman>delete obsolete;
rman>delete obsolete noprompt;

Delete expired - will delete those files are marked as expired and physically
 not exists.
rman>delete expired backup;
---------------------------------------------------
Compressed backup
-----------------
rman>BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG;

Validate the db
RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL;

Skip those archives missing,and free up space on archive location while
backup.
----------------------------------------------------
RMAN>backup archivelog all delete input skip inaccessible;

/archives - 100%--->/orabackup
space resume by delete
if missed,skipping

move -/archives - /orabackup (1-10 -old ls -ltr)
backup - delete - space resumed
/orabackup-/archives (1-10) - free already
crosscheck
backup - delete

13.arc bkp arclog
14.arc
15.arc
16.arc till - next fail. due to missing archives
18.arc skip(17) - inaccessible will continue also delete
those backedup(13,14,15,16,18).
21.arc skip(19,20) - inaccessible
backup completed and resumed space
22.arc
23.arc
missing 17/19







NOTE: info on Rman may be differs in  your environment like production,testing,development or u r host machine.




THANK YOU VIEWING MY BLOG FOR MORE UPDATES VISIT MY BLOG REGULARLY















































ITIL Process

ITIL Process Introduction In this Blog i am going to explain  ITIL Process, ITIL stands for Information Technology Infrastructure Library ...