備份恢復之資料檔案丟失
一、實驗環境
執行環境:
[root@localhost ~]# lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5.4 (Tikanga)
Release: 5.4
Codename: Tikanga
資料庫版本:
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
歸檔狀態:
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
二、實驗步驟
1、對資料庫進行一次全備
2、將資料庫檔案任一刪除一個(system表空間的資料檔案或者undo表空間的資料檔案)
3、通過RMAN對進行恢復
三、具體過程
1、檢視資料檔案
SQL> select t.name tname,d.name dname from v$datafile d,v$tablespace t
2 where t.ts#=d.ts#;
TNAME DNAME
------- ------------------------------------------------------------
SYSTEM /u01/app/oracle/oradata/lzcdb/system01.dbf
UNDOTBS /u01/app/oracle/oradata/lzcdb/undotbs01.dbf
1
SYSAUX /u01/app/oracle/oradata/lzcdb/sysaux01.dbf
USERS /u01/app/oracle/oradata/lzcdb/users01.dbf
LZCDB01 /u01/app/oracle/oradata/lzcdb/lzcdb0101
LZCDB01 /u01/app/oracle/oradata/lzcdb/lzcdb0102
2、將控制檔案刪除
SQL> !rm /u01/app/oracle/oradata/lzcdb/system01.dbf
SQL> !ls /u01/app/oracle/oradata/lzcdb/system01.dbf
ls: /u01/app/oracle/oradata/lzcdb/system01.dbf: No such file or directory
成功刪除
3、在刪除資料檔案之後資料庫有可能會直接掛掉,但由於我的實驗資料庫沒有任何負載所以現在手動將其關閉
(注意同時動態檢視alert日子)
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 96470608 bytes
Database Buffers 184549376 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/lzcdb/system01.dbf'
在有mount狀態啟動到open狀態是會出現如上錯誤,此時檢視alert日誌會看到如下資訊
ALTER DATABASE OPEN
Thu Jun 14 17:25:03 2012
ORA-01110: data file 1: '/u01/app/oracle/oradata/lzcdb/system01.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
我們可以看到錯誤資訊提示我們system01.dbf檔案找不到
4、使用RMAN恢復
[oracle@localhost ~]$ rman target sys/oracle/lzcdb
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jun 14 17:28:33 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: LZCDB (DBID=404353836, not open)
RMAN> list backup;
using target database control file instead of recovery catalog
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 920.27M DISK 00:01:58 14-JUN-12
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20120614T091107
Piece Name: /u01/app/oracle/flash_recovery_area/03ndgj9b_1_1
List of Datafiles in backup set 3
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 682642 14-JUN-12 /u01/app/oracle/oradata/lzcdb/system01.dbf
2 Full 682642 14-JUN-12 /u01/app/oracle/oradata/lzcdb/undotbs01.dbf
3 Full 682642 14-JUN-12 /u01/app/oracle/oradata/lzcdb/sysaux01.dbf
4 Full 682642 14-JUN-12 /u01/app/oracle/oradata/lzcdb/users01.dbf
可以看到我的實驗庫的備份資訊如上
RMAN> restore datafile 1; ------這兒我用的是system01.dbf檔案號
RMAN> recover database;
將資料庫啟動!
四、實驗總結
在實驗的過程中遇到了一些小插曲,由於自己搗鼓的時候有部分歸檔日誌被我刪掉了卻且沒有其他備份。
所以當我執行
RMAN> recover database;
恢復資料庫時告訴我
RMAN-03002: failure of recover command at 06/14/2012 18:18:06
RMAN-06053: unable to perform. media recovery because of missing log
RMAN-06025: no backup of log thread 1 seq 36 lowscn 730729 found to restore
這樣我就只能將整個資料庫恢復到我上次的全備點了,這就造成了大量資料的丟失
所以體會就是歸檔日誌不要隨便刪除,除非你已經確定它沒有用了或者你有備份!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26723566/viewspace-732848/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle備份與恢復【丟失資料檔案的恢復】Oracle
- 【備份恢復】 丟失一個控制檔案 之恢復操作
- rman恢復--歸檔模式有備份,丟失資料檔案的恢復模式
- rman恢復--歸檔模式無備份,丟失資料檔案的恢復模式
- RMAN資料庫恢復 之歸檔模式有(無)備份-丟失資料檔案的恢復資料庫模式
- 歸檔模式無備份丟失資料檔案後恢復模式
- 歸檔模式有備份丟失資料檔案後恢復模式
- 備份與恢復--資料檔案損壞或丟失
- 【備份恢復】非歸檔模式下丟失任意資料檔案 恢復操作模式
- 無備份丟失部分資料檔案和控制檔案恢復 [轉]
- 【備份恢復】歸檔模式下丟失系統關鍵資料檔案 利用RMAN備份恢復模式
- 【備份恢復】恢復 丟失已歸檔重做日誌檔案
- 沒備份,歸檔日誌存在,丟失資料檔案的恢復
- oracle實驗記錄(恢復-丟失未備份資料檔案)Oracle
- 恢復之丟失全部控制檔案以及備份中的控制檔案
- 備份&恢復之五:歸檔模式下丟失或損壞一個資料檔案模式
- Oracle RMAN 不完全恢復(只有資料檔案備份,丟失歸檔日誌備份)Oracle
- 資料檔案丟失的恢復
- 資料檔案丟失如何恢復
- 備份&恢復之八:RMAN備份歸檔模式下損壞(丟失)多個資料檔案,進行整個資料庫的恢復模式資料庫
- 完全恢復之所有資料庫檔案丟失資料庫
- 只有rman備份集,控制檔案丟失的恢復
- 備份恢復實驗(1)丟失部分控制檔案
- 【備份恢復】所有控制檔案丟失後 利用trace中的控制檔案備份執行恢復
- RMAN恢復案例:丟失全部資料檔案恢復
- 備份與恢復系列 九 丟失表空間資料檔案的還原與恢復
- 非歸檔無備份下控制檔案丟失的恢復
- undo表空間檔案丟失恢復(1)--有備份
- RMAN完全恢復丟失的資料檔案
- 普通資料檔案丟失的恢復方法
- 資料檔案丟失損壞的恢復--
- dg丟失歸檔,使用rman增量備份恢復
- 利用增量備份恢復gap歸檔丟失DG
- rman備份丟失控制檔案恢復
- 丟失全部控制檔案後從RMAN備份集中恢復示例
- 恢復之利用備份在所有控制檔案丟失情況下恢復(四)
- 恢復之利用備份在所有控制檔案丟失情況下恢復(三)
- 恢復之利用備份在所有控制檔案丟失情況下恢復(二)