ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle之rman备份

oracle之rman备份

原创 Linux操作系统 作者:wang_0720 时间:2013-11-06 14:48:36 0 删除 编辑
本文中目录数据库和目标数据库在不同的服务器上,目录数据库sid=orcl2,目标数据库sid=orcl
一 恢复目录数据库创建
1 数据库安装本文不作详细叙述
2 创建表空间cattabs,大小为50MB
create tablespace cattabs datafile '/u01/app/oracle/oradata/orcl2/catdata01.dbf' size 50m autoextend on next 50m maxsize unlimited
3 创建存储目录的用户
create user rman identified by rman
default tablespace cattabs
temporary tablespace temp;
alter user rman quota unlimited on cattabs;
4 为rman用户授权,必须授予recovery_catalog_owner权限
grant connect,resource to rman;
grant recovery_catalog_owner to rman;
5 启动rman,在目录与rman直接建立连接
rman
connect catalog rman/rman
6 创建恢复目录
create catalog tablespace cattabs;
7 与目标数据库建立连接
connect target sys@orcl
8 注册目标数据库
register database;
9 手动同步目标数据库和目录数据库控制文件
resync catalog;
10 带catalog连接目标数据库
rman target sys@orcl catalog rman/rman@orcl2
二 备份
备份脚本
cat orabackup.sh
#!/bin/bash
TMP=/tmp;export TMP
TMPDIR=$TMP;export TMPDIR
ORACLE_BASE=/u01/app/oracle;export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;export ORACLE_HOME
ORACLE_SID=orcl;export ORACLE_SID
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
RMAN_LOG=${ORACLE_BASE}/flash_recovery_area/ORCL2/rman.log
SCRIPTS_PATH=${ORACLE_BASE}/backups/
TARGET_USER=sys
TARGET_PASSWORD=sys
CATALOG_USER=rman
CATALOG_PASSWORD=rman
WEEK=`date +%w`
#周日0级备份,周一周二周四周五周六2级备份,周三1级备份
case $WEEK in
        0)
            SCRIPTS_FILE=rman_level_0
            ;;
        1|2|4|5|6)
            SCRIPTS_FILE=rman_level_2
            ;;
        3)   
            SCRIPTS_FILE=rman_level_1
            ;;
esac
nohup rman target ${TARGET_USER}/${TARGET_PASSWORD}@orcl catalog ${CATALOG_USER}/${CATALOG_PASSWORD}@orcl2 log=${RMAN_LOG}  cmdfile=${SCRIPTS_PATH}${SCRIPTS_FILE} >/dev/null 2>&1 &
全备
cat rman_full
run{
CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
allocate channel ch1 type disk;
backup full tag 'full' format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/full_%T%t'
database include current controlfile;
sql 'alter system archive log current';
backup archivelog all format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/log/db_arch_%T_%U'
delete all input;
delete noprompt obsolete;
release channel ch1;
}
0级备份
cat rman_level_0
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
allocate channel ch1 type disk;
backup incremental level 0
tag 'inc0'
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/rman_inc0_%T%t'
database include current controlfile;
sql 'alter system archive log current';
backup archivelog all
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/log/db_arch_%T_%U'
delete all input;
delete noprompt obsolete;
release channel ch1;
}
1级备份
cat rman_level_1
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
allocate channel ch1 type disk;
backup incremental level 1
tag 'inc1'
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/rman_inc1_%T%t'
database include current controlfile;
sql 'alter system archive log current';
backup archivelog all
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/log/db_arch_%T_%U'
delete all input;
delete noprompt obsolete;
release channel ch1;
}
2级备份
cat rman_level_2
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
allocate channel ch1 type disk;
backup incremental level 2
tag 'inc2'
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/rman_inc2_%T%t'
database include current controlfile;
sql 'alter system archive log current';
backup archivelog all
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/log/db_arch_%T_%U'
delete all input;
delete noprompt obsolete;
release channel ch1;
}

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

上一篇: oracle批量删除表
请登录后发表评论 登录
全部评论

注册时间:2013-11-05

  • 博文量
    111
  • 访问量
    907428