RMAN Commands Part-2

RMAN Commands  Part-2
===================


RMAN:
=====

·Obsolete means “not needed,” whereas expired means “not found.”

·A backup becomes obsolete based on retention policy, that it is not needed for recovery.

·A Backup becomes expired only when RMAN perform CROSSCHECK and can’t find the file. 
(Assume file is deleted by OS).

Difference Between OBSOLETE AND EXPIRED Backup:
=======================================================

RMAN considers backups of datafiles and control files as obsolete, that is, no longer needed for 
recovery, according to criteria that we specify in the CONFIGURE command. 
We can then use the REPORT OBSOLETE command to view obsolete files 
and DELETE OBSOLETE to delete them .
For ex  :  we set our retention policy to redundancy 2. this means we always want to keep at 
least 2 backup, 
after 2 backup,
 if we take an another backup oldest one become obsolete because there is 3 backup and we want 
 to keep  2. 
 if our flash recovery area is full then obsolete backups can be overwrite.

A status of "expired" means that the backup piece or backup set is not found in the backup 
destination or missing .
Since backup info is hold in our controlfile and catalog . Our controlfile thinks that there 
is a backup 
under a directory with 
a name but someone delete this file from operating system. We can run crosscheck command to 
check if these  files are exist 
and if rman found a file is missing then mark that backup record as expired which means is
 no more exists.


V$DATABASE_BLOCK_CORRUPTION

A backup set :consists of one or more backup pieces, which physical files are written in a 
format that only RMAN can access.

A backup set contains one or more binary files in an RMAN-specific format. Each of these 
files is known as a "backup piece"

ex: datafiles, archived redo logs, control files, or server parameter file.

How do u know how much RMAN task has been completed?
By querying v$rman_status or v$session_longops

Which is one is good, differential (incremental) backup or cumulative (incremental) backup?
A differential backup, which backs up all blocks changed after the most recent incremental
 backup at level 1 or 0
A cumulative backup, which backs up all blocks changed after the most recent incremental 
backup at level 0

What is the difference between backup set and backup piece?
Backup set is logical and backup piece is physical.

Database Incarnation:
Whenever you perform incomplete recovery or perform recovery using a backup control file, 
you must reset the online redo logs when you open the database 
  The new version of the reset database is called a new incarnation 
  The reset database command directs RMAN to create a new database incarnation record in the 
  recovery catalog 
  This new incarnation record indicates the current incarnation


The block change tracking:  feature for incremental backups improves incremental backup performance 
by recording 
changed blocks in each data file in a block change tracking file.
SQL> alter database enable/disable block change tracking;
The change tracking writer (CTWR) background process another new feature, writes the block change 
information to the change tracing file.
Database will automatically delete block change tracking file when you disable block change 
tracking.

BACKUP INCREMENTAL LEVEL 0 DATABASE;

BACKUP INCREMENTAL LEVEL 1 DATABASE;

BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;

You can use the VALIDATE command: to confirm that all database files exist, are in their 
correct location, and are free of physical corruption.

The CROSSCHECK command : synchronizes the logical records of RMAN backups and copies with 
the files on storage media. 
If a backup is on disk, then CROSSCHECK determines whether the header of the file is valid

Data Recovery Advisor tool:
---------------------------
RMAN> list backup summary   --- To list backups in summary mode
RMAN> LIST FAILURE;
RMAN> ADVISE FAILURE;
RMAN> REPAIR FAILURE;
RMAN> VALIDATE DATABASE;--> determining which data files are missing
ex: V$RECOVER_FILE to list data files requiring recovery by data file number with their status and 
error information
RMAN> report obsolete -->Which backup can be delete (obsolete)
RMAN> delete obsolete --> delete obsolete backup

RMAN> show all;    --> show all RMAN configuration settings
RMAN> show default device type  ---> To show the default device type
RMAN> show retention policy  -->retention policy configuration settings
RMAN> show maxsetsize   --->To show the maximum size for RMAN backup sets

Backup the df and ts:
======================
RMAN> backup datafile ‘/u01/orcl/oradata/system.dbf’;

RMAN> backup datafile 1,3,5;

RMAN> backup tablespace system, users, tools

RMAN> BACKUP ARCHIVELOG ALL;

            If you want to specify any destination for your archive logs then  

RMAN> BACKUP ARCHIVELOG ALL FORMAT ‘/u11/oradata/backup/al_%t.%S_P%P’;

RMAN>backup database

RMAN> BACKUP database plus ARCHIVELOG;

RMAN> connect catalog rman/rman target sys/sys@TO-PROD
Connecting to the Recovery catalog

              
Create a password file

