Friday, September 28, 2018

Getting started with RMAN – Overview of RMAN, Starting and connecting to database – RMAN Part-1

Many times, We always have question in our mind that from where to start learning, when we suppose to implement a new concept, isn’t it? This article is for beginners who willing to learn RMAN in depth. In this article I am going to cover overview of RMAN, Various components of RMAN, and how to start and connect with database.

Lets begin with RMAN overviews:


RMAN stands for Recovery Manager, this is client who performs not only backup and recovery for oracle database but also making DBA’s life easier in terms of automation, backup, restore and recovery of database. RMAN consist of some backup utilities and collaborated with your oracle database that combine play a role in database backup.



RMAN components:


Target Database:
Target database is the registered database with the RMAN, on which RMAN is performing backup and recovery operations. All operations performed and practiced ( i.e.metadata is also known as repository. ) by RMAN would be logged in database control file.

RMAN client:

RMAN client is nothing but the executable required to run RMAN and performers its desire task. RMAN client situated in ‘ORACLE_HOME/bin’. No extra efforts would be required to install this client, because this client installed automatically when oracle software being installed.



RMAN Optional components are as follows:


Fast Recovery Area:
Fast Recovery Area also called as FRA, this is nothing but the disk location where database can stored and manage files regarding backup and recovery. We can control FRA by specifying its location and size according to user’s convenience.

Media Manager:
Media manager is responsible in making communication between RMAN client and media like tape, etc. It also responsible for managing media while backup and recovery, media loading, media labeling and unloading.

Recovery Catalog:
Recovery catalog is one of the database schema, who holds all RMAN activity of one or more target databases.
There is a risk involved in losing all RMAN repository metadata while loss of controlfile. But with the help of recovery catalog we can reatain it.

In case of loss of database controlfile there is a risk to loss of all RMAN repository metadata.
Recovery catalog don’t overwrite older records but control file do by the time goes on.

Lets do some practical, Starting RMAN and connecting to your database.
To start RMAN, we need to instantiate RMAN client by RMAN command on OS prompt:

[root@ol11g ~]# su - oracle
 -bash-4.1$ rman 
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Oct 6 22:13:05 2006
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
RMAN>

Note: Above, we considered oracle environmental variables already set. ( ‘ORACLE_HOME’, ‘ORACLE_SID’ and ‘PATH’ )

To connect target database, issue the command “connect target /” on RMAN prompt with the help of OS authentication.

RMAN> connect target /
connected to target database: GALAXY (DBID=3647455456)

Note: GALAXY is my target database & 3647455456 is its Database ID.

We can also connect to target database with the help of user authentication:

RMAN> connect target system@galaxy
connected to target database: GALAXY (DBID=3647455456)

To quite from RMAN prompt, simply write ‘exit’ on RMAN prompt:

RMAN> exit;



These is all about Overview, components of RMAN and starting RMAN and connecting with database.

How to backup database in Archivelog and NoArchivelog mode with RMAN backup utility – RMAN Part-2


In my previous article I have covered, overview of RMAN, Various components of RMAN, and how to start and connect with database.
In this article, I am going to cover how to backup database with the help of RMAN backup utility in Archive log and NoArchive log mode.
We can backup database file with the help “backup database” RMAN command. This will backup your database files to already configured device type. i.e. Disk or SBT, default is Disk.
With RMAN, we backup database as “backup set” OR backup database as “backup as copy”. While backup, by default RMAN creates “backup sets”, backup sets consist of backup piece[s], backup piece means physical file genrated and readable by only RMAN.
With the help of “backup as copy” RMAN command, we can backup database as copy of that database, In which each files would be copy as image. Image copy are similar to copies generated with OS command like cp/copy. Usable by RMAN only. We can use “backup as copy” while database in open mode.

