1. 程式人生 > >ORACLE 11G 中採用rman備份異機恢復資料庫詳細過程

ORACLE 11G 中採用rman備份異機恢復資料庫詳細過程


場景:
        有一個生產庫的使用者下面所有的表都不見了,懷疑人為被刪除了,現在需要用備份去恢復下,找出原來的表,線上是oracle dataguard環境,有全庫備份檔案,準備去測試庫恢復一下。



1,從生產庫上copy好全備份檔案
恢復資料庫需要準備的檔案:rman完整備份(包括資料檔案、日誌檔案、控制檔案、引數檔案),記錄源資料庫的DBID

安裝的測試資料庫ORACLE資料庫軟體並建立跟源資料庫同名和資料庫SID並修改資料庫DBID跟源資料庫DBID一樣,建立跟源資料庫伺服器相同的資料檔案目錄、日誌檔案目錄、控制檔案目錄。

檢視環境
1.1,檢視引數檔案資訊
RMAN>  list backup of spfile;



using target database control file instead of recovery catalog


List of Backup Sets
===================




BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7       Full    1.05M      DISK        00:00:01     30-JAN-15      
        BP Key: 7   Status: AVAILABLE  Compressed: YES  Tag: TAG20150130T201758

        Piece Name: /data/oracle/backup/data/2015-01-30/full_stuorcl_20150130_7.bak
  SPFILE Included: Modification time: 30-JAN-15
  SPFILE db_unique_name: stuorcl


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
11      Full    9.39M      DISK        00:00:01     31-JAN-15      

        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20150131T180139
        Piece Name: /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015_01_31/o1_mf_ncsnf_TAG20150131T180139_bdsb18jn_.bkp
  SPFILE Included: Modification time: 31-JAN-15
  SPFILE db_unique_name: stuorcl


1.2檢視控制檔案資訊:
RMAN>  list backup of controlfile;




List of Backup Sets
===================




BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7       Full    1.05M      DISK        00:00:01     30-JAN-15      
        BP Key: 7   Status: AVAILABLE  Compressed: YES  Tag: TAG20150130T201758
        Piece Name: /data/oracle/backup/data/2015-01-30/full_stuorcl_20150130_7.bak
  Control File Included: Ckp SCN: 1635989      Ckp time: 30-JAN-15


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
11      Full    9.39M      DISK        00:00:01     31-JAN-15      
        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20150131T180139
        Piece Name: /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015_01_31/o1_mf_ncsnf_TAG20150131T180139_bdsb18jn_.bkp
  Control File Included: Ckp SCN: 1758247      Ckp time: 31-JAN-15



1.3 檢視資料庫資訊: 
RMAN>  list backup of database;




List of Backup Sets
===================




BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6       Full    270.16M    DISK        00:00:56     30-JAN-15      
        BP Key: 6   Status: AVAILABLE  Compressed: YES  Tag: TAG20150130T201758
        Piece Name: /data/oracle/backup/data/2015-01-30/full_stuorcl_20150130_6.bak
  List of Datafiles in backup set 6
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 1635573    30-JAN-15 /oracle/data_ora/stuorcl/system01.dbf
  2       Full 1635573    30-JAN-15 /oracle/data_ora/stuorcl/sysaux01.dbf
  3       Full 1635573    30-JAN-15 /oracle/data_ora/stuorcl/undotbs01.dbf
  4       Full 1635573    30-JAN-15 /oracle/data_ora/stuorcl/users01.dbf
  5       Full 1635573    30-JAN-15 /oracle/data_ora/stuorcl/SBXTAX01.dbf
  6       Full 1635573    30-JAN-15 /oracle/data_ora/stuorcl/SMS01.dbf


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10      Full    1.11G      DISK        00:00:29     31-JAN-15      
        BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: TAG20150131T180139
        Piece Name: /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015_01_31/o1_mf_nnndf_TAG20150131T180139_bdsb04jz_.bkp
  List of Datafiles in backup set 10
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 1758077    31-JAN-15 /oracle/data_ora/stuorcl/system01.dbf
  2       Full 1758077    31-JAN-15 /oracle/data_ora/stuorcl/sysaux01.dbf
  3       Full 1758077    31-JAN-15 /oracle/data_ora/stuorcl/undotbs01.dbf
  4       Full 1758077    31-JAN-15 /oracle/data_ora/stuorcl/users01.dbf
  5       Full 1758077    31-JAN-15 /oracle/data_ora/stuorcl/SBXTAX01.dbf
  6       Full 1758077    31-JAN-15 /oracle/data_ora/stuorcl/SMS01.dbf



1.4 檢視歸檔日誌資訊: 
RMAN> list backup of archivelog all;




List of Backup Sets
===================




BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
8       1.26M      DISK        00:00:00     30-JAN-15      
        BP Key: 8   Status: AVAILABLE  Compressed: YES  Tag: TAG20150130T201906
        Piece Name: /data/oracle/backup/data/2015-01-30/arch_stuorcl_20150130_8.bak


  List of Archived Logs in backup set 8
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    104     1635562    30-JAN-15 1635995    30-JAN-15


BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
9       195.19M    DISK        00:00:04     31-JAN-15      
        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20150131T180132
        Piece Name: /data/oracle/backup/data/ALL_0cpu493s_1_1.BKP


  List of Archived Logs in backup set 9
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    105     1635995    30-JAN-15 1636013    30-JAN-15
  1    106     1636013    30-JAN-15 1653304    30-JAN-15
  1    107     1653304    30-JAN-15 1679217    31-JAN-15
  1    108     1679217    31-JAN-15 1703168    31-JAN-15
  1    109     1703168    31-JAN-15 1731695    31-JAN-15
  1    110     1731695    31-JAN-15 1757189    31-JAN-15
  1    111     1757189    31-JAN-15 1758005    31-JAN-15
  1    112     1758005    31-JAN-15 1758039    31-JAN-15
  1    113     1758039    31-JAN-15 1758055    31-JAN-15


BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
12      1.12M      DISK        00:00:00     31-JAN-15      
        BP Key: 12   Status: AVAILABLE  Compressed: NO  Tag: TAG20150131T180218
        Piece Name: /data/oracle/backup/data/ALL_0fpu495a_1_1.BKP


  List of Archived Logs in backup set 12
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    114     1758055    31-JAN-15 1758252    31-JAN-15


RMAN>






2、開始恢復引數檔案控制檔案:
SQL> select dbid from v$database;                                                                                                                                                              


      DBID
----------
3391761643


SQL>


2.1 設定DBID:
注意:在rman下即使沒有引數檔案,預設也會啟動一個DUMMY例項,以便能夠恢復引數檔案。
set dbid 3391761643


2.2 恢復spfile檔案
startup到open狀態,先檢視spfile檔案位置:
SQL> show parameter spfile;


NAME     TYPE
------------------------------------ ----------------------
VALUE
------------------------------
spfile     string
/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfilestuorcl.ora
SQL>

shutdown後,再startup 到 nomount狀態
startup nomount再恢復
restore spfile to '/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfilestuorcl.ora' from '/oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-27/full_stuorcl_20150127_3069.bak';


恢復報錯,去生產環境檢視備份資訊:
RMAN> show all;                                                                                                                                                                                


using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name stuunq are:                                                                                                                      
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 15 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/pddata2/oracle/backup/data/ctl_auto/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_stuorcl.f'; # default                                                                           

RMAN> 
有CONFIGURE CONTROLFILE AUTOBACKUP ON; 表示引數檔案和控制檔案有備份


restore spfile to '/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfilestuorcl.ora' from  '/oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-27/c-3391761643-20150127-03';
RMAN> restore spfile to '/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfilestuorcl.ora' from  '/oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-27/c-3391761643-20150127-03';


Starting restore at 02-FEB-15
using channel ORA_DISK_1


channel ORA_DISK_1: no AUTOBACKUP in 7 days found
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 02/02/2015 11:36:30
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece
restore spfile to '/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfilestuorcl.ora' from  '/oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-27/c-3391761643-20150127-03' until time 'sysdate - 30'




RMAN> restore spfile to '/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfilestuorcl.ora' from  '/oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-27/c-3391761643-20150127-03' until time 'sysdate - 30';


Starting restore at 02-FEB-15
using channel ORA_DISK_1


channel ORA_DISK_1: restoring spfile from AUTOBACKUP /oracle/app/oracle/flash_recovery_area/stuorcl/backupset/2015-01-27/c-3391761643-20150127-03
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 02-FEB-15


RMAN> 
OK,成功了,引數檔案恢復成功。


CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 15 DAYS;
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
這是兩個庫不一樣的地方


2.3,恢復控制檔案位置
檢視控制檔案位置
SQL> show parameter control


NAME     TYPE

相關推薦

ORACLE 11G 採用rman備份恢復資料庫詳細過程

場景:        有一個生產庫的使用者下面所有的表都不見了,懷疑人為被刪除了,現在需要用備份去恢復下,找出原來的表,線上是oracle dataguard環境,有全庫備份檔案,準備去測試庫恢復一下。1,從生產庫上copy好全備份檔案恢復資料庫需要準備的檔案:rman完整備

Rman備份恢復

最後更新時間:2018/12/29 前置條件 已準備一臺安裝好Centos6+oracle11gr2 軟體的伺服器; 只安裝了 oracle 資料庫軟體,需要手工建立以下目錄: #環境變數 export ORACLE_SID=orcl #由於只安裝軟體未建立資料庫所以需建立對應資料夾 mkdir -p $

rac環境rman備份恢復至單機

2、將rac環境的rman備份拷貝到單機。並就rac環境pfile copy到單機,根據單機主機資源,修改叢集引數,例項名,檔案路徑以及sga和pga等引數。修改如下: [[email protected] trace]$ more /backup/test1.ora binbin1.__db_ca

ORACLE 只有rman 完整備份恢復

