RMAN恢复遇到ORA-19909错误
May232016
在使用RMAN恢复数据库的时候,有一个数据库在恢复的时候遇到ORA-01180错误,如下:
Starting restore at 20-MAY-16 creating datafile file number=1 name=/data2/u01/app/oracle/oradata/ivlifdb/system01.dbf released channel: d1 released channel: d2 released channel: d3 released channel: d4 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of restore command at 05/20/2016 11:17:25 ORA-01180: can not create datafile 1 ORA-01110: data file 1: '/u01/app/oracle/oradata/ivlifdb/system01.dbf'
经查询,备份没有任何问题,由于备份文件的存放位置发生变化,事先已经清理了无效的备份,重新注册的,数据文件的位置也发生了变化,转换后的路径也没有任何问题,权限都正确,在一切情况都正常的情况下遇到这个错误,通常都是控制文件的问题,重建控制文件即可解决。我在这里并没有重建控制文件,而是使用dbms_backup_restore包来恢复的数据文件,这里只简单举个例子,关于如何使用这个包恢复数据文件,在我的BLOG直接搜索包名即可找到相关文章。
SQL> DECLARE 2 V_DEVICE VARCHAR2(100); 3 V_FINISH BOOLEAN; 4 TYPE T_FILENAMETABLE IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER; 5 V_FILENAMETABLE T_FILENAMETABLE; 6 V_MAXPIECES NUMBER :=3; 7 BEGIN 8 V_FILENAMETABLE(1) :='/data2/ivlifdb/dbfull_20160515/dbfull_4cr5k89k_1164_1_911876404'; 9 V_DEVICE := SYS.DBMS_BACKUP_RESTORE.DEVICEALLOCATE(); 10 SYS.DBMS_BACKUP_RESTORE.RESTORESETDATAFILE; 11 SYS.DBMS_BACKUP_RESTORE.RESTOREDATAFILETO(1, '/data2/u01/app/oracle/oradata/ivlifdb/system01.dbf'); 12 FOR I IN 1..V_MAXPIECES LOOP 13 SYS.DBMS_BACKUP_RESTORE.RESTOREBACKUPPIECE(V_FILENAMETABLE(I), V_FINISH); 14 IF V_FINISH THEN 15 SYS.DBMS_BACKUP_RESTORE.DEVICEDEALLOCATE; 16 RETURN; 17 END IF; 18 END LOOP; 19 SYS.DBMS_BACKUP_RESTORE.DEVICEDEALLOCATE; 20 END; 21 / PL/SQL procedure successfully completed.
这里是通过DBMS_BACKUP_RESTORE程序包从/data2/ivlifdb/dbfull_20160515/dbfull_4cr5k89k_1164_1_911876404备份片中恢复/data2/u01/app/oracle/oradata/ivlifdb/system01.dbf数据文件,也就是1号数据文件。由于数据文件路径发生改变,需要修改控制文件中数据文件的新路径。
SQL> alter database rename file '/u01/app/oracle/oradata/ivlifdb/system01.dbf' to '/data2/u01/app/oracle/oradata/ivlifdb/system01.dbf'; Database altered.
Restore完数据文件后,在recover的时候,遇到了ORA-19909错误。
Starting recover at 20-MAY-16 starting media recovery media recovery failed released channel: d1 released channel: d2 released channel: d3 released channel: d4 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 05/20/2016 16:13:14 ORA-00283: recovery session canceled due to errors RMAN-11003: failure during parse/execution of SQL statement: alter database recover if needed start until time 'MAY 19 2016 00:00:00' using backup controlfile ORA-00283: recovery session canceled due to errors ORA-19909: datafile 1 belongs to an orphan incarnation ORA-01110: data file 1: '/data2/u01/app/oracle/oradata/ivlifdb/system01.dbf'
这个错误需要重建控制文件解决,到头来还是得重建控制文件。
SQL> CREATE CONTROLFILE REUSE DATABASE "IVLIFDB" RESETLOGS ARCHIVELOG 2 MAXLOGFILES 16 3 MAXLOGMEMBERS 3 4 MAXDATAFILES 100 5 MAXINSTANCES 8 6 MAXLOGHISTORY 292 7 LOGFILE 8 GROUP 1 '/u01/app/oracle/oradata/ivlifdb/redo01.log' SIZE 500M BLOCKSIZE 512, 9 GROUP 2 '/u01/app/oracle/oradata/ivlifdb/redo02.log' SIZE 500M BLOCKSIZE 512, 10 GROUP 3 '/u01/app/oracle/oradata/ivlifdb/redo03.log' SIZE 500M BLOCKSIZE 512, 11 GROUP 4 '/u01/app/oracle/oradata/ivlifdb/redo04.log' SIZE 500M BLOCKSIZE 512, 12 GROUP 5 '/u01/app/oracle/oradata/ivlifdb/redo05.log' SIZE 500M BLOCKSIZE 512 13 -- STANDBY LOGFILE 14 -- GROUP 10 '/u01/app/oracle/oradata/ivlifdb/st_redo10.log' SIZE 500M BLOCKSIZE 512, 15 -- GROUP 11 '/u01/app/oracle/oradata/ivlifdb/st_redo11.log' SIZE 500M BLOCKSIZE 512, -- GROUP 12 '/u01/app/oracle/oradata/ivlifdb/st_redo12.log' SIZE 500M BLOCKSIZE 512, 16 17 -- GROUP 13 '/u01/app/oracle/oradata/ivlifdb/st_redo13.log' SIZE 500M BLOCKSIZE 512, 18 -- GROUP 14 '/u01/app/oracle/oradata/ivlifdb/st_redo14.log' SIZE 500M BLOCKSIZE 512, -- GROUP 15 '/u01/app/oracle/oradata/ivlifdb/st_redo15.log' SIZE 500M BLOCKSIZE 512 19 20 DATAFILE 21 '/data2/u01/app/oracle/oradata/ivlifdb/system01.dbf', 22 '/data2/u01/app/oracle/oradata/ivlifdb/sysaux01.dbf', 23 '/data2/u01/app/oracle/oradata/ivlifdb/undotbs01.dbf', 24 '/data2/u01/app/oracle/oradata/ivlifdb/users01.dbf', 25 '/data2/u01/app/oracle/oradata/ivlifdb/ts_if01.dbf', '/data2/u01/app/oracle/oradata/ivlifdb/ts_inx_if01.dbf' 26 27 CHARACTER SET AL32UTF8 ; 28 Control file created.
重建控制文件后,问题解决,一切都很顺利。