当前位置: 移动技术网 > IT编程>数据库>Oracle > oracle自动清理archivelog文件的具体方法

oracle自动清理archivelog文件的具体方法

2017年12月12日  | 移动技术网IT编程  | 我要评论
1.登陆到服务器上创建rman自动删除两天前的归档日志脚本
[oracle@108 ~]$ cat >>del_ora_log.rman <<eof
 crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt force archivelog until time 'sysdate -2';   -------删除两天前的archivelog
exit;
eof
2.手动执行清除日志
[oracle@108 ~]$ rman target/ cmdfile=/home/oracle/del_ora_log.rman msglog=/home/oracle/del_ora_log.rman.log

3.将脚本加入系统定时任务
注意:任务执行的时候环境变量不能应用上,导致rman命令不能执行成功,可以将环境变量和命令放到一个脚本中,这样执行就没有问题。
shell代码 
path=$path:$home/bin 

export path 

export oracle_base=/home/oracle/app 

export oracle_home=$oracle_base/oracle/product/11.2.0/dbhome_1 

export oracle_sid=orcl 

export path=$path:$home/bin:$oracle_home/bin 

export ld_library_path=$oracle_home/lib:/usr/lib:/usr/local/lib 

rman target/ cmdfile=/home/oracle/del_ora_log.rman msglog=/home/oracle/del_ora_log.rman.log >>/home/oracle/rman.log 2>&1 

[oracle@108 ~]$ crontab -e  
13 * * * * /home/oracle/del_ora_log.sh >>del_ora_log.log 2>&1

4.某些表插入数据频繁但数据又不太重要可以去掉log。

alter table  <tablename>  nologging;

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网