手记

删除Oracle归档日志方法


一、查看归档日志情况

1:在数据库处于打开状态

查看数据归档状态:

C:\Users\Administrator>sqlplus /nolog

 

SQL*Plus: Release 11.2.0.3.0 Production on Fri Mar 23 12:10:31 2012

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

SQL> connect /as sysdba;

Connected.

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     1

Next log sequence to archive   2

Current log sequence           2

从这个可以看出Archive destination            USE_DB_RECOVERY_FILE_DEST   归档日志的存放闪回区.

查看闪回区大小

SQL> show parameter db_re

 

NAME                                 TYPE        VALUE

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

db_recovery_file_dest                string      D:\app\Administrator\fast_reco very_area

db_recovery_file_dest_size            big integer  4122M

db_recycle_cache_size                big integer  0

从这里可以看出闪回去的位置和大小

去查看归档所在目录的真实大小 .这里就是闪回区所在的目录,如果真实目录的大小是不是已经打到闪回区的大小,如果是可以增大闪回区的大小,使用下面命令

SQL> alter system set db_recovery_file_dest_size=6G;

System altered.

2:数据已经关闭状态

数据已经关闭,在开启是报错.可以把数据库开启到mount 状态下修改参数

SQL> startup mount

ORACLE instance started.

Total System Global Area 2572144640 bytes

Fixed Size                  2257952 bytes

Variable Size             570428384 bytes

Database Buffers         1979711488 bytes

Redo Buffers               19746816 bytes

Database mounted.

可以再这种模式下修改参数 ,和查看.修改完毕后,在开启数据库

SQL> alter database open;

 

Database altered.

二、删除归档日志方法

方法1 :可以先删除磁盘上的日志文件,在去数据库里删除逻辑日志记录

登陆到rman

C:\Users\Administrator>rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Mar 23 12:31:50 2012

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

connected to target database: TEST (DBID=2076824462)

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 TEST

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

 

Key     Thrd Seq     S Low Time

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

1       1    2       A 23-MAR-12

        Name: D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2012_03_23

\O1_MF_1_2_7PQYKCLL_.ARC

这里可以看到日志清单;

检查归档日志状态;

RMAN> crosscheck archivelog all;

 

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=8 device type=DISK

validation failed for archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\

012_03_23\O1_MF_1_2_7PQYKCLL_.ARC RECID=1 STAMP=778681261

validation failed for archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\

012_03_23\O1_MF_1_3_7PQYKGH3_.ARC RECID=2 STAMP=778681262

validation failed for archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\

012_03_23\O1_MF_1_4_7PQYKKFQ_.ARC RECID=3 STAMP=778681265

validation failed for archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\

012_03_23\O1_MF_1_5_7PQYKQTW_.ARC RECID=4 STAMP=778681272

validation failed for archived log

删除日志:

RMAN> delete expired archivelog all;

 

released channel: ORA_DISK_1

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=8 device type=DISK

List of Archived Log Copies for database with db_unique_name TEST

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

 

Key     Thrd Seq     S Low Time

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

1       1    2       X 23-MAR-12

        Name: D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2012_03_23

\O1_MF_1_2_7PQYKCLL_.ARC

 

2       1    3       X 23-MAR-12

        Name: D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2012_03_23

\O1_MF_1_3_7PQYKGH3_.ARC

 

3       1    4       X 23-MAR-12

        Name: D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2012_03_23

\O1_MF_1_4_7PQYKKFQ_.ARC

 

4       1    5       X 23-MAR-12

        Name: D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2012_03_23

\O1_MF_1_5_7PQYKQTW_.ARC

 

5       1    6       X 23-MAR-12

        Name: D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2012_03_23

\O1_MF_1_6_7PQYKSX0_.ARC

 

这里会提示你是否删除:

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

deleted archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2

012_03_23\O1_MF_1_2_7PQYKCLL_.ARC RECID=1 STAMP=778681261

deleted archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2

012_03_23\O1_MF_1_3_7PQYKGH3_.ARC RECID=2 STAMP=778681262

deleted archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2

012_03_23\O1_MF_1_4_7PQYKKFQ_.ARC RECID=3 STAMP=778681265

deleted archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2

012_03_23\O1_MF_1_5_7PQYKQTW_.ARC RECID=4 STAMP=778681272

deleted archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2

012_03_23\O1_MF_1_6_7PQYKSX0_.ARC RECID=5 STAMP=778681274

Deleted 5 EXPIRED objects

查看闪回区使用状态  

SQL> select * from v$flash_recovery_area_usage;

 

FILE_TYPE            PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES

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

CONTROL FILE                          0                         0               0

REDO LOG                              0                         0               0

ARCHIVED LOG                      11.99                         0            1224

BACKUP PIECE                          0                         0               0

IMAGE COPY                            0                         0               0

FLASHBACK LOG                         0                         0               0

FOREIGN ARCHIVED LOG                  0                         0               0

 

7 rows selected

方法2:直接在rman下删除归档日志

RMAN> delete archivelog all completed before 'sysdate'; 

这个命令是把当前日期之前的全部删掉

可以指定删除几天之前的,比如删除七天之前的

RMAN> delete archivelog all completed before 'sysdate-7';

RMAN> delete archivelog all completed before 'sysdate';

 

released channel: ORA_DISK_1

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=8 device type=DISK

List of Archived Log Copies for database with db_unique_name TEST

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

 

Key     Thrd Seq     S Low Time

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

6       1    7       A 23-MAR-12

        Name: D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2012_03_23

\O1_MF_1_7_7PQYKTMZ_.ARC

 

7       1    8       A 23-MAR-12

        Name: D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2012_03_23

\O1_MF_1_8_7PQYKVVZ_.ARC

 

8       1    9       A 23-MAR-12

        Name: D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2012_03_23

\O1_MF_1_9_7PQYKYYF_.ARC

 

9       1    10      A 23-MAR-12

        Name: D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2012_03_23

\O1_MF_1_10_7PQYL03B_.ARC

 

10      1    11      A 23-MAR-12

        Name: D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2012_03_23

\O1_MF_1_11_7PQYL0XS_.ARC

 

 

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

deleted archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2

012_03_23\O1_MF_1_7_7PQYKTMZ_.ARC RECID=6 STAMP=778681275

deleted archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2

012_03_23\O1_MF_1_8_7PQYKVVZ_.ARC RECID=7 STAMP=778681276

deleted archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2

012_03_23\O1_MF_1_9_7PQYKYYF_.ARC RECID=8 STAMP=778681279

deleted archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2

012_03_23\O1_MF_1_10_7PQYL03B_.ARC RECID=9 STAMP=778681280

deleted archived log

archived log file name=D:\APP\ADMINISTRATOR\FAST_RECOVERY_AREA\TEST\ARCHIVELOG\2

012_03_23\O1_MF_1_11_7PQYL0XS_.ARC RECID=10 STAMP=778681281

Deleted 5 objects

 

 

 

©著作权归作者所有:来自51CTO博客作者itbill的原创作品,如需转载,请注明出处,否则将追究法律责任

ORACLE归档日志Database


0人推荐
随时随地看视频
慕课网APP