部署自动清理任务解决ORA-00257: archiver error. Connect internal only, until freed

使用oracle数据库的时候,我们一般都会开启归档,确保数据库的日志连续和和数据安全。但随着数据库的运行,归档文件会越来越多,最终撑满磁盘空间,数据库无法继续归档,出现"ORA-00257: archiver error. Connect internal only, until freed"错误。人为手工清理日志文件,可以暂时解决相应问题,为彻底解决该问题,我们可以设置清理任务。

一、直接清理方法

1.1,制作清理脚本

我们在服务器上,生成一个脚本,通过rman命令去清理3天前的归档文件:

bash 复制代码
[oracle@oracle11g app]$ pwd
/oracle/app
[oracle@oracle11g app]$ ls
control180116.ora  controlbak.ora  createcontrol.sh  data  orabak  oracle  oraInventory  rm_arch.sh
[oracle@oracle11g app]$ cat rm_arch.sh
delete noprompt archivelog until time 'sysdate-3';
crosscheck archivelog all;
[oracle@oracle11g app]$ 

1.2,配置自动任务脚本

bash 复制代码
[oracle@oracle11g app]$ ls auto_rm_arch.sh 
auto_rm_arch.sh
[oracle@oracle11g app]$ cat auto_rm_arch.sh 
su - oracle -c "rman target / cmdfile=/oracle/app/rm_arch.sh msglog=/oracle/app/rm_arch.log"
[oracle@oracle11g app]$ 

我们配置crontab自动任务,让其每天晚上2点调用auto_rm_arch.sh,进行归档文件的自动清理。

bash 复制代码
[root@oracle11g ~]# crontab -l
0 2 * * * sh /oracle/app/auto_rm_arch.sh
[root@oracle11g ~]# 

二、备份归档日志文件方法

大部分oracle数据库,我们都需要进行rman的备份,我们可以通过备份归档的时候,对备份完成的归档日志文件进行清理,下面我们列出归档日志备份清理的脚本:

bash 复制代码
crosscheck archivelog all;
run 
{  allocate channel a1 type 'disk';
   allocate channel a2 type 'disk';
   allocate channel a3 type 'disk';	   
   sql 'alter system archive log CURRENT';
   backup filesperset=25 format '%d_arch_%s_%p_%h'  skip inaccessible                                       
   (archivelog all delete input); //这里delete input完成备份日志文件的清理 
   release channel a1;
   release channel a2;
   release channel a3;
}
相关推荐
jiayou648 小时前
KingbaseES 实战:深度解析数据库对象访问权限管理
数据库
李广坤1 天前
MySQL 大表字段变更实践(改名 + 改类型 + 改长度)
数据库
爱可生开源社区2 天前
2026 年,优秀的 DBA 需要具备哪些素质?
数据库·人工智能·dba
随逸1772 天前
《从零搭建NestJS项目》
数据库·typescript
加号33 天前
windows系统下mysql多源数据库同步部署
数据库·windows·mysql
シ風箏3 天前
MySQL【部署 04】Docker部署 MySQL8.0.32 版本(网盘镜像及启动命令分享)
数据库·mysql·docker
李慕婉学姐3 天前
Springboot智慧社区系统设计与开发6n99s526(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
数据库·spring boot·后端
百锦再3 天前
Django实现接口token检测的实现方案
数据库·python·django·sqlite·flask·fastapi·pip
tryCbest3 天前
数据库SQL学习
数据库·sql
jnrjian3 天前
ORA-01017 查找机器名 用户名 以及library cache lock 参数含义
数据库·oracle