Step 5,SQL Plus一致性关闭数据库,失败,只有强制关闭数据库
SQL> CONN / AS SYSDBA CONN / AS SYSDBA Connected. SQL> SHUTDOWN IMMEDIATE; ORA-01116: error in opening database file 3 ORA-01110: data file 3: '/u01/oracle/oradata/justdb/undotbs01.dbf' ORA-27041: unable to open file Linux-x86_64 Error: 2: No such file or directory Additional information: 3 SQL> SHUTDOWN ABORT; ORACLE instance shut down.
Step 6,再次登录到SQL Plus,启动数据库到MOUNT状态
[oracle@orcl ~]$ sqlplus [uniread] Loaded history (157 lines) SQL*Plus: Release 11.2.0.3.0 Production on Thu Dec 12 10:37:52 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to an idle instance. SQL> STARTUP MOUNT; ORACLE instance started. Total System Global Area 1269366784 bytes Fixed Size 2227984 bytes Variable Size 754974960 bytes Database Buffers 503316480 bytes Redo Buffers 8847360 bytes Database mounted.
Step 7,SQL Plus中使3号文件(UNDO表空间)离线
SQL> ALTER DATABASE DATAFILE 3 OFFLINE; Database altered.
Step 8,使用sys用户登录到RMAN
[oracle@orcl ~]$ uniread rman target / [uniread] Loaded history (96 lines) Recovery Manager: Release 11.2.0.3.0 - Production on Thu Dec 12 10:38:26 2013 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: JUSTDB (DBID=57321598, not open) RMAN>
Step 9,RMAN中还原3号文件
RMAN> RESTORE DATAFILE 3; Starting restore at 12-DEC-13 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=20 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/oracle/oradata/justdb/undotbs01.dbf channel ORA_DISK_1: reading from backup piece /u01/oracle/fast_recovery_area/JUSTDB/backupset/2013_12_12/o1_mf_nnndf_TAG20131212T095816_9bl61rrn_.bkp channel ORA_DISK_1: piece handle=/u01/oracle/fast_recovery_area/JUSTDB/backupset/2013_12_12/o1_mf_nnndf_TAG20131212T095816_9bl61rrn_.bkp tag=TAG20131212T095816 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 12-DEC-13
Step 10,RMAN中恢复3号文件
RMAN> RECOVER DATAFILE 3; RECOVER DATAFILE 3; Starting recover at 12-DEC-13 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:00 Finished recover at 12-DEC-13
Step 11,SQL Plus中使3号数据文件在线
SQL> ALTER DATABASE DATAFILE 3 ONLINE; Database altered.
Step 12,SQL Plus中打开数据库
SQL> ALTER DATABASE OPEN; Database altered.
Step 13,SQL Plus查看数据,插入数据,成功
SQL> SELECT * FROM scott.dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> INSERT INTO dept VALUES(89,'GZ','DBA');
1 row created.
SQL> COMMIT;
Commit complete.