Oracle下定时删除归档日志脚本

1、报错信息html

前几天网站忽然访问不了,而且报了以下错误:python

ora-27101: shared memory realm does not existsql

ora-01034: oracle not available 11g数据库

ORA-24324: service handle not initializedvim


缘由:因为数据库归档日志满了,不能继续往数据库里写数据。oracle


2、查看归档日志大小app

su - oracleide

sqlplus / as sysdba网站

show parameter recover

1.png

可查看到归档日志目录为:/u01/app/oracle/fast_recovery_area/******/archivelogspa

能够查看该目录的大小,对比数据库设置的日志空间,该目录大小不能大于数据库设置的空间。


3、扩大归档日志大小

alter system set db_recovery_file_dest_size=100G;

2.png


4、清理归档日志

扩大后还需设置定时计划清理归档日志,须要切换到oracle帐号执行命令

rman target /

RMAN> crosscheck archivelog all;

RMAN> delete expired archivelog all;

RMAN> delete archivelog until time 'sysdate-3'

 

上面三条命令的解释:

一、第一条命令能够把无效的expired的archivelog标出来。

二、第二条命令直接所有删除过时的归档日志。

三、第三条命令直接删除三天前全部的归档日志。

参考:https://www.2cto.com/database/201308/235338.html


5、设置自动脚本

一、编写脚本

su - oracle        //切换到oracle用户下执行操做

cd /u01/app

vim arcclear.sh

#!/usr/bin
rman target / <<EOF
delete force noprompt archivelog all completed before 'sysdate-3';
exit;
EOF

chmod +x arcclear.sh


二、添加到计划任务

crontab -e

30 1 * * * sh /u01/app/arcclear.sh >> /u01/app/arcclear.log

service crond restart

相关文章
相关标签/搜索