Oracle 11g資料庫恢復:場景11:資料檔案損壞,不能恢復到原來的位置, 恢復到新的路徑

LuiseDalian發表於2014-05-04

sys@TESTDB11>select '! rm ' || name from v$datafile;

 

'!RM'||NAME

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

! rm /u01/app/oracle/oradata/TestDB11/system01.dbf

! rm /u01/app/oracle/oradata/TestDB11/sysaux01.dbf

! rm /u01/app/oracle/oradata/TestDB11/undotbs01.dbf

! rm /u01/app/oracle/oradata/TestDB11/users01.dbf

! rm /u01/app/oracle/oradata/TestDB11/example01.dbf

! rm /u01/app/oracle/oradata/TestDB11/newundotbs01.dbf

 

6 rows selected.

 

--關庫

sys@TESTDB11>shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

 

--檔案損壞

sys@TESTDB11>! rm /u01/app/oracle/oradata/TestDB11/system01.dbf

 

! rm /u01/app/oracle/oradata/TestDB11/system01.dbf

! rm /u01/app/oracle/oradata/TestDB11/sysaux01.dbf

! rm /u01/app/oracle/oradata/TestDB11/undotbs01.dbf

! rm /u01/app/oracle/oradata/TestDB11/users01.dbf

! rm /u01/app/oracle/oradata/TestDB11/example01.dbf

! rm /u01/app/oracle/oradata/TestDB11/newundotbs01.dbff

 

sys@TESTDB11>! ls /u01/app/oracle/oradata/TestDB11

control01.ctl  redo01.log     redo02.log     redo03.log     temp01.dbf

 

--還原到新的位置

sys@TESTDB11>! cp /backup/inconsistent_backup/*.dbf /oradata/TestDB11

 

--嘗試啟動

sys@TESTDB11>startup

ORACLE instance started.

 

Total System Global Area  855982080 bytes

Fixed Size                  2230792 bytes

Variable Size             641730040 bytes

Database Buffers          209715200 bytes

Redo Buffers                2306048 bytes

Database mounted.

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

ORA-01110: data file 1: '/u01/app/oracle/oradata/TestDB11/system01.dbf'

 

--檢視需要恢復的檔案的狀態

sys@TESTDB11>select * from v$recover_file;

 

     FILE# ONLINE  ONLINE_ ERROR                                                                CHANGE# TIME

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

         1 ONLINE  ONLINE  FILE NOT FOUND                                                             0

         2 ONLINE  ONLINE  FILE NOT FOUND                                                             0

         3 ONLINE  ONLINE  FILE NOT FOUND                                                             0

         4 ONLINE  ONLINE  FILE NOT FOUND                                                             0

         5 ONLINE  ONLINE  FILE NOT FOUND                                                             0

         6 ONLINE  ONLINE  FILE NOT FOUND                                                             0

 

6 rows selected.

 

--確定在控制檔案中重名稱檔案需要執行的命令

sys@TESTDB11>select length('/u01/app/oracle/oradata/TestDB11/') from dual;

 

LENGTH('/U01/APP/ORACLE/ORADATA/TESTDB11/')

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

                                         33

sys@TESTDB11>select substr(name, 34) from v$datafile;

 

SUBSTR(NAME,34)

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

system01.dbf

sysaux01.dbf

undotbs01.dbf

users01.dbf

example01.dbf

newundotbs01.dbf

 

6 rows selected.

 

sys@TESTDB11>select 'alter database rename file ''' || name || ''' to ''/oradata/TestDB11/' ||

  2  substr(name, 34) || ''';' from v$datafile;

 

'ALTERDATABASERENAMEFILE'''||NAME||'''TO''/ORADATA/TESTDB11/'||SUBSTR(NAME,34)||''';'

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

alter database rename file '/u01/app/oracle/oradata/TestDB11/system01.dbf' to '/oradata/TestDB11/system01.dbf';

alter database rename file '/u01/app/oracle/oradata/TestDB11/sysaux01.dbf' to '/oradata/TestDB11/sysaux01.dbf';

alter database rename file '/u01/app/oracle/oradata/TestDB11/undotbs01.dbf' to '/oradata/TestDB11/undotbs01.dbf';

alter database rename file '/u01/app/oracle/oradata/TestDB11/users01.dbf' to '/oradata/TestDB11/users01.dbf';

alter database rename file '/u01/app/oracle/oradata/TestDB11/example01.dbf' to '/oradata/TestDB11/example01.dbf';

alter database rename file '/u01/app/oracle/oradata/TestDB11/newundotbs01.dbf' to '/oradata/TestDB11/newundotbs01.dbf';

 

6 rows selected.

 

--修改控制檔案中記錄的檔案位置和名稱

alter database rename file '/u01/app/oracle/oradata/TestDB11/system01.dbf' to '/oradata/TestDB11/system01.dbf';

alter database rename file '/u01/app/oracle/oradata/TestDB11/sysaux01.dbf' to '/oradata/TestDB11/sysaux01.dbf';

alter database rename file '/u01/app/oracle/oradata/TestDB11/undotbs01.dbf' to '/oradata/TestDB11/undotbs01.dbf';

alter database rename file '/u01/app/oracle/oradata/TestDB11/users01.dbf' to '/oradata/TestDB11/users01.dbf';

alter database rename file '/u01/app/oracle/oradata/TestDB11/example01.dbf' to '/oradata/TestDB11/example01.dbf';

alter database rename file '/u01/app/oracle/oradata/TestDB11/newundotbs01.dbf' to '/oradata/TestDB11/newundotbs01.dbf';

 

--確定修改成功

sys@TESTDB11>select name from v$datafile;

 

NAME

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

/oradata/TestDB11/system01.dbf

/oradata/TestDB11/sysaux01.dbf

/oradata/TestDB11/undotbs01.dbf

/oradata/TestDB11/users01.dbf

/oradata/TestDB11/example01.dbf

/oradata/TestDB11/newundotbs01.dbf

 

6 rows selected.

--恢復,開庫

sys@TESTDB11>recover database;

Media recovery complete.

sys@TESTDB11>alter database open;

 

Database altered.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17013648/viewspace-1153193/,如需轉載,請註明出處,否則將追究法律責任。

相關文章