启用快速增量备份

简介: 提高增量备份的性能的方法可以启用块更改跟踪(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.

相关文章
|
6月前
|
关系型数据库 数据库 PostgreSQL
postgresql|【基于pg_basebackup命令的归档备份和恢复---热备冷恢复方式】
postgresql|【基于pg_basebackup命令的归档备份和恢复---热备冷恢复方式】
280 0
|
6月前
|
安全
linuxdd命令备份与恢复
`dd`命令实例:用于备份/恢复磁盘,如`dd if=/dev/hdb of=/dev/hdd`复制整个硬盘。还能压缩备份(`dd if=/dev/hdb | gzip > /root/image.gz`)、恢复(`gzip -dc /root/image.gz | dd of=/dev/hdb`)、备份MBR(`dd if=/dev/hda of=/root/image count=1 bs=512`)、创建swap分区(`dd if=/dev/zero of=/swapfile`)
133 1
|
Shell 开发工具
备份日志
备份日志
88 1
|
SQL 存储 安全
MySQL日志管理和完全备份增量备份与恢复(二)
MySQL日志管理和完全备份增量备份与恢复(二)
MySQL日志管理和完全备份增量备份与恢复(二)
xtrabackup 增量,全备份,恢复备份
mysql5x 版本对应xrtabackup2.4
176 0
|
数据库 关系型数据库 PostgreSQL
Confluence 6 如何备份和恢复
如何备份 有关备份你数据库使用的命令与你使用的具体数据库有关,例如针对 PostgreSQL 数据库,备份命令为 pg_dump dbname > outfile。
1654 0
|
关系型数据库 MySQL 数据库