1. 程式人生 > >Oracle RMAN恢復帶有OFFLINE資料檔案的資料庫

Oracle RMAN恢復帶有OFFLINE資料檔案的資料庫

1、建立測試表空間及測試資料檔案
SQL> create tablespace test datafile '/u01/app/oracle/oradata/qlotcdb/test.dbf' size 1M;
SQL> create user test identified by test default tablespace test;
User created.

SQL> alter system switch logfile;
System altered.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/qlotcdb/system01.dbf
/u01/app/oracle/oradata/qlotcdb/sysaux01.dbf
/u01/app/oracle/oradata/qlotcdb/undotbs01.dbf
/u01/app/oracle/oradata/qlotcdb/users01.dbf
/u01/app/oracle/oradata/qlotcdb/test.dbf

2、將測試資料檔案OFFLINE

SQL> alter database datafile '/u01/app/oracle/oradata/qlotcdb/test.dbf' offline;
Database altered.

3、刪除全部歸檔日誌
[[email protected] ~]$ cd /u01/app/oracle/product/11.2.0/db_1/dbs/arch
[[email protected] arch]$ ls
1_12_911428282.dbf  1_14_911428282.dbf  1_16_911428282.dbf  1_18_911428282.dbf  1_49_917365262.dbf
1_13_911428282.dbf  1_15_911428282.dbf  1_17_911428282.dbf  1_48_917365262.dbf  redo.log
[
[email protected]
arch]$ rm -rf *

4、嘗試ONLINE測試資料檔案失敗
SQL> alter database datafile 5 online;
alter database datafile 5 online
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: '/u01/app/oracle/oradata/qlotcdb/test.dbf'

5、recover OFFLINE資料檔案失敗
SQL> recover datafile 5;
ORA-00279: change 2036178 generated at 09/18/2016 16:51:38 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/product/11.2.0/db_1/dbs/arch/1_48_917365262.dbf
ORA-00280: change 2036178 for thread 1 is in sequence #48

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/product/11.2.0/db_1/dbs/arch/1_48_917365262.dbf
ORA-00308: cannot open archived log
'/u01/app/oracle/product/11.2.0/db_1/dbs/arch/1_48_917365262.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

ORA-00308: cannot open archived log
'/u01/app/oracle/product/11.2.0/db_1/dbs/arch/1_48_917365262.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3

6、RMAN全備資料庫進行異機恢復

RMAN> backup database format  '/home/oracle/db_%d_%s_%p_%t_%T';
Starting backup at 18-SEP-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/qlotcdb/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/qlotcdb/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/qlotcdb/users01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/qlotcdb/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/qlotcdb/test.dbf
channel ORA_DISK_1: starting piece 1 at 18-SEP-16
channel ORA_DISK_1: finished piece 1 at 18-SEP-16
piece handle=/home/oracle/db_qlotcdb_5_1_922899986_20160918 tag=TAG20160918T170626 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 18-SEP-16
channel ORA_DISK_1: finished piece 1 at 18-SEP-16
piece handle=/home/oracle/db_qlotcdb_6_1_922900041_20160918 tag=TAG20160918T170626 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 18-SEP-16

RMAN> list backup of database;
List of Backup Sets
==================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    1.40G      DISK        00:00:16     18-SEP-16      
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20160918T170253
        Piece Name: /home/oracle/1.ddd
  List of Datafiles in backup set 2
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 2037314    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/system01.dbf
  2       Full 2037314    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/sysaux01.dbf
  3       Full 2037314    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/undotbs01.dbf
  4       Full 2037314    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/users01.dbf
  5       Full 2036178    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/test.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3       Full    1.40G      DISK        00:00:15     18-SEP-16      
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20160918T170444
        Piece Name: /home/oracle/1_U%
  List of Datafiles in backup set 3
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 2037360    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/system01.dbf
  2       Full 2037360    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/sysaux01.dbf
  3       Full 2037360    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/undotbs01.dbf
  4       Full 2037360    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/users01.dbf
  5       Full 2036178    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/test.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4       Full    1.40G      DISK        00:00:51     18-SEP-16      
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20160918T170626
        Piece Name: /home/oracle/db_qlotcdb_5_1_922899986_20160918
  List of Datafiles in backup set 4
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 2037401    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/system01.dbf
  2       Full 2037401    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/sysaux01.dbf
  3       Full 2037401    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/undotbs01.dbf
  4       Full 2037401    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/users01.dbf
  5       Full 2036178    18-SEP-16 /u01/app/oracle/oradata/qlotcdb/test.dbf
  

7、異機恢復引數檔案及控制檔案(略)

8、異機restore database
RMAN> shutdown immediate
database closed
database dismounted
Oracle instance shut down

RMAN> startup mount
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area     413372416 bytes
Fixed Size                     2253784 bytes
Variable Size                327158824 bytes
Database Buffers              79691776 bytes
Redo Buffers                   4268032 bytes

