【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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Mysql,Oracle字符串转Date函数[通俗易懂]

    Mysql,Oracle字符串转Date函数[通俗易懂]str_to_date(‘2021-06-1014:01:33′,’%Y-%m-%d%H:%i:%s’)

    2022年10月4日
    2
  • java中的局部变量和全局变量哪个优先_java中成员变量是全局变量吗

    java中的局部变量和全局变量哪个优先_java中成员变量是全局变量吗Java变量java中主要有如下几种类型的变量:一、局部变量只在特定的过程或函数中可以访问的变量,被称为局部变量。与局部变量相对应的,是全局变量。全局变量就是从定义的位置起,作用域覆盖整个程序范围的变量。局部变量可以和全局变量重名,但是局部变量会屏蔽全局变量。在函数内引用这个变量时,会用到同名的局部变量,而不会

    2022年8月21日
    9
  • flake8配置_errorflashdownloadfailed-could

    flake8配置_errorflashdownloadfailed-couldflake8错误码

    2022年9月13日
    2
  • matlab怎么表示二元函数,如何用Matlab画二元函数?[通俗易懂]

    matlab怎么表示二元函数,如何用Matlab画二元函数?[通俗易懂]1、首先打开matlab。2、在matlab当前目录空2113间右键5261。41023、然后点击new->M-File。4、然后将文件命令为hello.m。5、然后双击该文1653件,输入[Rmdm]=meshgrid(15:5:50,1:10);6、然后添加f=0.034488*(Rm.^1.9400).*(10^-0.0173*dm);7、接着添加surf(Rm,dm,f)…

    2025年9月29日
    2
  • Windows Azure服务购买,收费,使用注意事项及学习资料推荐

    Windows Azure服务购买,收费,使用注意事项及学习资料推荐近来,QQ群里不少朋友比较关注WindowsAzure,然而又仿佛不知道怎么入手。怎么开始开发,部署这些是技术细节,相信难不倒大家,但是如何购买服务以及收费这些东西确实模模糊糊的。这一方面是因为中文资料太少,WindowsAzure的入口网站也比较模糊,很多人找不到,更重要的是微软还没有正式对大陆开放。据说,曾经微软准备在大陆建一个数据中心,由于某些原因最后选择…

    2022年10月5日
    1
  • Java集合框架关系图谱

    Java集合框架关系图谱Java集合是用于存储数量不等的对象的容器,还可以保存具有映射关系的关联数组,Collection是集合接口,它提供了对集合对象进行基本操作的通用接口方法。Java集合大致分为下面四种类型:List,Set,Queue,Map。List代表有序,可重复集合,Set代表无序,不可重复集合,Queue代表队列集合,Map代表具有映射关系的集合。Java集合主要有Collection和Map接口派生,…

    2022年6月26日
    52

发表回复

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

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