上周因为DATAGUARD系统空间满,导致紧急删除了部分未应用的归档日志,
事后通过RMAN提取主库中ASM的归档日志到本地磁盘,运行了如下命令:
RMAN> copy archivelog '+DATA/log/archivelog/rman2_5585_697238176.dbf' to '/u01/rman2_5585_697238176.dbf';
然后FTP到DATAGUARD服务器并激活日志应用,使得DATAGUARD系统日志得以完全恢复,
但后续在主库的RMAN备份中发现了归档日志备份错误,具体如下:
Starting backup at 02-JUN-11
current log archived
archived log /u01/rman/2_5585_697238176.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 2, sequence 5585
released channel: d1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03015: error occurred in stored script global_inc1
RMAN-03015: error occurred in stored script global_arch
RMAN-03002: failure of backup command at 06/02/2011 01:20:45
RMAN-06059: expected archived log not found, lost of archived log compromises recoverability
ORA-19625: error identifying file /u01/rman2_5585_697238176.dbf
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
分析:
显然是RMAN认为/u01/rman2_5585_697238176.dbf也需要备份,而该文件在我使用后被我从操作系统删除了,
如果通过RMAN删除显然不会出现该问题。
为了解决备份问题,采取如下两条命令解决问题:
1、crosscheck archivelog all;--检查控制文件和实际物理文件的差别
2、delete expired archivelog all;--同步控制文件的信息和实际物理文件的信息
理论支持:
在controlfile中记录着每一个archivelog的相关信息,当我们在OS下把这些物理文件delete掉或异常变动后,
在controlfile中仍然记录着这些archivelog的信息,当我们手工清除archive目录下的文件后,
这些记录并没有被我们从controlfile中清除掉,也就是oracle并不知道这些文件已经不存在了!
这时候我们要做手工的清除。
如果单独执行crosscheck而没有执行delete那么备份还是失败的,原因是那些控制文件的信息和实际的信息还是不同。
实际运行结果:
--检查控制文件和实际物理文件的差别
RMAN> crosscheck archivelog all;
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=956 instance=log1 devtype=DISK
validation succeeded for archived log
archive log filename=+DATA/log/archivelog/1_6677_697238176.dbf recid=17370 stamp=752462211
validation succeeded for archived log
……省略n行
Crosschecked 424 objects
--同步控制文件的信息和实际物理文件的信息
RMAN> delete expired archivelog all;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=956 instance=log1 devtype=DISK
List of Archived Log Copies
Key Thrd Seq S Low Time Name
------- ---- ------- - ------------------- ----
17229 2 5585 X 2011-05-29 06:19:58 /u01/rman/2_5585_697238176.dbf
17222 2 5585 X 2011-05-29 06:19:58 /u01/rman2_5585_697238176.dbf
17230 2 5586 X 2011-05-29 06:22:09 /u01/rman/2_5586_697238176.dbf
17223 2 5586 X 2011-05-29 06:22:09 /u01/rman2_5586_697238176.dbf
17231 2 5587 X 2011-05-29 06:23:57 /u01/rman/2_5587_697238176.dbf
17224 2 5587 X 2011-05-29 06:23:57 /u01/rman2_5587_697238176.dbf
17232 2 5588 X 2011-05-29 06:25:39 /u01/rman/2_5588_697238176.dbf
17225 2 5588 X 2011-05-29 06:25:39 /u01/rman2_5588_697238176.dbf
17233 2 5589 X 2011-05-29 06:27:25 /u01/rman/2_5589_697238176.dbf
17226 2 5589 X 2011-05-29 06:27:25 /u01/rman2_5589_697238176.dbf
17234 2 5590 X 2011-05-29 06:29:28 /u01/rman/2_5590_697238176.dbf
17227 2 5590 X 2011-05-29 06:29:28 /u01/rman2_5590_697238176.dbf
17235 2 5591 X 2011-05-29 06:31:29 /u01/rman/2_5591_697238176.dbf
17228 2 5591 X 2011-05-29 06:31:29 /u01/rman2_5591_697238176.dbf
17238 2 5593 X 2011-05-29 06:34:38 /u01/rman/2_5593_697238176.dbf
17239 2 5594 X 2011-05-29 06:36:12 /u01/rman/2_5594_697238176.dbf
Do you really want to delete the above objects (enter YES or NO)? y----------此处输入y
deleted archive log
archive log filename=/u01/rman/2_5585_697238176.dbf recid=17229 stamp=752428754
deleted archive log
archive log filename=/u01/rman2_5585_697238176.dbf recid=17222 stamp=752428605
deleted archive log
archive log filename=/u01/rman/2_5586_697238176.dbf recid=17230 stamp=752428762
deleted archive log
archive log filename=/u01/rman2_5586_697238176.dbf recid=17223 stamp=752428613
deleted archive log
archive log filename=/u01/rman/2_5587_697238176.dbf recid=17231 stamp=752428770
deleted archive log
archive log filename=/u01/rman2_5587_697238176.dbf recid=17224 stamp=752428622
deleted archive log
archive log filename=/u01/rman/2_5588_697238176.dbf recid=17232 stamp=752428779
deleted archive log
archive log filename=/u01/rman2_5588_697238176.dbf recid=17225 stamp=752428630
deleted archive log
archive log filename=/u01/rman/2_5589_697238176.dbf recid=17233 stamp=752428787
deleted archive log
archive log filename=/u01/rman2_5589_697238176.dbf recid=17226 stamp=752428638
deleted archive log
archive log filename=/u01/rman/2_5590_697238176.dbf recid=17234 stamp=752428795
deleted archive log
archive log filename=/u01/rman2_5590_697238176.dbf recid=17227 stamp=752428646
deleted archive log
archive log filename=/u01/rman/2_5591_697238176.dbf recid=17235 stamp=752428847
deleted archive log
archive log filename=/u01/rman2_5591_697238176.dbf recid=17228 stamp=752428673
deleted archive log
archive log filename=/u01/rman/2_5593_697238176.dbf recid=17238 stamp=752432689
deleted archive log
archive log filename=/u01/rman/2_5594_697238176.dbf recid=17239 stamp=752432700
Deleted 16 EXPIRED objects
RMAN>
处理完毕!