Oracle Rman跨resetlogs版本恢複

來源:互聯網
上載者:User

RMAN> startup nomount;

RMAN> sql 'alter session set nls_date_format=''yyyy-mm-dd hh24:mi:ss''";
--因為rman預設以環境變數來讀取時間格式,與sqlplus的固定格式不同,所以,此處要設定時間格式變數。
RMAN> restore controlfile from autobackup until time '2009-03-10 18:15:00';
注意,仍然需要適當的還原控制檔案。
RMAN> alter database mount;
RMAN> restore database;
RMAN> sql "alter session set nls_date_format=''yyyy-mm-dd hh24:mi:ss''";
RMAN> recover database until time '2009-03-10 18:15:00';

 

此時,出現以下錯誤:

RMAN-03002: recover 命令 (在 03/10/2009 19:21:19 上) 失敗
RMAN-20207: UNTIL TIME 或 RECOVERY WINDOW 在 RESETLOGS 時間之前

 

20207錯誤:預設的認為until time或RECOVERY WINDOW的時間不能早於resetlogs的時間. 既然resetlogs了,就不認識之前的歸檔日誌資訊了。把之前的歸檔日誌排除在可供恢複的選擇之外了。這隻是預設的行為,可能處於節省系統資源的考慮,畢竟resetlogs之前的資料再利用可能很小。

 

其解決可按以下方法處理:

1.找到資料庫的當前incarnation號:

RMAN> list incarnation of database "test";

資料庫原型列表
DB 關鍵字  Inc 關鍵字 DB 名  DB ID            STATUS  重設 SCN  重設時間
------- ------- -------- ---------------- --- ---------- ----------
1       1       TEST     1978860036       PARENT  1          30-8月 -05
2       2       TEST     1978860036       PARENT  534907     05-3月 -09
3       3       TEST     1978860036       PARENT  762990     10-3月 -09
4       4       TEST     1978860036       PARENT  764885     10-3月 -09
5       5       TEST     1978860036       PARENT  765443     10-3月 -09
6       6       TEST     1978860036       PARENT  767488     10-3月 -09
7       7       TEST     1978860036       PARENT  771807     10-3月 -09
8       8       TEST     1978860036       PARENT  774320     10-3月 -09
9       9       TEST     1978860036       PARENT  779541     10-3月 -09
10      10      TEST     1978860036       PARENT  782000     10-3月 -09
11      11      TEST     1978860036       PARENT  783792     10-3月 -09
12      12      TEST     1978860036       CURRENT 801599     10-3月 -09  --此行原型(incarnation)號狀態為current,即當前

 
所以,資料庫的前一個(resetlogs之前)原型號為11.

我們重新啟動資料庫到mount狀態(因為需要知道是重設哪個庫,所以要掛載)

 

2.重設資料庫到前一個原型(注意:此時的控制檔案已經在前面的步驟中,還原到了適當的時間點。實際上,我們應該在nomount前還原控制檔案)

RMAN> reset database to incarnation 11;

將資料庫重設為原型 11

RMAN> sql "alter session set nls_date_format=''yyyy-mm-dd hh24:mi:ss''";
RMAN> restore database;
RMAN> recover database until time '2009-03-10 18:15:00';
RMAN> alter database open resetlogs;  (此時,資料庫的incarnation編號將再次上漲)

資料庫正常開啟

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.