Chinaunix首页 | 论坛 | 博客
  • 博客访问: 676615
  • 博文数量: 163
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1625
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-24 11:40
个人简介

资深Oracle数据库专家 OCM认证大师 10年数据库相关服务及开发经验 各类数据库相关方案的编写,管理及实施 数据中心数据库日常运维、大型项目割接、性能优化等方面有丰富的实战经验 客户包括: 电信,银行,保险,航空,国网,汽车,烟草等 想要一起学习探讨数据安全技术的请加qq群 256041954

文章分类

全部博文(163)

文章存档

2017年(2)

2016年(112)

2015年(38)

2014年(11)

我的朋友

分类: Oracle

2014-12-23 17:27:48

1.关闭数据库

SQL> shutdown immediate;

2.启动数据库为mount模式

SQL> startup mount

3.显示和修改归档模式

SQL> archive log list

SQL> alter database archivelog;

SQL> alter database open

4.设置归档日志的格式

SQL>alter system set log_archive_format='ARC%s%t%r.log' scope=spfile;

5.设置归档日志的存放路径

SQL>alter system set log_archive_dest='/oradata/arcl/arcl' scope=spfile;

SQL>shutdown immediate

SQL>startup

6.强制切换归档日至

SQL>alter system switch logfile;

7.取消归档

SQL>alter database noarchivelog;

 

设置归档文件自动备份。

CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE channel DEVICE TYPE DISK format '/u01/app/oracle/oradata/PROD/Disk1/rmanbak/full_%s.bk';

configure device type disk parallelism 4 backup type to compressed backupset;

configure snapshot controlfile name to '/u01/app/oracle/oradata/PROD/CONTROLbak/snapcf_PROD.f';

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

 

1.首先需要先建立一个用于备份的账户并赋权:

    create user rmanadm identified by xxxx;

   grant sysdba to rmanadm;

2.RMAN登录并配置相关信息:

 (1)rman target rmanadm/xxxx;

 (2)configure controlfile autobackup on; ##自动备份控制文件

 (3)CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS; ##过期时间为7日前(以前的备份数据将被删除)

3.备份命令:

 

$ORACLE_HOME/bin/rman target rmanadm/xxxx   cmdfile=/home/oracle/rman_level0_backup.rcv  log=/home/oracle/rman_backup.log append

 

4.run脚本:

 

run {

allocate channel d1 type disk;

allocate channel d2 type disk;

 

backup incremental level 0 cumulative as compressed   BACKUPSET format '/oracledb_backup/datebackup/level0_%T_%t_%d_%s_%p_%u'  tag='db full backup'  database include current controlfile;

 

backup as compressed BACKUPSET tag='archivelog  backup' archivelog all not backed up format '/oracledb_backup/datebackup/log_%T_%t_%d_%s_%p_%u';

 

release channel d2;

release channel d1;

 

crosscheck backupset;

 

delete noprompt expired backupset;

 

delete noprompt expired archivelog all;

 

DELETE NOPROMPT OBSOLETE;

 

}

 

1.编写bak_full.sh脚本文件,主要为针对Oracle数据库的0级备份
2.
编写schedule_full.sh脚本文件,该文件直接在TSM中调用执行(每周六)
3.
编写bak_incr.sh脚本文件,主要为针对Oracle数据库的1级备份
4.
编写schedule_incr.sh脚本文件,该脚本直接在TSM中调用执行(每周一至周五)
5.
所有的备份脚本放置于/home/oracle/tsm_script目录下
6.
另外生成的日志放置于/home/oracle/tsm_script/baklog目录下(产生的日志文件打上时间戳)
7.
定期检测和删除磁带中的RMAN过期备份版本,以实现空间回收(每月一次)

脚本文件信息:

bak_full.sh
内容:
====================================================================
connect target /
run {
allocate channel t1 type sbt;
allocate channel t2 type sbt;
send 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
backup incremental level 0
format 'orcl_full_%T_%t_%U'database;
sql 'alter system archive log current';
backup format 'orcl_arhc_%T_%t_%U' archivelog all delete all input;
release channel t1;
release channel t2;
}
=====================================================================

schedule_full.sh
内容:
=====================================================================
CMDFILE=/home/oracle/tsm_script/bak_full.sh
LOGFILE=/home/oracle/tsm_script/baklog/full_baklog_`date +%y%m%d`.log
rman cmdfile $CMDFILE msglog $LOGFILE
=====================================================================

bak_incr.sh
内容:
=====================================================================
connect catalog rman/rman@rmanlog
connect target /
run {
allocate channel t1 type sbt;
allocate channel t2 type sbt;
send 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
backup incremental level 1
format 'orcl_incr_%T_%t_%U'database;
sql 'alter system archive log current';
backup format 'orcl_arhc_%T_%t_%U' archivelog all delete all input;
release channel t1;
release channel t2;
}
============================================================

schedule_incr.sh
内容:
===============================================================
CMDFILE=/home/oracle/tsm_script/bak_incr.sh
LOGFILE=/home/oracle/tsm_script/baklog/incr_baklog_`date +%y%m%d`.log
rman cmdfile $CMDFILE msglog $LOGFILE
===========================================================

说明:生成的日志文件自动打上(年份+月份+日期),在实现方面:
AIX
环境下为XXXX_baklog_`date +%y%m%d`.log
Windows
环境下为XXXX_baklog_%date:~4,6%.log

另外如要定期回收磁带空间,还需要设置RMAN的过期版本删除脚本
bak_maintenance.sh
内容:
===============================================================
connect catalog rman/rman@rmanlog
connect target /
allocate channel for maintenance type sbt;
send 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
report obsolete;
delete noprompt obsolete;
release channel;

阅读(1686) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~