首先确认归档日志是否开启:archive log list;
SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 3017 Next log sequence to archive 3019 Current log sequence 3019 SQL>
查看归档日志占用的空间大小:
SQL> select * from v$recovery_file_dest; NAME -------------------------------------------------------------------------------- SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES ----------- ---------- ----------------- --------------- /volumes01/app/flash_recovery_area 1.0737E+10 2008462336 0 86 SQL> 解释: SPACE_LIMIT: 日志最大空间 SPACE_USED: 日志使用空间 SPACE_RECLAIMABLE:可回收的空间 NUMBER_OF_FILES:日志文件数量
SQL> select sum(percent_space_used)*3/100 from v$flash_recovery_area_usage; SUM(PERCENT_SPACE_USED)*3/100 ----------------------------- .5613 查询日志占用空间的百分比
查询归档日志:
[oracle@az1-ffs-prd-db-01 ~]$ rman target sys/Oracle123@orcl Recovery Manager: Release 11.2.0.1.0 - Production on Mon May 13 14:41:31 2019 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database: ORCL (DBID=1534994283) RMAN> crosscheck archivelog all; using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=52 device type=DISK validation succeeded for archived log archived log file name=/volumes01/app/flash_recovery_area/ORCL/archivelog/2019_05_13/o1_mf_1_2993_gfkk8tn0_.arc RECID=272 STAMP=1008148506 validation succeeded for archived log 。。。。。。。。 RMAN>
清理归档日志:
RMAN> delete archivelog until time 'sysdate'; --删除所有日志 RMAN> delete archivelog until time 'sysdate-7'; --删除7天前的日志 RMAN> delete expired archivelog all;--删除过期日志