生产案例:突然产生大量的归档日志,导致磁盘空间满了无法登陆数据库
sqlplus / as sysdba ERROR: ORA-09817: Write to audit file failed. SVR4 Error: 28: No space left on device ORA-01075: you are currently logged on
很明显几个单词NO SPACE,赶忙看系统df -h 果然100%没了,第一反应,是归档日志占满了空间,数据库不会增长那么快,所以到归档日志目录里发现很多很多归档日志;
为了让业务人员能马上连上数据库使用,先手动删除了部分归档日志,腾出一点点空间,但是没多久空间又满了,然后去看归档日志目录,发现每个6秒就要生成一个归档日志文件,每一个文件大小187M,这很吓人,
SELECT TRUNC(FIRST_TIME) "TIME", SUM(BLOCK_SIZE * BLOCKS) / 1024 / 1024 / 1024 "SIZE(GB)" FROM V$ARCHIVED_LOG GROUP BY TRUNC(FIRST_TIME);
select * from v$archived_log
问题排查一,看alert告警日志
select group#,sequence#,bytes/1024/1024,members,status from v$log; alter database add logfile group 4 (\'/oradata/hhfz/redo04.log\') size 200M; alter database add logfile group 5 (\'/oradata/hhfz/redo05.log\') size 200M;
问题排查二,logminer查看归档日志
--创建logminer数据字典表 @?/rdbms/admin/dbmslm.sql; @?/rdbms/admin/dbmslmd.sql; --执行要分析的归档日志 exec sys.dbms_logmnr.add_logfile(logfilename => \'/oradata/hhfz_arch/1_5056_912160774.arc\',options => dbms_logmnr.new); exec sys.dbms_logmnr.start_logmnr(options => sys.dbms_logmnr.dict_from_online_catalog); --查询 归档日志的内容 select seg_owner,count(*) from v$logmnr_contents group by seg_owner; select count(1),substr(sql_redo,1,60) from v$logmnr_contents group by substr(sql_redo,1,60) order by count(1) desc ; --增加别的日志文件 exec sys.dbms_logmnr.add_logfile(logfilename=>\'/oradata/hhfz_arch/1_5056_912160774.arc\'); exec sys.dbms_logmnr.add_logfile(logfilename=>\'/oradata/hhfz_arch/1_4986_912160774.arc\'); --结束分析归档日志 exec sys.dbms_logmnr.end_logmnr;
最后查出一些sql,但是业务觉得这些sql不算大,所以并不觉得有啥问题。我也感觉,虽然一直同一个SQL在插入,但是这点应该能承受才对。