`

Oracle 块修改跟踪 (Block Change Tracking) 说明

 
阅读更多

Block ChangeTracking 是Oracle 10g里推出的特性。官网对Block change tracking 的定义如下:

       Adatabase option that causes Oracle to track data file blocks affected by eachdatabase update. The tracking information is stored in a block change trackingfile. When block change tracking is enabled, RMAN uses the record of changedblocks from the change tracking file to improve incremental backup performanceby only reading those blocks known to have changed, instead of reading datafiles in their entirety.

       --Block change tracking 会记录data file里每个block的update 信息,这些tracking信息保存在tracking 文件里。 当启动block change tracking 后,RMAN 使用trackingfile里的信息,只读取改变的block信息,而不用在对整个data file进行扫描,从而提高了RMAN 备份的性能。

      

11gR2 文档里的说明。

http://download.oracle.com/docs/cd/E11882_01/backup.112/e10642/rcmbckba.htm#BRADV8125

 

一.About Block Change Tracking

If block changetracking is enabled on a primary or standby database, then RMAN uses a blockchange tracking file to identify changed blocks for incrementalbackups. By reading this small bitmap file to determine which blocks changed,RMAN avoids having to scan every block in the data file that it is backing up.

--block change tracking file 是bitmap file。

 

Block changetracking is disabled by default. Nevertheless, the benefits of avoiding fulldata file scans during backup are considerable, especially if only a smallpercentage of data blocks are changed between backups. If your backup strategyinvolves incremental backups, then block change tracking is recommended. Blockchange tracking does not change the commands used to perform incrementalbackups. The change tracking file requires no maintenance after initialconfiguration.

--Block change tracking 默认是禁用的,如果启用了incrementalbackup,那么建议开启block change tracking。 启用BCT后,不需要其他的维护操作。

 

You can only enable block change tracking at a physical standby database if a license forthe Oracle Active Data Guard option is enabled.

 

1.1 SpaceManagement in the Block Change Tracking File

The change tracking file maintains bitmaps that mark changes in the datafiles betweenbackups. The database performs a bitmap switch before each backup. OracleDatabase automatically manages space in the change tracking file to retainblock change data that covers the eight most recent backups. After the maximumof eight bitmaps is reached, the oldest bitmap is overwritten by the bitmapthat tracks the current changes.

--在备份期间,change tracking会维护已经标记为change 的block 的bitmap 信息。Oracle 会自动管理change tracking file的大小,只保留最近最近8次blockchange 的信息。 超过8次, 那么最前面的block bitmap 信息会被current change 覆盖。

 

The first level0 incremental backup scans the entire data file. Subsequent incremental backupsuse the block change tracking file to scan only the blocks that have beenmarked as changed since the last backup. An incremental backup can be optimizedonly when it is based on a parent backup that was made after the start of theoldest bitmap in the block change tracking file.

--第一个0级的增量备份扫描整个datafile。 随后的增量备份使用block changetracking file的信息,只扫描自上次备份以来被标记为change 的block。

 

Consider theeight-bitmap limit when developing your incremental backup strategy. Forexample, if you make a level 0 database backup followed by seven differentialincremental backups, then the block change tracking file now includes eightbitmaps. If you then make a cumulative level 1 incremental backup, then RMANcannot optimize the backup, because the bitmap corresponding to the parentlevel 0 backup is overwritten with the bitmap that tracks the current changes.

--要考虑change tracking file 的8次限制与备份策略的关系。 如果我们在0级备份之后又进行了7次不同的增量备份,那么这时block change tracking 就包含了8个bitmaps信息。 如果我们在进行1级的增量备份,那么此时的增量就不是最优的, 还会扫描整个data file。 因为我们之前0级的bitmap信息被我们当前的bitmap 信息覆盖掉了,这样就没有了参考的依据。

 所以RMAN的备份策略要考虑到这个8次bitmap 的影响。

 

1.2 Location of the Block Change Tracking File

One block changetracking file is created for the whole database. By default, the changetracking file is created as an Oraclemanaged file in the destination specified by theDB_CREATE_FILE_DEST initializationparameter. You can also place the change tracking file in any location that youchoose, by specifying its name when enabling block change tracking. Oraclerecommends against using a raw device (that is, a disk without a file system)as a change tracking file.

       --block change tracking 文件是针对整个数据库,默认情况下,changetracking file 会作为Oracle managed file,在DB_CREATE_FILE_DEST指定的目录下创建。 可以放到放到其他的目录。 Oracle  不建议使用rawdevice 来存放change tracking file.

 

Note:

In an Oracle RACenvironment, the change tracking file must be located on shared storageaccessible from all nodes in the cluster.

       --如果是RAC 环境,change tracking file 必须放在共享设备上。

 

RMAN does notsupport backup and recovery of the change tracking file. The database resetsthe change tracking file when it determines that the change tracking file isinvalid. If you restore and recover the whole database or a subset, then thedatabase resets the block change tracking file and starts tracking changesagain. After you make a level 0 incremental backup, the next incremental backupcan use change tracking data.

--RMAN 不支持对change tracking file 的备份与恢复。当数据检测到change tracking file 无效时,就会reset changetracking file。 如果我们还原了数据库,那么数据库也会reset block change tracking,并从新进行tracking。

 

1.3 Size of the Block Change Tracking File

The size of the block change tracking file is proportional to thesize of the database and the number of enabled threads of redo. The size of theblock change tracking file can increase and decrease as the database changes.The size is not related to the frequency of updates to the database.

--block change tracking file的大小和数据库的大小及 enabledthreads of redo 的数量有关系,tracking file 的大小会根据数据库大小的变化和变化。 和更新频率没有关系。

 

Typically, thespace required for block change tracking for a single instance is approximately1/30,000 the size of the data blocks to be tracked. For an Oracle RACenvironment, it is 1/30,000 of the size of the database, times the number ofenabled threads.

--典型的,单实例下大约DB的1/30000的block 会把track。 如果是RAC 环境,在乘以threads。

 

The followingfactors that may cause the file to be larger than this estimate suggests:

--一下因素会导致file 超过估计值:

(1)To avoid theoverhead of allocating space as your database grows, the block change trackingfile size starts at 10 megabytes. New space is allocated in 10 MB increments.Thus, for any database up to approximately 300 gigabytes, the file size is nosmaller than 10 MB, for up to approximately 600 gigabytes the file size is nosmaller than 20 megabytes, and so on.

--为了避免tracking file 占用太多的空间, 初始值是10M,然后每次增加10M,如果数据库接近300G,那么trackingfile 不能小于10M,如果接近600G,不能小于20M。

 

(2)For each datafile, a minimum of 320 kilobytes of space is allocated in the block changetracking file, regardless of the size of the data file. Thus, if you have alarge number of relatively small data files, the change tracking file is largerthan for databases with a smaller number of larger data files containing thesame data.

       --每个datafile,在tracking file里最少需要分配320k的空间,所以如果有大量的小data file, change tracking file 也会相对较大。

 

 

二.Enablingand Disabling Block Change Tracking

You can enable block change tracking whenthe database is either open or mounted. This section assumes that you intend tocreate the block change tracking file as an Oracle Managed File in the databasearea, which is where the database maintains active database files such asdata files, control files, and online redo log files. See "Overviewof the Fast Recovery Area" to learn about the database area and fastrecovery area.

--数据库在open 或者 mounted 状态都可以启用blockchange tracking.

 

2.1 To enable block change tracking:

(1)Start SQL*Plus and connect to atarget database with administrator privileges.

(2) Ensure thatthe DB_CREATE_FILE_DEST initialization parameter is set.

 

SQL> showparameter db_create_file_dest

NAME                                 TYPE        VALUE

----------------------------------------------- ------------------------------

db_create_file_dest                  string

 

If the parameteris not set, and if the database is open, then you can set the parameter withthe following form of the ALTERSYSTEM statement:

--如果该参数没有设置,并且数据库是open 状态,可可以修改该参数:

 

SQL> alter system setdb_create_file_dest = '/u01/bct/' scope=both sid='*';

System altered.

 

SQL> show parameter db_create_file_dest

NAME                                 TYPE        VALUE

----------------------------------------------- ------------------------------

db_create_file_dest                  string      /u01/bct/

SQL>

 

(3) Enable block change tracking.

Execute the following ALTER DATABASE statement:

SQL> alter database enable block changetracking;

Database altered.

 

You can alsocreate the change tracking file in a location that you choose yourself by usingthe following form of SQL statement:

--也可以在创建时指定其他目录:

SQL>alter database enable block change tracking using file '/mydir/rman_change_track.f' reuse;

The REUSE optiontells Oracle Database to overwrite any existing block change tracking file withthe specified name.

 

2.2 DisablingBlock Change Tracking

This section assumes that the block changetracking feature is currently enabled. When you disable block change tracking,the database removes the block change tracking file from the operating system.

 

To disable block changetracking:

(1)Start SQL*Plus and connect to atarget database with administrator privileges.

(2)Ensure that the target database ismounted or open.

(3)Disable block change tracking.

Execute thefollowing ALTER DATABASE statement:

SQL>alter database disable block change tracking;

 

2.3 Checking Whether Change Tracking is Enabled

You can query the V$BLOCK_CHANGE_TRACKING viewto determine whether change tracking is enabled, and if it is, the file name ofthe block change tracking file.

--可以使用v$block_change_tracking 视图查看tracking 启动情况。

 

To determine whetherchange tracking is enabled:

Enter the following query in SQL*Plus(sample output included):

 

SQL> col status   format a8

SQL> col filename format a60

SQL> select status, filename fromv$block_change_tracking;

STATUS  FILENAME

--------------------------------------------------------------------

ENABLED /u01/bct/XEZF/changetracking/o1_mf_7dnc623t_.chg

 

 

2.4 Changingthe Location of the Block Change Tracking File

To move the change tracking file, use the ALTERDATABASE RENAME FILE statement. The database must be mounted. Thestatement updates the control file to refer to the new location and preservesthe contents of the change tracking file. If you cannot shut down the database,then you can disable and enable block change tracking. In this case, you losethe contents of the existing block change tracking file.

--可以使用alter database rename 语句来修改changetracking file 文件的位置,该命令会更新控制文件里的信息,命令必须在mount 下执行,会如果DB 不能shutdown,那么可以先disable,然后指定新的位置在启动,但是这样会丢失以前在tracking file里的数据。

 

To change the location of the change tracking file:

 (1)Start SQL*Plus and connect to atarget database.

(2)If necessary, determine the currentname of the change tracking file:

SQL> select filename from v$block_change_tracking;

(3)If possible, shut down thedatabase. For example:

SQL> shutdown immediate

 

If you shut downthe database, then skip to the next step. If you choose not to shut down thedatabase, then execute the following SQL statements and skip all remainingsteps:

SQL> alter database disable block changetracking;

SQL> alter database enable block changetracking using file 'new_location';

 

In this case youlose the contents of the block change tracking file. Until the next time youcomplete a level 0 incremental backup, RMAN must scan the entire file.

 

(4)Using host operating systemcommands, move the change tracking file to its new location.

       --在OS 级别移动tracking file到新的目录。

(5)Mount the database and move thechange tracking file to a location that has more space. For example:

SQL>alter database rename file

  '/disk1/bct/RDBMS/changetracking/o1_mf_2f71np5j_.chg' to

  '/disk2/bct/RDBMS/changetracking/o1_mf_2f71np5j_.chg';

 

This statement changes the location of the change tracking file while preserving its contents.

 

(6)Open the database:

SQL> alter database open;

 

 

小结:

       在使用RMAN 增量备份的情况下,启动block change tracking,在做增量备份时会缩短RMAN 备份的时间, 因为不用扫描整个data file。 但是block tracking 也会带来其他的一些开销。 所以要根据实际情况决定是否启用block change tracking。

分享到:
评论

相关推荐

    block change tracking和rman通常增量备份方式的比较

    Block Change Tracking是Oracle 10g引入的一项新技术,其主要作用在于记录数据文件中发生更改的数据块的信息。通过这种方式,可以在进行增量备份时仅备份那些已更改的数据块,从而提高备份效率。 - **工作原理**: ...

    oracle OCP笔记

    2. **解决方案**:通常情况下,Block Change Tracking文件的大小应该足够大,以便能够记录长时间内的块更改信息。然而,如果文件过大,可能会占用过多的空间。Oracle建议的默认大小通常是100MB,但具体的大小取决于...

    如何使用改变跟踪技术加速Oracle递增备份

    改变跟踪技术(Block Change Tracking,BCT)是 Oracle 10g 及以后版本引入的一项重要优化,它通过在单独的跟踪文件中记录数据块的更改来提升递增备份的性能。这个跟踪文件由后台进程实时维护,记录所有已修改的数据...

    oracle 增量恢复详细记录

    - **系统更改编号 (SCN):** 每个数据块都包含一个SCN,用来记录该数据块的最后修改时间点。这是增量备份判断数据块是否需要备份的关键依据。 - **检查点 SCN (Checkpoint SCN):** 这是上一次备份时的数据块SCN值。...

    用改变跟踪技术加速Oracle递增备份

    ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '<pathname>'; ``` 这里的`<pathname>`是改变跟踪文件在操作系统的实际存储位置。如果启用了Oracle的自动管理文件(Automatic Managed Storage),则可以...

    Oracle OCP认证(1Z0-053)模拟题库

    Block Change Tracking是一种优化恢复过程的技术,它通过记录块更改的时间戳来减少恢复过程中读取的数据量。题目中提及,如果尝试使用`ALTER DATABASE ENABLE BLOCK CHANGE TRACKING`命令启用此功能但收到错误消息,...

    Oracle11g面向DBA的新功能学习指南less10_RMAN.pdf

    1. 物理备用数据库的增量备份:现在可以在物理备用数据库上启用块更改跟踪,通过ALTER DATABASE ENABLE/DISABLE BLOCK CHANGE TRACKING SQL语句实现。这允许RMAN在备用数据库上跟踪更改的块,从而加速增量备份过程,...

    OCP易错题本.docx

    - 使用`ALTER DATABASE ENABLE BLOCK CHANGE TRACKING`命令启用块更改跟踪后,该功能将在下次增量备份时开始使用,而不是立即生效。因此: A. **块更改跟踪数据将只从下一个增量0备份使用** - 这是正确的。 C. **...

    Oracle_11g_面向DBA的新功能学习指南 less10

    - **实现方式**:使用 `ALTER DATABASE ENABLE/DISABLE BLOCK CHANGE TRACKING` SQL 语句在物理备用数据库上启用块更改跟踪功能。 - **优点**:相比早期版本,这种方法可以显著提高增量备份的速度。 #### 改进的块...

    ORACLE 数据库备份技术

    3. Block Change Tracking:块变化跟踪文件用于增量备份,记录自上次备份后发生变化的数据块。 五、Oracle恢复机制 1. Point-in-Time Recovery (PITR):允许恢复到任意时间点,利用归档日志和控制文件实现。 2. ...

    Oracle 11g rac管理最佳实战手册

    在性能优化方面,本书将深入探讨RAC的负载均衡机制(如Global Cache服务和Block Change Tracking),并讲解如何利用Automatic Workload Repository (AWR) 和SQL Tuning Advisor进行性能监控和调优。此外,还会讨论...

    OCP认证 Oracle-1Z0-053 英文试题

    Block Change Tracking(块变更跟踪) #### 知识点概述: - **块变更跟踪**是一种优化备份过程的功能,通过记录哪些块自上次备份以来发生了变化,从而提高增量备份的效率。 - 启用块变更跟踪时,会创建一个跟踪...

    oracle实时在线备份工具-rman

    - 启用更改跟踪:执行`SQL> alter database enable block change tracking;`。 ##### 4. 配置备份选项 为了进一步增强数据的安全性,我们可以配置RMAN自动对控制文件和服务参数文件进行备份。这些备份将存储在快速...

    oracle的rman数据库备份方案.doc

    此外,通过使用RMAN的块改变跟踪(Block Change Tracking)功能,可以更有效地进行增量备份,因为只需要跟踪自上次备份以来发生变化的块。 **使用简单** RMAN提供了易于理解的命令语法,使得备份和恢复过程变得直观...

    Testpassport最新Oracle_11G_OCP_1Z0-053题库

    SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING; ``` 但是,您收到错误消息,并且没有创建跟踪文件。可能的原因是什么? - A. 参数`DB_RECOVERY_FILE_DEST`未设置。 - B. 必须使用`ALTER SYSTEM`而不是`ALTER ...

    OraCle 10G教程

    - **Block Change Tracking**: 用于跟踪数据块的变化,优化归档日志模式下的数据恢复。 以上是Oracle 10G教程的核心内容,涵盖了数据库集群、存储管理、数据保护、SQL优化、内存管理等多个方面。通过学习这些知识...

    LINUX-下ORACLE利用rman备份迁移数据库.docx

    如果启用了块改变跟踪,迁移后需要关闭,使用`alter database disable block change tracking;`命令。 10. **重启数据库和检查日志路径**: 最后,重启数据库以应用更改,并使用`Select member from v$archived_...

    RMAN 初学者指南

    - **备份优化**:利用块变更跟踪(Block Change Tracking File)减少备份所需时间。 8. **RMAN的其他功能** - **验证备份**:检查备份集的完整性。 - **报告生成**:提供详细的备份和恢复报告。 - **复制数据库...

Global site tag (gtag.js) - Google Analytics