Oracle恢復實驗(二)

環境:Oracle10g、Red Hat 4,Oracle運行在歸檔模式。

場景:數據文件user01.dbf損壞,打開數據庫情況下進行恢復。

具體步驟:
1、刪除user01.dbf文件模擬數據文件損壞,關閉數據庫,嘗試打開。
!rm -f /home/oracle/oracle/product/oradata/orcl、users01.dbf
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  130023424 bytes
Fixed Size                  1218100 bytes
Variable Size              62917068 bytes
Database Buffers           62914560 bytes
Redo Buffers                2973696 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/home/oracle/oracle/product/oradata/orcl/users01.dbf'
可以看到:數據文件4找不到,無法打開數據庫,數據庫啓動到Mount狀態

2、將損壞數據文件脫機
SQL> alter database datafile 4 offline;

Database altered.

3、打開數據庫
SQL> alter database open;

Database altered.
脫機後,數據庫可以正常打開。

4、複製數據文件,嘗試將數據文件聯機
SQL> !cp /disk2/bak/users01.dbf /home/oracle/oracle/product/oradata/orcl

SQL> alter database datafile 4 online;
alter database datafile 4 online
*
ERROR at line 1:
ORA-01113: file 4 needs media recovery
ORA-01110: data file 4: '/home/oracle/oracle/product/oradata/orcl/users01.dbf'
此時Oracle會提示需要介質恢復

5、介質恢復
recover tablespace users;

6、將表空間聯機
SQL> select name,status from v$datafile;

NAME                                                         STATUS
------------------------------------------------------------ -------
/home/oracle/oracle/product/oradata/orcl/system01.dbf        SYSTEM
/home/oracle/oracle/product/oradata/orcl/undotbs01.dbf       ONLINE
/home/oracle/oracle/product/oradata/orcl/sysaux01.dbf        ONLINE
/home/oracle/oracle/product/oradata/orcl/users01.dbf         OFFLINE

SQL> alter database datafile 4 online;

Database altered.


7、檢查數據
SQL> select count(*) from scott.recover_test;

  COUNT(*)
----------
       448
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章