1、adump目录下大量aud文件
事情的起因是一个客户的监控告警,/u01目录的inode使用率100%,经过排查发现是oracle数据库的audit_file_dest目录(/u01/app/oracle/admin/ora11g/adump)有大量的.aud文件,这些文件单个文件小,但是数量众多,导致占用了大量inode空间。
为了尽快恢复,先把adump目录下.aud文件先删除掉
cd /u01/app/oracle/admin/ora11g/adump
rm -rf *
屏幕显示:-bash: /bin/rm: Argument list too long
说明文件太多,无法一次性删除,使用下面的命令分批次删除:
ls | xargs -n 10 rm -fr ls
[oracle@ora11g:/u01/app/oracle/admin/ora11g/adump]$ ls | xargs -n 10 rm -fr ls
[oracle@ora11g:/u01/app/oracle/admin/ora11g/adump]$ ls
ora11g_ora_30081_20240614152501554813143795.aud ora11g_ora_30083_20240614152501582383143795.aud ora11g_ora_30088_20240614152501703067143795.aud ora11g_ora_30092_20240614152501852521143795.aud
ora11g_ora_30082_20240614152501568151143795.aud ora11g_ora_30087_20240614152501690481143795.aud ora11g_ora_30089_20240614152501716605143795.aud
2、查找生成大量aud文件的原因
前面先删除所有aud文件,释放了空间,只是一个临时解决方案,要找到根源,防止后续还会出现这个问题。
(1)检查了数据库,并未开通审计日志
SQL> show parameter audit
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest string /u01/app/oracle/admin/ora11g/a
dump
audit_sys_operations boolean FALSE
audit_syslog_level string
audit_trail string NONE
可以看到audit_trail为none,audit_sys_operations也是FALSE,数据库并未开通审计外部记录,为什么adump目录会生成那么多的dump文件?
(2)查看aud文件内容和生成时间
–查看aud都记录什么信息
$ strings ora11g_ora_31758_20240614153102295854143795.aud
Audit file /u01/app/oracle/admin/ora11g/adump/ora11g_ora_31758_20240614153102295854143795.aud
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11.2.0/db
System name: Linux
Node name: ora11g
Release: 5.4.17-2102.201.3.el7uek.x86_64
Version: #2 SMP Fri Apr 23 09:05:55 PDT 2021
Machine: x86_64
VM name: VMWare Version: 6
Instance name: ora11g
Redo thread mounted by this instance: 1
Oracle process number: 31
Unix process pid: 31758, image: oracle@ora11g (TNS V1-V3)
Fri Jun 14 15:31:02 2024 +08:00
LENGTH : ‘153’
ACTION :[7] ‘CONNECT’
DATABASE USER:[1] ‘/’
PRIVILEGE :[6] ‘SYSDBA’
CLIENT USER:[6] ‘oracle’
CLIENT TERMINAL:[0] ‘’
STATUS:[1] ‘0’
DBID:[9] ‘260591189’
You have new mail in /var/spool/mail/oracle
[oracle@ora11g:/u01/app/oracle/admin/ora11g/adump]$ ls -lrt
可以看到这些文件记录是sysdba登录相关记录,而且生成时间都是有规律的,每分钟都会生成,怀疑是不是有什么定时任务执行时候产生的呢?
(3)查看系统的crontab
[oracle@ora11g:/u01/app/oracle/admin/ora11g/adump]$ crontab -l
* * */1 * * /home/oracle/scripts/del_arch.sh
00 04 * * * /home/oracle/scripts/dbbackup_lv0.sh
发现crontab有一个定时删除归档的脚本,该脚本内容如下:
[oracle@ora11g:/u01/app/oracle/admin/ora11g/adump]$ cat /home/oracle/scripts/del_arch.sh
#!/bin/bash
source ~/.bash_profile
rman target / nocatalog msglog /home/oracle/scripts/del_arch.log