Chinaunix首页 | 论坛 | 博客
  • 博客访问: 218829
  • 博文数量: 49
  • 博客积分: 1532
  • 博客等级: 上尉
  • 技术积分: 352
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-17 13:37
个人简介

..................................

文章分类

全部博文(49)

文章存档

2023年(1)

2020年(2)

2019年(2)

2018年(17)

2017年(15)

2016年(12)

分类: Oracle

2016-12-07 14:26:45

---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执行脚本,删除日志)

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