ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle 的 BLOCK CHANGE TRACKING

oracle 的 BLOCK CHANGE TRACKING

原创 Linux操作系统 作者:aaqwsh 时间:2011-05-14 19:02:30 0 删除 编辑

10G版本开始,引入了BLOCK CHANGE TRACKING特性,这次算是真正的增量了。

当这个特性开启后,ORACLE会创建一个trace文件,并起用后台进程CTWR记录变化的数据块,当需要增量备份的时候,就直接读这个文件获得要备份的数据块,速度确实是有质的飞跃(参考http://www.alidba.net/index.php/archives/51

 

 

--启用BLOCK CHANGE TRACKING特性

SQL> alter database enable block change tracking using file '/data/ora10g/RACDBSTD/trace.dbf' reuse;

 

Database altered.

 

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area  167772160 bytes

Fixed Size                  1218316 bytes

Variable Size              62916852 bytes

Database Buffers          100663296 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

 

--全备数据库(这个全备好像需要再开启BLOCK CHANGE TRACKING后,后面的增备才能利用到)

RMAN> run{

2>     allocate channel c1 device type disk format '/data/backup/db_fullb%u';

3>     backup incremental level 0 database ;

4> }

 

released channel: ORA_DISK_1

allocated channel: c1

channel c1: sid=141 devtype=DISK

 

Starting backup at 14-MAY-11

channel c1: starting incremental level 0 datafile backupset

channel c1: specifying datafile(s) in backupset

input datafile fno=00001 name=/data/ora10g/RACDBSTD/system.259.727735501

input datafile fno=00003 name=/data/ora10g/RACDBSTD/sysaux.261.727735559

input datafile fno=00002 name=/data/ora10g/RACDBSTD/undo01.DBF

input datafile fno=00005 name=/data/ora10g/RACDBSTD/users.264.727735605

channel c1: starting piece 1 at 14-MAY-11

channel c1: finished piece 1 at 14-MAY-11

piece handle=/data/backup/db_fullb17mcb0h7 tag=TAG20110514T182335 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:45

channel c1: starting incremental level 0 datafile backupset

channel c1: specifying datafile(s) in backupset

including current control file in backupset

channel c1: starting piece 1 at 14-MAY-11

channel c1: finished piece 1 at 14-MAY-11

piece handle=/data/backup/db_fullb18mcb0ik tag=TAG20110514T182335 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:02

Finished backup at 14-MAY-11

released channel: c1

 

--增量备份

SQL> drop table testtab purge;

 

Table dropped.

 

SQL> create table testtab  as select * from dba_objects where 1 = 2;

 

Table created.

 

SQL> insert into testtab select * from dba_objects;

 

44964 rows created.

 

SQL> commit;

 

Commit complete.

 

RMAN> run{

2> allocate channel c1 device type disk format '/data/backup/db_incb%u';

3> backup incremental level 1 database ;

4> };

 

allocated channel: c1

channel c1: sid=141 devtype=DISK

 

Starting backup at 14-MAY-11

channel c1: starting incremental level 1 datafile backupset

channel c1: specifying datafile(s) in backupset

input datafile fno=00001 name=/data/ora10g/RACDBSTD/system.259.727735501

input datafile fno=00003 name=/data/ora10g/RACDBSTD/sysaux.261.727735559

input datafile fno=00002 name=/data/ora10g/RACDBSTD/undo01.DBF

input datafile fno=00005 name=/data/ora10g/RACDBSTD/users.264.727735605

channel c1: starting piece 1 at 14-MAY-11

channel c1: finished piece 1 at 14-MAY-11

piece handle=/data/backup/db_incb19mcb0k0 tag=TAG20110514T182503 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:07

channel c1: starting incremental level 1 datafile backupset

channel c1: specifying datafile(s) in backupset

including current control file in backupset

channel c1: starting piece 1 at 14-MAY-11

channel c1: finished piece 1 at 14-MAY-11

piece handle=/data/backup/db_incb1amcb0k7 tag=TAG20110514T182503 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:02

Finished backup at 14-MAY-11

released channel: c1

 

 

SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

 

Session altered.

 

SQL> select file#, incremental_level, completion_time, datafile_blocks ,blocks_read,

  2  trunc((blocks_read / datafile_blocks) * 100,2) as "read%",

  3  used_change_tracking

  4  from v$backup_datafile

  5  where incremental_level > 0

  6  order by completion_time;

 

     FILE# INCREMENTAL_LEVEL COMPLETION_TIME     DATAFILE_BLOCKS BLOCKS_READ      read% USE

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

         5                 1 2011-05-14 18:10:51             640         640        100 NO

         2                 1 2011-05-14 18:10:58            6400        6400        100 NO

         3                 1 2011-05-14 18:11:08           20480       20480        100 NO

         1                 1 2011-05-14 18:11:17           53760       53760        100 NO

         5                 1 2011-05-14 18:15:51             640         640        100 NO

         2                 1 2011-05-14 18:15:58            6400        6400        100 NO

         3                 1 2011-05-14 18:16:08           20480       20480        100 NO

         1                 1 2011-05-14 18:16:18           53760       53760        100 NO

         3                 1 2011-05-14 18:17:25           20480           1          0 YES

         1                 1 2011-05-14 18:17:25           53760           1          0 YES

         2                 1 2011-05-14 18:17:25            6400           1        .01 YES

 

     FILE# INCREMENTAL_LEVEL COMPLETION_TIME     DATAFILE_BLOCKS BLOCKS_READ      read% USE

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

         5                 1 2011-05-14 18:17:25             640           1        .15 YES

         1                 1 2011-05-14 18:25:07           53760         679       1.26 YES

         3                 1 2011-05-14 18:25:07           20480        2039       9.95 YES

         2                 1 2011-05-14 18:25:07            6400         419       6.54 YES

         5                 1 2011-05-14 18:25:07             640           1        .15 YES

 

16 rows selected.

 

SQL> shutdown abort

ORACLE instance shut down.

 

--删除数据文件

rm /data/ora10g/RACDBSTD/users.264.727735605

 

 

--恢复

RMAN> startup mount

 

Oracle instance started

database mounted

 

Total System Global Area     167772160 bytes

 

Fixed Size                     1218316 bytes

Variable Size                 62916852 bytes

Database Buffers             100663296 bytes

Redo Buffers                   2973696 bytes

 

RMAN> restore database;

 

Starting restore at 14-MAY-11

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=157 devtype=DISK

 

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /data/ora10g/RACDBSTD/system.259.727735501

restoring datafile 00002 to /data/ora10g/RACDBSTD/undo01.DBF

restoring datafile 00003 to /data/ora10g/RACDBSTD/sysaux.261.727735559

restoring datafile 00005 to /data/ora10g/RACDBSTD/users.264.727735605

channel ORA_DISK_1: reading from backup piece /data/backup/db_fullb17mcb0h7

channel ORA_DISK_1: restored backup piece 1

piece handle=/data/backup/db_fullb17mcb0h7 tag=TAG20110514T182335

channel ORA_DISK_1: restore complete, elapsed time: 00:00:46

Finished restore at 14-MAY-11

 

--recover 用到了增量备份

RMAN> recover database;

 

Starting recover at 14-MAY-11

using channel ORA_DISK_1

channel ORA_DISK_1: starting incremental datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

destination for restore of datafile 00001: /data/ora10g/RACDBSTD/system.259.727735501

destination for restore of datafile 00002: /data/ora10g/RACDBSTD/undo01.DBF

destination for restore of datafile 00003: /data/ora10g/RACDBSTD/sysaux.261.727735559

destination for restore of datafile 00005: /data/ora10g/RACDBSTD/users.264.727735605

channel ORA_DISK_1: reading from backup piece /data/backup/db_incb19mcb0k0

channel ORA_DISK_1: restored backup piece 1

piece handle=/data/backup/db_incb19mcb0k0 tag=TAG20110514T182503

channel ORA_DISK_1: restore complete, elapsed time: 00:00:03

 

starting media recovery

media recovery complete, elapsed time: 00:00:05

 

Finished recover at 14-MAY-11

 

RMAN> alter database open;

 

database opened

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/758322/viewspace-695271/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-11-24

  • 博文量
    132
  • 访问量
    262225