合 rman在rac或ASM环境做增量恢复时报错RMAN-06094 datafile 1 must be restored
Tags: Oracle故障处理rman增量恢复RMAN-06094
现象
rman先做了全量的resotore+recover操作,然后还原增量的控制文件,然后做增量的recover操作,结果报错了:
1 2 3 4 5 6 7 8 | RMAN> recover database; Starting recover at 27-FEB-22 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 02/27/2022 17:44:52 RMAN-06094: datafile 1 must be restored |
报错的意思:文件1必须被还原,文件1不存在。
分析
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | [oracle@odsa ~]$ rman target / Recovery Manager: Release 12.2.0.1.0 - Production on Sun Feb 27 17:34:46 2022 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. connected to target database: lhrdb (DBID=461586729, not open) RMAN> report schema; using target database control file instead of recovery catalog RMAN-06139: warning: control file is not current for REPORT SCHEMA Report of database schema for database with db_unique_name lhrdb List of Permanent Datafiles =========================== File Size(MB) Tablespace RB segs Datafile Name ---- -------- -------------------- ------- ------------------------ 1 0 SYSTEM *** +DATA/lhrdb/datafile/system.259.985609967 2 0 SYSAUX *** +DATA/lhrdb/datafile/sysaux.260.985609969 3 0 UNDOTBS1 *** +DATA/lhrdb/datafile/undotbs1.261.985609969 4 0 UNDOTBS2 *** +DATA/lhrdb/datafile/undotbs2.263.985609973 5 0 USERS *** +DATA/lhrdb/datafile/users.264.985609975 。。。。。 List of Temporary Files ======================= File Size(MB) Tablespace Maxsize(MB) Tempfile Name ---- -------- -------------------- ----------- -------------------- 1 20 TEMP 32767 +DATA/lhrdb/tempfile/temp.262.985609969 2 16384 TEMP 16384 +DATA/lhrdb/tempfile/temp.353.1096538341 RMAN> exit |
结果发现,“Size(MB)”列都是0。有点奇怪。
然后去asmcmd里查看是否存在文件:
1 2 3 4 5 6 | ASMCMD> ls -l +DATA/lhrdb/datafile/system.259.985609967 ASMCMD-8002: entry 'system.259.985609967' does not exist in directory '+DATA/lhrdb/datafile/' ASMCMD> cd +DATA/lhrdb/datafile/ ASMCMD> ls -l system* Type Redund Striped Time Sys Name DATAFILE UNPROT COARSE FEB 27 17:00:00 Y SYSTEM.329.1097770431 |
结果发现,文件名不一样。
于是找之前的全量的restore过程,发现还原的文件名为:
1 2 3 4 5 6 | channel ORA_DISK_6: starting datafile backup set restore channel ORA_DISK_6: specifying datafile(s) to restore from backup set channel ORA_DISK_6: restoring datafile 00001 to +DATA/lhrdb/datafile/system.259.985609967 channel ORA_DISK_6: restoring datafile 00014 to +DATA/lhrdb/datafile/ids.276.985620689 channel ORA_DISK_6: restoring datafile 00022 to +DATA/lhrdb/datafile/ods.284.985621183 channel ORA_DISK_6: restoring datafile 00038 to +DATA/lhrdb/datafile/ods.300.985621707 |
第一次全量restore的时候,终端显示还原后的文件名为system.259.985609967,但是,其实asmcmd中的文件名已经发生了变化,这一点在我删除环境后,第二次做实验的时候得到了验证,另外,可以在告警日志中查询到恢复后的数据文件名:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | RMAN> report schema; using target database control file instead of recovery catalog RMAN-06139: warning: control file is not current for REPORT SCHEMA Report of database schema for database with db_unique_name lhrdb List of Permanent Datafiles =========================== File Size(MB) Tablespace RB segs Datafile Name ---- -------- -------------------- ------- ------------------------ 1 4096 SYSTEM *** +DATA/lhrdb/DATAFILE/system.289.1097780323 2 0 SYSAUX *** +DATA/lhrdb/datafile/sysaux.260.985609969 3 30720 UNDOTBS1 *** +DATA/lhrdb/DATAFILE/undotbs1.338.1097780321 4 0 UNDOTBS2 *** +DATA/lhrdb/datafile/undotbs2.263.985609973 5 4958 USERS *** +DATA/lhrdb/DATAFILE/users.270.1097780323 |
由于,第一次的全量后的归档丢失,所以,若要做恢复操作,必须恢复最新的控制文件,但是最新的控制文件里记录的文件名依然是源库的控制文件,所以就导致了报错“RMAN-06094: datafile 1 must be restored”。
解决
所以,解决方法就是,在做增量恢复操作,恢复最新的控制文件之前,执行report schema操作或“select file#,name from v$datafile;”记录最新的文件名,然后恢复最新的控制文件,再通过rename重命名的方式将控制文件中的名称修改为最新的数据文件名。