恢復資料庫需要準備的檔案:rman完整備份(包括資料檔案、日誌檔案、控制檔案、引數檔案),記錄源資料庫的DBID 一、安裝資料庫ORACLE資料庫軟體並建立跟源資料庫同名和資料庫SID並修改資料庫DBID跟源資料庫DBID一樣,建立跟源資料庫伺服器相同的資料檔案目錄、日誌檔

RMAN恢復資料庫

      RMAN> list backup;   RMAN-00571: ===========================================================   RMAN-00569: =============== ERROR MESSAGE STACK FOL

oracle 11g備份-------邏輯備份

備份 : 是資料庫中資料的副本,它可以保護資料在出現意外損失時最大限度的恢復。(現有備份才能恢復) Oracle資料庫的備份包括以下兩種型別: ①物理備份是對資料庫的作業系統物理檔案(如資料檔案、控制檔案和線上日誌檔案等)的備份 在oracle 11

Oracle RMAN恢復歸檔RMAN-07518(供日誌挖掘使用)及修改dbid步驟

Recovery Manager: Release 11.2.0.4.0 - Production on Sat Jul 16 15:35:06 2016 Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

oracle 12c RMAN恢復還原RAC叢集(ASM)為單例項庫(檔案系統)記錄

CONFIGURE CONTROLFILE AUTOBACKUP ON備份集準備 backup database format '/home/databak/whole_%d_%U'; backup spfile format '/home/databak/spfile_%

Oracle 單例項 遷移到 RAC 例項 -- 使用RMAN 恢復

Oracle 官網有關單例項遷移到RAC的一個步驟說明: How to Convert 10g Single-Instance database to 10g RAC using Manua

oracle 11g oracle 10g) crsctl 的 替換命令

替換 delet pla tran 11g deb cells clas nat  oracle 11g 中 (oracle 10g) crsctl 的 替換命令 Deprecated Comman

[精]Oracle 11G數據庫VMware虛擬下載

ice vmware虛擬機 mes host bind eas manager 文件 clas 虛擬機文件下載地址: http://pan.baidu.com/s/1pJL5Tub 備份一個防止失效 https://pan.baidu.com/s/1nvbZ

Oracle 11g的IO Calibrate(automatic DOP: skipped because of IO calibrate statistics are missing)

Oracle 11g有兩個對於效能方面的測試工具,一個就是RAT(Real Application Test),另一個就是IO校準(Calibrate IO)。RAT是一種負載重演元件,當進行系統軟硬體升級的時候,我們一個很關注的問題是:此次變化能否提升系統性能

31 Oracle深度學習筆記——RMAN備份常用命令

conf chang del get csdn 刪除 log style 增量備份 31.Oracle深度學習筆記——RMAN備份常用命令 歡迎轉載,轉載請標明出處:http://blog.csdn.net/notbaron/article/details/508308

oracle 12c叢集使用rman備份恢復

1、資料庫備份 物理備份 熱備:在資料庫開機狀態下進行的備份。 冷備:資料庫關閉的情況下,進行作業系統檔案的拷貝(注意此時關閉資料庫庫必須是按照正常情況關閉的)。 邏輯備份 2、物理熱備 recovery manager(RMAN) 是一個客戶端應用程式,用於資料庫的備份

Oracle-11g的併發控制(2012/11/16)

1 事務基礎在DB中,可能出現如下3種現象髒讀 在事務中,讀到了其它事務沒有提交的記錄 不可重複讀 在事務中,即使查詢條件相同,下次返回的記錄與上次返回記錄不一樣,不一樣體現在記錄被修改或記錄被刪除 幻影讀 在事務中,即使查詢條件相同,下次返回的記錄與上次返回記錄不一樣

oracle 11gsql plus使用

一、啟動sql plus 進入sql*plus方法: 1)從安裝程式目錄進入 2)cmd方式 sqlplus username/[email protected]主機字串 1)2)既可以使用sql語句也支援sql命令 3)sql developer :只能寫sql語句,sql命令

oracle 恢復 從asm到檔案系統成功例項

1.1   確實 源資料庫與目標庫版本一致  語句:select * from v$version; 源庫: 1.2   確認源資料庫名與目標庫資料庫名一致  查詢資料庫名語句:select name fromv$database; 如果不一致通過恢復spfile檔

利用rman進行還原(目錄不同)

--注:備份操作省略,詳見利用rman進行異機還原(目錄相同)。下列操作均在目標伺服器上進行。 --rman [[email protected] ~]$ rman target / Recovery Manager: Release 10.2.0.1.0 - P

oracle恢復參考官方文檔

ocata backups class sta eat ndb done online diff How to use Rman Duplicate on ASM/RAC/OMF/Single Instance (Doc ID 840647.1) How to perfo

oracle恢復測試

(一)問題背景 最近在生產環境中,開發人員誤操作,使用truncate將oracle資料庫某個表的資料全部刪除了,在刪除之後,開發人員發現自己闖禍了,於是聯絡值班的DBA進行緊急資料恢復。 經過分析,表被truncate後,使用一般的閃回表、閃回查詢、閃回事物等方法,是不可能將資料找回來的,可以使用閃回資料庫