Oracle归档日志删除

前端之家收集整理的这篇文章主要介绍了Oracle归档日志删除前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

环境说明

版本:Oracle 11gR2

操作步骤

查看系统磁盘使用情况

[oracle@Oracle ~]$ df -h
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/vg_vm1-lv_root   28G   21G  5.6G  79% /
tmpfs                        12G  5.3G  6.8G  44% /dev/shm
/dev/sda1                   485M   40M  421M   9% /boot
/dev/sdb1                    99G   19G   76G  20% /data

查看Oracle归档日志文件路径

sql> select name from v$archived_log;
······
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9480_886035729.dbf
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9481_886035729.dbf
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9482_886035729.dbf
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9483_886035729.dbf
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9484_886035729.dbf
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9485_886035729.dbf
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9486_886035729.dbf
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9487_886035729.dbf
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9488_886035729.dbf
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9489_886035729.dbf
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9490_886035729.dbf

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9491_886035729.dbf

1024 rows selected.

正确删除归档日志

[oracle@Oracle ~]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/bin/ 
[oracle@Oracle bin]$ rman 
 
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Oct 24 20:30:08 2016 
 
Copyright (c) 1982,2009,Oracle and/or its affiliates. All rights reserved. 
 
RMAN> connect target / 
 
connected to target database: ORCL (DBID=1413816463) 
 
RMAN> LIST ARCHIVELOG ALL;  //执行该命令查看所有归档日志
RMAN> DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-7';  //删除7天前的归档日志
(注:SYSDATA-7,表示当前系统时间7天前,before关键字表示在7天前的归档日志,如果使用了闪回功能,也会删除闪回的数据)
······
Do you really want to delete the above objects (enter YES or NO)? YES

RMAN> DELETE ARCHIVELOG FROM TIME 'SYSDATE-7';  //删除从第7天到当前的归档日志

RMAN> CROSSCHECK ARCHIVELOG ALL;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=195 device type=DISK
specification does not match any archived log in the repository

RMAN> DELETE EXPIRED ARCHIVELOG ALL;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=195 device type=DISK
specification does not match any archived log in the repository

RMAN> exit


Recovery Manager complete.

再次查看系统磁盘使用情况

[oracle@Oracle bin]$ df -h
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/vg_vm1-lv_root   28G   13G   15G  46% /
tmpfs                        12G  5.3G  6.8G  44% /dev/shm
/dev/sda1                   485M   40M  421M   9% /boot
/dev/sdb1                    99G   19G   76G  20% /data​

猜你在找的Oracle相关文章