oracle自动清理archivelog文件
2014-10-17 14:03
225 查看
oracle自动清理archivelog文件
登陆到服务器上创建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;
登陆到服务器上创建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;
相关文章推荐
- oracle自动清理archivelog文件的具体方法
- oracle自动清理archivelog文件的具体方法
- oracle归档日志的自动清理
- Oracle自动清理归档日志脚本
- How To Automate Cleanup Of Dead Connections And INACTIVE 【如何自动清理ORACLE中的死连接和非活动会话】
- Oracle rman 自动清理归档日志
- Oracle自动清理日志脚本
- oracle设置自动清理归档日志脚本
- 利用脚本自动清理Oracle归档日志
- Linux下Oracle归档日志自动清理脚本代码(sh)
- Oracle 日志归档 自动清理
- win2000不能自动启动oracle服务全攻略
- oracle中实现主键的自动增加(csdn)
- 实现在Oracle中字段值自动增加1的方法
- win2000环境下的oracle自动备份
- 让oracle自动启动方法!
- oracle日积月累[ZT]-浅析自动连续数或者按目的取数函数RANK(),DENSE_RANK()功能
- linux下 Oracle自动启动与停止
- oracle中实现主键的自动增加