关于block change tracking的那些事

1.block change tracking介绍

Block chage tracking是Oracle10g的一个新特性,Block change tracking进程记录自从上一次备份以来数据块的变化,并把这些信息记录在跟踪文件中。RMAN使用这个文件判断增量备份中需要备份的变更数据。这极大的促进了备份性能,RMAN可以不再扫描整个文件以查找变更数据。

为此Oracle引入了一个新的后台进程,CTWR,其全称为Change Tracking Writer,用于记录变化的块并将变化写入相应的日志文件中。 

 

2.配置block change tracking

 

开启bct:

可以在数据文件,asm,裸设备上创建日志跟踪文件

 

alter database enable block change tracking using
file '/oradata/block_track.log';
alter database enable block change tracking using file ‘+data’;
alter database enable block change tracking using file ‘/dev/rlvbct’;
通过查询v$block_change_tracking视图查询bct的使用情况。
禁用bct:
alter database disable block change tracking;
 修改块修改跟踪文件路径

  修改块修改跟踪文件可以通过alter database rename file命令,但是只能在mount状态下操作。

  查看当前块修改跟踪文件路径:

  • SQL> select filename from v$block_change_tracking;

    FILENAME

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

    E:/ORACLE/PRODUCT/10.2.0/DB_1/DATABASE/RMAN_INC.TRK

  Shutdown 数据库并启动到mount状态:

  • SQL> shutdown immediate

    Database closed.

    Database dismounted.

    ORACLE instance shut down.

    SQL> startup mount

    ORACLE instance started.

    Total System Global Area  167772160 bytes

    Fixed Size                  1295608 bytes

    Variable Size              88083208 bytes

    Database Buffers           71303168 bytes

    Redo Buffers                7090176 bytes

    Database mounted.

  手工复制块修改文件到新路径下,然后执行alter database命令:

  • SQL> alter database rename file 'E:/ORACLE/PRODUCT/10.2.0/DB_1/DATABASE/RMAN_INC.TRK'

      2  to 'E:/oracle/oradata/jssweb/rman_inc.trk';

    Database altered.

    SQL> alter database open;

    Database altered.

  查看当前块修改跟踪文件路径:

  • SQL> select filename from v$block_change_tracking;

    FILENAME

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

    E:/ORACLE/ORADATA/JSSWEB/RMAN_INC.TRK

  如果你的数 据库无法shutdown , 其实也无所谓,先disable,然后执行enable时指定一个新路径也可以的:),只不过,原来文件中记录的块修改的跟踪信息也就没有了。

3.How To Size the Block Change Tracking File [ID 306112.1]

In this Document
  Goal
  Solution


Platforms: 1-914CU;

This document is being delivered to you via Oracle Support's Rapid Visibility (RaV) process and therefore has not been subject to an independent technical review.

 

Applies to:

Oracle Server - Enterprise Edition - Version: 10.1.0.2 to 10.2.0.1 - Release: 10.1 to 10.2
Oracle Server - Enterprise Edition - Version: 10.1.0.2 to 11.1.0.7   [Release: 10.1 to 11.1]
Information in this document applies to any platform.

Goal

This is a clarification of the documentation for sizing the Block Change Tracking File.

Block Change Tracking is used to optimize incremental backups. A new file is introduced:

- Changed blocks are tracked by the CTWR background process as redo is generated
- Database backups automatically use the change tracking file


Sizing of this file is important, and even though you can use V$BLOCK_CHANGE_TRACKING view
to monitor the usage, it may in some cases not be easy to change the size, ie when using raw devices.

Solution

The formula is:

 

<size of change tracking file> = <# of redo threads> * (# of old backups + 2) * (size of db/250000)

 

Let’s take an example of a 500 GB database, with only one thread, and having eight backups kept
in RMAN. The repository for this will require a block change tracking file of 20 MB.

Threads * (number of old backups+2) * (database size in bytes/250000) = 20 MB

The amount of data that each bit in the change tracking file covers is 32KB. That's 262144 bits.
That is where the 1/250000 figure comes from. This is the ratio of the size of *one bitmap* in the
change tracking file, to the size of the database data that the bitmap covers. And, because we
keep up to 8 levels of bitmap history in the file, plus the current bitmap, that reduces the ratio
to about 1/30000, per enabled thread.

Dividing 1TB by 30000, you get 30 MB, per TB, per enabled thread.

So the parameters we use to determine the block change tracking file are:
- Database size
- Number of enabled threads
- Number of old backups. (The block change tracking file keeps a record of all changes between previous backups, up to eight in total)

 

4.一些备忘知识点

 通过位图跟踪两次备份间变化的数据块;

 每次备份前进行位图切换;

 开发增量备份策略时,要考虑到8个位图的限制;

 在RAC环境中,change tracking file需要放在共享存储上;

 Change tracking file的大小和数据库的大小和enabled的redo thread的个数成正比;

 Change tracking file的大小和数据更新的频率无关;


 

 

整理自网络

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Block Change Tracking(BCT)是 Oracle 数据库中一种技术,用于跟踪在备份之间更改的数据块,以加速增量备份和恢复。如果你想从 BCT 中获取变数据块,可以按照以下步骤进行: 1. 首先,你需要确认 BCT 已经启用。你可以使用以下命令来检查: ``` SELECT status FROM v$block_change_tracking; ``` 如果返回的状态为 ENABLED,则表示 BCT 已经启用。如果状态为 DISABLED,则需要通过以下命令启用 BCT: ``` ALTER DATABASE ENABLE BLOCK CHANGE TRACKING; ``` 2. 接下来,你需要创建一个包含变数据块的文件。你可以使用以下命令来创建该文件: ``` ALTER DATABASE CREATE BLOCK CHANGE TRACKING FILE '/path/to/bct/file'; ``` 其中 '/path/to/bct/file' 是你想要创建的 BCT 文件的路径。请确保该路径对于数据库服务器上的 Oracle 进程是可读写的。 3. 等待一段时间后,BCT 文件将包含所有在最后一次备份之后更改的数据块。你可以使用以下命令来获取变数据块: ``` SELECT file#, block# FROM v$backup_block_change_tracking WHERE status = 'YES'; ``` 该命令将返回一个包含文件号和块号的结果集,表示包含变数据块的数据文件和该文件中的变数据块的块号。 请注意,BCT 文件只包含最后一次备份之后更改的数据块,因此如果你想获取之前的变数据块,需要使用相应的增量备份文件。同时,BCT 文件也需要定期清理或重新创建,以确保其有效性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值