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语句,第一条语句实现对整个数据库及归档日志进行压缩备份,第二条命令实现对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 / <<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;
CONFIGURE COMPRESSION ALGORITHM '';
About Me
........................................................................................................................ ● 本文作者:小麦苗,部分内容整理自网络,若有侵权请联系小麦苗删除 ● 本文在itpub、博客园、CSDN和个人微 信公众号( xiaomaimiaolhr )上有同步更新 ● 本文itpub地址: http://blog.itpub.net/26736162 ● 本文博客园地址: http://www.cnblogs.com/lhrbest ● 本文CSDN地址: https://blog.csdn.net/lihuarongaini ● 本文pdf版、个人简介及小麦苗云盘地址: http://blog.itpub.net/26736162/viewspace-1624453/ ● 数据库笔试面试题库及解答: http://blog.itpub.net/26736162/viewspace-2134706/ ● DBA宝典今日头条号地址: http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826 ........................................................................................................................ ● QQ群号: 230161599 (满) 、618766405 ● 微 信群:可加我微 信,我拉大家进群,非诚勿扰 ● 联系我请加QQ好友 ( 646634621 ) ,注明添加缘由 ● 于 2019-08-01 06:00 ~ 2019-08-31 24:00 在西安完成 ● 最新修改时间:2019-08-01 06:00 ~ 2019-08-31 24:00 ● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解 ● 版权所有,欢迎分享本文,转载请保留出处 ........................................................................................................................ ● 小麦苗的微店 : https://weidian.com/s/793741433?wfr=c&ifr=shopdetail ● 小麦苗出版的数据库类丛书 : http://blog.itpub.net/26736162/viewspace-2142121/ ● 小麦苗OCP、OCM、高可用网络班 : http://blog.itpub.net/26736162/viewspace-2148098/ ● 小麦苗腾讯课堂主页 : https://lhr.ke.qq.com/ ........................................................................................................................ 使用 微 信客户端 扫描下面的二维码来关注小麦苗的微 信公众号( xiaomaimiaolhr )及QQ群(DBA宝典)、添加小麦苗微 信, 学习最实用的数据库技术。
........................................................................................................................ |
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26736162/viewspace-2653257/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26736162/viewspace-2653257/