使用RMAN备份时遇到如下错误:
RMAN> backup full format '/home/oracle/backup/FULL_%t_%U' database plus archivelog;Starting backup at 05-AUG-17
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup plus archivelog command at 08/05/2017 20:31:47
RMAN-06059: expected archived log not found, loss of archived log compromises recoverability
ORA-19625: error identifying file /home/oracle/arch1_13_949547843.dbf
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
不能识别归档文件,按照百度出来的方法,执行以下操作:
RMAN> change archivelog all crosscheck;
再执行备份就成功了。
想起来之前是因为我配置了参数log_archive_dest_1的路径,但是之后忘记了这回事,在那个路径下发现了一些文件,误认为是其他没用的文件,所以删除了,但是此时控制文件中的记录并没有删除,oracle认为此时这个文件还是存在的,当用RMAN备份的时候,控制文件中记录的归档日志的信息和实际情况是不一致的,就会报错说不能识别这个文件。交叉检查就是用来进行这种检验的,检查在RMAN中记录的备份的状态和在磁盘上实际存在的东西是不是一致的。
举个例子来说:
刚做好的全备
RMAN> list backup of database;List of Backup Sets
===================BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10 Full 1.02G DISK 00:12:30 05-AUG-17 BP Key: 10 Status: AVAILABLE Compressed: NO Tag: TAG20170805T204240Piece Name: /home/oracle/FULL_951252160_0csb5t60_1_1List of Datafiles in backup set 10File LV Type Ckp SCN Ckp Time Name---- -- ---- ---------- --------- ----1 Full 1163458 05-AUG-17 /u01/app/oracle/oradata/orcl/system01.dbf2 Full 1163458 05-AUG-17 /u01/app/oracle/oradata/orcl/sysaux01.dbf3 Full 1163458 05-AUG-17 /u01/app/oracle/oradata/orcl/undotbs01.dbf4 Full 1163458 05-AUG-17 /u01/app/oracle/oradata/orcl/users01.dbf
对/home/oracle/FULL_951252160_0csb5t60_1_1这个备份做一些修改,往里边添加一些字符,人为破坏掉它。
然后查看这个备份的状态,available,依旧是可用的,也就是说RMAN现在并不能知道这个备份已经坏掉了。
RMAN> list backup of database;using target database control file instead of recovery catalogList of Backup Sets
===================BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10 Full 1.02G DISK 00:12:30 05-AUG-17 BP Key: 10 Status: AVAILABLE Compressed: NO Tag: TAG20170805T204240Piece Name: /home/oracle/FULL_951252160_0csb5t60_1_1List of Datafiles in backup set 10File LV Type Ckp SCN Ckp Time Name---- -- ---- ---------- --------- ----1 Full 1163458 05-AUG-17 /u01/app/oracle/oradata/orcl/system01.dbf2 Full 1163458 05-AUG-17 /u01/app/oracle/oradata/orcl/sysaux01.dbf3 Full 1163458 05-AUG-17 /u01/app/oracle/oradata/orcl/undotbs01.dbf4 Full 1163458 05-AUG-17 /u01/app/oracle/oradata/orcl/users01.dbf
要是执行交叉检查,就会发现问题了,此时的状态已经变成expired,过期的
RMAN> crosscheck backupset;using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
crosschecked backup piece: found to be 'EXPIRED' backup piece handle=/home/oracle/FULL_951252160_0csb5t60_1_1 RECID=10 STAMP=951252162
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/home/oracle/backup/con_bak/CTL_c-1477328572-20170805-01 RECID=12 STAMP=951252929
Crosschecked 2 objects
所以我理解交叉检查就是会把控制文件中记录的信息和你真实物理位置的文件进行比较,列出过期不可用的备份都有哪些,这时候要做的工作就是删除这些不可用的备份或文件。接下来的工作就会正常执行了。
RMAN> delete expired backupset;using channel ORA_DISK_1List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
10 10 1 1 EXPIRED DISK /home/oracle/FULL_951252160_0csb5t60_1_1Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/home/oracle/FULL_951252160_0csb5t60_1_1 RECID=10 STAMP=951252162
Deleted 1 EXPIRED objectsRMAN> crosscheck backup;using channel ORA_DISK_1
backup piece handle=/home/oracle/backup/con_bak/CTL_c-1477328572-20170805-01 RECID=12 STAMP=951252929
Crosschecked 1 objects