温故而知新(一): “Incremental Backups in Oracle 10.2.0.5” Translation & Notes

本文深入探讨了增量备份的概念,包括其目的、优势及不同类型的备份策略。重点介绍了RMAN工具如何进行增量备份,并讨论了差异性和累积性备份的区别及其应用场景。

前言:

过去有一顿时间总认为增量备份用不上的,那是因为没有完全理解其存在的意义。欠的债迟早要还的,读一遍之后,明朗了很多!


Incremental Backups

     The goal of an incremental backup is to back up only those data blocks that have changed since a previous backup. You can use RMAN to create incremental backups of datafiles, tablespaces, or the whole database.

     During media recovery, RMAN examines the restored files to determine whether it can recover them with an incremental backup. If it has a choice, then RMAN always chooses incremental backups over archived logs, as applying changes at a block level is faster than reapplying individual changes.

     RMAN does not need to restore a base incremental backup of a datafile in order to apply incremental backups to the datafile during recovery. For example, you can restore non-incremental image copies of the datafiles in the database, and RMAN can recover them with incremental backups.

     Incremental backups allow faster daily backups, use less network bandwidth when backing up over a network, and provide better performance when tape I/O bandwidth limits backup performance. They also allow recovery of database changes not reflected in the redo logs, such as direct load inserts. Finally, incremental backups can be used to back upNOARCHIVELOG databases, and are smaller than complete copies of the database (though they still require a clean database shutdown).

     One effective strategy is to make incremental backups to disk (as image copies), and then back up these image copies to a media manager withBACKUPASBACKUPSET. Then, you do not have the problem of keeping the tape streaming that sometimes occurs when making incremental backups directly to tape. Because incremental backups are not as big as full backups, you can create them on disk more easily.

增量备份:

       增量备份的目的是仅仅备份自从前一次备份以来变化的数据块。你可以使用RMAN为数据文件、表空间、或者整个数据库进行增量备份。

       在进行介质恢复时,RMAN会判断还原的数据文件是否可以使用增量备份集进行恢复。如果可以的话,RMAN会优先选择增量备份集而非归档日志。因为应用变化的数据块比应用独立改变(日志文件的)要快得多。

       RMAN恢复时,并不需要首先恢复一个基本的数据文件增量备份集以完成随后增量备份集的应用。例如:你可以恢复一个数据文件的非增量镜像拷贝,随后RMAN可以使用增量备份集对其进行恢复。

       利用增量备份可以在每天进行较快的备份,当通过网络备份时,它能使用更少的网络带宽,并且能在磁带IO性能有限时提供更好的性能。增量备份集也能恢复与与日志文件不相关的改变。例如:“直接加载插入”。最后一点,增量备份集可以用来备份非归档日志模式的数据库,并且它的体积会比数据库的完全拷贝小一些。(虽然这仍然需要数据库干净关闭)

       一个有用的技巧是:以镜像的模式进行增量备份,然后将这些镜像使用“BACKUPASBACKUPSET.”拷贝至介质管理器。这样一来,你不会在直接将增量备份直接存放在磁带,并且你需要保存这些磁带时遇到麻烦。因为增量备份并不是跟全备一样大,你可以在磁带上更容易的创建(保存)他们。


Incremental Backup Algorithm

     Each data block in a datafile contains a system change number (SCN), which is the SCN at which the most recent change was made to the block. During an incremental backup, RMAN reads the SCN of each data block in the input file and compares it to the checkpoint SCN of the parent incremental backup. (If block change tracking is enabled, RMAN does not read the portions of the file known to have not changed since the parent incremental backup.) If the SCN in the input data block is greater than or equal to the checkpoint SCN of the parent, then RMAN copies the block.

     One consequence of this mechanism is that RMAN applies all blocks containing changed data during recovery—even if the change is to an object created with theNOLOGGING option. Hence, making incremental backups is a safeguard against the loss of changes made byNOLOGGING operations.


