利用incremental backup恢復丟失日誌的standby
當standby已經丟失archive log之後怎麼辦?
除了重建還有什麼辦法?答案就是利用incremental backup前滾standby。
這個feature早就在官檔上作為場景出現過,以前一直沒有注意也沒有看到,最近在生產資料庫上做了一次這樣的恢復。
需要注意的地方:
1.在10g的官檔上面miss掉的一個步驟是:需要重建standby的control file。否則在recover新的archive log時報錯。
(其實我們認為Oracle其實應該直接讀取v$datafile_header的checkpoint_change#來進行選擇該應用哪個日誌。因為重建standby control file是沒有必要的操作。希望在將來的12G時可以不用重建standby control file,因為11G的官檔上已經加了這一步:restore controlfile..sigh)
2.如果在丟失的日誌裡有新加的datafile,需要提前在standby上create一個空的出來,否則在應用incremental backup時報錯。
3.我們需要估算incremental backup的大小,因為如果丟失過多的日誌,增量備份時有可能很大的。對於整個incremental backup sets,Oracle預設是將3個datafiles的change放入一個incremental backup檔案中的,我想是便於我們儲存、搬取和傳輸。
以下post一個在測試資料庫上做的例子:
1. Disaster happens
on pirmary:
SQL> alter tablespace data01 add datafile '/xxx/xxx/xxx/haozhu/data/data01_07.dbf' size 1m;
Tablespace altered.
SQL> alter system switch logfile;
System altered.
\mv haozhu_365.1_690165123_arc deletedlog3
2. on primary, recreate the standby controlfile.
SQL> alter database create standby controlfile as '/tmp/ctl_hao_1.ctl';
Database altered.
3. on standby , check current scn and shutdown
SQL> SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
-----------
213879349
SQL> shutdown immediate;
4. on primary, transfer the new control file to standby.
rcp /tmp/ctl_hao_1.ctl xxx.xxx.xxx.com:/xxx/xxx/data01/haozhu/control/ctl_hao_1.ctl
rcp /tmp/ctl_hao_1.ctl xxx.xxx.xxx.com:/xx/xxx/data01/haozhu/control/ctl_hao_2.ctl
5. on primary, check the newly created datafile.
SQL>select FILE#,name from v$datafile where CREATION_CHANGE#>=213879349;
FILE#
----------
NAME
-------------------------------------------------------------------------------------------------------------------------------------------------------------
14
/xxx/xxx/data01/haozhu/data/data01_07.dbf
6. on standby, startup using the newly created control file.
SQL> startup mount
rename files accordingly and skip the newly created datafiles in the gap.
SQL> select 'alter database rename file '''||name||''' to ''/xxx/xxx/xxx/haozhu/data/'||substr(name,32,length(name))||''';'
2 from v$datafile where file#<>14;
'ALTERDATABASERENAMEFILE'''||NAME||'''TO''/xxx/xxx/xxx/HAOZHU/DATA/'||SUBSTR(NAME,32,LENGTH(NAME))||''';'
-----------------------------------------------------------------------------------------------------------------------------------------------
alter database rename file '/oracle/xxx/data01/haozhu/data/system01.dbf' to '/oracle/xxx/data01/haozhu/data/system01.dbf';
alter database rename file '/oracle/xxx/data01/haozhu/data/undotest.dbf' to '/oracle/xxx/data01/haozhu/data/undotest.dbf';
alter database rename file '/oracle/xxx/data01/haozhu/data/sysaux01.dbf' to '/oracle/xxx/data01/haozhu/data/sysaux01.dbf';
alter database rename file '/oracle/xxx/data01/haozhu/data/data01_01.dbf' to '/oracle/xxx/data01/haozhu/data/data01_01.dbf';
alter database rename file '/oracle/xxx/data01/haozhu/data/data01_04.dbf' to '/oracle/xxx/data01/haozhu/data/data01_04.dbf';
alter database rename file '/oracle/xxx/data01/haozhu/data/data01_05.dbf' to '/oracle/xxx/data01/haozhu/data/data01_05.dbf';
alter database rename file '/oracle/xxx/data01/haozhu/data/undo01_01.dbf' to '/oracle/xxx/data01/haozhu/data/undo01_01.dbf';
alter database rename file '/oracle/xxx/data01/haozhu/data/test32k_01.dbf' to '/oracle/xxx/data01/haozhu/data/test32k_01.dbf';
alter database rename file '/oracle/xxx/data01/haozhu/data/wwf_01.dbf' to '/oracle/xxx/data01/haozhu/data/wwf_01.dbf';
alter database rename file '/oracle/xxx/data01/haozhu/data/data01_02.dbf' to '/oracle/xxx/data01/haozhu/data/data01_02.dbf';
alter database rename file '/oracle/xxx/data01/haozhu/data/data01_03.dbf' to '/oracle/xxx/data01/haozhu/data/data01_03.dbf';
alter database rename file '/oracle/xxx/data01/haozhu/data/alex_01.dbf' to '/oracle/xxx/data01/haozhu/data/alex_01.dbf';
7. on primary, create the incremental backup since the SCN recorded on standby:
rman target /
BACKUP INCREMENTAL FROM SCN 213879349 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FOR STANDBY';
rcp /tmp/ForStandby_* xxx.xxx.xxx.com:/oracle/xxx/data01/haozhu/archive
8. on standby , recreate the newly created datafile and apply the incremental backup
SQL> alter database create datafile 14 as '/oracle/xxx/data01/haozhu/data/data01_data07.dbf';
Database altered.
rman target / nocatalog
RMAN> CATALOG START WITH '/oracle/xxx/data01/haozhu/archive/ForStandby';
searching for all files that match the pattern /oracle/xxx/data01/haozhu/archive/ForStandby
List of Files Unknown to the Database
=====================================
File Name: /oracle/xxx/data01/haozhu/archive/ForStandby_0ekpglmn_1_1
File Name: /oracle/xxx/data01/haozhu/archive/ForStandby_0fkpgloe_1_1
File Name: /oracle/xxx/data01/haozhu/archive/ForStandby_0gkpglog_1_1
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /oracle/xxx/data01/haozhu/archive/ForStandby_0ekpglmn_1_1
File Name: /oracle/xxx/data01/haozhu/archive/ForStandby_0fkpgloe_1_1
File Name: /oracle/xxx/data01/haozhu/archive/ForStandby_0gkpglog_1_1
RMAN> RECOVER DATABASE NOREDO;
Starting recover at 17-SEP-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=2193 devtype=DISK
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /oracle/xxx/data01/haozhu/data/system01.dbf
destination for restore of datafile 00002: /oracle/xxx/data01/haozhu/data/undotest.dbf
destination for restore of datafile 00003: /oracle/xxx/data01/haozhu/data/sysaux01.dbf
destination for restore of datafile 00004: /oracle/xxx/data01/haozhu/data/data01_01.dbf
destination for restore of datafile 00005: /oracle/xxx/data01/haozhu/data/data01_04.dbf
destination for restore of datafile 00006: /oracle/xxx/data01/haozhu/data/data01_05.dbf
destination for restore of datafile 00007: /oracle/xxx/data01/haozhu/data/undo01_01.dbf
destination for restore of datafile 00009: /oracle/xxx/data01/haozhu/data/wwf_01.dbf
destination for restore of datafile 00010: /oracle/xxx/data01/haozhu/data/data01_02.dbf
destination for restore of datafile 00011: /oracle/xxx/data01/haozhu/data/data01_03.dbf
destination for restore of datafile 00012: /oracle/xxx/data01/haozhu/data/alex_01.dbf
destination for restore of datafile 00014: /oracle/xxx/data01/haozhu/data/data01_data07.dbf
channel ORA_DISK_1: reading from backup piece /oracle/xxx/data01/haozhu/archive/ForStandby_0ekpglmn_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/xxx/haozhu/archive/ForStandby_0ekpglmn_1_1 tag=FOR STANDBY
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00008: /oracle/xxx/data01/haozhu/data/test32k_01.dbf
channel ORA_DISK_1: reading from backup piece /oracle/xxx/data01/haozhu/archive/ForStandby_0gkpglog_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/xxx/data01/haozhu/archive/ForStandby_0gkpglog_1_1 tag=FOR STANDBY
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished recover at 17-SEP-09
RMAN> DELETE BACKUP TAG 'FOR STANDBY';
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
1 1 1 1 AVAILABLE DISK /oracle/xxx/data01/haozhu/archive/ForStandby_08kpgiif_1_1
2 2 1 1 AVAILABLE DISK /oracle/xxx/data01/haozhu/archive/ForStandby_0bkpgktm_1_1
3 3 1 1 AVAILABLE DISK /oracle/xxx/data01/haozhu/archive/ForStandby_0ckpgkve_1_1
4 4 1 1 AVAILABLE DISK /oracle/xxx/data01/haozhu/archive/ForStandby_0dkpgkvf_1_1
5 5 1 1 AVAILABLE DISK /oracle/xxx/data01/haozhu/archive/ForStandby_0ekpglmn_1_1
6 6 1 1 AVAILABLE DISK /oracle/xxx/data01/haozhu/archive/ForStandby_0fkpgloe_1_1
7 7 1 1 AVAILABLE DISK /oracle/xxx/data01/haozhu/archive/ForStandby_0gkpglog_1_1
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/oracle/xxx/data01/haozhu/archive/ForStandby_08kpgiif_1_1 recid=1 stamp=697849191
deleted backup piece
backup piece handle=/oracle/xxx/data01/haozhu/archive/ForStandby_0bkpgktm_1_1 recid=2 stamp=697849191
deleted backup piece
backup piece handle=/oracle/xxx/data01/haozhu/archive/ForStandby_0ckpgkve_1_1 recid=3 stamp=697849191
deleted backup piece
backup piece handle=/oracle/xxx/data01/haozhu/archive/ForStandby_0dkpgkvf_1_1 recid=4 stamp=697849191
deleted backup piece
backup piece handle=/oracle/xxx/data01/haozhu/archive/ForStandby_0ekpglmn_1_1 recid=5 stamp=697849692
deleted backup piece
backup piece handle=/oracle/xxx/data01/haozhu/archive/ForStandby_0fkpgloe_1_1 recid=6 stamp=697849692
deleted backup piece
backup piece handle=/oracle/xxx/data01/haozhu/archive/ForStandby_0gkpglog_1_1 recid=7 stamp=697849692
Deleted 7 objects
9.check if recover is OK.
on primary,transfer the new logs:
rcp haozhu_36[6-8].1_690165123_arc xxx.xxx.xxx.com:/oracle/xxx/data01/haozhu/archive
on standby:
alter database recover automatic standby database
Thu Sep 17 23:13:19 2009
Media Recovery Start
Managed Standby Recovery not using Real Time Apply
parallel recovery started with 3 processes
Thu Sep 17 23:13:19 2009
Media Recovery Log /oracle/xxx/data01/haozhu/archive/haozhu_366.1_690165123_arc
Thu Sep 17 23:13:22 2009
Media Recovery Log /oracle/xxx/data01/haozhu/archive/haozhu_367.1_690165123_arc
Thu Sep 17 23:13:22 2009
Media Recovery Log /oracle/xxx/data01/haozhu/archive/haozhu_368.1_690165123_arc
Thu Sep 17 23:13:22 2009
SQL> alter database open read only;
Database altered.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15415488/viewspace-615573/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【恢復】Redo日誌檔案丟失的恢復
- rman恢復--丟失聯機重做日誌的恢復
- 聯機重做日誌丟失的恢復
- 丟失非活動日誌組的恢復
- oracle丟失日誌檔案的恢復( 轉)Oracle
- 從丟失日誌組中恢復流程
- 非歸檔丟失日誌檔案的恢復
- 丟失聯機重做日誌檔案的恢復
- 【備份恢復】恢復 丟失已歸檔重做日誌檔案
- sqlplus 下恢復active 日誌丟失的情況SQL
- oracle歸檔日誌丟失後的資料庫恢復Oracle資料庫
- 在歸檔模式下丟失日誌檔案的恢復模式
- oracle丟失inactive日誌檔案的恢復操作過程Oracle
- SQL Server 2005資料庫日誌丟失的恢復SQLServer資料庫
- Oracle重做日誌檔案損壞或丟失後的恢復Oracle
- 備份恢復之redo日誌組member成員丟失
- 恢復案例:無歸檔,丟失全部控制檔案、日誌檔案恢復案例
- 丟失活動或當前日誌組的恢復
- oracle丟失active或current日誌檔案的恢復操作過程Oracle
- 丟失所有重做日誌檔案的恢復例子丟失所有重做日誌檔案的恢復例子如下:
- 丟失已歸檔日誌檔案下恢復資料庫資料庫
- oracle 線上日誌全部丟失的資料恢復Oracle資料恢復
- 沒備份,歸檔日誌存在,丟失資料檔案的恢復
- 引數檔案丟失無法啟動_ 利用alert日誌修復
- 丟失當前current重做日誌檔案下恢復資料庫資料庫
- 解決Oracle資料庫日誌檔案丟失恢復問題Oracle資料庫
- dbms_backup_restore恢復測試!nocatalog,丟失controlfile的恢復辦法!REST
- RMAN恢復案例:無恢復目錄,丟失全部資料檔案、控制檔案、日誌檔案恢復
- (個人)利用日誌挖掘恢復誤操作
- 利用增量備份恢復gap歸檔丟失DG
- Oracle恢復例項之二:Inactive聯機日誌檔案丟失Oracle
- 運用incremental backup(增量備份)恢復歸檔GAP的DGREM
- 非歸檔模式下,丟失日誌檔案的一次恢復過程模式
- 利用rman做資料檔案丟失的恢復實驗
- rman恢復:資料檔案丟失,控制檔案丟失,聯機日誌檔案丟失(非當前使用與當前使用)
- 恢復丟失的控制檔案
- 利用binlog日誌恢復mysql資料MySql
- Oracle恢復例項之三:active或current聯機日誌檔案丟失Oracle