zoukankan      html  css  js  c++  java
  • RMAN(catalog)

    五个级别:0(完全),1,2,3,4,5.级别越大,备份的数据块相对越小

    1.增量备份

       例如:周日---0(完全)

              周一---2(周一变化的所有数据块)

              周二---2(周二变化的所有数据块)

              周三---1(周一到周三间变化的所有数据块)

              周四---2(周四变化的所有数据块)

              周五---2(周五变化的所有数据块)

               周六---2(周六变化的所有数据块)

        backup incremental level 0 format='d:\backup\%d_%s.dbf' tablespace users;

        backup incremental level 2 format='d:\backup\%d_%s.dbf' tablespace users;

        backup incremental level 1 format='d:\backup\%d_%s.dbf' tablespace users;

    2.累积备份

       例如:周日---0(完全)

              周一---2(周一变化的所有数据块)

              周二---2(周日到周二变化的所有数据块)

              周三---1(周日到周三间变化的所有数据块)

              周四---2(周三到周四变化的所有数据块)

              周五---2(周三到周五变化的所有数据块)

               周六---2(周三到周六变化的所有数据块)

         backup incremental level 0 format='d:\backup\%d_%s.dbf' tablespace users;

        backup incremental level 2 format='d:\backup\%d_%s.dbf' tablespace users;

        backup incremental level 2 cumulative format='d:\backup\%d_%s.dbf' tablespace users;

         backup incremental level 1 format='d:\backup\%d_%s.dbf' tablespace users;

    -----------------------------------------------------------------------------

    准备工作:

    创建恢复目录
    1、在目录数据库中创建恢复目录所用表空间
    SQL> create tablespace rmants datafile 'c:\oracle\oradata\cc\rmants.ora' size 20M ;
    表空间已创建。
    2、在目录数据库中创建RMAN 用户并授权
    SQL> create user rman identified by rman default tablespace rmants temporary tablespace temp quota
    unlimited on rmants;
    用户已创建
    SQL> grant recovery_catalog_owner to rman ;
    授权成功。
    3、在目录数据库中创建恢复目录
    C:\>rman catalog rman/rman
    恢复管理器:版本8.1.7.0.0 - Production
    RMAN-06008:连接到恢复目录数据库
    RMAN-06428:未安装恢复目录
    RMAN>create catalog tablespace rmants;
    RMAN-06431:恢复目录已创建
    4、注册目标数据库到恢复目录
    注意哦,这里我的目标数据库使用的服务名称是rman,意思为要使用RMAN 进行备份的数据库,而目录
    数据库使用的服务名称是CC。
    C:\>rman target sys/sys@rman
    恢复管理器:版本8.1.7.0.0 - Production
    RMAN-06005:连接到目标数据库:RMAN (DBID=1303772234)
    RMAN>connect catalog rman/rman@cc
    RMAN-06008:连接到恢复目录数据库
    RMAN>register database;
    RMAN-03022:正在编译命令:register
    RMAN-03023:正在执行命令:register
    RMAN-08006:注册在恢复目录中的数据库
    RMAN-03023:正在执行命令:full resync
    RMAN-08002:正在启动全部恢复目录的resync
    RMAN-08004:完成全部resync
    好了,到此为止前面的准备工作都做好了,下面就可以使用RMAN 来进行备份和恢复了。

    每半年做一个数据库的全备份(包含只读表空间)

    每个月做一次零级备份(不包含只读表空间)

    每个星期做一次一级备份

    每天做一个二级备份

    数据库全备份脚本:

    run {

    allocate channel c1 type disk;

    allocate channel c2 type disk;

    allocate channel c3 type disk;

    backup full tag 'dbfull' format '/backup/ncfc/full%d_%p_%t' database ;

    sql 'alter system archive log current' ;

    backup format /backup/ncfc/dbL0/dbL0%d_%p_%t.arc' filesperset 5 archivelog all delete input;

    release channel c1;

    release channel c2;

    release channel c3;

    }

    零级备份脚本(只读表空间除外)

    run {

    allocate channel c1 type disk maxpiecesize =;

    allocate channel c2 type disk maxpiecesize =;

    allocate channel c3 type disk maxpiecesize =;

    backup incremental level 0 filesperset 10 tag 'dbL0' format '/backup/ncfc/dbL0/dbL0%u_%p_%c ' database skip readonly;

    sql 'alter system archive log current' ;

    backup format '/backup/ncfc/dbL0/arch%u_%p_%c.arc' filesperset 5 archivelog from time "sysdate-1" all;

    release channel c1;

    release channel c2;

    release channel c3;

    }

    一级备份脚本

    run {

    allocate channel c1 type disk maxpiecesize =;

    allocate channel c2 type disk maxpiecesize =;

    allocate channel c3 type disk maxpiecesize =;

    backup incremental level 1 filesperset 5 tag 'dbL1' format '/backup/ncfc/dbL1/dbL1%d_%p_%t ' ddatabase skip readonly;

    sql 'alter system archive log current' ;

    backup format '/backup/ncfc/dbL1/dbL1%d_%p_%t.arc' filesperset 5 archivelog from time "sysdate-1" all;

    release channel c1;

    release channel c2;

    release channel c3;

    }

    二级备份脚本

    run {

    allocate channel c1 type disk maxpiecesize =;

    allocate channel c2 type disk maxpiecesize =;

    allocate channel c3 type disk maxpiecesize =;

    backup incremental level 2 filesperset 5 tag 'dbL2' format '/backup/ncfc/dbL2/dbL2%u_%p_%c' ddatabase skip readonly;

    sql 'alter system archive log current' ;

    backup format '/backup/ncfc/dbL2/dbL2%d_%p_%t.arc' filesperset 5 archivelog from time "sysdate-1" all;

    release channel c1;

    release channel c2;

    release channel c3;

    }

    归档文件备份脚本

    run {

        allocate channel dev1 type disk maxpiecesize =;

        allocate channel dev2 type disk maxpiecesize =;

        allocate channel dev3 type disk maxpiecesize =;

        sql 'alter system archive log current' ;

        backup format '/backup/ncfc/arc/arch%u_%p_%c ' archivelog from time "sysdate-1" all;

        release channel dev1;

        release channel dev2;

        release channel dev3;

    }

    表空间备份脚本(以users表空间为例)

    run {

    allocate channel c1 type disk;

    allocate channel c2 type disk;

    allocate channel c3 type disk;

    backup tag 'tabsp' format '/backup/ncfc/tabsp/tabsp%u_%p_%c' tablespace users;

    sql 'alter system archive log current' ;

    backup format 'e:\oradata\%d_%p_%t.arc' filesperset 5 archivelog all delete input;

    release channel c1;

    release channel c2;

    release channel c3;

    }

    则每天所需要备份的数据量只有一天的改变量。而做恢复时最多只要恢复当月的一个零级备份+三个一级备份+6个二级备份+当天的归档文件。如果不能接受这样的恢复时间,就只能够减少零级备份之间的时间间隔(如可以每个星期做一个零级备份,这样恢复时最多只需要恢复一个星期的数据量)。

    备份CATALOG数据库(数据库逻辑输出)

    exp pafile=exp.dat

    其中exp.dat如下

    userid=rman/rman

    file=rmanexp.dmp

    ------------------------------------------

    用filesperset控制备份集的尺寸
    当指定filesperset参数时,rman比较filesperset与自动计算出来的值(对每个已分配通道的文件数目)并取其中较小的那个值来保证所有的通道被使用。
    如果指定或者通过组合backupSpec语句暗示的文件数目比filesperset要大,那么rman创建多个备份集来维护正确的速率(ratio);
    如果没有指定filesperset,rman比较计算出来的值(文件数目除以已分配的通道)和默认值64,并取其中较小的那个值来保证所有通道可用。
    Rman通常尝试创建足够的备份集以使所有已分配的通道有事可做。一个例外是通道比要备份的文件还要多

  • 相关阅读:
    Visual C++ 打印编程技术-内存设备环境
    MySQL存储引擎
    记录阿里云服务器docker安装wordpress
    记录dockerfile参数
    记录一次 在公网使用FRP内网穿透开源软件,通过SSH连接内网服务器
    记录一次docker安装zabbix5.0
    记录一次zabbix邮件告警搭建过程和问题处理
    记录一次yum-config-manager命令的使用
    记录一次解决zabbix5.0图形化界面文字乱码的问题
    记录一次查看本地端口10050被哪个IP地址访问
  • 原文地址:https://www.cnblogs.com/danghuijian/p/4400386.html
Copyright © 2011-2022 走看看