oracle归档未自动清理,Oracle rman 自动清理归档日志

一、背景:

数据库开户归档日志,若不及时清理归档日志,系统就会报

ORA-00257: archiver error. Connect internal only, until freed

有没有自动清理归档脚本,不需要每次都手动清理呢?

当然有,实现自动清理归档日志,可以通过 Linux crontab,Oracle rman。

二、编写删除rman脚本

新建一个脚本clearLog.sh

${ORACLE_HOME}/bin/rman nocatalog log=/home/oracle/del_arch$(date +%Y-%m-%d).log <

connect target /

#crosscheck archivelog all;

#delete noprompt expired archivelog all;

DELETE noprompt ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-11';

exit;

EOF

三、手动测试脚本

赋权:chomd +x clearLog.sh

执行:./clearLog.sh

ok,,查看del_arch.log,能删除归档。

四、添加至corntab

在oracle 用户下执行crontab -e

42 20 * * * /home/oracle/clearLOG.sh晚上20:42分执行clearLog.sh

五、测试与验证

修改crontab中的clearLog.sh运行时间为系统时候后的1分钟 。

1、查看运行日志: more del_arch文件,并无内容

2、查看cron运行日志

more /var/log/cron

Jul 4 18:40:01 orac1 CROND[632]: (root) CMD (/usr/lib64/sa/sa1 1 1)

Jul 4 18:41:18 orac1 crontab[1415]: (oracle) BEGIN EDIT (oracle)

Jul 4 18:41:37 orac1 crontab[1415]: (oracle) REPLACE (oracle)

Jul 4 18:41:37 orac1 crontab[1415]: (oracle) END EDIT (oracle)

Jul 4 18:42:01 orac1 crond[3515]: (oracle) RELOAD (/var/spool/cron/oracle)

Jul 4 18:42:02 orac1 CROND[1604]: (oracle) CMD

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值