Lets Consider hands-on on Database backup in NoArchive log mode:
While database is running under NoArchive log mode, than only way to consider consistent backup is to take your database in mount state after consistant shutdown. ( i.e. ‘shutdown’ OR ‘shutdown immediate’ ) So that restoring database backup would not required any kind of recovery.
To backup your database in NoArchivelog mode ( i.e. consistent backup ), consider following:
Switch to oracle user:
[root@ol11g ~]# su - oracle
Connect to database and shutdown database consistently:
-bash-4.1$ sqlplus / as sysdba
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
Start your database in mount state:
SQL> startup mount;
ORACLE instance started.
Total System Global Area 442601472 bytes
Fixed Size 2214176 bytes
Variable Size 331351776 bytes
Database Buffers 104857600 bytes
Redo Buffers 4177920 bytes
Database mounted.
SQL> exit
Connect to RMAN prompt with target database ( i.e. galaxy ) and start database backup:
-bash-4.1$ rman target /
connected to target database: GALAXY (DBID=3647455456, not open)
RMAN> backup database;
OR
RMAN> backup as copy database;
Lets Consider hands-on on Database backup in Archive log mode:
Note:
To backup your database in archive log mode, your database must be configured in archive log mode. If not, follow my one of the article to convert database in archivelog mode.
As we know, Redo logs are required at the time of recovery to open database in consitent state, thats why we called this backup as inconsistent.
To backup database along with archive log, issue the following RMAN command:
RMAN> backup database plus archivelog;

These is all about backup database with the help of RMAN backup utility in Archive log and NoArchive log mode.

How to take oracle database incremental backup with RMAN backup utility – RMAN Part-3


In my earlier article, I have covered “How to backup oracle database in Archivelog and NoArchivelog mode with RMAN backup utility”.
Here, Now I am going to explain RMAN Incremental backup terminologies and how to make incremental backups of your database.
What is Incremental backup?
Incremental backup is a backup who takes backup of only those blocks who modified ( i.e. block level changes done ) after full/incremental database backup. Incremental. backups are smaller and takes less time to backup as compared to full RMAN database backup.
While taking first incremental backup, it will be count as level 0 incremental backup, which is same in content to RMAN full backup and takes backup of all blocks in the database. Level 1 incremental backup takes backup of only those blocks who modified after earlier incremental backup.
There are two levels of incremental backup:
  • Cumulative: In which backup considered all modified blocks to backup right after last level 0 incremental backup.
  • Differential: In which backup considered all modified blocks to backup right after recent incremental backup. Default: differential.
Lets consider small scenario and you will get total idea of what is differential and what is cumulative incremental backup:
Consider we have big organizational data with huge size, whose full and incremental backup scheduled are as follows:
Sun: Full RMAN backup @ 9pm.
Mon: Differential incremental backup @ 9pm.
Tue: Differential incremental backup @ 9pm.
Wed: Cumulative incremental backup @ 9pm.
Now consider we got worst scenario of data loss:
Scenario 1:
In case of worst situation occurs on Monday after backup, If we want to recover database till Monday than RMAN will consider Sunday:full RMAN backup + Monday:differential incremental backup to recover database.
Scenario 2:
In case of worst situation occurs on Tuesday after backup, If we want to recover database till Tuesday than RMAN will consider Sunday:full RMAN backup + Monday:differential incremental backup + Tuesday:differential incremental backup to recover database.
Scenario 3:
In case of worst situation occurs on Wednesday after backup, If we want to recover it till Wednesday than RMAN will consider Sunday: full RMAN backup + Wed: Cumulative incremental backup to recover database. because cumulative backup already backed up all modified blocks changes of Monday, Tuesday & Wednesday in one time, in this case no need to apply differential backup of Monday and Tuesday.
Lets consider hands-on on how to take Incremental backups:
To take Level 0 incremental backup, issue the following command on RMAN prompt:
RMAN> backup incremental level 0 database;
To take Level 1 incremental backup, issue the following command:
RMAN> backup incremental level 1 database;
To take Level 1 cumulative incremental backup, issue the following command:
RMAN>backup incremental level 1 cumulative database;

With the help of above RMAN commands, you can take database incremental backups.
This is all about RMAN Incremental backup terminologies and how to make incremental backups of your database.

No comments:

Post a Comment

[ERROR]: The value of s_patch_service_name is not set correctly in atleast one of the context files.

[ERROR]: The value of s_patch_service_name is not set correctly in atleast one of the context files. I got the issue below wh...