• RMAN备份策略


    前言

    对Oracle数据库制定一个有效的备份策略,使用RMAN做增量备份,减少每次都全备所带来的时间、系统资源和存储空间的占用,同时也尽量地减少恢复数据库的时间。

     一、备份规划

    二、RMAN配置

    RMAN> show all;
    
    RMAN configuration parameters for database with db_unique_name ORCL are:
    CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
    CONFIGURE BACKUP OPTIMIZATION OFF; # default
    CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
    CONFIGURE CONTROLFILE AUTOBACKUP ON;
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/home/backup/controlfile/%F';
    CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
    CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
    CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
    CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/home/backup/backup_%U';
    CONFIGURE MAXSETSIZE TO UNLIMITED; # default
    CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
    CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
    CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
    CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
    CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_orcl.f'; # default

    三、备份脚本

     3.1、0级备份脚本

    #!/usr/bin/bash
    export ORACLE_SID=orcl 
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
    DATE=`date +%y-%m-%d`
    $ORACLE_HOME/bin/rman target / log=/home/scripts/rman/log/${DATE}_L0.log <<EOF
    run
    {
    allocate channel c1 device type disk;
    allocate channel c2 device type disk;
    sql 'alter system archive log current';
    backup filesperset 2 incremental level 0 tag 'level0' format '/home/backup/level0/lvl0_%d_%T_%U' database include current controlfile;
    sql 'alter system archive log current';
    backup  filesperset 2 archivelog all tag 'arch_level0' format '/home/backup/arch/arch_lvl0_%d_%T_%U' delete all input;
    crosscheck backup;
    crosscheck archivelog all;
    delete noprompt expired backup;
    delete noprompt expired archivelog all;
    delete noprompt obsolete;
    release channel c1;
    release channel c2;
    }
    EOF

    3.2、1级备份脚本

    #!/usr/bin/bash
    export ORACLE_SID=orcl 
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
    DATE=`date +%y-%m-%d`
    $ORACLE_HOME/bin/rman target / log=/home/scripts/rman/log/${DATE}_L1.log <<EOF
    run
    {
    allocate channel c1 device type disk;
    allocate channel c2 device type disk;
    sql 'alter system archive log current';
    backup filesperset 2 incremental level 1 tag 'level1' format '/home/backup/level1/lvl1_%d_%T_%U' database include current controlfile;
    sql 'alter system archive log current';
    backup filesperset 2 archivelog all tag 'arch_level1' format '/home/backup/arch/arch_lvl1_%d_%T_%U' delete all input;
    crosscheck backup;
    crosscheck archivelog all;
    delete noprompt expired backup;
    delete noprompt expired archivelog all;
    delete noprompt obsolete;
    release channel c1;
    release channel c2;
    }
    EOF

    3.3、2级备份脚本

    #!/usr/bin/bash
    export ORACLE_SID=orcl 
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
    DATE=`date +%y-%m-%d`
    $ORACLE_HOME/bin/rman target / log=/home/scripts/rman/log/${DATE}_L2.log <<EOF
    run
    {
    allocate channel c1 device type disk;
    allocate channel c2 device type disk;
    sql 'alter system archive log current';
    backup filesperset 2 incremental level 2 tag 'level2' format '/home/backup/level2/lvl2_%d_%T_%U' database include current controlfile;
    sql 'alter system archive log current';
    backup filesperset 2 archivelog all tag 'arch_level2' format '/home/backup/arch/arch_lvl2_%d_%T_%U' delete all input;
    crosscheck backup;
    crosscheck archivelog all;
    delete noprompt expired backup;
    delete noprompt expired archivelog all;
    delete noprompt obsolete;
    release channel c1;
    release channel c2;
    }
    EOF

    四、添加脚本到定时任务

    0 2 * * 0 nohup sh /home/scripts/rman/bak/rman0.sh >/dev/null 2>&1 &
    0 2 * * 1 nohup sh /home/scripts/rman/bak/rman2.sh >/dev/null 2>&1 &
    0 2 * * 2 nohup sh /home/scripts/rman/bak/rman2.sh >/dev/null 2>&1 &
    0 2 * * 3 nohup sh /home/scripts/rman/bak/rman1.sh >/dev/null 2>&1 &
    0 2 * * 4 nohup sh /home/scripts/rman/bak/rman2.sh >/dev/null 2>&1 &
    0 2 * * 5 nohup sh /home/scripts/rman/bak/rman2.sh >/dev/null 2>&1 &
    0 2 * * 6 nohup sh /home/scripts/rman/bak/rman2.sh >/dev/null 2>&1 &
  • 相关阅读:
    培训课程大纲
    十个心理细节
    海马记忆训练
    手把手教你_怎么找android应用的包名和启动activity
    LoaderManager使用具体解释(四)---实例:AppListLoader
    strtok函数
    猫猫学iOS 之微博项目实战(2)微博主框架-自己定义导航控制器NavigationController
    OpenCV实践之路——Python的安装和使用
    状态模式
    一个有意思的Ruby Webdriver超时问题的解决过程
  • 原文地址:https://www.cnblogs.com/shaozi/p/8392748.html
Copyright © 2020-2023  润新知