

Oracle使用rman定时清除7天前的日志
source link: https://bajie.dev/posts/20221208-oracle_rman/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Oracle使用rman定时清除7天前的日志
这一篇正规的DBA看到肯定会呲之以鼻,但对于没有用过oracle的系统运维来说,就是必须知道的事情了。
公司的 Oracle 实例有两台数据库,定时用rman备份,但是没有自动清理机制 ,过一阵子磁盘就会超过 80% 告警,需要手动清理,烦不胜烦。
凡是要手动做三次的事情必须自动化处理,启荣大师如是说,照办就是。
cat del_log.sh
#!/bin/bash
source /home/oracle/.bash_profile
rman target / << EOF
delete noprompt archivelog until time 'sysdate-7';
exit;
EOF
很简单吧。上面引用的 .bash_profile 内容如下:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export ORACLE_BASE=/data/u01/app/oracle
export ORACLE_HOME=/data/u01/app/oracle/product/18.3.0/dbhome_1
export ORACLE_SID=oradb
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH:/usr/local/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:$ORACLE_HOME/rdbms/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss'
export EDITOR=vi
umask 022
这个 del_log.sh 的脚本放进 oracle 用户的 crontab 里执行就好
0 3 * * * /usr/local/bin/del_log.sh
Recommend
-
9
自己写的RMAN备份脚本
-
3
rman generate script set until time
-
11
12c RMAN新特性restore/recover from service远程恢复
-
17
0x00 前言 Windows Event Viewer Log (EVT)单条日志清除系列文章的第三篇,介绍删除当前系统指定时间段evt日志记录的方法和详细测试过程,说明无法修改日志数量的原因,最后开源查询日志内容和修改日志内容的实现代码 0x01 简介
-
13
Windows Event Viewer Log (EVT)单条日志清除(二)——程序实现删除evt文件指定时间段的日志记录 0x00 前言 Windows Event Viewer Log (EVT)单条日志清除系列文章的第二篇,介绍删除evt文件指定时间段日志记录的思路,解决...
-
11
0x00 前言 Windows Event Viewer Log (EVT)单条日志清除系列文章的第一篇,侧重于介绍evt日志文件的基础知识和删除单条日志的实现思路与实例 Windows Event Viewer Log (EVT)适用于以下Windows系统: Windows NT 4
-
27
Windows XML Event Log (EVTX)单条日志清除(三)——通过解除文件占用删除当前系统单条日志记录 0x00 前言 Windows XML Event Log (EVTX)单条日志清除系列文章的第三篇,介绍第一种删除当前系统evtx日志文件单条日志记录的...
-
5
nginx日志切割及7天前的历史日志删除脚本Jager · 7月21日 · 2014年nginx日志切割...
-
6
Oracle故障处理:Rman-06207&Rman-06214 精选 原创 1、在给客户系统巡检时通过r...
-
2
作为IT运维人员,尤其是数据库岗位,数据的备份重于一切。 现在很多用户会有一个普遍误区,认为现在类似ADG这类灾备已经很完善,且实时性也更佳,往往就忽略了传统的备份效用。 但实际上,我们千万不能因为有了容灾建设就盲目忽略备份的作用,二者其实有...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK