archive log清理

查看归档日志的路径:

bb

查看归档目录下的日志:

bb

删除两天以前的归档日志:

第一种方案:

使用RMAN列出所有的归档文件

[oracle@localhost arch]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jun 28 21:56:33 2016

 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ATSDB (DBID=2827649560)

 

RMAN> list archivelog all;

 

using target database control file instead of recovery catalog

List of Archived Log Copies for database with db_unique_name ATSDB

=====================================================================

 

Key     Thrd Seq     S Low Time

------- ---- ------- - ---------

1       1    109     A 25-JUN-16

        Name: /opt/app/oracle/arch/1_109_914614683.dbf

 

2       1    110     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_110_914614683.dbf

 

3       1    111     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_111_914614683.dbf

 

4       1    112     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_112_914614683.dbf

 

5       1    113     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_113_914614683.dbf

 

6       1    114     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_114_914614683.dbf

 

7       1    115     A 27-JUN-16

        Name: /opt/app/oracle/arch/1_115_914614683.dbf

 

8       1    116     A 27-JUN-16

        Name: /opt/app/oracle/arch/1_116_914614683.dbf

 

……..

查找出两天以前的归档文件:

RMAN> list archivelog until time 'sysdate-2';

 

List of Archived Log Copies for database with db_unique_name ATSDB

=====================================================================

 

Key     Thrd Seq     S Low Time

------- ---- ------- - ---------

1       1    109     A 25-JUN-16

        Name: /opt/app/oracle/arch/1_109_914614683.dbf

 

2       1    110     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_110_914614683.dbf

 

3       1    111     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_111_914614683.dbf

 

4       1    112     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_112_914614683.dbf

 

5       1    113     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_113_914614683.dbf

 

6       1    114     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_114_914614683.dbf

 

 

RMAN>

删除两天前的归档日志:

RMAN> delete archivelog until time 'sysdate-2';

 

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=2485 device type=DISK

List of Archived Log Copies for database with db_unique_name ATSDB

=====================================================================

 

Key     Thrd Seq     S Low Time

------- ---- ------- - ---------

1       1    109     A 25-JUN-16

        Name: /opt/app/oracle/arch/1_109_914614683.dbf

 

2       1    110     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_110_914614683.dbf

 

3       1    111     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_111_914614683.dbf

 

4       1    112     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_112_914614683.dbf

 

5       1    113     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_113_914614683.dbf

 

6       1    114     A 26-JUN-16

        Name: /opt/app/oracle/arch/1_114_914614683.dbf

 

 

Do you really want to delete the above objects (enter YES or NO)? yes

deleted archived log

archived log file name=/opt/app/oracle/arch/1_109_914614683.dbf RECID=1 STAMP=915503406

deleted archived log

archived log file name=/opt/app/oracle/arch/1_110_914614683.dbf RECID=2 STAMP=915503487

deleted archived log

archived log file name=/opt/app/oracle/arch/1_111_914614683.dbf RECID=3 STAMP=915503583

deleted archived log

archived log file name=/opt/app/oracle/arch/1_112_914614683.dbf RECID=4 STAMP=915505227

deleted archived log

archived log file name=/opt/app/oracle/arch/1_113_914614683.dbf RECID=5 STAMP=915531348

deleted archived log

archived log file name=/opt/app/oracle/arch/1_114_914614683.dbf RECID=6 STAMP=915589805

Deleted 6 objects

 

 

RMAN>

校验

RMAN> crosscheck archivelog all;

 

released channel: ORA_DISK_1

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=2485 device type=DISK

validation succeeded for archived log

archived log file name=/opt/app/oracle/arch/1_115_914614683.dbf RECID=7 STAMP=915589865

validation succeeded for archived log

archived log file name=/opt/app/oracle/arch/1_116_914614683.dbf RECID=8 STAMP=915589910

validation succeeded for archived log

archived log file name=/opt/app/oracle/arch/1_117_914614683.dbf RECID=9 STAMP=915617816

validation succeeded for archived log

archived log file name=/opt/app/oracle/arch/1_118_914614683.dbf RECID=10 STAMP=915676203

validation succeeded for archived log

…….

 

 

RMAN>

 

可以看到之前删除的日志不存在了。

第二种方案:

先从操作系统层面删除掉

[oracle@localhost arch]$ rm 1_115_914614683.dbf

[oracle@localhost arch]$ rm 1_116_914614683.dbf

[oracle@localhost arch]$ rm 1_117_914614683.dbf

然后使用RMAN查询下

RMAN> list archivelog all;

 

using target database control file instead of recovery catalog

List of Archived Log Copies for database with db_unique_name ATSDB

=====================================================================

 

Key     Thrd Seq     S Low Time

------- ---- ------- - ---------

7       1    115     A 27-JUN-16

        Name: /opt/app/oracle/arch/1_115_914614683.dbf

 

8       1    116     A 27-JUN-16

        Name: /opt/app/oracle/arch/1_116_914614683.dbf

 

9       1    117     A 27-JUN-16

        Name: /opt/app/oracle/arch/1_117_914614683.dbf

 

10      1    118     A 27-JUN-16

        Name: /opt/app/oracle/arch/1_118_914614683.dbf

……

RMAN>

可以看到已经删除的archivelog还存在列表中,也就是说控制文件中还保存在已经删除的归档文件的记录

RMAN> list expired archivelog all;

 

List of Archived Log Copies for database with db_unique_name ATSDB

=====================================================================

 

Key     Thrd Seq     S Low Time

------- ---- ------- - ---------

7       1    115     X 27-JUN-16

        Name: /opt/app/oracle/arch/1_115_914614683.dbf

 

8       1    116     X 27-JUN-16

        Name: /opt/app/oracle/arch/1_116_914614683.dbf

 

9       1    117     X 27-JUN-16

        Name: /opt/app/oracle/arch/1_117_914614683.dbf

 

 

RMAN> delete expired archivelog all;

 

released channel: ORA_DISK_1

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=2485 device type=DISK

List of Archived Log Copies for database with db_unique_name ATSDB

=====================================================================

 

Key     Thrd Seq     S Low Time

------- ---- ------- - ---------

7       1    115     X 27-JUN-16

        Name: /opt/app/oracle/arch/1_115_914614683.dbf

 

8       1    116     X 27-JUN-16

        Name: /opt/app/oracle/arch/1_116_914614683.dbf

 

9       1    117     X 27-JUN-16

        Name: /opt/app/oracle/arch/1_117_914614683.dbf

 

 

Do you really want to delete the above objects (enter YES or NO)? yes

deleted archived log

archived log file name=/opt/app/oracle/arch/1_115_914614683.dbf RECID=7 STAMP=915589865

deleted archived log

archived log file name=/opt/app/oracle/arch/1_116_914614683.dbf RECID=8 STAMP=915589910

deleted archived log

archived log file name=/opt/app/oracle/arch/1_117_914614683.dbf RECID=9 STAMP=915617816

Deleted 3 EXPIRED objects

 

 

RMAN>

因为已经删除的归档日志是不存在的,expired的,因此删除expired 的archivelog就可以了。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29335043/viewspace-2121145/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29335043/viewspace-2121145/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值