首页 > 代码库 > ORA-01113: file xxxx needs media recovery
ORA-01113: file xxxx needs media recovery
由于规范存储位置以及存储空间缘故需要移动表空间MRP_INDEX2的数据文件,如下所示,首先将表空间MRP_INDEX2脱机; 然后复制数据文件;然后重命名文件,最后将表空间MRP_INDEX2联机.
在操作过后,最后一步将表空间MRP_INDEX2联机上线时,出现了意外错误信息,如下所示:
SQL> ALTER TABLESPACE MRP_INDEX2 OFFLINE NORMAL;
Tablespace altered.
SQL> !cp /u03/flash_recovery_area/oradata/epps/mrp_index2_x01.dbf /u04/epps/oradata/mrp_index2_x01.dbf
SQL> !cp /u03/flash_recovery_area/oradata/epps/mrp_index2_x02.dbf /u04/epps/oradata/mrp_index2_x02.dbf
SQL> ALTER DATABASE RENAME FILE ‘/u03/flash_recovery_area/oradata/epps/mrp_index2_x01.dbf‘ TO ‘/u04/epps/oradata/mrp_index2_x01.dbf‘;
Database altered.
如下所示,在重命名文件时,其中一个文件路径‘u04/epps/oradata/mrp_index2_x02.dbf‘弄错了,当时一直没有留言到这个错误,怕耽搁Tablespace的联机上线时间。于是先将表空间MRP_INDEX2联机上线
SQL> ALTER DATABASE RENAME FILE ‘/u03/flash_recovery_area/oradata/epps/mrp_index2_x02.dbf‘ TO ‘u04/epps/oradata/mrp_index2_x02.dbf‘
*
ERROR at line 1:
ORA-01511: error in renaming log/data files
ORA-01141: error renaming data file 86 - new file
‘u04/epps/oradata/mrp_index2_x02.dbf‘ not found
ORA-01110: data file 86:
‘/u03/flash_recovery_area/oradata/epps/mrp_index2_x02.dbf‘
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
SQL> ALTER TABLESPACE MRP_INDEX2 ONLINE ;
Tablespace altered.
检查过后发现了上面脚本错误,于是接着处理,但是将表空间MRP_INDEX2脱机后,没有重新拷贝数据文件过去,直接重命名数据文件(SCN已经改变,导致下面ORA-01113错误),然后表空间联机上线时,出现了下面错误
SQL> ALTER TABLESPACE MRP_INDEX2 OFFLINE NORMAL;
Tablespace altered.
SQL> ALTER DATABASE RENAME FILE ‘/u03/flash_recovery_area/oradata/epps/mrp_index2_x02.dbf‘ TO ‘/u04/epps/oradata/mrp_index2_x02.dbf‘;
Database altered.
SQL>
SQL> ALTER TABLESPACE MRP_INDEX2 ONLINE ;
ALTER TABLESPACE MRP_INDEX2 ONLINE
*
ERROR at line 1:
ORA-01113: file 86 needs media recovery
ORA-01110: data file 86: ‘/u04/epps/oradata/mrp_index2_x02.dbf‘
解决方法:
1:首先将该报错的数据文件脱机
SQL> alter database datafile ‘/u04/epps/oradata/mrp_index2_x02.dbf‘ offline;
Database altered.
2:其次recover这个数据文件
SQL> alter database recover datafile ‘/u04/epps/oradata/mrp_index2_x02.dbf‘;
Database altered.
3:然后将该数据文件联机上线
SQL> alter database datafile ‘/u04/epps/oradata/mrp_index2_x02.dbf‘ online;
Database altered.
4:最后将该表空间MRP_INDEX2联机上线。
SQL> ALTER TABLESPACE MRP_INDEX2 ONLINE ;
当然也可以使用RMAN还原,这里感觉使用SQL命令还原要简单方便一点,最后删除拷贝前的文件
rm /u03/flash_recovery_area/oradata/epps/mrp_index2_x01.dbf
rm /u03/flash_recovery_area/oradata/epps/mrp_index2_x02.dbf
ORA-01113: file xxxx needs media recovery
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。