Oracle11g在
备份和
恢复方面新增了很多的功能,无论是
性能、功能性、
安全性和可操作性方面都有了不同程度的提高。
这一篇介绍RMAN在备份级压缩方面的提高。
Oracle11新特性——备份恢复功能增强(一):
http://yangtingkun.itpub.net/post/468/412991Oracle10g增加了对备份集压缩的功能,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,但是花费时间最多,需要1分52秒。而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压缩算法所花费的时间。