部署自动清理任务解决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;
}
相关推荐
星星也在雾里2 小时前
PgBouncer 解决 PostgreSQL 连接数超限 + 可视化监控
数据库·postgresql
雨辰AI4 小时前
SpringBoot3 + 人大金仓读写分离 + 分库分表 + 集群高可用 全栈实战
java·数据库·mysql·政务
长城20244 小时前
关于MySql的ONLY_FULL_GROUP_BY问题
数据库·mysql·聚合列
常常有4 小时前
MySQL 底层执行原理:输入SQL语句到两阶段提交
数据库·sql·mysql
Mr. zhihao5 小时前
深入解析redis基本数据结构
数据结构·数据库·redis
m0_748839495 小时前
利用天正暖通CAD快速掌握风管数量统计的方法
数据库
随身数智备忘录5 小时前
什么是设备管理体系?设备管理体系包含哪些核心模块?
网络·数据库·人工智能
海市公约6 小时前
MySQL更新语句执行全流程:从Buffer Pool修改到二阶段提交
数据库·mysql·binlog·innodb·undo log·二阶段提交·update执行原理
颂love6 小时前
MySQL的执行流程
android·数据库·mysql
程序leo源7 小时前
Qt窗口详解
开发语言·数据库·c++·qt·青少年编程·c#