Oracle11新特性——備份恢復功能增強(二)

yangtingkun發表於2007-11-21

打算寫一系列的文章介紹11g的新特性和變化。

Oracle11g在備份和恢復方面新增了很多的功能,無論是效能、功能性、安全性和可操作性方面都有了不同程度的提高。

這一篇介紹RMAN在備份級壓縮方面的提高。

Oracle11新特性——備份恢復功能增強(一):http://yangtingkun.itpub.net/post/468/412991


Oracle10g增加了對備份集壓縮的功能,11g在這方面進行了增強,新增了另外一種壓縮演算法,這種新的壓縮演算法(ZLIB)提供更快的壓縮效率,但是產生的壓縮檔案會比預設壓縮演算法(BZIP2)要大一些。

下面看一下兩種壓縮演算法的對比:

$ rman target /

Recovery Manager: Release 11.1.0.6.0 - Production on Wed Nov 21 15:31:01 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: TEST11G (DBID=790993044)

RMAN> report schema;

using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name TEST11G

List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 1024 SYSTEM *** /data/oracle/oradata/test11g/system01.dbf
2 1450 SYSAUX *** /data/oracle/oradata/test11g/sysaux01.dbf
3 2048 UNDOTBS1 *** /data/oracle/oradata/test11g/undotbs01.dbf
4 5 USERS *** /data/oracle/oradata/test11g/users01.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 2048 TEMP 131071 /data/oracle/oradata/test11g/temp01.dbf

RMAN> backup tablespace system;

Starting backup at 21-NOV-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=56 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/oracle/oradata/test11g/system01.dbf
channel ORA_DISK_1: starting piece 1 at 21-NOV-07
channel ORA_DISK_1: finished piece 1 at 21-NOV-07
piece handle=/data/backup/0rj1k4qd_1_1 tag=TAG20071121T153124 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 21-NOV-07
channel ORA_DISK_1: finished piece 1 at 21-NOV-07
piece handle=/data/backup/0sj1k4s2_1_1 tag=TAG20071121T153124 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-NOV-07

RMAN> backup as compressed backupset tablespace system;

Starting backup at 21-NOV-07
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/oracle/oradata/test11g/system01.dbf
channel ORA_DISK_1: starting piece 1 at 21-NOV-07
channel ORA_DISK_1: finished piece 1 at 21-NOV-07
piece handle=/data/backup/0tj1k4to_1_1 tag=TAG20071121T153312 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:36
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 21-NOV-07
channel ORA_DISK_1: finished piece 1 at 21-NOV-07
piece handle=/data/backup/0uj1k51a_1_1 tag=TAG20071121T153312 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-NOV-07

RMAN> show compression algorithm;

RMAN configuration parameters for database with db_unique_name TEST11G are:
CONFIGURE COMPRESSION ALGORITHM 'BZIP2';

RMAN> configure compression algorithm 'ZLIB';

old RMAN configuration parameters:
CONFIGURE COMPRESSION ALGORITHM 'BZIP2';
new RMAN configuration parameters:
CONFIGURE COMPRESSION ALGORITHM 'ZLIB';
new RMAN configuration parameters are successfully stored

RMAN> backup as compressed backupset tablespace system;

Starting backup at 21-NOV-07
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/oracle/oradata/test11g/system01.dbf
channel ORA_DISK_1: starting piece 1 at 21-NOV-07
channel ORA_DISK_1: finished piece 1 at 21-NOV-07
piece handle=/data/backup/0vj1k59v_1_1 tag=TAG20071121T153943 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 21-NOV-07
channel ORA_DISK_1: finished piece 1 at 21-NOV-07
piece handle=/data/backup/10j1k5c9_1_1 tag=TAG20071121T153943 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-NOV-07

RMAN> list backup of tablespace system;


List of Backup Sets
===================


BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
27 Full 730.97M DISK 00:00:51 21-NOV-07
BP Key: 27 Status: AVAILABLE Compressed: NO Tag: TAG20071121T153124
Piece Name: /data/backup/0rj1k4qd_1_1
List of Datafiles in backup set 27
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 886894 21-NOV-07 /data/oracle/oradata/test11g/system01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
29 Full 132.84M DISK 00:01:52 21-NOV-07
BP Key: 29 Status: AVAILABLE Compressed: YES Tag: TAG20071121T153312
Piece Name: /data/backup/0tj1k4to_1_1
List of Datafiles in backup set 29
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 886989 21-NOV-07 /data/oracle/oradata/test11g/system01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
31 Full 146.19M DISK 00:01:10 21-NOV-07
BP Key: 31 Status: AVAILABLE Compressed: YES Tag: TAG20071121T153943
Piece Name: /data/backup/0vj1k59v_1_1
List of Datafiles in backup set 31
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 887443 21-NOV-07 /data/oracle/oradata/test11g/system01.dbf

從上面的備份結果看,不加壓縮的備份方法速度最快,只需要36秒,但是產生的結果集也最大有731M,而採用預設的壓縮演算法BZIP2,結果集大小隻有133M,但是花費時間最多,需要152秒。而11g增加的新演算法ZLIB,結果集比BZIP2演算法稍大為146M,但是花費的時間卻少了很多,只需要55秒就完成了備份。

應該說,這種新演算法的空間時間比率是最好的。

對於壓縮率比較大的情況,這種演算法的速度甚至可能超過不進行壓縮的情況:

RMAN> backup tablespace sysaux;

Starting backup at 21-NOV-07
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/data/oracle/oradata/test11g/sysaux01.dbf
channel ORA_DISK_1: starting piece 1 at 21-NOV-07
channel ORA_DISK_1: finished piece 1 at 21-NOV-07
piece handle=/data/backup/11j1k7sa_1_1 tag=TAG20071121T162338 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:16
Finished backup at 21-NOV-07

RMAN> backup as compressed backupset tablespace sysaux;

Starting backup at 21-NOV-07
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/data/oracle/oradata/test11g/sysaux01.dbf
channel ORA_DISK_1: starting piece 1 at 21-NOV-07
channel ORA_DISK_1: finished piece 1 at 21-NOV-07
piece handle=/data/backup/12j1k83c_1_1 tag=TAG20071121T162724 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
Finished backup at 21-NOV-07

RMAN> configure compression algorithm 'BZIP2';

old RMAN configuration parameters:
CONFIGURE COMPRESSION ALGORITHM 'ZLIB';
new RMAN configuration parameters:
CONFIGURE COMPRESSION ALGORITHM 'BZIP2';
new RMAN configuration parameters are successfully stored

RMAN> backup as compressed backupset tablespace sysaux;

Starting backup at 21-NOV-07
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/data/oracle/oradata/test11g/sysaux01.dbf
channel ORA_DISK_1: starting piece 1 at 21-NOV-07
channel ORA_DISK_1: finished piece 1 at 21-NOV-07
piece handle=/data/backup/13j1k8ed_1_1 tag=TAG20071121T163317 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
Finished backup at 21-NOV-07

RMAN> list backup of tablespace sysaux;


List of Backup Sets
===================


BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
33 Full 1.13G DISK 00:01:28 21-NOV-07
BP Key: 33 Status: AVAILABLE Compressed: NO Tag: TAG20071121T162338
Piece Name: /data/backup/11j1k7sa_1_1
List of Datafiles in backup set 33
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 890660 21-NOV-07 /data/oracle/oradata/test11g/sysaux01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
34 Full 60.66M DISK 00:01:03 21-NOV-07
BP Key: 34 Status: AVAILABLE Compressed: YES Tag: TAG20071121T162724
Piece Name: /data/backup/12j1k83c_1_1
List of Datafiles in backup set 34
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 890866 21-NOV-07 /data/oracle/oradata/test11g/sysaux01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
35 Full 51.53M DISK 00:01:40 21-NOV-07
BP Key: 35 Status: AVAILABLE Compressed: YES Tag: TAG20071121T163317
Piece Name: /data/backup/13j1k8ed_1_1
List of Datafiles in backup set 35
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 891231 21-NOV-07 /data/oracle/oradata/test11g/sysaux01.dbf

造成這個問題的原因就是壓縮比率比較高,磁碟寫入1G資料的時間超過了ZLIB壓縮演算法所花費的時間。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4227/viewspace-69510/,如需轉載,請註明出處,否則將追究法律責任。

相關文章