UNDO表空间数据文件和system表空间数据文件都是数据库的关键数据文件,如果损坏会导致sql执行失败,用户无法登录,甚至实例崩溃等。同样恢复UNDO表空间数据文件也必须在数据库mount状态下进行。
数据库在运行过程中发现UNDO表空间数据文件损坏,此时是无法正常关闭数据库的:
SQL> shutdown immediate;
ORA-01122: database file 3 failed verification check
ORA-01110: data file 3: '/u01/app/oracle/oradata/orcl/undotbs01.dbf'
ORA-01210: data file header is media corrupt
只能强制关闭数据库,再启动实例到mount状态下,利用备份恢复损坏的数据文件:
步骤:
A、 关闭数据库
SQL> shutdown abort
ORACLE instance shut down.
B、 启动数据库到mount状态
SQL> startup mount;
C、 在RMAN中,执行restore命令还原UNDO表空间数据文件
RMAN> restore datafile '/u01/app/oracle/oradata/orcl/undotbs01.dbf';
Starting restore at 02-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/full_ORCL_20121201_6_1.bak
channel ORA_DISK_1: piece handle=/u01/app/oracle/backup/full_ORCL_20121201_6_1.bak tag=TAG20121201T193434
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:08
Finished restore at 02-DEC-12
D、 在RMAN中,执行recover database 恢复数据文件。
RMAN> recover database;
Starting recover at 02-DEC-12
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 02-DEC-12
E、 打开数据库,恢复完成
RMAN> alter database open;
database opened
如果在数据库启动时,发现UNDO表空间数据文件损坏,数据库只能启动到mount状态,其恢复方法相同。