$orapwd file=orapw$ORACLE_SID password=sys force=y entries=5

Now set remote_login_password=exclusive


==============================================================================================================
MAXPIECESIZE –
————————–------
– This parameter controls the maximum size a backup piece can have
– If we backup only one file, it will split into multiple pieces

- Check the size of datafiles.
– Note that datafile datafile for tablespace sysaux is 570m in size

rman>report schema;
File Size(MB) Tablespace           RB segs Datafile Name
—- ——– ——————– ——- ————————
1    690      SYSTEM               ***     C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
2    570      SYSAUX               ***     C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF


FILESPERSET –
-———————------
– This parameter decides how many files will be included in one backupset.
– If > 1 files are backed up and filesperset = 1, one backupset will be created for each file

rman>delete backup;
rman>backup datafile 7,8 filesperset 1 format ‘c:\%U.bak';

list backup ;
— Note that two backupsets are created with one datafile each

Allocating multiple channels and backing up specified files using specified channels
————————————————————————————–-------------------------------------------------------
— Note that RMan  backs up rman1 and rman2 using c1 and rman3 using c2 as specified
RMAN>delete backup;
run{
allocate channel c1 device type disk format ‘c:\%U.bak';
allocate channel c2 device type disk format ‘c:\%U.bak';
backup (tablespace rman1, rman2 channel c1)
(tablespace rman3 channel c2);
}


==================================================================================================
We can parallelize the backup/recovery operation by
   – setting parallelism for the device
   – Allocating multiple channels and
      . Let RMAN decide which file to backup/restore using which channel
      . BAcking up/Restoring specified files using specified channels
- Filesperset
  . Using this parameter we can reduce the recovery time by limiting the no. of files per
backupset, since to restore a particular datafile we will have to restore a smaller file.
  . This is also beneficial in case the backup fails in the middle. Next time, we can backup
only those datafiles which could not be successfully backed up.
- Maxpiecesize
  This option can be used
   – to exercise the operating system limit on the file size.
   – to split the backup of a datafile into multiple pieces if the backup does not fit in one tape
   – if backup is to be transferred over network.
- Maxopenfiles
  This parameter decides how many files can be backed up simultaneously i.e. data from how many files 
  can be read at a time.
- Multiplexing
  Level of multiplexing means the no. of files whose data is intermingled in the backup file. 
  It depends on the following:
- # of files being backed up using one channel
- FIlesperset
- Maxopenfiles
Level of multiplexing = Minimum of the above 3.
   – Increasing the level of multiplexing can effectively keep the tape streaming.
   – Increasing the level of multiplexing may increase the speed of backup. On the other
hand , it can reduce the restore speed as data for a file has to be extracted from the
intermingled data.
   – Thus , one has to decide the level of multiplexing based on whether performance of the
backup or recovery is more critial.
   – In case files being backed up are ASM files, level of multiplexing may be reduced as 
   ASM automatically takes care of the contention by striping the data.
- Input buffers are allocated for the backup. The no. of buffers allocated per file depends
upon the level of multiplexing.
Multiplexing level        Allocation rule
   Level <= 4           1 MB buffers are allocated so that the total buffer size for all
input files is 16 MB.
   4 < Level <= 8       512 KB are allocated so that the total buffer size for all files is
less than 16 MB.
   Level > 8            RMAN allocates four 128 KB disk buffers per channel for each file,
so that the total size is 512 KB per channel for each file.
- We can calculate the size of the buffers required by RMAN as follows:
    Multiply the total buffer bytes for each data file by the number of data files that are being 
concurrently accessed by the channel, and then multiply this number by the number of channels.
Assume that you use one channel to back up four data files, and use the settings that are shown above. 
In this case, multiply as follows to obtain the total size of the buffers that are allocated for the backup:
4 MB per data file Î 1 channel Î 4 data files per channel = 16 MB

==========================
RMAN can perform i/o in two ways : Synchronous and Asynchr nous.
s>sho parameter disk_asynch_io;

 If asynchronous i/o is supported by the O/s, we should size PGA to a value more than the size of the 
 buffers required by RMAN.

- If asynchronous i/o is not supported by O/S and we are simulating it, we should size large pool to a 
value more than the size 
of the buffers required by RMAN.

==============================================

Backup Retention Polity

 A backup retention policy tells RMAN to consider backups of datafiles and log files obsolet
 You can set a retention policy by using either of two methods: 
 the default redundancy option or recovery window

  The Redundancy Option

 The Redundancy option lets you specify how many copies of the backups you want to retain

  The default is one

  You set retention policy this way

 RMAN>configure retention policy to REDUNDANCY 2;

 The previous RMAN command specifies the RMAN keep only two backups of each database files

