案例2:


--部分数据文件丢失,恢复数据文件(mount 或 open)



1)测试环境


07:30:40 SQL> create table test (id int) tablespace test;


Table created.


07:30:52 SQL> conn /as sysdba


Connected.


07:30:57 SQL>


07:30:57 SQL> insert into scott.test values (1);


1 row created.


07:31:02 SQL> commit;


Commit complete.


07:31:04 SQL> alter system archive log current;


System altered.


07:31:10 SQL> insert into scott.test values (2);


1 row created.


07:31:13 SQL> commit;


Commit complete.


07:31:15 SQL> alter system archive log current;


System altered.


07:31:16 SQL> insert into scott.test values (3);


1 row created.


07:31:19 SQL> commit;


Commit complete.


07:31:20 SQL> alter system archive log current;


System altered.


07:31:24 SQL> insert into scott.test values (4);


1 row created.


07:31:26 SQL> insert into scott.test values (5);


1 row created.


07:31:28 SQL> commit;


Commit complete.


07:31:30 SQL> select * from scott.test;


ID


----------


1


2


3


4


5


07:31:34 SQL>


07:31:34 SQL> shutdown abort


ORACLE instance shut down.


07:33:23 SQL> exit


Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production


With the Partitioning, OLAP and Data Mining options


[oracle@work ~]$ rm /u01/app/oracle/oradata/prod/test0*.dbf




2)启动database


07:34:07 SQL> startup


ORACLE instance started.


Total System Global Area  314572800 bytes


Fixed Size                  1219184 bytes


Variable Size              79693200 bytes


Database Buffers          230686720 bytes


Redo Buffers                2973696 bytes


Database mounted.


ORA-01157: cannot identify/lock data file 6 - see DBWR trace file


ORA-01110: data file 6: '/u01/app/oracle/oradata/prod/test01.dbf'


07:34:15 SQL> select file#,error from v$recover_file;


FILE# ERROR


---------- -----------------------------------------------------------------


6 FILE NOT FOUND


8 FILE NOT FOUND





3)利用rman 恢复datafile


RMAN> run {


2> startup force mount;


3> sql 'alter database datafile 6,8 offline';


4> alter database open;


5> restore datafile 6,8;


6> recover datafile 6,8;


7> sql 'alter database datafile 6,8 online';


8> }


Oracle instance started


database mounted


Total System Global Area     314572800 bytes


Fixed Size                     1219184 bytes


Variable Size                 79693200 bytes


Database Buffers             230686720 bytes


Redo Buffers                   2973696 bytes


using target database control file instead of recovery catalog


sql statement: alter database datafile 6,8 offline


database opened


Starting restore at 18-AUG-11


allocated channel: ORA_DISK_1


channel ORA_DISK_1: sid=146 devtype=DISK


channel ORA_DISK_1: starting datafile backupset restore


channel ORA_DISK_1: specifying datafile(s) to restore from backup set


restoring datafile 00006 to /u01/app/oracle/oradata/prod/test01.dbf


restoring datafile 00008 to /u01/app/oracle/oradata/prod/test02.dbf


channel ORA_DISK_1: reading from backup piece /disk1/rman/prod/PROD_31.bak


channel ORA_DISK_1: restored backup piece 1


piece handle=/disk1/rman/prod/PROD_31.bak tag=TAG20110818T071905


channel ORA_DISK_1: restore complete, elapsed time: 00:00:03


Finished restore at 18-AUG-11


Starting recover at 18-AUG-11


using channel ORA_DISK_1


starting media recovery


archive log thread 1 sequence 8 is already on disk as file /disk1/arch/prod/arch_8_1_759396736.log


archive log thread 1 sequence 9 is already on disk as file /disk1/arch/prod/arch_9_1_759396736.log


archive log thread 1 sequence 10 is already on disk as file /disk1/arch/prod/arch_10_1_759396736.log


archive log thread 1 sequence 11 is already on disk as file /disk1/arch/prod/arch_11_1_759396736.log


archive log thread 1 sequence 12 is already on disk as file /disk1/arch/prod/arch_12_1_759396736.log


archive log thread 1 sequence 13 is already on disk as file /disk1/arch/prod/arch_13_1_759396736.log


archive log filename=/disk1/arch/prod/arch_8_1_759396736.log thread=1 sequence=8


archive log filename=/disk1/arch/prod/arch_9_1_759396736.log thread=1 sequence=9


archive log filename=/disk1/arch/prod/arch_10_1_759396736.log thread=1 sequence=10


archive log filename=/disk1/arch/prod/arch_11_1_759396736.log thread=1 sequence=11


media recovery complete, elapsed time: 00:00:03


Finished recover at 18-AUG-11


sql statement: alter database datafile 6,8 online


RMAN>





4)验证:


[oracle@work ~]$ sqlplus / as sysdba


SQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 18 07:37:17 2011


Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:


Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production


With the Partitioning, OLAP and Data Mining options


07:37:18 SQL>


07:37:18 SQL> select * from scott.test;


ID


----------


1


2


3


4


5


07:37:23 SQL>


oracle视频教程请关注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html