RMAN Fundamentals
In this section, I am going to cover the details about RMAN.
Let's go into the topic!!!
Let's go into the topic!!!
RMAN
RMAN also like a normal backup operation. However, it has own recovery catalog to track the backups taken in the database.
The database can be in two formats
1) Archivelog --> Once the redo log is full, it will write the
info into archive log file. So, we can recover
the database in any Point-In-Time
2) Nonarchivelog --> Redo log will get overwritten, recovery only
from the last backup
Types of Backup
Below are the types of RMAN backup
Whole backup --> This is full database backup
Incremental --> This is incremental database backup
--> Only changed block from the last incremental Backup
--> There are 2 types in incremental backup
--> 1. Differential Incremental Backup
--> 2. Cumulative Incremental Backup
Partial Backup --> This is the backup which we have taken only the tablespace and datafiles
Consistent --> No need of recovery and the backup taken in DB closed mode
Inconsistent --> Recovery needed. Backup taken when the DB is open
Open --> Backup taken while the database is running and
this is known as hot,warm,online backup
Closed --> Backup taken after the database is closed. This
is known as cold and offline backup
Multilevel Incremental Backups
RMAN can create multilevel incremental backups. Each incremental level is denoted by a value of 0 or 1.
A level 0 incremental backup, which is the base for subsequent incremental backups, copies all blocks containing data.
The only difference between a level 0 incremental backup and a full backup is that a full backup is never included in an incremental strategy. Which means, those are physically identical and only metadata will be different.
A level 1 incremental backup can be either of the following types:
A differential incremental backup, which backs up all blocks changed after the most recent incremental backup at level 1 or 0
For example, in a differential level 1 backup, RMAN determines which level 1 backup occurred most recently and backs up all blocks modified after that backup.
If no level 1 is available, then RMAN copies all blocks changed since the base level 0 backup.
A cumulative incremental backup, which backs up all blocks changed after the most recent incremental backup at level 0
For example, in a cumulative level 1 backup, RMAN determines which level 0 backup occurred most recently and backs up all blocks modified after that backup.
Cumulative incremental backups reduce the work needed for a restore operation by ensuring that you only need one incremental backup from any particular level.
Cumulative backups require more space and time than differential backups because they duplicate the work done by previous backups at the same level.
Incremental backups are differential by default.
Incremental backups at level 0 can be either backup sets or image copies, but incremental backups at level 1 can only be backup sets.
Incremental Backup Algorithm
The following concepts are essential for understanding the algorithm that RMAN uses to make incremental backups
Checkpoint SCN
Every data file has a data file checkpoint SCN, which you can view in V$DATAFILE.CHECKPOINT_CHANGE#. All changes with an SCN lower than this SCN are guaranteed to be in the file. When a level 0 incremental backup is restored, the restored data file contains the checkpoint SCN that it had when the level 0 was created. When a level 1 incremental backup is applied to a file, the checkpoint SCN of the file is advanced to the checkpoint SCN that the file had when the incremental level 1 backup was created.
Incremental start SCN
This SCN applies only to level 1 incremental backups. All blocks whose SCN is greater than or equal to the incremental start SCN are included in the backup. Blocks whose SCN is lower than the incremental start SCN are not included in the backup. The incremental start SCN is most often the checkpoint SCN of the parent of the level 1 backup.
Block SCN
Every data block in a data file records the SCN at which the most recent change was made to the block.
When RMAN makes a level 1 incremental backup of a file, RMAN reads the file, examines the SCN of every block, and backs up blocks whose SCN is greater than or equal to the incremental start SCN for this backup. If the backup is differential, then the incremental start SCN is the checkpoint SCN of the most recent level 1 backup. If the backup is cumulative, then the incremental start SCN is the checkpoint SCN of the most recent level 0 backup.
When block change tracking is enabled, RMAN uses bitmaps to avoid reading blocks that have not changed during the range from incremental start SCN to checkpoint SCN. RMAN still examines every block that is read and uses the SCN in the block to decide which blocks to include in the backup.
One consequence of the incremental backup algorithm is that RMAN applies all blocks containing changed data during recovery, even if the change is to an object created with the NOLOGGING option. Thus, if you restore a backup made before NOLOGGING changes were made, then incremental backups are the only way to recover these changes.
Benefits
1) RMAN will reduce the Human Error because it keeps track all the Backups
2) Simple command line interface
3) Unused block compression which will used to save space
4) Can be fully automated
5) High-speed incremental backups
6) Perform error checking
7) Can perform image copied
8) Integrated with third party backup management software
9) Integrated with OEM to schedule the job
RMAN Architecture
RMAN operates via server session connecting to target database which will first read the RMAN metadata which is called RMAN repository. The repository contains the information are
1) Datafiles Backup copies and sets
2) Archived log copies and sets
3) Tablespace and datafiles information
4) Stored scripts (This is only stored in recovery catalog)
5) RMAN configuration settings
Recovery Catalog
RMAN will use controlfile to store the repository information, optionally, we can store the repository information in any other target database for RMAN which is called as recovery catalog. So, the information will get stored in the database (Recovery Catalog) and controlfile as well.
Information stored in control files will be stored in a circular and non-circular reuse records. Non-critical records will be stored in circular reuse and critical records will be stored in non-circular reuse. Non-Critical records like datafiles, redo log information.
Temp tablespace, parameter file (init.ora) and password files cant be backed up.
Based on the parameter (CONTROL_FILE_RECORD_KEEP_TIME), Oracle will maintain the records in the control file.
V$CONTROLFILE_RECORD_SECTION --> This shows the controlfile records
Media Management Layer
If we want to take backup to tape, it is required to have Media Management Layer (MML) or Media Manager. Media Manager is a API which will be the interface with the different vendors tape libraries.
RMAN Terminology
Backup Piece --> This is like operating system files containing
backup of controlfile, datafiles, etc.
Backup Set --> The logical structure which contains more backup pieces
Image Copy --> Operating system file which created by RMAN and it
is like the file which created using cp or dd
command (OS Command)
Proxy Copy --> Media Manager is able to backup the process
Channel --> Channel allocation is a method of connecting RMAN
and target database while also specifying the type
of backup whether disk or tape
Configuring RMAN persistent settings
Format Options
%F --> Combination of Database Identifier (DBID), day, month, year and sequence number
%U --> Specifies system generated unique file name (Default)
%u --> Specifies an 8 character name
%d --> database name
%s --> Backupset number
%t --> backup set timestamp
%p --> piece number within the backup set
show all --> It will display all the existing configurations
Commands:-
configure default device type to disk;
--> Disk backup
configure default device type to sbt;
--> Tape backup
configure device type disk backup type to copy
--> This is image copy backup which is in DISK
configure device type disk backup type to compressed backupset;
--> This is compressed backupset which is in disk
configure device type sbt backup type to compressed backupset;
--> This is compressed backupset which is in tape
configure device type disk parallelism 4
--> 4 channels will be created to run in parallel which is in disk
configure device type sbt parallelism 4
--> 4 channels will be created to run in parallel which is in sbt
configure backup optimization on
--> This will ensure that RMAN wont perform backup if it has already backedup identical versions
configure retention policy to recovery window of 30 days
--> rentention policy is 30 days for the backup
configure controlfile autobackup format for device type disk to 'controlfile_%F';
configure channel device type disk format 'backup_%d_%t_%s_D_%d';
configure archivelog deletion policy to backed up 1 times to device type disk;
--> This ensures all archive log must be backed up before deleting through RMAN
configure archivelog deletion policy to applied on all standby;
--> This ensures all archive log has to be applied in
standby before deleting them through RMAN
Channel Parameters/Options
These parameters are used to control the resources by RMAN.
Channel device type --> This is where to save the backup whether disk or sbt
Channel rate --> Limits I/O bandwith KB, MB or GB
Channel maxpiecesize --> limits the size of the backup piece
Channel maxsetsize --> limits the size of the backup set
Channel Connect --> Instruct to connect to other instance
duration --> Controls the time for backup jobs
params --> send specific instruction to tape library
Examples:-
configure channel device type disk rate = 5m;
configure channel device type disk maxpiecesize = 2g;
configure channel device type disk maxsetsize = 10g;
Backup Retention
Default is redundancy 1 which means always keep only one image or backup set of every datafile, controlfile and archived log file
Examples:-
configure retention policy to recovery window of 30 days
--> Keep backup for 30 days
configure retention policy to redundancy 2;
--> Keep at least 2 copies
configure retention policy clear;
--> Clear the retention configuration settings
change backupset tag full_bkp keep until time '01Jun2017' logs
--> Extend the retention period
Validating and Cross checking backup
Validate backup will check the files are there in the backup location (Proper Location) and they are readable and free from any logical/physical corruptions.
Crosscheck backup will check the backup files gets deleted from the location or not (Backup sets can be deleted through OS).
Catalog Commands
This is help to identify and catalog any files which are not recorded in the RMAN repository and thus are known to RMAN
Commands:-
catalog all data files copies
--> catalog datafilecopy 'c:\oracle\backup\users01.dbf';
catalog all backup pieces copies
--> catalog backuppiece ':c\oracle\backup\backup_20.bkp';
Search for uncatalogued files in a directory
--> catalog start with ':c\oracle\backup';
Delete discrepancy in catalog
--> delete force noprompt archivelog sequence 40;
Block Change tracking
This is used to backup very large databases. When we enable a change block tracking, a new process CTWR is then started
Enabling
--> alter database enable block change tracking using file
'/u01/app/oracle/tracking/blocktrack.log'
Viewing
--> select filename, status, bytes from v$block_change_tracking;
Disabling
--> alter database disable block change tracking;
Merged Incremental Backup Copy
Oracle 10g introduced, new feature which will merge the incremental backup copy using only one command. Whenever, we took the backup, the command will refresh the whole backup and merged all as one.
Examples:-
Backup incremental level 1 for recover of copy with tag 'Merged_Backup' database;
Recover Copy of database with TAG 'Merged_Backup';
Snapshot Controlfile
When RMAN needs a read consistent control file, it will take a snapshot of the control file which will be used to re-synchronize with recovery catalog or when we backup a current control file.
SHOW SNAHPSHOT CONTROLFILE NAME; --> Show the snapshot control file location
Useful Commands
list all image copies
--> list copy;
list all backups
--> list backup;
--> list backupset by backup [summary|verbose];
list backed up files
--> list backupset by file;
list backed up databases;
--> list backup of database;
list all datafile number 1 backups
--> list backup of datafile 1;
list backed up controlfiles
--> list backup of controlfile;
list backup scripts
--> list script names;
--> list global script names;
list all backups no longer required according to retention policy
--> report obsolete;
list all the physical datafiles
--> report schema;
list files that require backing up
--> report need backup
We can use CHANGE command to uncatalog the files which are already known to RMAN
SET UNTIL time is used to recover/backup command runs until that time. After specify UNTIL TIME, we can run any commands.
RMAN Dictionary Views
Below are the dictionary views which is used to get the details regarding RMAN jobs
v$controlfile_record_Section
--> displays information about the control file record sections
v$backup_files
--> list each file backed up, also has compressed option
v$backup_set
--> list backup sets
v$backup_piece
--> list backup pieces
v$backup_redolog
--> list archived backup logs
v$backup_spfile
--> list spfiles
v$backup_device
--> names of SBT devices that have been linked to rman
v$rman_configuration
--> lists all changed configurations settings (good point to check config)
v$rman_status
--> Status of all completed rman jobs
v$backup_corruption
--> provides important corruption information
v$copy_corruption
--> provides important corruption information
The database can be in two formats
1) Archivelog --> Once the redo log is full, it will write the
info into archive log file. So, we can recover
the database in any Point-In-Time
2) Nonarchivelog --> Redo log will get overwritten, recovery only
from the last backup
Types of Backup
Below are the types of RMAN backup
Whole backup --> This is full database backup
Incremental --> This is incremental database backup
--> Only changed block from the last incremental Backup
--> There are 2 types in incremental backup
--> 1. Differential Incremental Backup
--> 2. Cumulative Incremental Backup
Partial Backup --> This is the backup which we have taken only the tablespace and datafiles
Consistent --> No need of recovery and the backup taken in DB closed mode
Inconsistent --> Recovery needed. Backup taken when the DB is open
Open --> Backup taken while the database is running and
this is known as hot,warm,online backup
Closed --> Backup taken after the database is closed. This
is known as cold and offline backup
Multilevel Incremental Backups
RMAN can create multilevel incremental backups. Each incremental level is denoted by a value of 0 or 1.
A level 0 incremental backup, which is the base for subsequent incremental backups, copies all blocks containing data.
The only difference between a level 0 incremental backup and a full backup is that a full backup is never included in an incremental strategy. Which means, those are physically identical and only metadata will be different.
A level 1 incremental backup can be either of the following types:
A differential incremental backup, which backs up all blocks changed after the most recent incremental backup at level 1 or 0
For example, in a differential level 1 backup, RMAN determines which level 1 backup occurred most recently and backs up all blocks modified after that backup.
If no level 1 is available, then RMAN copies all blocks changed since the base level 0 backup.
A cumulative incremental backup, which backs up all blocks changed after the most recent incremental backup at level 0
For example, in a cumulative level 1 backup, RMAN determines which level 0 backup occurred most recently and backs up all blocks modified after that backup.
Cumulative incremental backups reduce the work needed for a restore operation by ensuring that you only need one incremental backup from any particular level.
Cumulative backups require more space and time than differential backups because they duplicate the work done by previous backups at the same level.
Incremental backups are differential by default.
Incremental backups at level 0 can be either backup sets or image copies, but incremental backups at level 1 can only be backup sets.
Incremental Backup Algorithm
The following concepts are essential for understanding the algorithm that RMAN uses to make incremental backups
Checkpoint SCN
Every data file has a data file checkpoint SCN, which you can view in V$DATAFILE.CHECKPOINT_CHANGE#. All changes with an SCN lower than this SCN are guaranteed to be in the file. When a level 0 incremental backup is restored, the restored data file contains the checkpoint SCN that it had when the level 0 was created. When a level 1 incremental backup is applied to a file, the checkpoint SCN of the file is advanced to the checkpoint SCN that the file had when the incremental level 1 backup was created.
Incremental start SCN
This SCN applies only to level 1 incremental backups. All blocks whose SCN is greater than or equal to the incremental start SCN are included in the backup. Blocks whose SCN is lower than the incremental start SCN are not included in the backup. The incremental start SCN is most often the checkpoint SCN of the parent of the level 1 backup.
Block SCN
Every data block in a data file records the SCN at which the most recent change was made to the block.
When RMAN makes a level 1 incremental backup of a file, RMAN reads the file, examines the SCN of every block, and backs up blocks whose SCN is greater than or equal to the incremental start SCN for this backup. If the backup is differential, then the incremental start SCN is the checkpoint SCN of the most recent level 1 backup. If the backup is cumulative, then the incremental start SCN is the checkpoint SCN of the most recent level 0 backup.
When block change tracking is enabled, RMAN uses bitmaps to avoid reading blocks that have not changed during the range from incremental start SCN to checkpoint SCN. RMAN still examines every block that is read and uses the SCN in the block to decide which blocks to include in the backup.
One consequence of the incremental backup algorithm is that RMAN applies all blocks containing changed data during recovery, even if the change is to an object created with the NOLOGGING option. Thus, if you restore a backup made before NOLOGGING changes were made, then incremental backups are the only way to recover these changes.
Benefits
1) RMAN will reduce the Human Error because it keeps track all the Backups
2) Simple command line interface
3) Unused block compression which will used to save space
4) Can be fully automated
5) High-speed incremental backups
6) Perform error checking
7) Can perform image copied
8) Integrated with third party backup management software
9) Integrated with OEM to schedule the job
RMAN Architecture
RMAN operates via server session connecting to target database which will first read the RMAN metadata which is called RMAN repository. The repository contains the information are
1) Datafiles Backup copies and sets
2) Archived log copies and sets
3) Tablespace and datafiles information
4) Stored scripts (This is only stored in recovery catalog)
5) RMAN configuration settings
Recovery Catalog
RMAN will use controlfile to store the repository information, optionally, we can store the repository information in any other target database for RMAN which is called as recovery catalog. So, the information will get stored in the database (Recovery Catalog) and controlfile as well.
Information stored in control files will be stored in a circular and non-circular reuse records. Non-critical records will be stored in circular reuse and critical records will be stored in non-circular reuse. Non-Critical records like datafiles, redo log information.
Temp tablespace, parameter file (init.ora) and password files cant be backed up.
Based on the parameter (CONTROL_FILE_RECORD_KEEP_TIME), Oracle will maintain the records in the control file.
V$CONTROLFILE_RECORD_SECTION --> This shows the controlfile records
Media Management Layer
If we want to take backup to tape, it is required to have Media Management Layer (MML) or Media Manager. Media Manager is a API which will be the interface with the different vendors tape libraries.
RMAN Terminology
Backup Piece --> This is like operating system files containing
backup of controlfile, datafiles, etc.
Backup Set --> The logical structure which contains more backup pieces
Image Copy --> Operating system file which created by RMAN and it
is like the file which created using cp or dd
command (OS Command)
Proxy Copy --> Media Manager is able to backup the process
Channel --> Channel allocation is a method of connecting RMAN
and target database while also specifying the type
of backup whether disk or tape
Configuring RMAN persistent settings
Format Options
%F --> Combination of Database Identifier (DBID), day, month, year and sequence number
%U --> Specifies system generated unique file name (Default)
%u --> Specifies an 8 character name
%d --> database name
%s --> Backupset number
%t --> backup set timestamp
%p --> piece number within the backup set
show all --> It will display all the existing configurations
Commands:-
configure default device type to disk;
--> Disk backup
configure default device type to sbt;
--> Tape backup
configure device type disk backup type to copy
--> This is image copy backup which is in DISK
configure device type disk backup type to compressed backupset;
--> This is compressed backupset which is in disk
configure device type sbt backup type to compressed backupset;
--> This is compressed backupset which is in tape
configure device type disk parallelism 4
--> 4 channels will be created to run in parallel which is in disk
configure device type sbt parallelism 4
--> 4 channels will be created to run in parallel which is in sbt
configure backup optimization on
--> This will ensure that RMAN wont perform backup if it has already backedup identical versions
configure retention policy to recovery window of 30 days
--> rentention policy is 30 days for the backup
configure controlfile autobackup format for device type disk to 'controlfile_%F';
configure channel device type disk format 'backup_%d_%t_%s_D_%d';
configure archivelog deletion policy to backed up 1 times to device type disk;
--> This ensures all archive log must be backed up before deleting through RMAN
configure archivelog deletion policy to applied on all standby;
--> This ensures all archive log has to be applied in
standby before deleting them through RMAN
Channel Parameters/Options
These parameters are used to control the resources by RMAN.
Channel device type --> This is where to save the backup whether disk or sbt
Channel rate --> Limits I/O bandwith KB, MB or GB
Channel maxpiecesize --> limits the size of the backup piece
Channel maxsetsize --> limits the size of the backup set
Channel Connect --> Instruct to connect to other instance
duration --> Controls the time for backup jobs
params --> send specific instruction to tape library
Examples:-
configure channel device type disk rate = 5m;
configure channel device type disk maxpiecesize = 2g;
configure channel device type disk maxsetsize = 10g;
Backup Retention
Default is redundancy 1 which means always keep only one image or backup set of every datafile, controlfile and archived log file
Examples:-
configure retention policy to recovery window of 30 days
--> Keep backup for 30 days
configure retention policy to redundancy 2;
--> Keep at least 2 copies
configure retention policy clear;
--> Clear the retention configuration settings
change backupset tag full_bkp keep until time '01Jun2017' logs
--> Extend the retention period
Validating and Cross checking backup
Validate backup will check the files are there in the backup location (Proper Location) and they are readable and free from any logical/physical corruptions.
Crosscheck backup will check the backup files gets deleted from the location or not (Backup sets can be deleted through OS).
Catalog Commands
This is help to identify and catalog any files which are not recorded in the RMAN repository and thus are known to RMAN
Commands:-
catalog all data files copies
--> catalog datafilecopy 'c:\oracle\backup\users01.dbf';
catalog all backup pieces copies
--> catalog backuppiece ':c\oracle\backup\backup_20.bkp';
Search for uncatalogued files in a directory
--> catalog start with ':c\oracle\backup';
Delete discrepancy in catalog
--> delete force noprompt archivelog sequence 40;
Block Change tracking
This is used to backup very large databases. When we enable a change block tracking, a new process CTWR is then started
Enabling
--> alter database enable block change tracking using file
'/u01/app/oracle/tracking/blocktrack.log'
Viewing
--> select filename, status, bytes from v$block_change_tracking;
Disabling
--> alter database disable block change tracking;
Merged Incremental Backup Copy
Oracle 10g introduced, new feature which will merge the incremental backup copy using only one command. Whenever, we took the backup, the command will refresh the whole backup and merged all as one.
Examples:-
Backup incremental level 1 for recover of copy with tag 'Merged_Backup' database;
Recover Copy of database with TAG 'Merged_Backup';
Snapshot Controlfile
When RMAN needs a read consistent control file, it will take a snapshot of the control file which will be used to re-synchronize with recovery catalog or when we backup a current control file.
SHOW SNAHPSHOT CONTROLFILE NAME; --> Show the snapshot control file location
Useful Commands
list all image copies
--> list copy;
list all backups
--> list backup;
--> list backupset by backup [summary|verbose];
list backed up files
--> list backupset by file;
list backed up databases;
--> list backup of database;
list all datafile number 1 backups
--> list backup of datafile 1;
list backed up controlfiles
--> list backup of controlfile;
list backup scripts
--> list script names;
--> list global script names;
list all backups no longer required according to retention policy
--> report obsolete;
list all the physical datafiles
--> report schema;
list files that require backing up
--> report need backup
We can use CHANGE command to uncatalog the files which are already known to RMAN
SET UNTIL time is used to recover/backup command runs until that time. After specify UNTIL TIME, we can run any commands.
RMAN Dictionary Views
Below are the dictionary views which is used to get the details regarding RMAN jobs
v$controlfile_record_Section
--> displays information about the control file record sections
v$backup_files
--> list each file backed up, also has compressed option
v$backup_set
--> list backup sets
v$backup_piece
--> list backup pieces
v$backup_redolog
--> list archived backup logs
v$backup_spfile
--> list spfiles
v$backup_device
--> names of SBT devices that have been linked to rman
v$rman_configuration
--> lists all changed configurations settings (good point to check config)
v$rman_status
--> Status of all completed rman jobs
v$backup_corruption
--> provides important corruption information
v$copy_corruption
--> provides important corruption information
Comments
Post a Comment