RMAN> restore database;
Starting restore at 18-SEP-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/qlotcdb/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/qlotcdb/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/qlotcdb/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/qlotcdb/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/qlotcdb/test.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/db_qlotcdb_5_1_922899986_20160918
channel ORA_DISK_1: piece handle=/home/oracle/db_qlotcdb_5_1_922899986_20160918 tag=TAG20160918T170626
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:26
Finished restore at 18-SEP-16

9、restore database後無法直接OPEN,提示資料檔案需要介質恢復
RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 09/18/2016 17:09:51
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/u01/app/oracle/oradata/qlotcdb/system01.dbf'

10、recover亦失敗
RMAN> recover database;
Starting recover at 18-SEP-16
using channel ORA_DISK_1
starting media recovery
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 09/18/2016 17:09:57
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of archived log for thread 1 with sequence 50 and starting SCN of 2036521 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 49 and starting SCN of 2036497 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 48 and starting SCN of 2035586 found to restore

11、此時資料庫無法OPEN
RMAN> alter database open;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 09/18/2016 17:17:28
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/u01/app/oracle/oradata/qlotcdb/system01.dbf'

RMAN> alter database open resetlogs;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 09/18/2016 17:17:51
ORA-01152: file 1 was not restored from a sufficiently old backup 
ORA-01110: data file 1: '/u01/app/oracle/oradata/qlotcdb/system01.dbf'

12、重建控制檔案,去除OFFLINE的資料檔案
RMAN> shutdown immediate
database dismounted
Oracle instance shut down

SQL> STARTUP NOMOUNT
ORACLE instance started.
Total System Global Area  413372416 bytes
Fixed Size                  2253784 bytes
Variable Size             327158824 bytes
Database Buffers           79691776 bytes
Redo Buffers                4268032 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "qlotcdb" NORESETLOGS  ARCHIVELOG
  2      MAXLOGFILES 16
  3      MAXLOGMEMBERS 3
  4      MAXDATAFILES 100
  5      MAXINSTANCES 8
  6      MAXLOGHISTORY 292
  7  LOGFILE
  8    GROUP 1 '/u01/app/oracle/oradata/qlotcdb/redo01.log'  SIZE 50M BLOCKSIZE 512,
  9    GROUP 2 '/u01/app/oracle/oradata/qlotcdb/redo02.log'  SIZE 50M BLOCKSIZE 512,
 10    GROUP 3 '/u01/app/oracle/oradata/qlotcdb/redo03.log'  SIZE 50M BLOCKSIZE 512
 11  -- STANDBY LOGFILE
 12  DATAFILE
 13    '/u01/app/oracle/oradata/qlotcdb/system01.dbf',
 14    '/u01/app/oracle/oradata/qlotcdb/sysaux01.dbf',
 15    '/u01/app/oracle/oradata/qlotcdb/undotbs01.dbf',
 16    '/u01/app/oracle/oradata/qlotcdb/users01.dbf'
 17  CHARACTER SET ZHS16GBK
 18  ;
Control file created.

13、重建控制檔案後,recover database,資料庫成功OPEN
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
MOUNTED

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/u01/app/oracle/oradata/qlotcdb/system01.dbf'

SQL> recover database;        
Media recovery complete.

SQL> alter database open;
Database altered.

相關推薦

Oracle RMAN恢復帶有OFFLINE資料檔案資料庫

1、建立測試表空間及測試資料檔案 SQL> create tablespace test datafile '/u01/app/oracle/oradata/qlotcdb/test.dbf' size 1M; SQL> create user test ide

oracle rman恢復資料檔案路徑不一致

