Thursday, August 19, 2021

RMAN Block Change Tracking Overview

     RMAN Block Change Tracking Overview During incremental backup, RMAN checks every data block in all datafiles of the database and compares its scn number with the SCN value that is at the incremental 0 backup.  If the first value is greater than the second, it means that the data block has been changed after the last backup and needs to be backed up, so RMAN writes it to the backup file.  This procedure is done for every data block in the database.  Prior to 10gR2, RMAN was backing up the data block in case it was written once by any Oracle process even though it was empty.  But in 10gR2, RMAN backs up only used extents. 


       So as RMAN checks all data blocks and writes down only changed ones during incremental backup, it takes more time for the checking procedure. 

Starting from Oracle 10gR1, the new feature called Block Change Tracking was presented, which uses a new process called Change Tracking Writer (CTWR). 
This tracks the changes made to the data blocks as redo is generated and stores their addresses to the special tracking file.  When incremental backups are done, RMAN uses the tracking file and backs up only those data blocks that are written in this file, thus making incremental backups much faster, and it does not scan the unchanged data blocks.  This feature is disabled by default.  Only one tracking file is used for one database.

To determine if block change tracking is enabled, check the STATUS and FILENAME columns in the V$BLOCK_CHANGE_TRACKING view, using the following statement from the SQL or RMAN prompt:

SQL>  SELECT status, filename FROM V$BLOCK_CHANGE_TRACKING;

STATUS     FILENAME
---------- ------------------------------
DISABLED

SQL>

To enable block change tracking:

1. Determine the current location of the database data files by submitting the following query:

SQL> SELECT NAME FROM V$DATAFILE;

NAME
--------------------------------------------------------------------------------
/ua1001/DEV/app/oradev/oradata/DEV/DEV/system01.dbf
/ua1001/DEV/app/oradev/oradata/DEV/DEV/sysaux01.dbf
/ua1001/DEV/app/oradev/oradata/DEV/DEV/undotbs01.dbf
/ua1001/DEV/app/oradev/oradata/DEV/DEV/users01.dbf

SQL>

2.In this example, the query results show that data files are stored in the file system in the  directory /ua1001/DEV/app/oradev/oradata/.

Data files might also be stored in an Oracle Automatic Storage Management disk group.

3.Set the DB_CREATE_FILE_DEST initialization parameter to specify the location where new  database files, including the block change tracking file, must be stored.

You can specify the same directory shown in query results from the previous step, with the final portion of the path the database SID—stripped, as shown in the following example, or designate a new directory. Any directory that you specify must have the write permission for the Oracle software owner.

The following command specifies that new database files must be stored in the directory /ua1001/DEV/app/oradev/oradata/.

SQL> ALTER SYSTEM SET DB_CREATE_FILE_DEST='/ua1001/DEV/app/oradev/oradata/';

System altered.


Enable block change tracking for the database using the following command:

SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;

Database altered.

We can also specify file name using below command .

SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE
'/ua1001/DEV/app/oradev/oradata/DEV/changetracking/block_change_TESTDB.log';


If there is already a file named block_change_TESTDB.log and it needs to be overwritten, add a REUSE clause as follows:

SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE
'/ua1001/DEV/app/oradev/oradata/DEV/changetracking/block_change_TESTDB.log'
REUSE;


And the new CTWR process will be created to track the changes:

[DEV|oradev@nadhans DEV]$ ps -ef | grep ctwr
oradev    15306      1  0 16:32 ?        00:00:00 ora_ctwr_DEV
oradev    15885   3798  0 16:41 pts/1    00:00:00 grep --color=auto ctwr

And you can see Physical file here .

[DEV|oradev@nadhans changetracking]$ ls -ltr
total 11348
-rw-r----- 1 oradev dba 11600384 Aug 19 16:49 o1_mf_jkwgl317_.chg
[DEV|oradev@nadhans changetracking]$ pwd
/ua1001/DEV/app/oradev/oradata/DEV/changetracking
[DEV|oradev@nadhans changetracking]$

 

 

No comments:

Post a Comment

ORACLE DATABASE CONTENT

ORACLE DATABASE 11gR2 & 12C  CONTENT Pre-Requisite: UNIX, SQL Basics Introduction to Oracle Database §   Introduction of Database ...