【RMAN】使用RMAN的 Compressed Backupsets備份壓縮技術

swq618發表於2016-11-03
1.Oracle參考文件中關於RMAN備份壓縮的描述
1)關於如何透過調整RMAN引數啟用取消備份壓縮功能

使用關鍵字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命令啟用備份壓縮功能

兩條壓縮備份的RMAN語句,第一條語句實現對整個資料庫及歸檔日誌進行壓縮備份,第二條命令實現對1、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 / <<EOF
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 / <<EOF
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換取空間的做法。如果系統有合理的備份視窗,不妨將這項技術引入到日常備份中去。

Good luck.

secooler
10.07.21

-- The End --

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

相關文章