部署自动清理任务解决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;
}
相关推荐
夜雪一千4 分钟前
MySQL自定义函数应该如何设计
数据库·mysql
一条小小yu6 分钟前
mysql的锁
数据库·mysql·oracle
fb_1234516 分钟前
MySQL基础核心|数据库原理+MySQL详解
数据库·mysql
‎ദ്ദിᵔ.˛.ᵔ₎22 分钟前
Mysql 基本查询
数据库·mysql
-madongyu-29 分钟前
GaussDB 性能调优:等待事件、慢 SQL 定位与关键参数
数据库·sql·gaussdb
-madongyu-41 分钟前
GaussDB 部署规划:磁盘水位、RAID 与端口设计
数据库·gaussdb
weixin_511255218 小时前
MySQL升级记录
数据库·mysql
程序猿乐锅9 小时前
【黑马点评 | 第八篇】Redisson分布式锁
java·数据库·spring boot·redis·分布式·spring·缓存
Leo.yuan9 小时前
2026年本地化Data Agent优质厂商盘点:哪些产品更适合企业生产环境
大数据·数据库·人工智能
做运维的阿瑞9 小时前
数据库增删改的安全写法
数据库·sql·mysql