增量备份的算法

        每个数据文件的数据块含有一个SCN号,这些SCN是在数据块最近一次发生改变时产生的。在进行增量备份时,RMAN读取输入的每个数据块的SCN,将其与父增量备份集的检查点SCN进行比较。(如果启用了block chang tracking,RMAN就不会读取自父增量备份集以来,没有发生变化的部分了)。 如果输入的数据块SCN大于或者等于父备份集的检查点SCN,RMAN就会拷贝他们。
        这种机制的结果之一就是:RMAN在恢复期间,会应用所有包含变化的数据块,甚至这些改变是没有被日志记录的(使用nologging选项)。因此,使用增量备份是nologging操作产生的变化的安全保障 (不会丢失这部分数据)。



Multilevel Incremental Backups

    RMAN can create multilevel incremental backups. Each incremental level is denoted by a value of 0 or 1. A level 0 incremental backup, which is the base for subsequent incremental backups, copies all blocks containing data. The only difference between a level 0 incremental backup and a full backup is that a full backup is never included in an incremental strategy.

A level 1 incremental backup can be either of the following types:

  • A differential backup, which backs up all blocks changed after the most recent incremental backup at level 1 or 0

  • A cumulative backup, which backs up all blocks changed after the most recent incremental backup at level 0

Incremental backups are differential by default.

Note:

Cumulative backups are preferable to differential backups when recovery time is more important than disk space, because fewer incremental backups need to be applied during recovery.

The size of the backup file depends solely upon the number of blocks modified and the incremental backup level.

多级别的增量备份

RMAN 能创建多级别的增量备份。每种增量级别使用0或1的值为符号。一个0级增量备份是随后增量备份的基础,它会拷贝所有包含数据的块。0级备份与全备的唯一区别是全备不具备增量备份的功能(技巧、方案)。

一个1级备份可以有两种类型:

      1. 差异备份,仅备份在最近一次1级或0级增量备份以来包含变化的数据块

      2. 累计备份,仅备份在最近一次o级备份以来包含变化的数据块

差异备份是被默认使用的模式。

说明:

累计备份在恢复时间比磁盘空间更重要的情况下更优异一些。因为在恢复时会有更少数量的增量备份集需要被应用。

备份文件的尺寸仅仅取决于更新的数据块的数量与增量备份的级别。


Differential Incremental Backups

      In a differential level 1 backup, RMAN backs up all blocks that have changed since the most recent incremental backup at level 1 (cumulative or differential) or level 0. For example, in a differential level 1 backup, RMAN determines which level 1 backup occurred most recently and backs up all blocks modified after that backup. If no level 1 is available, RMAN copies all blocks changed since the base level 0 backup.

     If no level 0 backup is available, then the behavior varies with the compatibility mode setting. If compatibility is >=10.0.0, RMAN copies all blocks that have been changed since the file was created. Otherwise, RMAN behaves as it did in previous releases, by generating a level 0 backup.

Figure 2-4 Differential Incremental Backups


In the example shown in Figure 2-4, the following occurs each week:
  • Sunday

    An incremental level 0 backup backs up all blocks that have ever been in use in this database.

  • Monday - Saturday

    On each day from Monday through Saturday, a differential incremental level 1 backup backs up all blocks that have changed since the most recent incremental backup at level 1 or 0. The Monday backup copies blocks changed since Sunday level 0 backup, the Tuesday backup copies blocks changed since the Monday level 1 backup, and so forth.

差异型增量备份

        在1级差异备份中,RMAN备份了自从最近一次1级(差异或者累计模式)或者0级备份起包含变化的数据块。

例如,在1级差异备份中,RMAN会判定哪一个是最近的1级备份,还有所有在这个备份之后变化的数据块。如果没有1级备份,RMAN就会拷贝自从最初的0级备份起所有变化的数据块。

        如果没有0级备份存在,那么其行为会变化,使用compatibility mode对应的配置。如果compatibility is >=10.0.0,RMAN会拷贝自从数据文件创建以来所有变化的数据块。否则,在过去的release版本中,RMAN会做一次0级备份。


