问题

oracle数据库在连接的时候报以下提示:
ORA-00604: error occurred at recursive SQL level 1
ORA-01653: unable to extend table SYS.AUD$ by 8192 in tablespace SYSTEM
ORA-02002: error while writing to audit trail
ORA-00604: error occurred at recursive SQL level 1
ORA-01653: unable to extend table SYS.AUD$ by 8192 in tablespace SYSTEM

看字面意思应该是不能扩展system表空间,应该是表空间不够用了

尝试的操作

1、查看表空间使用情况

select * from (
Select  a.tablespace_name,
        a.bytes/1024/1024 total_bytes,
        b.bytes/1024/1024 free_bytes,
        a.bytes/1024/1024 - b.bytes/1024/1024 use_bytes,
        to_char(trunc((1 - b.bytes/a.bytes)*100)) || '%' use
from         (select tablespace_name,       
                sum(bytes) bytes
           from dba_data_files
          group by tablespace_name) a,
        (select tablespace_name,       
                sum(bytes) bytes
           from dba_free_space
          group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
union all
select         c.tablespace_name,
                c.bytes/1024/1024 total_bytes,
                (c.bytes-d.bytes_used)/1024/1024 free_bytes,
                d.bytes_used/1024/1024 use_bytes,
                to_char(trunc(1 - d.bytes_used/c.bytes)) || '%' use
from                
(select tablespace_name,
                sum(bytes) bytes
from dba_temp_files
group by tablespace_name) c,
(select tablespace_name,
                sum(bytes_used) bytes_used
from v$temp_space_header
group by tablespace_name               
) d
where c.tablespace_name = d.tablespace_name               
)
order by tablespace_name;

image.png 此时查已经是被我清空审计表的使用情况,原来是98% 2、查看system表空间是否是自动扩展的

SQL> select a.tablespace_name,a.bytes,a.autoextensible from dba_data_files a where a.tablespace_name='SYSTEM';

TABLESPACE_NAME 		    BYTES AUT
------------------------------ ---------- ---
SYSTEM			       3.4360E+10 YES

从返回值查看是自动增长的。 按上面看是自动增长的,按理来说是不需要再手动扩容的,还是试一下吧。 3、手动扩展表空间

alter database datafile '/userdata/app/Administrators/oradata/ORCL/system01.dbf' autoextend on next 5000M MAXSIZE 32G; 

在手动扩展表空间后发现还是报错,于是查看了一些system表空间对应的数据文件大小 image.png 根据oracle单个最大文件不能超过32G的原则,这个数据文件已经达到最大值了,不能写扩展了,于是决定清空system表空间的aud$表

4、清空aud$表

truncate table sys.aud$;

此处根据网友建议需要逐渐慢慢回收,否则一下清空会对数据库有性能影响,参考的操作方法是这样:

TRUNCATE TABLE SYS.AUD$ REUSE STORAGE;
ALTER TABLE SYS.AUD$ DEALLOCATE UNUSED KEEP 5000M;
ALTER TABLE SYS.AUD$ DEALLOCATE UNUSED KEEP 2000M;
……
ALTER TABLE SYS.AUD$ DEALLOCATE UNUSED KEEP 10M;

5、再次查看system表空间使用情况 查看审计日志大小 image.png 遗憾的是表空间大小并没有回收,仍然是33G image.png 据了解system表空间为预置空间,一旦达到单个数据文件的最大值就不能减小了,据说使用resize可以慢慢释放,我得再试一下。 6、另外网友也建议最好将aud审计表迁移到其他表空间,如果不是很在意审计可以关闭审计等。 参考链接:https://blog.csdn.net/line_on_database/article/details/120758149