測試環境:
作業系統 : red hat enterprise linux es release 4 (nahant update 4) vmware
資料庫 : oracle database 10g release 10.2.0.4.0 - production
簡要介紹,一台伺服器a位于虛拟機vmware上,由于測試需要,在vmware上克隆了該系統作為伺服器b,過了一段時間,由于資料變更,需要将伺服器a上的oracle資料庫還原恢複到伺服器b上。
案例介紹:
由
于這兩台伺服器的資料庫執行個體名稱相同、以及對應的環境基本一緻(恢複目錄相同,資料檔案、控制檔案都是一緻),是以雖然是rman異機備份,但是這種異機
恢複相對而言比較簡單,不需要修改執行個體名稱、資料庫名稱、指定資料檔案位置等等。一般來說,這種環境的恢複還原基本沒啥問題。下面介紹操作過程以及解決方
法。
step 1:通過ftp将對應的備份檔案以及歸檔日志放置到相應的目錄位置。
step 2:還原資料庫的spfile檔案。
step 3: 關閉資料庫後,利用還原spfile的初始化檔案啟動資料庫
step 4: 恢複資料庫控制檔案。
step 5: 将資料庫啟動到mount狀态
rman> alter database mount;
database mounted
released channel: ora_disk_1
step 6: restore 資料庫(中間太多資料檔案restore,使用.....替代)
step 7 : recover database
code snippet
rman> recover database;
starting recover at 02-apr-14
using channel ora_disk_1
starting media recovery
oracle error:
ora-01547: warning: recover succeeded but open resetlogs would get error below
ora-01152: file 1 was not restored from a sufficiently old backup
ora-01110: data file 1: '/u01/app/oracle/oradata/epps/system01.dbf'
rman-00571: ===========================================================
rman-00569: =============== error message stack follows ===============
rman-03002: failure of recover command at 04/02/2014 12:03:29
rman-06053: unable to perform media recovery because of missing log
rman-06025: no backup of log thread 1 seq 76757 lowscn 14312652139 found to restore
rman-06025: no backup of log thread 1 seq 76756 lowscn 14312646489 found to restore
rman-06025: no backup of log thread 1 seq 76755 lowscn 14312646378 found to restore
rman-06025: no backup of log thread 1 seq 76754 lowscn 14312646262 found to restore
rman-06025: no backup of log thread 1 seq 76753 lowscn 14312644427 found to restore
rman-06025: no backup of log thread 1 seq 76752 lowscn 14312642030 found to restore
rman-06025: no backup of log thread 1 seq 76751 lowscn 14312640281 found to restore
rman-06025: no backup of log thread 1 seq 76750 lowscn 14312638600 found to restore
rman-06025: no backup of log thread 1 seq 76749 lowscn 14312637270 found to restore
rman-06025: no backup of log thread 1 seq 76748 lowscn 14312636566 found to restore
rman-06025: no backup of log thread 1 seq 76747 lowscn 14312635786 found to restore
rman-06025: no backup of log thread 1 seq 76746 lowscn 14312634976 found to restore
rman-06025: no backup of log thread 1 seq 76745 lowscn 14312634196 found to restore
rman-06025: no backup of log thread 1 seq 76744 lowscn 14312633426 found to restore
rman-06025: no backup of log thread 1 seq 76743 lowscn 14312632650 found to restore
rman-06025: no backup of log thread 1 seq 76742 lowscn 14312631880 found to restore
rman-06025: no backup of log thread 1 seq 76741 lowscn 14312631120 found to restore
rman-06025: no backup of log thread 1 seq 76740 lowscn 14312630358 found to restore
rman-06025: no backup of log thread 1 seq 76739 lowscn 14312629580 found to restore
rman-06025: no backup of log thread 1 seq 76738 lowscn 14312628812 found to restore
rman-06025: no backup of log thread 1 seq 76737 lowscn 14312628019 found to restore
rman-06025: no backup of log thread 1 seq 76736 lowscn 14312627239 found to restore
rman-06025: no backup of log thread 1 seq 76735 lowscn 14312626460 found to restore
rman-06025: no backup of log thread 1 seq 76734 lowscn 14312625692 found to restore
rman-06025: no backup of log thread 1 seq 76733 lowscn 14312624924 found to restore
rman-06025: no backup of log thread 1 seq 76732 lowscn 14312624157 found to restore
rman-06025: no backup of log thread 1 seq 76731 lowscn 14312623377 found to restore
rman-06025: no backup of log thread 1 seq 76730 lowscn 14312622598 found to restore
rman-06025: no backup of log thread 1 seq 76729 lowscn 14312621836 found to restore
rman-06025: no backup of log thread 1 seq 76728 lowscn 14312621062 found to restore
rman-06025: no backup of log thread 1 seq 76727 lowscn 14312620313 found to restore
rman-06025: no backup of log thread 1 seq 76726 lowscn 14312618674 found to restore
rman-06025: no backup of log thread 1 seq 76725 lowscn 14312607258 found to restore
rman-06025: no backup of log thread 1 seq 76723 lowscn 14312598248 found to restore
rman-06025: no backup of log thread 1 seq 76722 lowscn 14312595919 found to restore
rman-06025: no backup of log thread 1 seq 76721 lowscn 14312593602 found to restore
rman-06025: no backup of log thread 1 seq 76720 lowscn 14312591274 found to restore
rman-06025: no backup of log thread 1 seq 76719 lowscn 14312588510 found to restore
rman-06025: no backup of log thread 1 seq 76718 lowscn 14312585861 found to restore
rman-06025: no backup of log thread 1 seq 76717 lowscn 14312583716 found to restore
rman-06025: no backup of log thread 1 seq 76716 lowscn 14312581142 found to restore
rman-06025: no backup of log thread 1 seq 76715 lowscn 14312578120 found to restore
rman-06025: no backup of log thread 1 seq 76714 lowscn 14312575570 found to restore
rman-06025: no backup of log thread 1 seq 76713 lowscn 14312572908 found to restore
rman-06025: no backup of log thread 1 seq 76712 lowscn 14312569377 found to restore
rman-06025: no backup of log thread 1 seq 76711 lowscn 14312200784 found to restore
rman-06025: no backup of log thread 1 seq 76710 lowscn 14312113790 found to restore
rman-06025: no backup of log thread 1 seq 76709 lowscn 14312070694 found to restore
rman-06025: no backup of log thread 1 seq 76708 lowscn 14312069907 found to restore
rman-06025: no backup of log thread 1 seq 76707 lowscn 14312069494 found to restore
rman-06025: no backup of log thread 1 seq 76706 lowscn 14312042189 found to restore
rman-06025: no backup of log thread 1 seq 76705 lowscn 14312014827 found to restore
rman-06025: no backup of log thread 1 seq 76704 lowscn 14311999274 found to restore
rman-06025: no backup of log thread 1 seq 76703 lowscn 14311967291 found to restore
rman-06025: no backup of log thread 1 seq 76702 lowscn 14311962023 found to restore
man-06025: no backup of log thre
rman>
截圖如下所示
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnLxMTMzADMwcTMyIDMwMDMvwFNwQTMwIzLcJDN1MzNvw1ZvxmYvwVbvNmLn9GbiRXauNmLzV2Zh1Wavw1LcpDc0RHaiojIsJye.png)
關于ora-01547的解釋如下所示:
此錯誤的最可能的原因是執行不完全恢複前。忘記從一個足夠舊的備份還原一個或 多個資料檔案。
step 8:
關于open
resetlogs選項,是指打開資料時,重置聯機重做日志(online redo
log),即将重做日志的sequence置零,為什麼要重置重做日志呢?不完全恢複後,原來的聯機重做日志(online redo
log)裡面包含的是未做恢複前的資料,而這些資料對于恢複後的資料庫不再有效,是以資料庫會要求在open之前先對聯機重做日志(online
redo
log)的sequence置零。resetlogs指令表示一個資料庫邏輯生存期的結束和另一個資料庫邏輯生存期的開始,每次使用resetlogs命
令的時候,scn不會被重置,不過oracle會重置日志序列号,而且會重置聯機重做日志内容(相當于把所有的聯機日志重新“格式化”)。
解決方法
此時可以通過設定隐藏參數_allow_resetlogs_corruption之後,使資料庫在open過程中,跳過某些一緻性檢查,進而使資料庫可能跳過不一緻狀态。操作步驟如下
[oracle@db-server 2014_04_01]$ sqlplus / as sysdba
sql*plus: release 10.2.0.4.0 - production on wed apr 2 12:05:57 2014
copyright (c) 1982, 2007, oracle. all rights reserved.
connected to:
oracle database 10g release 10.2.0.4.0 - production
sql> create spfile from pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initepps.ora';
file created.
sql> shutdown immediate;
ora-01109: database not open
database dismounted.
oracle instance shut down.
sql> startup mount;
oracle instance started.
total system global area 1258291200 bytes
fixed size 1267236 bytes
variable size 822086108 bytes
database buffers 419430400 bytes
redo buffers 15507456 bytes
database mounted.
sql> alter system set "_allow_resetlogs_corruption"=true scope=spfile;
system altered.
sql> recover database using backup controlfile until cancel;
ora-00279: change 14311145729 generated at 04/01/2014 08:57:48 needed for
thread 1
ora-00289: suggestion :
/u03/flash_recovery_area/epps/archivelog/2014_04_02/o1_mf_1_76627_%u_.arc
ora-00280: change 14311145729 for thread 1 is in sequence #76627
specify log: {<ret>=suggested | filename | auto | cancel}
cancel
media recovery cancelled.
sql> alter database open resetlogs;
database altered.
sql> select status from v$instance;
status
------------
open
使用了隐藏參數_allow_resetlogs_corruption後,需要從參數檔案(pfile或spfile中)移除隐藏參數,并對資料庫進行導入導出比較好,不過此處都是測試資料庫,重要性不是很高。在此忽略這些步驟。