启用快速增量备份

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.

上一篇:2016年DDoS攻击趋势分析报告


下一篇:MaxCompute Graph开发-eclipse.sql