The Recovery Window Option

 The recovery window refers to a time frame in which all backups will be kept, regardless 
 of how many  backups are taken you can set recovery window as follows

RMAN>configure retention policy

            To recovery window of 14 days

If  you set your policy to a ‘recovery window of 14 days then all the backups less than  
14days old would be retained, and all backups older than 14days would be marked for deletion

 Default Device Type

The default device for backups is disk; that is RMAN will automatically backup files to 
file system on you server.  If you want to backup to tape, you configure the default device type of sbt

RMAN>configure default device to type to sbt;

            If you wish to switch the default device back to disk then

RMAN>configure default device type to disk;

 Channel Configuration

An RMAN session must use some kind of a connection to the server to perform backup and recovery work, 
and channels represent those connection

If you have four channels configured, four connections will be made to target database to open four 
separate server sessions

The following example configures two channels with channel 1 backup to the backup directory under
 /test01 and channel 2 backing up to backup directory under /test02

RMAN>configure channel 1 device type disk format ‘/test01/app/oracle/oradata/backup/%U’;

RMAN>configure channel 2 device type disk format ‘/test02/app/oracle/oradata/backup/%U’;

 Degree of Parallelism

When two or more channels are allocated for single backup operation this is reffered to parallelization.
  The degree of parallelism denotes the number of channels that RMAN open during a backup or recovery. 
  The time taken to complete the backup or recovery will decrease as you increase degree of parallelism

RMAN>configure device type disk parallelism4;

 Backup optimization

The backup optimization option ensure that RMAN doesn’t perform a file backup if it has already 
backed up identical versions of the file

RMAN>configure backup optimization ON;

 Control File Auto backup

If you set the controlfile Auto backup option to ON, each time you do a backup of your data 
files the control file is automatically backed up along with the SPFILE

RMAN> configure controlfile autobackup ON;

=================================================
Configure retention policy to redundancy 2;

Configure backup optimization ON;

Configure default device type to disk;

Configure controlfile autobackup on;

Configure controlfile autobackup for device type disk to ‘/disk1/oradata/prod/rman/%F’;

Configure device type disk parallelism 2 backup type to backup set;

Configure channel 1 device type disk format ‘/disk1/oradata/rman/prod/%U.bkp’;

Configure channel 2 device type disk format ‘/disk1/oradata/rman/prod/%U.bkp’;

Configure data backup copies for device type disk to 1;

Configure archivelog backup copies for device type disk to 1;

Configure maxsetsize to unlimited;

Configure encryption for database OFF;

Configure encryption algorithm ‘AES128’;

Configure archivelog deletion policy to none;

Configure snapshot controlfile name to ‘/disk3/oradata/prod/rman/snapcf_karun_F’;

1. Retention Policy
- Configuring a retention policy tells RMAN how long
you want to keep your backup information.

2. Backup Optimization
- If you turn on backup optimization and a backup fails half way through, RMAN picks
up where it left off when you restart the backup. If it is turned off, RMAN starts from the
beginning.

3. Default Device Type
- You can have RMAN back up files to disk or tape.

4. Control File Autobackup
- You can configure RMAN to take a backup of the control file and the spfile every time
a backup runs. Also, if the database is in archive log mode, it will take a backup of the
control file any time the database file structure changes such as renaming or adding a data
file.

5. Control File Autobackup Format
- This tells RMAN the name and location you would like control file auto backups to take
on.

6. Parallelism
- On a machine with many backup devices, such as tapes or disks, as well as multiple
CPU’s, you can set this parameter to use more resources in hopes of speeding up the
backup.

7. Data file Backup Copies
- This parameter will tell RMAN how many copies to make when backing up files. The
more you have the safer you are from losing a backup file.

8. Archive Log Backup Copies
- Similar to data file backup copies, but applies to archive logs.

9. MAXSETSIZE
- This can be used when backing up to tape to make sure that the backup files don’t span
multiple tapes. This way, losing one tape won’t nullify an entire backup. Typically, this is
left to unlimited when backing up to disk.

10. Encryption for Database
- Typically, the backup files created will contain the character strings of data that reside
in your data files. A clever hacker can extract this data and perhaps make sense out of it.
By turning this parameter on, all the data in the backup file will be garbled.

11. Encryption Algorithm
- You can choose the level of encryption in Oracle. The higher the encryption level, the
longer it can take to back up the database. Choices follow:
• AES128 AES 128-bit key
• AES192 AES 192-bit key
• AES256 AES 256-bit key

12. Snapshot Control File Name
- Tell RMAN where to put the control file and what to name it when a snapshot of the
control file is taken.


