【rman,1】经典案例增量备份

【rman,1】经典案例增量备份

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

一.备份策略:

1.星期天晚上      -level 0 backup performed(全备份)
2.星期一晚上      -level 2 backup performed
3.星期二晚上      -level 2 backup performed
4.星期三晚上      -level 1 backup performed
5.星期四晚上      -level 2 backup performed
6.星期五晚上      -level 2 backup performed
7.星期六晚上      -level 2 backup performed
 
假设星期二须要恢复的话,仅仅须要1+2,
假设星期四须要恢复的话,仅仅须要1+4,
假设星期五须要恢复的话,仅仅须要1+4+5,
假设星期六须要恢复的话,仅仅须要1+4+5+6.
 
自己主动备份:
备份脚本+crontab
 bakl0
 bakl1
 bakl2

二.运行的脚本:

1.运行脚本:
rman target / msglog=bakl0.log cmdfile=bakl0 (/表示须要连接的目标数据库,msglog表示日志文件,cmdfile表示的是脚本文件)
rman target / msglog=bakl1.log cmdfile=bakl1
rman target / msglog=bakl2.log cmdfile=bakl2
实例:rman target system/oracle@ora10g(/) msglog=/u01/rmanbak/bakl1.log cmdfile=/u01/rmanbak/bakl0

完整的命令:/u01/oracle/product/10.2.0/bin/rman target system/oracle@ora10g(/) msglog=/u01/rmanbak/bakl1.log cmdfile=/u01/rmanbak/bakl0

2.编写rman备份脚本:
 
0级备份脚本:

把备份脚本放到/u01/rmanbak/script文件夹以下,vi bakl0,bakl0的内容为:
run{
    allocate channel cha1 type disk;
    backup
    incremental level  0
    format ‘/home/oracle/rmanbackup/inc0_%u_%T'(u表示唯一的ID,大T是日期。小t是时间)
    tag monday_inc0 //标签能够顺便起,没关系
    database 
plus archivelog delete input
;

    release channel cha1;
    }
1级备份脚本:
run{
    allocate channel cha1 type disk;
    backup
    incremental level  1
    format ‘/home/oracle/rmanbackup/inc1_%u_%T'(u表示唯一的ID,大T是日期,小t是时间)
    tag monday_inc1 //标签能够顺便起,没关系
    database 
plus archivelog delete input
;
    release channel cha1;
    }


2级备份脚本:
  
run{
    allocate channel cha1 type disk;
    backup
    incremental level  2
    format ‘/home/oracle/rmanbackup/inc2_%u_%T'(u表示唯一的ID,大T是日期,小t是时间)
    tag monday_inc2 //标签能够顺便起。没关系
    database 
plus archivelog delete input
;
    release channel cha1;
    }


3.编写调用rman脚本的shell脚本:

调用0备份的shell脚本 rmanbak0.sh为:
#!/bin/bash
source /home/oracle/.bash_profile
/u01/app/oracle/11.2.0/db_home_1/bin/rman target / nocatalog cmdfile=/home/oracle/script/bakl0  msglog=/home/oracle/bakl0.log


调用1备份的shell脚本 rmanbak0.sh为:
#!/bin/bash
source /home/oracle/.bash_profile
/u01/app/oracle/11.2.0/db_home_1/bin/rman target / nocatalog cmdfile=/home/oracle/script/bakl1  msglog=/home/oracle/bakl0.log

调用2备份的shell脚本 rmanbak0.sh为:
#!/bin/bash
source /home/oracle/.bash_profile
/u01/app/oracle/11.2.0/db_home_1/bin/rman target / nocatalog cmdfile=/home/oracle/script/bakl2  msglog=/home/oracle/bakl0.log

 
4.编写Linux定时任务运行自己主动备份

[root@gc2 ~]#crontab -e -u oracle(该命令的意思是编辑oracle用户的定时运行(-e,edit -u oracle,oracle用户))
分  时  日 月 星期(0代表星期天)
45 23  *  *    0    /home/oracle/script/rmanbak0.sh(星期天的23:45会以oracle用户的身份来运行命令)
45 23  *  *    1    /home/oracle/script/rmanbak2.sh
45 23  *  *    2    /home/oracle/script/rmanbak2.sh
45 23  *  *    3    /home/oracle/script/rmanbak1.sh
45 23  *  *    4    
/home/oracle/script/rmanbak2.sh

45 23  *  *    5    /home/oracle/script/rmanbak2.sh
45 23  *  *    6    /home/oracle/script/rmanbak2.sh



或者(用于測试):
使用oracle用户加入例行任务:
crontab -e
新打开的窗体中加入一下内容:
0 24 * * * /home/oracle/bin/
rmanbak0.sh
(*/3 * * * * /home/oracle/bin/rmanbak0.sh)
注。括号内的能够是做測试的时候用的,每三分钟运行一次备份。例为每天凌晨24点运行备份


 
#然后启动crontab ,启动crontab的命令:
[root@gc2 ~]# service crond restart
Stopping crond: [  OK  ]
Starting crond: [  OK  ]

#监控定时任务是否运行
[root@gc2 ~]# tail -f /var/log/cron

Mar 10 21:28:04 gc2 crond[4435]: (CRON) STARTUP (V5.0)
Mar 10 21:30:01 gc2 crond[4445]: (root) CMD (/usr/lib/sa/sa1 1 1)
Mar 10 21:39:08 gc2 crond[4486]: (CRON) STARTUP (V5.0)


版权声明:本文博客原创文章,博客,未经同意,不得转载。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/117622.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • c语言中的system函数_c语言system的头文件

    c语言中的system函数_c语言system的头文件函数原型包含在头文件“stdlib.h”中intsystem(constchar*command)函数功能执行dos(windows系统)或shell(Linux/Unix系统)命令,参数字符串command为命令名。另,在windows系统下参数字符串不区分大小写。说明:在windows系统中,system函数直接在控制台调用一个command命令。在Linux…

    2022年9月18日
    3
  • DB2存储过程语法解析

    DB2存储过程语法解析创建SQL存储过程(CREATEPROCEDURE(SQL)statement)语法格式如下:>>-CREATEPROCEDURE–procedure-name—————————–>>–+—————————————————-+–*—->’-(–+-

    2022年7月17日
    13
  • js 除法取整数、取余数的方法

    js 除法取整数、取余数的方法**js除法取整数、取余数的方法取整1.取整//丢弃小数部分,保留整数部分parseInt(5/2)  //22.向上取整//向上取整,有小数就整数部分加1Math.ceil(5/2)  //33.向下取整//向下取整,丢弃小数部分Math.floor(5/2)  //24四舍五入//四舍五入Math.round(5/2)  //3取余//取余6%4  //**…

    2022年6月21日
    80
  • BZOJ4872:[SHOI2017]分手是祝愿——题解

    BZOJ4872:[SHOI2017]分手是祝愿——题解

    2022年3月13日
    42
  • 阿里云Maven仓库完整版[通俗易懂]

    阿里云Maven仓库完整版[通俗易懂]阿里云Maven仓库完整版<?xmlversion=”1.0″encoding=”UTF-8″?><!–LicensedtotheApacheSoftwareFoundation(ASF)underoneormorecontributorlicenseagreements.SeetheNOTICEfiledistributedwiththisworkforadditionalinformationregardingcopy

    2025年7月11日
    4
  • pycharm专业版下载安装教程_pycharm2021专业版安装教程

    pycharm专业版下载安装教程_pycharm2021专业版安装教程Pycharm官网地址(下载):https://link.zhihu.com/?target=https%3A//www.jetbrains.com/pycharm/download/other.html有各种不同版本的Pycharm供下载,本文选择Pycharm专业版下载,建议下载2020.1.5版本.安装教程下载完成之后,就按照步骤开始安装了,点击Next:我选择安装在F盘,因为C盘太占用空间了,会比较卡,点击Next:一定要选着添加到环境变量中,不然后面还要手动配置环境变量,比较麻烦,

    2022年8月28日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号