Detailed explanation of data file recovery for Oracle database RMAN recovery

In addition to the data files (mount) of the system tablespace, other data files can be restored in the open (mount can also) state. Restoring data files in the open state can reduce the time when the database is disabled, so these data files should be restored in the open state.

Example 1: Data files are deleted by mistake

Delete non-system tablespace data files while the database is shut down.

Start the database to the mount state.

Offline missing datafiles, alter database datafile n offline.

Open the database, alter database open.

Dump data file, restore datafile n.

Use recover datafile n to apply archived logs.

Online data file, alter database datafile n online.

--Delete non-system tablespace data files when the database is closed.   

1.     [oracle@localhost ~]$  rm $ORACLE_BASE/product/10.2.0/oradatabak/example01.dbf;    

2.     SQL> select file#,error from v$recover_file;      

3.     FILE# ERROR    

4.     ---------- -----------------------------------------------------------------     

5.     5 FILE NOT FOUND    

6.     SQL> select file#,name from v$datafile where file#=5;    

7.     FILE# NAME    

8.     ---------- --------------------------------------------------------------------------------     

9.     5 /oracle/10g/oracle/product/10.2.0/oradatabak/example01.dbf    

10.  --Restore data files     

11.  RMAN> run {    

12.  startup force mount;    

13.  sql 'alter database datafile 5 offline';    

14.  sql 'alter database open';    

15.  restore datafile 5;    

16.  recover datafile 5;    

17.  sql 'alter database datafile 5 online';    

18.  8> }   

Example 2: The disk where the data file is located is damaged

Delete non-system tablespace data files while the database is shut down.

Start the database to the mount state.

Offline missing datafiles, alter database datafile n offline.

Open the database, alter database open.

Before restoring the database, execute set newname to specify a new location for the data files.

After restoring the database, execute switch datafile to change the location and name of the data file in the control file.

The archived logs are then applied by executing recover database.

Online data file, alter database datafile n online.

--Delete non-system tablespace data files when the database is closed.   

1.     [oracle@localhost ~]$  rm $ORACLE_BASE/product/10.2.0/oradatabak/example01.dbf;    

2.      

3.     SQL> select file#,error from v$recover_file;      

4.      

5.     FILE# ERROR    

6.      

7.     ---------- -----------------------------------------------------------------     

8.      

9.     5 FILE NOT FOUND    

10.   

11.  SQL> select file#,name from v$datafile where file#=5;    

12.   

13.  FILE# NAME    

14.   

15.  ---------- --------------------------------------------------------------------------------     

16.   

17.  5 /oracle/10g/oracle/product/10.2.0/oradatabak/example01.dbf    

18.   

19.  --Restore data files     

20.   

21.  [oracle@localhost ~]$ rman target sys/oracle@oralife nocatalog    

22.   

23.  RMAN> run {    

24.   

25.  2> startup force mount;    

26.   

27.  3> sql 'alter database datafile 5 offline';    

28.   

29.  4> sql 'alter database open';    

30.   

31.  5> set newname for datafile 5 to '$ORACLE_BASE/product/10.2.0/oradata/oralife/example01.dbf';    

32.   

33.  6> restore datafile 5;    

34.   

35.  7> switch datafile 5;    

36.   

37.  8> recover datafile 5;    

38.   

39.  9> sql 'alter database datafile 5 online';    

40.   

41.  10> }    

42.   

43.  SQL> select file#,name from v$datafile where file#=5;    

44.   

45.  FILE# NAME    

46.   

47.  ---------- --------------------------------------------------------------------------------     

48.   

49.  5 /oracle/10g/oracle/product/10.2.0/oradata/oralife/example01.dbf    

50.   

51.  SQL> select file#,error from v$recover_file;      

52.   

53.  no rows selected  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325127164&siteId=291194637