天天看點

[20151117]關于增量備份.txt

[20151117]關于增量備份.txt

PORT_STRING                    VERSION        BANNER

------------------------------ -------------- --------------------------------------------------------------------------------

x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

RMAN> backup incremental level 0 datafile 5  format '/home/oracle/backup/inc0_example_%u.dbf' TAG='INC0';

Starting backup at 2015-11-17 10:47:42

using channel ORA_DISK_1

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=00005 name=/mnt/ramdisk/book/example01.dbf

channel ORA_DISK_1: starting piece 1 at 2015-11-17 10:47:42

channel ORA_DISK_1: finished piece 1 at 2015-11-17 10:47:43

piece handle=/home/oracle/backup/inc0_example_40qmfume.dbf tag=INC0 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 2015-11-17 10:47:43

--如果我改名删除這個增量備份呢?

$ mv inc0_example_40qmfume.dbf inc0_example_40qmfume.dbf_ORG

RMAN> backup incremental level 1 datafile 5  format '/home/oracle/backup/inc1_example_%u.dbf' TAG='INC1';

Starting backup at 2015-11-17 10:52:01

channel ORA_DISK_1: starting incremental level 1 datafile backup set

channel ORA_DISK_1: starting piece 1 at 2015-11-17 10:52:01

channel ORA_DISK_1: finished piece 1 at 2015-11-17 10:52:02

piece handle=/home/oracle/backup/inc1_example_43qmfuuh.dbf tag=INC1 comment=NONE

Finished backup at 2015-11-17 10:52:02

--增量1級備份成功。

RMAN> list backupset ;

List of Backup Sets

===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ -------------------

120     Incr 0  68.84M     DISK        00:00:00     2015-11-17 10:47:42

        BP Key: 120   Status: AVAILABLE  Compressed: NO  Tag: INC0

        Piece Name: /home/oracle/backup/inc0_example_40qmfume.dbf

  List of Datafiles in backup set 120

  File LV Type Ckp SCN    Ckp Time            Name

  ---- -- ---- ---------- ------------------- ----

  5    0  Incr 1774661    2015-11-16 16:16:33 /mnt/ramdisk/book/example01.dbf

122     Incr 1  32.00K     DISK        00:00:00     2015-11-17 10:52:01

        BP Key: 122   Status: AVAILABLE  Compressed: NO  Tag: INC1

        Piece Name: /home/oracle/backup/inc1_example_43qmfuuh.dbf

  List of Datafiles in backup set 122

  5    1  Incr 1812018    2015-11-17 10:52:01 /mnt/ramdisk/book/example01.dbf

--說明備份并不是讀取增量備份檔案來比較的。而是通過控制檔案記錄的資訊來确定從那個scn開始。

SELECT recid

      ,file#

      ,incremental_level

      ,incremental_change#

      ,checkpoint_change#

      ,datafile_blocks

      ,blocks_read

  FROM V$BACKUP_DATAFILE;

     RECID      FILE# INCREMENTAL_LEVEL INCREMENTAL_CHANGE# CHECKPOINT_CHANGE# DATAFILE_BLOCKS BLOCKS_READ

---------- ---------- ----------------- ------------------- ------------------ --------------- -----------

       124          5                 0                   0            1774661           42240       39872

       126          5                 1             1774661            1812018           42240       42240

--可以從BLOCKS_READ看出,0級備份僅僅讀取使用的塊,而1級備份讀取全部的資料塊。要想充分使用增量備份最好打開塊跟蹤。

3.打開塊跟蹤檔案:

SCOTT@book> alter database enable block change tracking using file '/home/oracle/backup/change_tracking.dbf';

Database altered.

Starting backup at 2015-11-17 11:05:02

channel ORA_DISK_1: starting piece 1 at 2015-11-17 11:05:02

channel ORA_DISK_1: finished piece 1 at 2015-11-17 11:05:03

piece handle=/home/oracle/backup/inc1_example_44qmfvmu.dbf tag=INC1 comment=NONE

Finished backup at 2015-11-17 11:05:03

  FROM V$BACKUP_DATAFILE

       127          5                 1             1812018            1812564           42240       42240

--再隻執行1次增量備份就可以看出效果了。

Starting backup at 2015-11-17 11:06:04

channel ORA_DISK_1: starting piece 1 at 2015-11-17 11:06:05

channel ORA_DISK_1: finished piece 1 at 2015-11-17 11:06:06

piece handle=/home/oracle/backup/inc1_example_45qmfvot.dbf tag=INC1 comment=NONE

Finished backup at 2015-11-17 11:06:06

RMAN>

SCOTT@book> /

       128          5                 1             1812564            1812604           42240           1

--最後一次讀取量明顯減少,這樣可以加快1級備份的速度。

SCOTT@book> alter database disable block change tracking ;

$ ll /home/oracle/backup/change_tracking.dbf

ls: /home/oracle/backup/change_tracking.dbf: No such file or directory

總結:

1.使用增量備份模式,最好打開塊跟蹤模式。加快1級備份以及累積備份的速度。

2.注意檢查0級備份是否完好,如果删除或者損壞,後果比較嚴重。

繼續閱讀