SYS@ora11g>! rm
/u01/oracle/oradata/ora11g/users01.dbf
SYS@ora11g>! rm
/u01/oracle/oradata/ora11g/users01.dbf
SYS@ora11g>create table scott.test_emp as select * from
scott.emp;
create table scott.test_emp as select * from scott.emp
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4:
'/u01/oracle/oradata/ora11g/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
RMAN> list failure;
using target database control file instead of recovery
catalog
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- -------------------
-------
1102 HIGH OPEN 2018-02-07 22:23:15 One or
more non-system datafiles are missing
RMAN> advise failure;
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- -------------------
-------
1102 HIGH OPEN 2018-02-07 22:23:15 One or
more non-system datafiles are missing
analyzing automatic repair options; this may take some
time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
analyzing automatic repair options complete
Mandatory Manual Actions
========================
no manual actions available
Optional Manual Actions
=======================
1. If file /u01/oracle/oradata/ora11g/users01.dbf was
unintentionally renamed or moved, restore it
Automated Repair Options
========================
Option Repair Description
------ ------------------
1 Restore and recover datafile 4
Strategy: The repair includes complete
media recovery with no data loss
Repair script:
/u01/oracle/diag/rdbms/ora11g/ora11g/hm/reco_2346148381.hm
[oracle@rhel6 ora11g]$ more
/u01/oracle/diag/rdbms/ora11g/ora11g/hm/reco_2346148381.hm
# restore and recover
datafile
sql 'alter database
datafile 4 offline';
restore datafile 4;
recover datafile 4;
sql 'alter database
datafile 4 online';
RMAN> repair failure;
Strategy: The repair includes complete media recovery with no
data loss
Repair script:
/u01/oracle/diag/rdbms/ora11g/ora11g/hm/reco_2346148381.hm
contents of repair script:
# restore and recover
datafile
sql 'alter database
datafile 4 offline';
restore datafile 4;
recover datafile 4;
sql 'alter database
datafile 4 online';
Do you really want to execute the above repair (enter YES or
NO)? yes
executing repair script
sql statement: alter database datafile 4 offline
Starting restore at 2018-02-07 22:30:53
using channel ORA_DISK_1
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 00004 to
/u01/oracle/oradata/ora11g/users01.dbf
channel ORA_DISK_1: reading from backup piece
/u01/oracle/flash_recovery_area/ORA11G/backupset/2018_02_07/o1_mf_nnndf_TAG20180207T015604_f7mv1ntr_.bkp
channel ORA_DISK_1: piece
handle=/u01/oracle/flash_recovery_area/ORA11G/backupset/2018_02_07/o1_mf_nnndf_TAG20180207T015604_f7mv1ntr_.bkp
tag=TAG20180207T015604
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time:
00:00:01
Finished restore at 2018-02-07 22:30:54
Starting recover at 2018-02-07 22:30:54
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 2018-02-07 22:30:56
sql statement: alter database datafile 4 online
repair failure complete
注意:完成自动修复前提是有完整的rman备份且数据库为mount状态
[oracle@rhel6 ora11g]$ ls -lrt
total 1542328
-rw-r----- 1 oracle oinstall 9748480 Dec 30
2016 bak1.ctl
-rw-r----- 1 oracle oinstall 52429312 Feb
7 21:28 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Feb
7 21:28 redo01.log
-rw-r----- 1 oracle oinstall 104865792 Feb 7
21:28 example01.dbf
-rw-r----- 1 oracle oinstall 104865792 Feb 7
22:15 temp00.dbf
-rw-r----- 1 oracle oinstall 5251072 Feb
7 22:30 users01.dbf
-rw-r----- 1 oracle oinstall 62922752 Feb
7 22:31 undotbs01.dbf
-rw-r----- 1 oracle oinstall 713039872 Feb 7
22:31 system01.dbf
-rw-r----- 1 oracle oinstall 513810432 Feb 7
22:33 sysaux01.dbf
-rw-r----- 1 oracle oinstall 52429312 Feb
7 22:33 redo03.log
-rw-r----- 1 oracle oinstall 9748480 Feb
7 22:33 control01.ctl