Oracle 差异增量和累计增量备份
网址: http://www.eygle.com/digest/2009/04/oracle_rman_incremental_backup.html
在rman增量备份中,有差异增量和累积增量的概念
1、概念
差异增量:是备份上级及同级备份以来所有变化的数据块,差异增量是默认增量备份方式
累积增量:是备份上级备份以来所有变化的块
因为累积增量是备份上级备份以来所有变化的数据块,所以累积增量需要更多的备份时间,同时需要较小的恢复时间;而差异增量正好相反,它可以备份同级备份以来变化的数据块。所以会减少备份时间,但需要更多的恢复时间.在oracle 9中增量备份需要通过扫描整个数据库的数据块才能知道哪些数据块发生了变化,这是一个代价很大,时间很长的过程,而且由于增量备份形成多个不同的备份集,使恢复变得更加不可靠,所以增量备份在版本9中仍然不被推荐使用;在10g中,增量备份作了很大的改进,不需要再扫描所有数据块就能得知哪些数据块发生变化,从而大大提升备份效率。但这些却以牺牲磁盘i/o为代价,所以在oltp事务系统中还得衡量是否愿意以i/o为代价来保证安全及高可用性。10g还支持增量合并,增量备份可支持7级增量。
2、备份策略及恢复
以rman多级增量备份来作为备份策略例子:
增量备份都需要一个0级备份来作为基础,0级备份与全备份的区别在于0级可以用来增量恢复,而全备份则不可以。
备份策略:
eg:我们对一星期做如下备份策略 ,如果是星期六发生了故障,那么差异增量只需要使用星期天的0级,星期三的一级,星期四、五的二级就可以恢复,累积增量则需要星期天的0级、星期三的1级,星期五的二级即可进行恢复。以上是一个星期的备份策略,如果做长期的备份策略则只需要把备份的时间延长即可得到新的备份策略,具体需要看自己备份及恢复能够接受的程度而顶,见最后的备份策略典型案例。
星期 |
差异增量 |
累积增量 |
星期天 |
0级 |
0级 |
星期一 |
2级 |
2级 |
星期二 |
2级 |
2级 |
星期三 |
1级 |
1级 |
星期四 |
2级 |
2级 |
星期五 |
2级 |
2级 |
星期六 |
2级 |
2级 |
星期天 |
0级 |
0级 |
备份命令如下:
零级备份
backup incremental level 0 database;
一级差异增量
backup incremental level 1 database;
一级累计增量
backup incremental level 1 cumulative database;
备份策略典型案例:
每半年做一个数据库的全备份(包括所有的数据和只读表空间)
每一个月做一次零级备份(不包含只读表空间)
每个星期做一次一级备份
每天做一次二级备份
任何数据库的更改需要重新同步CATALOG目录并重新备份(如添加数据文件)或重新备份(如修改表空间为只读)
建议备份一段时间归档日志和定期备份归档到到磁带上
全库备份脚本
run{ |
零级备份脚本
run{ |
一级备份脚本
run{ |
如果按照以上备份策略,则每天的所需要备份的数据量只有一天的改变量。而做恢复时最多要恢复当月的一个零级备份+三个一级备份+6个二级备份+当天的归档文件。如果不能接受这样的恢复时间,可以减少零级备份之间的时间间隔。在每次备份后,原则上在该备份点之前的归档日志就可以删除掉了,但是为了进一步的安全以及日后需要(如使用LOGMNR查找所需信息),建议有条件的话,归档日志保存到能够接受的时间点,可以保存在磁带等廉价存取设备上。
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 th
Oracle 差异增量和累计增量备份的更多相关文章
- Oracle 差异性增量 和 累计增量 原理(转)
RMAN一个强大的功能是支持增量备份,增量备份中心思想就是减少备份的数据量,我们不需要在从头开始备份了,只需要备份自上次已备份之后的数据块即可. Oracle 9i 共有五种级别 0 1 2 3 ...
- ORACLE RMAN备份--差异增量与累积增量的策略实例图
转自原文 ORACLE RMAN备份--差异增量与累积增量的策略实例图
- 【转】在rman增量备份中,有差异增量和累积增量的概念
本文转自hougoo的博客 1.概念 差异增量:是备份上级及同级备份以来所有变化的数据块,差异增量是默认增量备份方式 累积增量:是备份上级备份以来所有变化的块 因为累积增量是备份上级备份以来所有变化的 ...
- 示例说明Oracle RMAN两种库增量备份的差别
1差异增量实验示例 1.1差异增量备份 为了演示增量备份的效果,我们在执行一次0级别的备份后,对数据库进行一些改变. 再执行一次1级别的差异增量备份: 执行完1级别的备份后再次对数据库进行更改: 再执 ...
- 利用shell脚本将Oracle服务器中数据定时增量刷新到ftp服务器中
现有需求:将oracle数据库中的数据准实时同步至某ftp服务器中,以便前端应用能定时从ftp服务器目录中取增量数据 方法:将加工脚本写为存储过程,然后利用shell脚本执行该存储过程并将增量数据导出 ...
- Oracle数据库三种标准的备份方法
Oracle数据库的三种标准的备份方法: 1.导出/导入(EXP/IMP). 2.热备份. 3.冷备份. 注释:导出备件是一种逻辑备份,冷备份和热备份是物理备份. 一.导出/导入(Export/Imp ...
- Oracle 【IT实验室】数据库备份与恢复之:如何对Oracle数据库文件进行恢复与备份
任何数据库在长期使用过程中,都会存在一定的安全隐患.对于数据库管理员来说不能仅寄希望于计算机操作系统的安全运行,而是要建立一整套的数据库备份与恢复机制.当数据库发生故障后,希望能重新建立一个完整的数据 ...
- Oracle数据库误删文件导致rman备份报错RMAN-06169解决办法
Oracle数据库误删文件导致rman备份报错RMAN-06169解决办法 可能是误删文件导致在使用rman备份时候出现以下提示 RMAN-06169: could not read file hea ...
- oracle:rman恢复----通过增量备份来恢复
试验计划:先rman进行一个0级备份,插入表相关数据,再进行level 1级增量备份,进行rman恢复 实验环境:归档模式下,oracle10.2.0.1 开始试验: 1. rman level 0级 ...
随机推荐
- .net下的跨域问题
环境: IIS7.0 MVC 4.0 公司官网 asp.net 需要的报名系统,需要有后台管理 由于是配合传统产业,所以MVC系统的数据,是由AIPS系统提供. (制作前是考虑去年用 ...
- linux svn服务器svnserve 安装配置
svnserve 是一个轻量级的服务, 使用自定义的协议通过TCP/IP与客户端通讯.客户端通过由 svn:// 或者 svn+ssh:// 开始的URL访问svnserve服务器. svn服务器有两 ...
- winform 对话框、打印框
winform 对话框控件 1.打开文件对话框(OpenFileDialog) 2.保存文件对话框(SaveFileDialog) 3.字体对话框(FontDialog) 4.颜色对话框(ColorD ...
- 使用NetBeans搭建基于Spring框架的Web应用
NetBeans下载链接:https://netbeans.org/. 第一步:选择“文件”菜单下的“新建项目”: 第二步:类别选择“Java Web”,项目选择“Web应用程序”,单击“下一步”: ...
- Git 遇到了 early EOF index-pack failed 问题
Git 遇到了 early EOF index-pack failed 问题 今天想 clone 一下 boost 在 github 的 repo,结果在 clone 的过程中遇到了下面的错误.我原本 ...
- 解决Failed to allocate memory: 8转
解决Failed to allocate memory: 8 昨天换了x64的Win7,发现在Eclipse上启动模拟器的时候存在问题,当设置的模拟器分辨率大于400×800的时候会出现 Failed ...
- html+css创建提示框
看到下面的效果了吗? 本来我们站点是用下面的图片做的背景, 但是后期当更改完框中的提示内容,并且更新内容较多的时候,发现内容溢出了,如下图: 但是背景图片不能自动拉伸,还得重新做一张背景图,这样就导致 ...
- YTU 3025: 创建二叉树
原文链接:https://www.dreamwings.cn/ytu3025/2628.html 3025: 创建二叉树 时间限制: 1 Sec 内存限制: 128 MB 提交: 3 解决: 3 ...
- Hibernate框架的使用。。。
在lib文件夹里面导入Hibernate开发的架包和连接mysql,连接数据源c3p0的架包... 在src目录下建立Hibernate Configuration File(cfg.xml)的配置 ...
- python协程与异步I/O
协程 首先要明确,线程和进程都是系统帮咱们开辟的,不管是thread还是process他内部都是调用的系统的API,而对于协程来说它和系统毫无关系; 协程不同于线程的是,线程是抢占式的调度,而协程是协 ...