这个例子中,每周发生如下内容:

        1.周日

         一个0级增量备份将数据库中所有使用过的数据块进行备份

        2 周一至周六

        周一至周六的每天,一个差异1级备份备份所有自从最近一次1级或者0级备份包含变化的所有数据块。周一备份自从周六0级备份起变化的数据块,然后周二备份自从周一的1级备份起包含变化的数据块,以此类推。



Cumulative Incremental Backups

      In a cumulative level 1 backup, RMAN backs up all the blocks used since the most recent level 0 incremental backup. Cumulative incremental backups reduce the work needed for a restore by ensuring that you only need one incremental backup from any particular level. Cumulative backups require more space and time than differential backups, however, because they duplicate the work done by previous backups at the same level.

Figure 2-5 Cumulative Incremental Backups


In the example shown in Figure 2-5, the following occurs each week:

  • Sunday

    An incremental level 0 backup backs up all blocks that have ever been in use in this database.

  • Monday - Saturday

    A cumulative incremental level 1 backup copies all blocks changed since the most recent level 0 backup. Because the most recent level 0 backup was created on Sunday, the level 1 backup on each day Monday through Saturday backs up all blocks changed since the Sunday backup.


累计型增量备份

        在一个累计行增量备份中,RMAN将自从最近一次0级备份以来包含变化的数据块进行备份。累计型增量备份减少了恢复所需的工作,确保你从任意级别恢复时仅需要一个增量备份集。累计型备份需要更多的空间与时间,因为无论如何,他们都要从上一次相同备份级别起做同样的工作。


在这个例子中,每周发生如下的事情:

         1.周日

         一个0级增量备份将数据库中所有使用过的数据块进行备份。

         2.周一至周六

         一个累计型1级备份备份自从最近一次0级备份起所有变化的数据块。因为最近一次0级备份是在周日创建的,周一至周六每天的1级备份会备份所有自从周日备份集起变化的数据块。


Planning an Incremental Backup Strategy

Choose a backup scheme according to an acceptable MTTR (mean time to recover). For example, you can implement a three-level backup scheme so that a full or level 0 backup is taken monthly, a cumulative level 1 is taken weekly, and a differential level 1 is taken daily. In this scheme, you never have to apply more than a day's worth of redo for complete recovery.

When deciding how often to take full or level 0 backups, a good rule of thumb is to take a new level 0 whenever 20% or more of the data has changed. If the rate of change to your database is predictable, then you can observe the size of your incremental backups to determine when a new level 0 is appropriate. The following query displays the number of blocks written to a backup set for each datafile with at least 50% of its blocks backed up:

SELECT FILE#, INCREMENTAL_LEVEL, COMPLETION_TIME, BLOCKS, DATAFILE_BLOCKS 
  FROM V$BACKUP_DATAFILE 
  WHERE INCREMENTAL_LEVEL > 0 
  AND BLOCKS / DATAFILE_BLOCKS > .5 
  ORDER BY COMPLETION_TIME;

Compare the number of blocks in differential or cumulative backups to a base level 0 backup. For example, if you only create level 1 cumulative backups, then take a new level 0 backup when the most recent level 1 backup is about half of the size of the base level 0 backup.


计划一个增量备份的技巧

       选择一个备份方案需要依据可接受的MTTR (mean time to recover).例如,你可以实现一个3个级别的备份方案,每月做一次全备或者0级备份,每周做一次1级累积型增量备份,并且每天做一次差异的1级备份。在这个方案里,你永远不需要应用超过一天的日志来完成一次完全恢复。

        在决定以多大的频率来做0级备份时,一个比较好的经验方法是 当有20%或者更过数据发生变化时就进行一次新的0级备份。如果这个变化的比率是可以预料的,那么你可以遵循增量备份的尺寸以决定何时一个新的0级备份为恰当的时间。以下的查询显示了写入每个数据文件备份集的数据块至少为其备份的50%:

        比较基于一个0级备份时,差异型增量备份与累计型增量备份的数据块的数量。例如如果你仅创建了1级累积型备份,然后当最近的一个1级备份已经是最初0级备份体积的一半时, 创建一个新的0级备份 (最后一句话不明白为什么要说“如果你仅创建了1级累积型备份”)



评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值