Chinaunix首页 | 论坛 | 博客
  • 博客访问: 36132
  • 博文数量: 10
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 100
  • 用 户 组: 普通用户
  • 注册时间: 2013-12-18 14:53
文章分类
文章存档

2016年(10)

我的朋友

分类: Oracle

2016-09-08 18:15:07

查看归档日志的路径:

查看归档目录下的日志:

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

第一种方案:

使用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就可以了。

阅读(1499) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~