How to configure RMAN with catalog:
======================================

Let us assume Prod = target database

                        Test=catalog database

Dba15 side

Step – 1

Check the database in archivelog mode or not, if not keep in archive log mode

SQL>archive log list

Step – 2

Create required directory for RMAN backup;

RMAN will put all backed up files in this directory

$mkdir rman

$pwd

/disk/oradata/prod/rman

Step – 3

Create a password file

$orapwd file=orapw$ORACLE_SID password=sys force=y

Now set remote_login_password=exclusive

Step – 4

Configure listner.ora file and start listener

dba12 side
============

Step – 5

Configure tnsnames.ora file and check pinging with tnsping

Step – 6

Create tablespace with 50m size

SQL>create tablespace rman datafile ‘/disk1/oradata/test/Rman.dbf’ size 50m;

Step – 7

Create user and assign above tablespace as default tablespace as default tablespace

SQL>create user rman identified by rman default tablespace rman;

Step – 8

Grant connect, resource, recovery_catalog_owner to rman(user)

SQL>grant connect, resource, recovery_catalog-owner to rman

Step – 9

In catalog side connect to the user “rman” by using rman utility at O/S level

$rman catalog rman/rman

rman>

Step – 10

Create catalog tables

rman>create catalog;

            recovery catalog created

Step – 11

In rman’s user schema check whether 90 catalog tables created or not

Rman>exit

$sqlplus ‘/as sysdba’

SQL>conn rman/rman

SQL>select count(*) from tab;

            90 tables selected

Step – 12

By connecting to the rman utility at O/S level as a sys of target database and register the target 
database

$rman catalog rman/rman Target sys/sys @to-prod

Rman>register database

Step – 13

Check whether database is registered or not by using rc_database table under ‘rman’ user schema

SQL>conn rman/rman

SQL>select * from rc_database;

            dbid    name

            ……    prod

Step – 14

Implement backup policy on top of target database by using rman utility

$rman catalog rman/rman target sys/sys@to-prod

rman>show all;

rman>exit;

validate the backup to make sure that the backup itself is not corrupted:

R>RESTORE DATABASE VALIDATE;

RMAN> RESTORE DATABASE PREVIEW SUMMARY;

Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
234587  B  F  A DISK        22-NOV-14       1       1       YES        WEEKLY_FULL_BKUP
234588  B  F  A DISK        22-NOV-14       1       1       YES        WEEKLY_FULL_BKUP

BACKUP VALIDATE DATABASE/RESTORE VALIDATE DATABASE:
===================================================
it is reading the files there only

How to know Number of CPUs on Oracle    
  
Login as SYSDBA                                                                                                                                                           
SQL>show parameter cpu_count 

 "#! /bin/ksh", then the contents of the file are executed as a korn shell

 V$GES_RESOURCE view to identify the master node.

 # /u1/app/../crsd>grep MASTER crsd.log | tail -1

(or)

cssd >grep -i  "master node" ocssd.log | tail -1

How do u know how much RMAN task has been completed?
By querying v$rman_status or v$session_longops

Which is one is good, differential (incremental) backup or cumulative (incremental) backup?
A differential backup, which backs up all blocks changed after the most recent incremental
 backup at level 1 or 0
A cumulative backup, which backs up all blocks changed after the most recent incremental 
backup at level 0

What is the difference between backup set and backup piece?
Backup set is logical and backup piece is physical.

Database Incarnation:
Whenever you perform incomplete recovery or perform recovery using a backup control file, 
you must reset the online redo logs when you open the database 
  The new version of the reset database is called a new incarnation 
  The reset database command directs RMAN to create a new database incarnation record in the 
  recovery catalog 
  This new incarnation record indicates the current incarnation
  
  
What is the difference between restoring and recovering?
Restoring the database involves copying backup files from the backup location to disk, 
sometimes it involves replacing damaged files etc., while recovery is the process of applying 
redo logs to the database in order to roll it forward. Database can be rolled forward to a 
specific point-in-time, or until the last transaction in the log files. 

During restoration, RMAN decides which backup sets, datafiles, and archive logs are necessary 
for the database restoration and verifies their contents. No files are actually restored during 
this process. 
Restoration of a datafile or a control file from backup involves retrieving the file onto disk 
from a backup location and making it available to the database server. While recovering a datafile
 involved takinhg a restored copy of the datafile and applying changes recorded in the redo logs.

Comments

Popular posts from this blog

Troubleshooting EBS login page issue in R12.2:

Oracle Apps EBS R12.2 Login Flow

Oracle apps dba Interview Q&A's