ITPub博客

首页 > 数据库 > Oracle > oracle rman备份及策略设置

oracle rman备份及策略设置

Oracle 作者:mzd75 时间:2013-12-06 21:14:15 0 删除 编辑
 

?  RMAN备份:(数据文件 参数文件控制文件 归档日志文件)

rman备份配置过程:

创建目录:

mkdir –p /arch/backup/rman

chmod 770 /arch/backup/rman

创建对象:

create tablespace rman_data datafile ' /oradata/tts/rman_data.dbf'  size 1024 m autoextend on next 1m maxsize unlimited;

create temporary tablespace rman_tmp tempfile ' /oradata/tts/rman_tmp.dbf' size 100m autoextend on next 32m maxsize 2048m;

create user rman identified by rman default tablespace rman_data temporary tablespace rman_tmp;

grant connect,resource,recovery_catalog_owner to rman;

连接catalog,注册数据库:

rman catalog rman/rman

create catalog tablespace rman_data;

register database;

report schema;

--基于冗余数量的设置

configure retention policy to redundancy 2;

--基于恢复窗口的设置

configure retention policy to recovery window of 7 days;

--设置自动备份控制文件为打开

CONFIGURE CONTROLFILE AUTOBACKUP ON;

全库(0级)备份脚本:

$ORACLE_HOME/bin/rman catalog rman/rman

connect  target sys/oracle

run {

allocate channel ch1 device type disk;

allocate channel ch2 device type disk;

allocate channel ch3 device type disk;

backup full database format '/arch/backup/rman/db_%U_%d.bak' tag="full" spfile include current controlfile;

sql 'alter system archive log current';

change archivelog all crosscheck;

backup archivelog all format '/arch/backup/rman/arch_%t_%s.bak'  tag="archivelog" delete all input;

crosscheck backup;

crosscheck archivelog all;

delete noprompt expired backup;

delete noprompt obsolete;

resync catalog;

release channel ch1;

release channel ch2;

release channel ch3;

}

备份RMAN数据库:

export ORACLE_SID=tts

export NLS_LANG=american_america.ZHS16GBK

today=`date +20%y-%m-%d`

exp userid=rman/rman buffer=6553600 owner=rman file=/arch/backup/rman/rman$today.dmp log=/arch/backup/rman$today.log

?  逻辑导出备份:

$ more exp.sh

export ORACLE_SID=tts

export NLS_LANG=american_america.ZHS16GBK

today=`date +20%y-%m-%d`

exp userid=system/oracle full=yes buffer=6553600 file=/arch/backup/full$today.dmp  log=/arch/backup/full$today.log 

?  定时任务:

在文件/etc/crontab最后添加如下几行:(最好使用绝对路径)

1 23 * * * su - oracle -c rman.sh>>rman.log

1 22 * * * su - oracle -c exp.sh>>exp.log

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/148459/viewspace-1062576/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-11-30

  • 博文量
    74
  • 访问量
    213513