RMAN的壓縮備份算法
1.Oracle參考文檔中關於RMAN備份壓縮的描述
1)關於如何經過調整RMAN參數啓用取消備份壓縮功能
http://download.oracle.com/docs/cd/B19306_01/backup.102/b14192/setup004.htm#sthref229
使用關鍵字COMPRESSED啓用RMAN壓縮備份方法
RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET;
去掉COMPRESSED關鍵字取消RMAN壓縮備份方法
RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET;
2)關於如何直接使用RMAN命令啓用備份壓縮功能
http://download.oracle.com/docs/cd/B19306_01/backup.102/b14192/bkup002.htm#BRBSC138
兩條壓縮備份的RMAN語句,第一條語句實現對整個數據庫及歸檔日誌進行壓縮備份,第二條命令實現對一、2和4號數據文件進行壓縮備份。
BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG;
BACKUP AS COMPRESSED BACKUPSET DATAFILE 1,2,4;
2.測試壓縮備份
1)測試腳本
(1)具備壓縮功能的測試腳本
[oracle@secdb rmanbak]$ cat test_rman_compress.sh
date
rman target / <<1eof<1 span="">
backup as compressed backupset full database format '/u01/app/oracle/rmanbak/full_bk1_%u%p%s.rmn';
exit;
EOF
date
(2)不含壓縮功能的測試腳本
[oracle@secdb rmanbak]$ cat test_rman_nocompress.sh
date
rman target / <<1eof<1 span="">
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET;
backup full database format '/u01/app/oracle/rmanbak/full_bk1_%u%p%s.rmn';
exit;
EOF
date
3.執行RMAN測試腳本及結論分析
1)具備壓縮功能的測試腳本執行輸出結果
[oracle@secdb rmanbak]$ sh test_rman_compress.sh
Thu Jul 21 22:29:46 CST 2010
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jul 21 22:29:46 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: SECOOLER (DBID=4067316777)
RMAN>
Starting backup at 21-JUL-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=152 devtype=DISK
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/secooler/system01.dbf
input datafile fno=00017 name=/u01/app/oracle/oradata/secooler/tbs_perf_01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/secooler/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/secooler/example01.dbf
input datafile fno=00007 name=/u01/app/oracle/oradata/secooler/tbs_rman_catalog01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/secooler/undotbs01.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/secooler/user_08.dbf
input datafile fno=00018 name=/u01/app/oracle/oradata/secooler/EXAMPLE1_01.dbf
input datafile fno=00019 name=/u01/app/oracle/oradata/secooler/OLTP_01.dbf
input datafile fno=00020 name=/u01/app/oracle/oradata/secooler/OLTP_02.dbf
input datafile fno=00008 name=/u01/app/oracle/oradata/secooler/tbs1.dbf
input datafile fno=00014 name=/u01/app/oracle/oradata/secooler/indx_01.dbf
input datafile fno=00016 name=/u01/app/oracle/oradata/secooler/tbs_assm_01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/secooler/users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-JUL-10
channel ORA_DISK_1: finished piece 1 at 21-JUL-10
piece handle=/u01/app/oracle/rmanbak/full_bk1_2nlje62e187.rmn tag=TAG20100721T222949 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00009 name=/u01/app/oracle/oradata/secooler/DATA01_02.dbf
input datafile fno=00010 name=/u01/app/oracle/oradata/secooler/DATA01_03.dbf
input datafile fno=00011 name=/u01/app/oracle/oradata/secooler/DATA01_04.dbf
input datafile fno=00012 name=/u01/app/oracle/oradata/secooler/DATA01_05.dbf
input datafile fno=00013 name=/u01/app/oracle/oradata/secooler/DATA01_01.dbf
input datafile fno=00015 name=/u01/app/oracle/oradata/secooler/lob_data01.dbf
channel ORA_DISK_1: starting piece 1 at 21-JUL-10
channel ORA_DISK_1: finished piece 1 at 21-JUL-10
piece handle=/u01/app/oracle/rmanbak/full_bk1_2olje653188.rmn tag=TAG20100721T222949 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 21-JUL-10
Starting Control File and SPFILE Autobackup at 21-JUL-10
piece handle=/u01/app/oracle/rmanbak/cf_c-4067316777-20100721-0e comment=NONE
Finished Control File and SPFILE Autobackup at 21-JUL-10
RMAN>
Recovery Manager complete.
Thu Jul 21 22:31:30 CST 2010
2)不含壓縮功能的測試腳本執行輸出結果
[oracle@secdb rmanbak]$ sh test_rman_nocompress.sh
Thu Jul 21 22:39:29 CST 2010
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jul 21 22:39:29 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: SECOOLER (DBID=4067316777)
RMAN>
using target database control file instead of recovery catalog
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET PARALLELISM 1;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET PARALLELISM 1;
new RMAN configuration parameters are successfully stored
RMAN>
Starting backup at 21-JUL-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=152 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/secooler/system01.dbf
input datafile fno=00017 name=/u01/app/oracle/oradata/secooler/tbs_perf_01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/secooler/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/secooler/example01.dbf
input datafile fno=00007 name=/u01/app/oracle/oradata/secooler/tbs_rman_catalog01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/secooler/undotbs01.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/secooler/user_08.dbf
input datafile fno=00018 name=/u01/app/oracle/oradata/secooler/EXAMPLE1_01.dbf
input datafile fno=00019 name=/u01/app/oracle/oradata/secooler/OLTP_01.dbf
input datafile fno=00020 name=/u01/app/oracle/oradata/secooler/OLTP_02.dbf
input datafile fno=00008 name=/u01/app/oracle/oradata/secooler/tbs1.dbf
input datafile fno=00014 name=/u01/app/oracle/oradata/secooler/indx_01.dbf
input datafile fno=00016 name=/u01/app/oracle/oradata/secooler/tbs_assm_01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/secooler/users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-JUL-10
channel ORA_DISK_1: finished piece 1 at 21-JUL-10
piece handle=/u01/app/oracle/rmanbak/full_bk1_2tlje6kl193.rmn tag=TAG20100721T223932 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00009 name=/u01/app/oracle/oradata/secooler/DATA01_02.dbf
input datafile fno=00010 name=/u01/app/oracle/oradata/secooler/DATA01_03.dbf
input datafile fno=00011 name=/u01/app/oracle/oradata/secooler/DATA01_04.dbf
input datafile fno=00012 name=/u01/app/oracle/oradata/secooler/DATA01_05.dbf
input datafile fno=00013 name=/u01/app/oracle/oradata/secooler/DATA01_01.dbf
input datafile fno=00015 name=/u01/app/oracle/oradata/secooler/lob_data01.dbf
channel ORA_DISK_1: starting piece 1 at 21-JUL-10
channel ORA_DISK_1: finished piece 1 at 21-JUL-10
piece handle=/u01/app/oracle/rmanbak/full_bk1_2ulje6mn194.rmn tag=TAG20100721T223932 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 21-JUL-10
Starting Control File and SPFILE Autobackup at 21-JUL-10
piece handle=/u01/app/oracle/rmanbak/cf_c-4067316777-20100721-10 comment=NONE
Finished Control File and SPFILE Autobackup at 21-JUL-10
RMAN>
Recovery Manager complete.
Thu Jul 21 22:41:06 CST 2010
3)比較時間消耗
從elapsed time能夠得出如下信息:
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
啓用壓縮耗時: 00:01:25 + 00:00:07 = 00:01:32
未啓用壓縮耗時:00:01:05 + 00:00:15 = 00:01:20
結論:啓用壓縮備份耗時略有增長(在數據量較大的環境下這個時間差會比較大)。
4)從top監控CPU使用率上進行比較
啓用壓縮備份期間CPU使用率監控結果
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4972 oracle 25 0 424m 52m 23m R 65.4 0.6 0:32.62 oracle
未啓用壓縮備份期間CPU使用率監控結果
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5902 oracle 25 0 423m 47m 25m R 33.1 0.6 0:09.17 oracle
結論:啓用壓縮CPU使用率在65.4%左右,未啓用時的CPU使用率在33.1%左右。差異很明顯,啓用壓縮將消耗更多的CPU資源。
5)比較生成的備份集大小
壓縮備份集大小
[oracle@secdb rmanbak]$ du -sm /u01/app/oracle/rmanbak/full_bk1_2nlje62e187.rmn
168 /u01/app/oracle/rmanbak/full_bk1_2nlje62e187.rmn
未壓縮備份集大小
[oracle@secdb rmanbak]$ du -sm /u01/app/oracle/rmanbak/full_bk1_2tlje6kl193.rmn
951 /u01/app/oracle/rmanbak/full_bk1_2tlje6kl193.rmn
結論:啓用壓縮功能,備份集大小是168M,而未啓用壓縮功能的備份集大小有951M大,是壓縮備份集的5.7倍。這就是壓縮備份帶來的最大好處。
4.小結
使用RMAN備份壓縮技術能夠在很大程度上節省存儲備份的空間,是典型的以時間和CPU換取空間的作法。若是系統有合理的備份窗口,不妨將這項技術引入到平常備份中去。
數據庫
binary compression:這個是手動在執行rman命令的時候要加as compressed命令的。當磁盤空間不夠的時候能夠考慮壓縮備份這種特性。壓縮率比較驚人。能夠達到1/2-1/4。可是這種高壓縮也是有缺點的。就是恢復起來比較慢。這個主要是在磁盤和cpu之間來作衡量。 11g 又出來了zlib壓縮算法,這種算法比以前要快。可是壓縮率不如以前的bzip2.網絡
RMAN> backup as compressed backupset archivelog all;
RMAN> backup as compressed backupset database;
RMAN> backup as compressed backupset current controlfile; oracle
CONFIGURE COMPRESSION ALGORITHM ''; app
Oracle10g容許你和BACKUP命令伴隨使用AS COMPRESSED BACKUPSET字句,對備份集進行壓縮。 ide
這個壓縮備份在恢復時無需解壓縮,這一特性在如下條件下可能大爲有益: 測試
1.你的備份存儲空間有限 spa
2.經過網絡備份而帶寬有限 日誌
3.直接備份至磁帶、CD,DVD介質而壓縮不可用 orm
你能夠選擇在備份命令裏顯示指定壓縮選項:
BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG;
--僅對1,5文件壓縮備份
BACKUP AS COMPRESSED BACKUPSET DATAFILE 1,5;
也能夠配置RMAN指定壓縮選項:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET;