資料檔案OFFLINE的3種情況
前言:
1、測試前對資料庫進行一個完整備份
RMAN> backup database;
Starting backup at 28-MAR-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=143 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oracle/oradata/dg1/system01.dbf
input datafile fno=00003 name=/oracle/oradata/dg1/sysaux01.dbf
input datafile fno=00005 name=/oracle/oradata/dg1/example01.dbf
input datafile fno=00006 name=/oracle/oradata/dg1/ws_app_data01.dbf
input datafile fno=00007 name=/oracle/oradata/dg1/ws_app_idx01.dbf
input datafile fno=00002 name=/oracle/oradata/dg1/undotbs01.dbf
input datafile fno=00008 name=/oracle/oradata/dg1/ws_app_sep01.dbf
input datafile fno=00009 name=/oracle/oradata/dg1/ws_app_oct01.dbf
input datafile fno=00010 name=/oracle/oradata/dg1/ws_app_nov01.dbf
input datafile fno=00011 name=/oracle/oradata/dg1/ws_app_dec01.dbf
input datafile fno=00012 name=/oracle/oradata/dg1/wdscr_part01.dbf
input datafile fno=00013 name=/oracle/oradata/dg1/wdscr_part02.dbf
input datafile fno=00004 name=/oracle/oradata/dg1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 28-MAR-09
channel ORA_DISK_1: finished piece 1 at 28-MAR-09
piece handle=/oracle/flash_recovery_area/DG1/backupset/2009_03_28/o1_mf_nnndf_TAG20090328T201934_4wxhnr1f_.bkp tag=TAG20090328T201934 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:46
Finished backup at 28-MAR-09
Starting Control File and SPFILE Autobackup at 28-MAR-09
piece handle=/oracle/flash_recovery_area/DG1/autobackup/2009_03_28/o1_mf_s_682719681_4wxhr320_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 28-MAR-09
2、歸檔模式下OFFLINE 資料檔案
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 10
Next log sequence to archive 12
Current log sequence 12
SQL> conn sys/oracle as sysdba
Connected.
SQL> alter database datafile '/oracle/oradata/dg1/wdscr_part01.dbf' offline drop;
Database altered.
SQL> conn ws_app/ws_app
Connected.
SQL> select * from woodscrew;
select * from woodscrew
*
ERROR at line 1:
ORA-00376: file 12 cannot be read at this time
ORA-01110: data file 12: '/oracle/oradata/dg1/wdscr_part01.dbf'
歸檔模式下,日誌都存在,因此直接介質恢復,將資料檔案ONLINE就可以了。
SQL> conn sys/oracle as sysdba
Connected.
SQL> recover datafile 12;
Media recovery complete.
SQL> alter database datafile '/oracle/oradata/dg1/wdscr_part01.dbf' online;
Database altered.
3、非歸檔聯機日誌存在情況下恢復
其實非歸檔在日誌組沒有被覆蓋之前和歸檔情況原理上是一樣的。
SQL> alter database noarchivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 10
Current log sequence 12
SQL> alter database datafile '/oracle/oradata/dg1/wdscr_part01.dbf' offline drop;
Database altered.
SQL> conn ws_app/ws_app;
Connected.
SQL> select * from woodscrew;
select * from woodscrew
*
ERROR at line 1:
ORA-00376: file 12 cannot be read at this time
ORA-01110: data file 12: '/oracle/oradata/dg1/wdscr_part01.dbf'
SQL> conn sys/oracle as sysdba
Connected.
SQL> recover datafile 12;
Media recovery complete.
SQL> alter database datafile '/oracle/oradata/dg1/wdscr_part01.dbf' online;
Database altered.
4、非歸檔聯機日誌不存在情況下恢復
很不幸,如果在沒有歸檔日誌,且聯機日誌被覆蓋的情況,要介質恢復了。
SQL> conn sys/oracle as sysdba
Connected.
SQL> alter database datafile '/oracle/oradata/dg1/wdscr_part01.dbf' offline drop;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> recover datafile 12;
ORA-00279: change 711334 generated at 03/28/2009 20:45:36 needed for thread 1
ORA-00289: suggestion :
/oracle/flash_recovery_area/DG1/archivelog/2009_03_28/o1_mf_1_12_%u_.arc
ORA-00280: change 711334 for thread 1 is in sequence #12
Specify log: {
auto
ORA-00308: cannot open archived log
'/oracle/flash_recovery_area/DG1/archivelog/2009_03_28/o1_mf_1_12_%u_.arc'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00308: cannot open archived log
'/oracle/flash_recovery_area/DG1/archivelog/2009_03_28/o1_mf_1_12_%u_.arc'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
下面做RMAN的恢復:
[oracle@dg1 ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Sat Mar 28 20:53:51 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: DG1 (DBID=1646839347, not open)
RMAN> restore database;
Starting restore at 28-MAR-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oracle/oradata/dg1/system01.dbf
restoring datafile 00002 to /oracle/oradata/dg1/undotbs01.dbf
restoring datafile 00003 to /oracle/oradata/dg1/sysaux01.dbf
restoring datafile 00004 to /oracle/oradata/dg1/users01.dbf
restoring datafile 00005 to /oracle/oradata/dg1/example01.dbf
restoring datafile 00006 to /oracle/oradata/dg1/ws_app_data01.dbf
restoring datafile 00007 to /oracle/oradata/dg1/ws_app_idx01.dbf
restoring datafile 00008 to /oracle/oradata/dg1/ws_app_sep01.dbf
restoring datafile 00009 to /oracle/oradata/dg1/ws_app_oct01.dbf
restoring datafile 00010 to /oracle/oradata/dg1/ws_app_nov01.dbf
restoring datafile 00011 to /oracle/oradata/dg1/ws_app_dec01.dbf
restoring datafile 00012 to /oracle/oradata/dg1/wdscr_part01.dbf
restoring datafile 00013 to /oracle/oradata/dg1/wdscr_part02.dbf
channel ORA_DISK_1: reading from backup piece /oracle/flash_recovery_area/DG1/backupset/2009_03_28/o1_mf_nnndf_TAG20090328T201934_4wxhnr1f_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/flash_recovery_area/DG1/backupset/2009_03_28/o1_mf_nnndf_TAG20090328T201934_4wxhnr1f_.bkp tag=TAG20090328T201934
channel ORA_DISK_1: restore complete, elapsed time: 00:01:36
Finished restore at 28-MAR-09
RMAN> exit
Recovery Manager complete.
SQL> alter database open resetlogs;
Database altered.
SQL> conn ws_app/ws_app
Connected.
SQL> select * from woodscrew;
select * from woodscrew
*
ERROR at line 1:
ORA-00376: file 12 cannot be read at this time
ORA-01110: data file 12: '/oracle/oradata/dg1/wdscr_part01.dbf'
SQL> conn sys/oracle as sysdba
Connected.
SQL> recover datafile 12;
Media recovery complete.
SQL> alter datafile '/oracle/oradata/dg1/wdscr_part01.dbf' online;
alter datafile '/oracle/oradata/dg1/wdscr_part01.dbf' online
*
ERROR at line 1:
ORA-00940: invalid ALTER command
SQL> alter database datafile '/oracle/oradata/dg1/wdscr_part01.dbf' online;
Database altered.
SQL> conn ws_app/ws_app
Connected.
SQL> select * from woodscrew;
SCR_ID MANUFACTR_ID SCR_TYPE THREAD_CNT LENGTH
---------- -------------------- -------------------- ---------- ----------
HEAD_CONFIG
--------------------
1000 Tommy Hardware Finish 30 1.5
Phillips
1000 Balaji Parts,Inc. Finish 30 1.5
Phillips
1003 Tommy Hardware Finish 20 1
Phillips
SCR_ID MANUFACTR_ID SCR_TYPE THREAD_CNT LENGTH
---------- -------------------- -------------------- ---------- ----------
HEAD_CONFIG
--------------------
1003 Balaji Parts,Inc. Finish 20 1
Phillips
1004 Tommy Hardware Finish 30 2
Phillips
1004 Balaji Parts,Inc. Finish 30 2
Phillips
SCR_ID MANUFACTR_ID SCR_TYPE THREAD_CNT LENGTH
---------- -------------------- -------------------- ---------- ----------
HEAD_CONFIG
--------------------
1001 Tommy Hardware Finish 30 1
Phillips
1001 Balaji Parts,Inc. Finish 30 1
Phillips
1002 Tommy Hardware Finish 20 1.5
Phillips
SCR_ID MANUFACTR_ID SCR_TYPE THREAD_CNT LENGTH
---------- -------------------- -------------------- ---------- ----------
HEAD_CONFIG
--------------------
1002 Balaji Parts,Inc. Finish 20 1.5
Phillips
1005 Tommy Hardware Finish 20 2
Phillips
1005 Balaji Parts,Inc. Finish 20 2
Phillips
12 rows selected.
因此,資料庫恢復完畢。基本遇到的也是這3種情況,因此在刪除資料檔案的時候,一定要小心。不要講資料庫至於危險境地。。。。。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8334342/viewspace-580490/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle 資料檔案offlineOracle
- OFFLINE和DROP資料檔案的理解
- windows重灌/資料庫物理檔案完好的情況下恢復資料庫Windows資料庫
- 表空間OFFLINE和資料檔案OFFLINE的區別
- 表空間offline,資料檔案offline 的區別(ZT)
- 檔案屬主改變的情況
- [20121105]重建控制檔案少一個資料檔案的情況.txt
- 個人學習系列 - @Transactional失效的3種情況
- 誤刪資料檔案在沒有歸檔的情況下恢復實驗
- 對多種情況下控制檔案的理解與疑問,請指正。
- 資料庫在沒有備份的情況下的資料檔案損壞的恢復資料庫
- NoClassDefFoundError的兩種情況Error
- 利用offline datafile檔案方式遷移資料
- 資料檔案offline後unusable索引造成的問題索引
- System File1 File Header(資料庫System檔案1檔案頭)損壞情況的恢復Header資料庫
- Mysql兩種情況下更新欄位中部分資料的方法MySql
- RabbitMQ如何解決各種情況下丟資料的問題MQ
- 使用C#如何監控選定資料夾中檔案的變動情況?C#
- Oracle 查詢各個 “表空間/資料檔案” 的空間使用比情況Oracle
- 【故障處理】DG環境主庫丟失歸檔情況下資料檔案的恢復
- 20160331資料檔案offline與open resetlogs3S3
- 公司使用大資料的基本情況大資料
- 查詢Oracle資料檔案的使用情況Oracle
- 在不使用 mv 命令的情況下移動檔案
- 資料檔案、表空間offline用法及區別
- [20160329]bbed修復offline的資料檔案.txt
- 分析針對EFS加密檔案無法開啟的情況資料恢復的解決方式加密資料恢復
- 遇到EXT3 MYSQL檔案遭到惡意刪除的情況,該如何解決?MySql
- 表空間與資料檔案的offline和online操作
- 資料檔案實驗操作datafile的create/offline/drop/rename等操作
- 轉載-表空間和資料檔案offline的影響分析
- Data Guard 主端OFFLINE資料檔案和表空間
- if 判斷為 false 的 6 種情況False
- 呼叫layoutSubviews各種情況分析View
- Oracle控制檔案在缺失歸檔日誌的情況下的恢復Oracle
- 工信部:2016年3月電話分省資料情況
- 資料治理--結構化資料處理 各種情況的資料重跑,流水錶用拉鍊表
- 修改資料檔案的位置的兩種方法