我是靠谱客的博主 友好橘子,最近开发中收集的这篇文章主要介绍我们的RMAN体系,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1、体系:采用LINUX CRONTAB定时计划调用SHELL,执行RMAN

[oracle@DB]$ crontab -l
0 1 * * 0 /u01/bak/rman/script/inc0.sh
0 1 * * 1 /u01/bak/rman/script/inc2.sh
0 1 * * 2 /u01/bak/rman/script/inc2.sh
0 1 * * 3 /u01/bak/rman/script/inc2.sh
0 1 * * 4 /u01/bak/rman/script/inc1.sh
0 1 * * 5 /u01/bak/rman/script/inc2.sh
0 1 * * 6 /u01/bak/rman/script/inc2.sh

2、相关脚本

drwxrwxrwx 2 oracle oinstall 4096 03-10 08:19 log
-rw------- 1 oracle oinstall 4458 03-09 17:37 nohup.out
-rwxrwxrwx 1 oracle oinstall   69 03-09 09:37 connect.rcv
-rwxrwxrwx 1 oracle oinstall   84 03-08 16:17 inc0.rcv
-rwxrwxrwx 1 oracle oinstall  165 03-08 16:17 inc0.sh
-rwxrwxrwx 1 oracle oinstall   84 03-08 16:17 inc1.rcv
-rwxrwxrwx 1 oracle oinstall  163 03-08 16:17 inc1.sh
-rwxrwxrwx 1 oracle oinstall   84 03-08 16:17 inc2.rcv
-rwxrwxrwx 1 oracle oinstall  164 03-08 16:17 inc2.sh

3、inc0.sh内容

export ORACLE_HOME=/home/oracle/product/10.2.0/db_1
nohup $ORACLE_HOME/bin/rman  cmdfile=/u01/bak/rman/script/inc0.rcv log=/u01/bak/rman/script/log/inc0.log append

 4、inc0.rcv 内容

@@/u01/bak/rman/script/connect.rcv
run{
execute global script global_inc0;
}
exit;

5、看看global_inc0是什么
-----是在RMAN中注册的脚本

replace global script global_inc0
comment ' A script for backup database using incremental level 0'
{
 execute global script global_del_obso;
 allocate channel ch1 device type disk;
 set limit channel ch1 readrate=10240;
 set limit channel ch1 kbytes=2048000;
 backup as compressed backupset incremental level 0 database
 format='/u01/bak/rman/inc0_%d_%U'
 tag='Inc0';
 release channel ch1;
 execute global script global_arch;
 execute global script global_bkctl;
}

 global_del_obso又是什么

--创建全局删除废弃备份的脚本
create global script global_del_obso 
comment 'A script for obsolete backup and delete it' {
allocate channel ch1 device type disk;
delete obsolete recovery window of 7 days; 
release channel ch1;
}

======================

再来看看其他注册的脚本

 

create global script global_arch
comment ' A script for archivelog and delete it '
{
   allocate channel ch1 device type disk;
   sql " alter system archive log current";
   set limit channel ch1 readrate=10240;
   set limit channel ch1 kbytes=2048000;
   backup as compressed backupset archivelog all delete input
   format='/u01/bak/rman/arch_%d_%U'
   tag='Archbk';
   release channel ch1;
  }
 

replace global script global_inc1
comment ' A script for backup database using incremental level 1'
{
 execute global script global_del_obso;
 allocate channel ch1 device type disk;
 set limit channel ch1 readrate=10240;
 set limit channel ch1 kbytes=2048000;
 backup as compressed backupset incremental level 1 database
 format='/u01/bak/rman/inc1_%d_%U'
 tag='Inc1';
 release channel ch1;
 execute global script global_arch;
 execute global script global_bkctl;
}

replace global script global_inc2
comment ' A script for backup database using incremental level 2'
{
 execute global script global_del_obso;
 allocate channel ch1 device type disk;
 set limit channel ch1 readrate=10240;
 set limit channel ch1 kbytes=2048000;
 backup as compressed backupset incremental level 2 database
 format='/u01/bak/rman/inc2_%d_%U'
 tag='Inc2';
 release channel ch1;
 execute global script global_arch;
 execute global script global_bkctl;
}

replace global script global_bkctl
comment ' A script for backup crontl file'
{
 allocate channel ch1 device type disk;
 set limit channel ch1 readrate=10240;
 set limit channel ch1 kbytes=2048000;
 backup as compressed backupset
 format='/u01/bak/rman/backupctl_%d_%U.ctl'
 tag='bkctl'
 current controlfile reuse;
 release channel ch1;
}
 

我们可以看看有哪些脚本

RMAN> list global script names;
 

再来关注下其他相关的脚本:

 

    --启用控制文件的自动备份功能

        RMAN> configure controlfile autobackup on;

        RMAN> configure controlfile autobackup format for device type disk to '/u01/bk/rmbk/auto_ctl_%d_%f';

   

    --删除以前的备份

        RMAN> delete noprompt backupset;

   

    --备份前验证归档日志是否存在

        RMAN> crosscheck archivelog all;

       

    --删除无效的归档日志信息

        RMAN> delete noprompt expired archivelog all;

       

    --使用0级增量备份数据库

        RMAN> run { execute global script global_inc0;}

 

    --查看刚刚完成的备份情况

        RMAN> list backupset summary;

        RMAN> list backupset ;

        RMAN> list backup of controlfile ;

        RMAN> list backup of archivelog all;

        RMAN> list backup of database;

        RMAN> list backup of datafile n ;
 


List of Stored Scripts in Recovery Catalog
 
 
    Global Scripts
 
 
       Script Name
       Description
       -----------------------------------------------------------------------
       global_arch
        A script for archivelog and delete it
 
       global_bkctl
        A script for backup crontl file
 
       global_del_obso
       A script for obsolete backup and delete it
 
       global_inc0
        A script for backup database using incremental level 0
 
       global_inc1
        A script for backup database using incremental level 1
 
       global_inc2
        A script for backup database using incremental level 2
 
RMAN>

最后

以上就是友好橘子为你收集整理的我们的RMAN体系的全部内容,希望文章能够帮你解决我们的RMAN体系所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部