Chinaunix首页 | 论坛 | 博客
  • 博客访问: 863869
  • 博文数量: 72
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 435
  • 用 户 组: 普通用户
  • 注册时间: 2013-04-27 20:07
个人简介

郭一军,网名guoyJoe,尖峰在线培训创始人、Oracle OCM、ITPUB论坛Oracle认证版版主、2013最佳精华贴、Senior DBA、Oracle OCT、 ACOUG MEMBER、CSDN 认证专家、RHCE、在线技术分享的倡导者和实践者。 http://www.jianfengedu.com http://jianfengedu.taobao.com

文章分类
文章存档

2014年(72)

分类: Oracle

2014-06-19 10:38:59

        转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/19297567 

       提高增量备份的性能的方法可以启用块更改跟踪(block change tracking),在我们没有启用块更改跟踪的增量备份时,RMAN必须检查数据库中要备份的所有数据文件中的每个数据块,查看自上次备份以来相应的块是否发生了变化(一般对比备份 数据块中的SCN与数据文件数据块的SCN大小,是否一致,如果一致就不需要备份,不一致就需要做增量备份)。当数据库的数据量很大时,那么扫描数据库中的块占用的时间很可能超过执行实际备份的时间。这时如果启用块更改跟踪,那RMAN会通过使用更改跟踪文件查看哪此数据文件中的块发生了变化,这样能快速知道哪些块变化了,大大减少了增量备份的时间。启动块更改跟踪的缺点是:占用一点空间和数据库维护的一点开销,优点是在我们大规模的数据库频繁做增量备份时大大节省了扫描对比数据块的时间,从而可以快速增量备份。



   1丶检查数据库有没有启用块更改跟踪
   gyj@OCP> col filename for a50
   gyj@OCP> select filename from v$block_change_tracking;


    FILENAME
   --------------------------------------------------


 说明没有启用块更改跟踪。


   2丶启用块更改跟踪
   
    gyj@OCP> alter database enable block change tracking;
    alter database enable block change tracking
    *
    ERROR at line 1:
    ORA-19773: must specify change tracking file name


   这里有两种方式指定改变跟踪文件:
   (1)第一种方式启动参数db_create_file_dest指定块更改跟踪文件的位置,以OMF文件形式创建相应的文件
   
   gyj@OCP> alter system set db_create_file_dest=\'/backup\';


   System altered.


   这里再启用块更改跟踪就可以成功了
   gyj@OCP> alter database enable block change tracking;


  Database altered.


    (2)第二种方式是在 alter database enable block change tracking加using file \'/backup\',可以参考官方文档。


  即alter database enable block change tracking  using file \'/backup\';



    3丶找到当前块更改跟踪文件的位置
    gyj@OCP> select filename,status,bytes from v$block_change_tracking;


    FILENAME                                           STATUS          BYTES
    -------------------------------------------------- ---------- ----------
    /backup/OCP/changetracking/o1_mf_9j1dbtco_.chg     ENABLED      11599872


    
    4丶启用块更改跟踪会产生后台进程CTWR
      
    [root@mydb ocm]# ps -ef |grep ctwr |grep -v grep
    oracle    6632     1  0 20:38 ?        00:00:00 ora_ctwr_ocp
     
   
    5丶做增量备份
     RMAN> backup incremental level=0 database;


Starting backup at 16-FEB-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=53 device type=DISK
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/ocm/undotbs01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/ocm/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/ocm/sysaux01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/ocm/tp1.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/ocm/example01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/ocm/tp2.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/ocm/tp3.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ocm/users01.dbf
channel ORA_DISK_1: starting piece 1 at 16-FEB-14
channel ORA_DISK_1: finished piece 1 at 16-FEB-14
piece handle=/u01/app/oracle/product/11.2.0/dbs/3kp0pu9t_1_1 tag=TAG20140216T210357 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:36
Finished backup at 16-FEB-14


Starting Control File and SPFILE Autobackup at 16-FEB-14
piece handle=/backup/c-2735927810-20140216-04 comment=NONE
Finished Control File and SPFILE Autobackup at 16-FEB-14


RMAN> backup incremental level=1 database;


Starting backup at 16-FEB-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/ocm/undotbs01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/ocm/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/ocm/sysaux01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/ocm/tp1.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/ocm/example01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/ocm/tp2.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/ocm/tp3.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ocm/users01.dbf
channel ORA_DISK_1: starting piece 1 at 16-FEB-14
channel ORA_DISK_1: finished piece 1 at 16-FEB-14
piece handle=/u01/app/oracle/product/11.2.0/dbs/3mp0puek_1_1 tag=TAG20140216T210628 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 16-FEB-14


Starting Control File and SPFILE Autobackup at 16-FEB-14
piece handle=/backup/c-2735927810-20140216-05 comment=NONE
Finished Control File and SPFILE Autobackup at 16-FEB-14


6丶监控块更改的跟踪文件
    gyj@OCP> select file#,avg(datafile_blocks) bloks,avg(blocks_read) blocks_read,
  2        avg(blocks_read/datafile_blocks)*100 pct_read,avg(blocks) blocks_backed_up
  3      from v$backup_datafile
  4      where used_change_tracking=\'YES\'
  5      and incremental_level=1
  6      group by file#
  7      order by file#;


     FILE#      BLOKS BLOCKS_READ   PCT_READ BLOCKS_BACKED_UP
---------- ---------- ----------- ---------- ----------------
         1      93440          69 .073844178               19
         2      81920          29 .035400391                7
         3     444800         165 .037095324               23
         4       2240           1 .044642857                1
         5      44240           1 .002260398                1
         6      64000           5   .0078125                2
         7       6400           1    .015625                1
         8       6400           1    .015625                1


8 rows selected.


   7丶关闭块更改跟踪
     
   gyj@OCP> alter database disable block change tracking;


   Database altered.
阅读(2404) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~