Rman Incremantal merge

1.1 Block change tracking:

Oracle 10g can be configured to track changed blocks for faster incremental backup with the help of block change tracking file. When tracking file is used with RMAN incremental backup database doesn’t have to read each data file to determine the changed block, instead it can directly fetch only changed block by referring to block address from the block change tracking file. The minimum size of tracking file is 10MB, but actual size will be approximately 1/30,000 the size of the data blocks to be tracked. Oracle does not enable block tracking by default; you can enable it with following command options.

To store tracking file in Oracle managed file system, set DB_ CREATE_FILE_DEST before issuing following SQL statement in SQL*Plus prompt.

SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;

You can also choose the tracking file location, using following SQL statement.

SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE ‘/u03/oradata/TEMPDB/bct.dbf’;

Oracle provides V$BLOCK_CHANGE_TRACKING view to query the information about tracking file.

Example:

SQL> col FILENAME format a50
SQL> set linesize 80
SQL> select * from V$BLOCK_CHANGE_TRACKING;

STATUS FILENAME BYTES
———- ————————————————– ——————————-
ENABLED /u03/oradata/TEMPDB/bct.dbf 11599872

If you need to relocate the tracking file, you have following two options.

Option1:
1. Shutdown the database.
2. Move tracking file to new location using operating system command.
3. Bring up the database, at mount state issue following SQL statement.

ALTER DATABASE RENAME FILE ‘/u03/oradata/TEMPDB/bct.dbf ‘ TO ‘/bct.dbf’;

Option2:

1. Disable block change tracking on your database.

ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;

2. Re-enable block tracking feature at new location.

SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE ‘/bct.dbf’ REUSE;

NOTE: In Option2 you will loose the block change tracking information stored on tracking file, any immediate RMAN incremental backup will force entire data file scan until you perform level 0 backup.

1.2 Incremental Merge backup:

Oracle 10g RMAN can incrementally update backup to full database backup. By doing this DBA’s doesn’t have to maintain incremental backup set separately for recoverability. With Incremental merge backup full database backup is regularly rolled-forward by merging latest incremental backup into full database backup, Thus it reduces recovery time.

The implementation of incremental merge is simple and straightforward; it can be better explained with RMAN command as below shown.

RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG “INCR_MERGE” DATABASE;
RECOVER COPY OF DATABASE WITH TAG “INCR_MERGE” ;

Here RMAN create Level – 1 backup with the with the tag “INCR_MERGE. If there is no image copy found on the disk with same tag name then it will actually creates image copy of datafiles.
The second command “RECOVER COPY OF DATABASE WITH TAG “INCR_MERGE;” will actually merge incremental backup to data file copies on the disk with the same tag.

Backup/recovery example:

The following examples demonstrate the use of above discussed features for faster RMAN backup and recovery. In this example we start with LEVEL 0 backup, execute DML operation to simulate block change, run incremental merge backup and perform database restore on different node.

Backup:

1. Perform level – 0 RMAN backup.

RMAN> run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 10;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘/u01 /app/oracle/RMAN/tempdb_backup/ora_df%t_s%s_s%p’;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO’/u01/app/oracle/RMAN/tempdb_backup/%F’;
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 2;
allocate channel c1 device type disk ;
allocate channel c2 device type disk ;
BACKUP INCREMENTAL LEVEL 0 DATABASE format ‘/u01/app/oracle/RMAN/tempdb_backu p/%d_%s_%T_%c_DB0’ TAG=”DB_LEV0″;
BACKUP ARCHIVELOG ALL format ‘/u01/app/oracle/RMAN/tempdb_backup/%d_%s_%T_%c_ARCH0’ tag “ARCH_LEV0”;
backup current controlfile format ‘/u01/app/oracle/RMAN/tempdb_backup/%d_%s_ %T_CONTROL’ tag “CNTRLFL” ;
backup spfile format ‘/u01/app/oracle/RMAN/tempdb_backup/%d_%s_%T_SPFILE’ ta g “SPFILE” ;
}

Total time taken to backup database of size 250MB in level-0 is 4 min.

TIPS: The RMAN configure statement “DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET” instruct the RMAN to perform binary compression, during recovery it can read the compressed backup set without uncompressing.

2. Perform DML operation.
3. Perform Incremental merge backup.

RMAN>run {
allocate channel c1 device type disk ;
allocate channel c2 device type disk ;
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG DB_LEV0 DATABASE;
RECOVER COPY OF DATABASE WITH TAG DB_LEV0;
BACKUP ARCHIVELOG ALL format ‘/u01/app/oracle/RMAN/tempdb_backup/%d_%s_%T_%c_ARCH0’ tag “ARCH_LEV1”;
backup current controlfile format ‘/u01/app/oracle/RMAN/tempdb_backup/%d_%s_%T_CONTROL’ tag “CNTRLFL” ;
backup spfile format ‘/u01/app/oracle/RMAN/tempdb_backup/%d_%s_%T_SPFILE’ tag “SPFILE” ;
}

Total time taken to perform incremental backup, level -1: is less than 30 sec,

Restore/recovery:
1. Transfer the backup set to server, where you want to perform the recovery.

2. Make manual entry to ‘/etc/oratab’ file with instance name and oracle home.
Also create password file (using orapwd utility) and init.ora file from the spfile.
Example: Orapwd password=pass file=$ORACLE_HOME/dbs/orapwTEMPDB cat TEMPDB_10_20071220_SPFILE > $ORACLE_HOME/dbs/initTEMPDB.ora
– eidit init.ora file and remove the extra character, if any.
– Use initiation parameter “*.DB_FILE_NAME_CONVERT=” if destination data file location differs from that of source.

3. Start the instance with ‘nomount’ option.

4. Invoke RMAN, set DBID,restore the most recent control file from the backup set
And mount the database.

RMAN> set DBID=3704929722
RMAN> restore controlfile from ‘/u01/app/oracle/RMAN/tempdb_backup/TEMPDB_28_20071220_CONTROL’;
RMAN> alter database mount;

5. Identify maximum available SCN for recovery from the backup set by querying the database in mount state.

SQL> select max(NEXT_CHANGE#)-1 from v$archived_log;

MAX(NEXT_CHANGE#)-1
——————-
1046754

5. Now complete the database restore and recovery.

RMAN> run{
set until scn=1046754;
restore database;
recover database;
}

6. Disable the block change tracking and open the database.

SQL> alter database disable block change tracking;
Database altered.

SQL> alter database open;
Database altered.

Conclusion: Oracle 10g RMAN feature simplifies the database backup and recovery activity with greater efficiency. If you are already using RMAN script to backup database there is very minimal change necessary to your backup scripts.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: