博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
RMAN的使用
阅读量:6390 次
发布时间:2019-06-23

本文共 4057 字,大约阅读时间需要 13 分钟。

hot3.png

--本地

创建文件夹

mkdir /home/oracle/backup
mkdir /home/oracle/backup/script
mkdir /home/oracle/backup/log
mkdir /home/oracle/backup/export

--备份目的地
mkdir /home/oracle/rman_backup

创建备份表空间

create tablespace rman_tbs datafile '/oradata/luke/rman_tbs01.dbf' size 1024M;

创建备份用户

create user rman identified by rman default tablespace rman_tbs temporary tablespace temp;

grant connect,resource ,recovery_catalog_owner to rman;

rman catalog rman/rman
create catalog tablespace rman_tbs;
connect target sys/lukewhx
register database;
report schema;

configure retention policy to redundancy 2;
configure retention policy to recovery window of 7 days;

--倒出RMAN用户数据脚本exp_rman.par (即备份catalog库)

userid=rman/rman
file=/home/oracle/backup/export/rman.dmp
log=/home/oracle/backup/log/rman.log

-- 倒出RMAN数据SHELL脚本exp_rman.sh
#!/bin/bash
cd $HOME
. .bash_profile
cd $HOME/backup/script
exp parfile=exp_rman.par

-- 零级备份RMAN脚本level0_backup.rcv

connect catalog rman/rman
connect target sys/unumall@unu2
run {
 

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS; 

CONFIGURE CONTROLFILE AUTOBACKUP ON; 
allocate channel d1 type disk;
allocate channel d2 type disk;
backup incremental level 0 database format '/home/oracle/rman_backup/level0_%d_%s_%p_%u.bak'
tag='level 0' include current controlfile;
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/rman_backup/log_%d_%s_%p_%u.bak' delete all input;
release channel d2;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
resync catalog;

--零级备份SHELL脚本的level0_backup.sh

#!/bin/bash
cd $HOME
. .bash_profile
cd $HOME/backup/script
rman cmdfile=level0_backup.rcv msglog=$HOME/backup/log/level0_backup.log
. /home/oracle/backup/script/exp_rman.sh

--一级差异增量备份RMAN脚本 level1_backup.rcv

connect catalog rman/rman
connect target sys/luke
run {
allocate channel d1 type disk;
backup incremental level 1 format '/home/oracle/rman_backup/level1_%d_%s_%p_%u.bak' tag = 'level 1' database;
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/rman_backup/log_%d_%s_%p_%u.bak' delete all input;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
resync catalog;

--一级差异增量备份SHELL脚本level1_backup.sh

#!/bin/bash

cd $HOME
. .bash_profile
cd /home/oracle/backup/script
rman cmdfile=level1_backup.rcv msglog=$HOME/backup/log/level1.log
. /home/oracle/backup/script/exp_rman.sh

--二级差异增量备份RMAN脚本 level2_backup.rcv

connect catalog rman/rman
connect target sys/luke
run {
allocate channel d1 type disk;
backup incremental level 2 format '/home/oracle/rman_backup/level2_%d_%s_%p_%u.bak' tag = 'level 2' database;
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/rman_backup/log_%d_%s_%p_%u.bak' delete all input;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
resync catalog;

--二级差异增量备份SHELL脚本level2_backup.sh

#!/bin/bash
cd $HOME
. .bash_profile
cd /home/oracle/backup/script
rman cmdfile=level2_backup.rcv msglog=$HOME/backup/log/level2.log
. /home/oracle/backup/script/exp_rman.sh

提高 RMAN增量备份性能

alter database enable block change tracking using file

'/u01/app/oracle/admin/devdb/bdump/luke.log';

desc v$block_change_tracking;

linux下定时执行备份脚本

crontab -e -u oracle

SHELL=/bin/bash --以下脚本在bash下执行
MAILTO=oracle --执行日志以邮件形式邮给oracle用户,可以/var/spool/mail/oracle下查收
10 1 * * 0 /home/oracle/backup/script/level0_backup.sh
10 1 * * 1 /home/oracle/backup/script/level2_backup.sh
10 1 * * 2 /home/oracle/backup/script/level2_backup.sh
10 1 * * 3 /home/oracle/backup/script/level1_backup.sh
10 1 * * 4 /home/oracle/backup/script/level2_backup.sh
10 1 * * 5 /home/oracle/backup/script/level2_backup.sh
10 1 * * 6 /home/oracle/backup/script/level2_backup.sh

一周差异备份策略:

备份目标库和catalog库
周日0级全备,周一周二为2级,周三为1级,周四周五周六为2级。
每天凌晨1点10分开始备份

零级备份

backup incremental level 0 database;
一级差异增量 差异增量是默认增量备份方式
backup incremental level 1 database;
一级累计增量
backup incremental level 1 cumulative database;

转载于:https://my.oschina.net/sansom/blog/198138

你可能感兴趣的文章
关键基础设施是否会成为DDoS攻击的新目标?答案是不大会
查看>>
加拿大某党代会被偷窥,黑客看到了一切…
查看>>
“拟态防御”: 让黑客找不到破门之机
查看>>
鸿海拟收购韩国家电企业东洋美吉 价格或达4.5亿美元
查看>>
第四范式陈雨强:万字深析工业界机器学习最新黑科技
查看>>
我国拟开展2016年新型智慧城市评价工作
查看>>
《HTML 5与CSS 3权威指南 》 (第2版·下册)——第19章 19.3.5
查看>>
半导体量子芯片开发获重要进展
查看>>
HPE第四季度财报数据喜忧参半
查看>>
智能家居市场的魔方法则深度剖析
查看>>
容量和速度是选购闪存盘的关键
查看>>
微软解释Edge浏览器比Chrome更加安全的原因
查看>>
学习c语言好书推荐——学习c语言的7本书
查看>>
Oculus也陷隐私门:向Facebook发送隐私数据
查看>>
架构师是如何炼成的?以天猫APP架构&开发模式升级工程为例
查看>>
“智慧城市”方便百姓生活服务企业发展
查看>>
Colocation Guard公司再增1万平方英尺的数据中心空间
查看>>
任正非迷茫的背后是华为在“治未病”
查看>>
解读《电力发展“十三五”规划》
查看>>
无所不在的物联网设备 你我都需要正视所带来的安全问题
查看>>