zoukankan      html  css  js  c++  java
  • 【RMAN】使用RMAN的 Compressed Backupsets备份压缩技术 (转载)

    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 / <<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 --

  • 相关阅读:
    cmd net use
    Linux虚拟机安装VMware Tools
    转:完成端口(Completion Port)详解
    很幽默的讲解六种Socket IO模型
    重新学习二叉树作的几道习题
    RuntimeException和Exception区别
    不同概率的抽奖
    SpringMVC的几种返回方式
    mybatis动态sql trim
    Tomcat 7最大并发连接数的正确修改方法
  • 原文地址:https://www.cnblogs.com/-abm/p/9322439.html
Copyright © 2011-2022 走看看