Chinaunix首页 | 论坛 | 博客
  • 博客访问: 277414
  • 博文数量: 38
  • 博客积分: 836
  • 博客等级: 准尉
  • 技术积分: 390
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-15 23:50
文章分类

全部博文(38)

文章存档

2014年(1)

2013年(1)

2012年(10)

2011年(26)

我的朋友

分类: Oracle

2012-06-25 21:29:43

---del_arch.sh
#! /bin/bash
exec >> delarch`date +%y%m%d%H`.log
$ORACLE_HOME/bin/rman target / <crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog until time 'sysdate-14';
exit;
EOF


#说明:以上脚本删除14天以前所有归档日志,同时记录log

$ORACLE_HOME/bin/rman target / <等同于
$ORACLE_HOME/bin/rman <connect target sys/password@mydb

delete noprompt archivelog all completed before 'sysdate-14';
等同于
delete noprompt archivelog until time 'sysdate-14';

-------
Archivelog List Commands

RMAN>list archivelog all;
RMAN>list copy of archivelog until time ‘SYSDATE-10′;
RMAN>list copy of archivelog from time ‘SYSDATE-10′
RMAN>list copy of archivelog from time ‘SYSDATE-10′ until time ‘SYSDATE-2′;
RMAN>list copy of archivelog from sequence 1000;
RMAN>list copy of archivelog until sequence 1500;
RMAN>list copy of archivelog from sequence 1000 until sequence 1500;

-------
Archivelog Delete Commands

RMAN>delete archivelog all;
RMAN>delete archivelog until time ‘SYSDATE-10′;
RMAN>delete archivelog from time ‘SYSDATE-10′
RMAN>delete archivelog from time ‘SYSDATE-10′ until time ‘SYSDATE-2′;
RMAN>delete archivelog from sequence 1000;
RMAN>delete archivelog until sequence 1500;
RMAN>delete archivelog from sequence 1000 until sequence 1500;

Note : Also, you can use noprompt statement for do not yes-no question.
RMAN>delete noprompt archivelog until time ‘SYSDATE-10′;


AIX下计划任务
以下为rman定时删除归档日志方法:
将附件中del_arch.sh文件上传至数据库服务器,oracle用户的可读取目录,例如/home/oracle。赋予可执行权限(chmod +x del_arch.sh)
在root用户下,crontab -e
20 20 * * 3 su - oracle -c '/home/oracle/del_arch.sh' 引号内为脚本位置。(代表每周三20:20执行脚本,删除日志)

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