編輯恢復指令碼:vi recover.txt run{allocate channel c1 type sbt;allocate channel c2 type sbt;allocate channel c3 type sbt;allocate channel c4 type sbt;allocate ch

12c容器資料庫匯入操作_筆記(Linux/oracle借用shell工具匯入資料檔案操作)

Linux/oracle借用shell工具匯入資料檔案操作 一、使用shell工具,遠端連線到Linux下的oracle資料庫服務上 Xshell 6 (Build 0095) Copyright (c) 2002 NetSarang Computer, Inc. All rights reserved

oracle 12c誤刪pdb資料檔案導致整個資料庫無法開啟問題

同事誤刪了某個外掛資料庫(PDB)的資料檔案,結果整個資料庫,包括容器資料庫(CDB),以及其他外掛資料庫都用不了了。 1、用sys賬號進入例項,可見容器資料庫處於mounted狀態;插在上面的所有PDB當然也都是mounted。 sqlplus sys/p

oracle rman恢復數據文件路徑不一致

over ora release 後臺 tar rod ada backup alloc 編輯恢復腳本:vi recover.txt run{allocate channel c1 type sbt;allocate channel c2 type sbt;allocate

Oracle 10g使用amdu抽取資料檔案

環境:OEL 5.7 + Oracle 10.2.0.5 RAC 需求:實驗在Oracle 10g環境使用amdu抽取資料庫檔案 本文主要目的是介紹3個知識點: 1.使amdu可以在oracle 10g環境中使用 2.使kfed可以在oracle 10g環境中使用 3.amdu如何抽取損壞的

oracle-dba-表空間與資料檔案管理

表空間與資料檔案管理 ORACLE資料庫應用系統ORACLE中介軟體DBMS資料檔案 邏輯結構:一個數據庫有多個表空間,一個表空間有多個段,一個段有多個區段,一個區段有多個數據塊,一個數據塊有多個作業系統資料庫塊 物理結構:一個表空間有多個數據

Oracle異常關閉後謹防資料檔案受損

資料庫是智慧校園下各類資訊系統的核心組成部分。Oracle資料庫憑藉其強大的穩定性和可伸縮性,目前基本是國內所有高校作為軟體平臺底層資料倉庫的主流選擇。 正所謂“好馬配好鞍,寶劍贈英雄”,穩定高效的Oracle資料庫,自然也對運維人員技術水平和底層硬體執行環境的要求更高,一

使用Oracle儲存過程匯入匯出資料檔案

 搞了幾天,終於把使用Oracle儲存過程匯入匯出資料做成功了。現在分享一下,供大家共同進步。在這裡我非常非常感謝“往事如夢”,以及“Oracle愛好者”上好友的幫助。     首先判斷utl_file_dir的目錄  SQL> show parameter utl_

SD卡CF卡U盤硬碟等磁碟屬性顯示為0位元組怎麼修復恢復照片視訊資料檔案

【故障現象】磁碟(如U盤,SD卡,行動硬碟等)打不開,右鍵檢視磁碟屬性,顯示為0位元組: 【原因分析】出現這種錯誤提示的原因可能有以下幾種:1.沒有安全彈出移動磁碟,2. 突然斷電,讀盤中斷。3.電腦病毒引起的,4.移動磁碟質量問題 【恢復方法】這種問題有2種損壞可能:一是磁

oracle 資料恢復,只有oradata資料夾裡的檔案,沒有備份檔案資料庫恢復,重灌系統後,oracle 10g資料庫恢復

格式化重灌系統後,才想起來oracle 10g 資料庫沒有做備份,開始以為很麻煩,沒想到資料庫恢復的還挺順利的 恢復方法: 1,把原來的資料庫檔案備份,(D:\oracle\product\10.2.0\oradata\gqxt),重新命名即可,我命名為gqxt_old,(

Oracle資料庫資料檔案rm -rf誤刪除後恢復

Oracle資料庫中表空間的資料檔案在基於OS系統級別被rm -rf 刪除後,只要資料庫在刪除後一直未被shutdown,那麼就可以手動恢復,恢復的前提是Oracle安裝在Linux系統下,下面是一個例項模擬 1. 在資料庫open的時候,直接刪除users表空間中的

oracle備份之rman_恢復資料檔案

測試環境:redhat 5.5 oracle 11g 測試步驟: 1.備庫 2.插資料 3.刪dbf 4.關閉並啟動到mount 5.restore 6.recover 7.開啟 RMAN> backup database; Starting back

Oracle資料庫備份與恢復 - RMAN恢復

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

資料檔案還在的情況下 進行資料庫恢復

今天在為windows作業系統恢復資料時,碰到了如圖問題 此時我已經通過源庫的spfile生成了pfile,並修改過pfile裡的相關路徑, 將資料庫啟到mount狀態了 。 原因: 根據報錯可以看出,資料檔案的目錄不對,通過 select name from v$d

ORACLE資料庫、表空間、資料檔案之間的關係

完整的Oracle資料庫通常由兩部分組成:Oracle資料庫和資料庫例項。 1) 資料庫是一系列物理檔案的集合(資料檔案,控制檔案,聯機日誌,引數檔案等); 2) Oracle資料庫例項則是一組Oracle後臺程序/執行緒以及在伺服器分配的共享記憶體區。 在啟動

linux平臺通過lsof命令恢復被誤刪的oracle資料檔案

背景:測試環境suse12作業系統,開發人員誤刪了/home/oracle下面的資料檔案             oracle狀態看起來一切正常,但資料檔案已經被rm掉。 恢復方法:通過lsof命令找到被刪除的資料檔案,拷貝出來

ORACLE 資料庫、表空間、SCHEMA、資料檔案的概念

      在Oracle中,結合邏輯儲存與物理儲存的概念,我們可以這樣來理解資料庫、表空間、SCHEMA、資料檔案這些概念:      資料庫是一個大圈,裡面圈著的是表空間,表空間裡面是資料檔案,那麼schema是什麼呢?schema是一個邏輯概念,是一個集合,但schem

Oracle中查詢當前資料庫中的所有表空間和對應的資料檔案語句命令

--轉載路徑:http://www.cnblogs.com/wangsaiming/p/3573917.html --------------------------------------------------------------------------------

oracle資料庫,表空間,資料檔案的關係

資料庫,表空間,及資料檔案關係密切,但同時又有很多區別: 一個Oracle資料庫是由一個或多個表空間(tablespace)的邏輯儲存單位構成的,這些表空間共同來儲存資料庫的資料 Oracle資料庫