Menu Close

DataGuard ORA-01274 RMAN-06085 数据文件恢复

环境描述:
Oracle 18c RAC + DataGuard

1. 故障现象(SYMPTOMS)

备份在恢复时报如下错误:

(10):File #203 added to control file as 'UNNAMED00206' because
(10):the parameter STANDBY_FILE_MANAGEMENT is set to MANUAL
(10):The file should be manually created to continue.
Errors with log /dbData/OracleArch/ArchiveLog/1_429932_1007720356.arc
PR00 (PID:422829): MRP0: Background Media Recovery terminated with error 1274
2021-10-14T08:53:24.515378+08:00
Errors in file /u01/app/oracle/diag/rdbms/xxxdg/XXXDG/trace/XXXDG_pr00_422829.trc:
ORA-01274: cannot add data file that was originally created as '+XXXDATA/XXXDB/952FEEEF7E4A7781E053821510AC6B42/DATAFILE/tbs_wsbsdt.493.1084378651'

2. 变化(CHANGES)

最初 Standby Database 的参数 standby_file_management 值为 AUTO,但是在将 Standby Database 转为 SNAPSHOT Database 后,为了处理文件,将其修改为 MANUAL,但是在转回 Standby Database 时没有修改该参数,导致 Primary Database 增加了数据文件后,并没有同步到备库中。

  • Standby Database 在备库中自动创建的文件名为
    /u01/app/oracle/product/18.3.0/dbhome_1/dbs/UNNAMED00206

  • Standby Database 实际需要创建的文件名为
    /dbData/OracleData/XXXDG/952feeef7e4a7781e053821510ac6b42/datafile/tbs_wsbsdt.493.1084378651

  • 在操作系统层面查看文件是否存在

~]$ ls -lhtr /u01/app/oracle/product/18.3.0/dbhome_1/dbs/UNNAMED00206
ls: cannot access /u01/app/oracle/product/18.3.0/dbhome_1/dbs/UNNAMED00206: No such file or directory

~]$ ls -lhtr /dbData/OracleData/XXXDG/952feeef7e4a7781e053821510ac6b42/datafile/tbs_wsbsdt.493.1084378651
ls: cannot access /dbData/OracleData/XXXDG/952feeef7e4a7781e053821510ac6b42/datafile/tbs_wsbsdt.493.1084378651: No such file or directory
  • 使用RMAN恢复的时候报错
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 10/14/2021 19:00:10
RMAN-06085: must use SET NEWNAME command to restore datafile /u01/app/oracle/product/18.3.0/dbhome_1/dbs/UNNAMED00206
  • 仍然报错
Warning: Datafile 206 (/dbData/OracleData/XXXDG/952feeef7e4a7781e053821510ac6b42/datafile/tbs_wsbsdt.493.1084378651) is offline during full database recovery and will not be recovered

3. 故障原因(CAUSE)

数据文件没有创建成功导致 Standby Database 恢复报错。

4. 解决方案(SOLUTION)

  • 首先停止备库的恢复,并将备库重启到mount状态。
alter database recover managed standby database cancel;
shu immediate;
startup mount;
alter system set standby_file_management='MANUAL';
  • 使用RMAN进行文件恢复
RMAN> run {
2> set newname for datafile 206 to '/dbData/OracleData/XXXDG/952feeef7e4a7781e053821510ac6b42/datafile/tbs_wsbsdt.493.1084378651';
3> restore datafile 206;
4> }

executing command: SET NEWNAME

creating datafile file number=206 name=/dbData/OracleData/XXXDG/952feeef7e4a7781e053821510ac6b42/datafile/tbs_wsbsdt.493.1084378651
restore not done; all files read only, offline, excluded, or already restored
Finished restore at 2021-10-14 19:04:05
  • 查看文件
~]$ ls -lhtr /dbData/OracleData/XXXDG/952feeef7e4a7781e053821510ac6b42/datafile/tbs_wsbsdt.493.1084378651
-rw-r-----. 1 oracle oinstall 2.1G Oct 14 19:03 /dbData/OracleData/XXXDG/952feeef7e4a7781e053821510ac6b42/datafile/tbs_wsbsdt.493.1084378651
  • 重命名文件
    进入sqlplus,将文件重命名
SQL> set lines 300 pages 999
SQL> col name for a160
SQL> select file#,name from v$datafile;

   206 /u01/app/oracle/product/18.3.0/dbhome_1/dbs/UNNAMED00206

SQL> alter database rename file '/u01/app/oracle/product/18.3.0/dbhome_1/dbs/UNNAMED00206' to '/dbData/OracleData/XXXDG/952feeef7e4a7781e053821510ac6b42/datafile/tbs_wsbsdt.493.1084378651';

SQL> select file#,name from v$datafile;

206 /dbData/OracleData/XXXDG/952feeef7e4a7781e053821510ac6b42/datafile/tbs_wsbsdt.493.1084378651
  • 修改参数standby_file_management
SQL> alter system set standby_file_management='AUTO';
SQL> ALTER DATABASE OPEN;
SQL> alter database recover managed standby database using current logfile disconnect from session;

5. 总结(SUMMARY)