delete archivelog all 无法彻底删除归档日志?
最近在因归档日志暴增,使用delete archivelog all貌似无法清除所有的归档日志,到底是什么原因呢?
[python]
1、演示环境
SQL> select * from v$version where rownum<2;
BANNER
----------------------------------------------------------------
Oracle Database 10g Release 10.2.0.3.0 - 64bit Production
SQL> select inst_id,instance_name from gv$instance; -->两节点RAC
INST_ID INSTANCE_NAME
---------- ----------------
1 GOBO4A
2 GOBO4B
SQL> show parameter db_recovery -->+REV,使用了ASM 存储方式
NAME TYPE VALUE
------------------------------------ ----------- -------------
db_recovery_file_dest string +REV
db_recovery_file_dest_size big integer 1G
SQL> select flashback_on from v$database; -->数据库未开启闪回特性,也就是说尽管指定了闪回区,未启用闪回特性
-->相应的,归档日志充满整个闪回区时,闪回区空间并不会被重用
FLASHBACK_ON
------------------
NO
2、查看及清除现有的归档日志文件
oracle@bo2dbp:~> export ORACLE_SID=+ASM1
oracle@bo2dbp:~> asmcmd
ASMCMD> cd +REV/GOBO4/ARCHIVELOG
ASMCMD> ls
2012_10_08/
....
arch_795194241_1_10.arc
arch_795194241_1_100.arc
....
oracle@bo2dbp:~> export ORACLE_SID=GOBO4A
oracle@bo2dbp:~> rman target /
Recovery Manager: Release 10.2.0.3.0 - Production on Thu Nov 29 16:23:15 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: GOBO4 (DBID=921286879)
#下面通过使用rman backup archivelog方式来删除所有的归档日志文件
RMAN> backup format '/install_source/rman_bak/arch_%d_%U'
2> archivelog all delete input;
Starting backup at 29-NOV-12
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1058 instance=GOBO4A devtype=DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=139 recid=214 stamp=797450261
input archive log thread=1 sequence=140 recid=215 stamp=797450292
input archive log thread=1 sequence=141 recid=216 stamp=797450308
input archive log thread=1 sequence=142 recid=218 stamp=797450347
input archive log thread=1 sequence=143 recid=219 stamp=797450372
input archive log thread=1 sequence=144 recid=220 stamp=797450409
channel ORA_DISK_1: starting piece 1 at 29-NOV-12
channel ORA_DISK_1: finished piece 1 at 29-NOV-12
piece handle=/install_source/rman_bak/arch_GOBO4_1dnrhkn4_1_1 tag=TAG20121129T162806 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:15
channel ORA_DISK_1: deleting archive log(s)
archive log filename=+REV/gobo4/archivelog/arch_795194241_1_139.arc recid=214 stamp=797450261
archive log filename=+REV/gobo4/archivelog/arch_795194241_1_140.arc recid=215 stamp=797450292
archive log filename=+REV/gobo4/archivelog/arch_795194241_1_141.arc recid=216 stamp=797450308
........
piece handle=/install_source/rman_bak/arch_GOBO4_1hnrhli2_1_1 tag=TAG20121129T162806 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:09
channel ORA_DISK_1: deleting archive log(s)
archive log filename=+REV/gobo4/archivelog/arch_795194241_2_141.arc recid=427 stamp=800547491
archive log filename=+REV/gobo4/archivelog/arch_795194241_2_142.arc recid=429 stamp=800549193
archive log filename=+REV/gobo4/archivelog/arch_795194241_2_143.arc recid=433 stamp=800578944
archive log filename=+REV/gobo4/archivelog/arch_795194241_2_144.arc recid=437 stamp=800641679
Finished backup at 29-NOV-12
#再次查看依然有很多归档日志文件存在,而且都是10月23日之前的
ASMCMD> pwd
+REV/GOBO4/ARCHIVELOG
ASMCMD> ls
2012_09_30/
2012_10_09/
2012_10_10/
2012_10_11/
2012_10_12/
2012_10_13/
2012_10_14/
2012_10_15/
2012_10_16/
2012_10_17/
2012_10_18/
2012_10_22/
2012_10_23/
arch_795194241_1_100.arc
arch_795194241_1_101.arc
arch_795194241_1_102.arc
............
#再次删除日志文件,来个更狠的命令,直接delete所有的archivelog,最近新增的一个archivelog被删除
RMAN> delete noprompt archivelog all;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1081 instance=GOBO4A devtype=DISK
List of Archived Log Copies
Key Thrd Seq S Low Time Name
------- ---- ------- - --------- ----
453 1 294 A 29-NOV-12 +REV/gobo4/archivelog/arch_795194241_1_294.arc
deleted archive log
archive log filename=+REV/gobo4/archivelog/arch_795194241_1_294.arc recid=453 stamp=800662185
Deleted 1 objects www.zzzyk.com
# 上面输出的结果只有一个归档日志被删除,何以故?
# 这个我们的分析一下delete noprompt archivelog all以及备份归档日志时使用的 delete input
# 回顾一下Oracle控制文件以及Oracle RMAN的的备份恢复的原理。
# 我们知道,Oracle 控制文件里边记录了数据库的名字,id,创建的时间戳....一大堆的信息,当然也有不可少的归档信息以及备份信息。
# 如果不知道控制文件有什么? 那就参考:Oracle 控制文件,文章尾部有给出链接。
# 其次,Oracle RMAN的备份恢复的所有信息都依赖于两个东东,要么是控制文件,要么是恢复目录(catalog)。
# 因为所有的备份与恢复信息都会依据备份是的方式存储到这两个位置。
# 理所当然的是,对这两个东东里的备份集,镜像副本,归档日志,等等所有能备份的对象的任意操作,首先会参考这些对象的记录的信息。
# 其次是当被记录的对象发生变化时做相应的更新。
3、深度分析无法清除的原因
#先来看看gv$archived_log,如果是单实例使用v$archived_log
#从下面的查询可知,又有两个新的归档日志产生,一个从第一个instance产生,一个从第二个instance产生。
SQL> select name,status,count(*) from gv$archived_log group by name,status;
NAME
补充:Web开发 , Python ,