使用RMAN增量備份處理Dataguard因歸檔丟失造成的gap
場景:
備庫執行日誌應用出現如下報錯:
Thu Mar 29 11:21:45 2018
FAL[client]: Failed to request gap sequence
GAP - thread 1 sequence 184-185
DBID 1484954774 branch 960494131
FAL[client]: All defined FAL servers have been attempted.
------------------------------------------------------------
Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization
parameter is defined to a value that's sufficiently large
enough to maintain adequate log switch information to resolve
archivelog gaps.
查詢缺失的歸檔日誌:
SQL> select * from v$archive_gap;
THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
1 183 185
去主庫檢視歸檔,發現歸檔已丟失
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/archivelog
Oldest online log sequence 186
Next log sequence to archive 188
Current log sequence 188
[Oracle@prim archivelog]$ pwd
/u01/archivelog
[oracle@prim archivelog]$ ls -ltr
total 1964
-rw-r----- 1 oracle oinstall 74752 Mar 29 11:17 1_186_960494131.dbf
-rw-r----- 1 oracle oinstall 1930240 Mar 29 11:17 1_187_960494131.dbf
下面開始使用RMAN進行基於SCN增量備份恢復的方式進行恢復,參考文件 ID 836986.1
1.取消備庫日誌應用
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE cancel;
2.在備庫上確定需要開始增量備份的SCN
SQL> SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
-----------
3505254
SQL> select min(checkpoint_change#) from v$datafile_header
where file# not in (select file# from v$datafile where enabled = 'READ ONLY');
MIN(CHECKPOINT_CHANGE#)
-----------------------
(如果結果為空,重啟備庫到mount狀態)
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1002127360 bytes
Fixed Size 2259440 bytes
Variable Size 285214224 bytes
Database Buffers 708837376 bytes
Redo Buffers 5816320 bytes
Database mounted.
SQL> select min(checkpoint_change#) from v$datafile_header
where file# not in (select file# from v$datafile where enabled = 'READ ONLY');
MIN(CHECKPOINT_CHANGE#)
-----------------------
3505255
選擇以上結果中最小SCN作為增量備份的起點(此處是350524)。
3.在主庫上進行基於SCN的增量備份
RMAN> BACKUP INCREMENTAL FROM SCN 3505254 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY';
4.複製剛才的備份到備庫
scp /tmp/ForStandby_* 192.168.211.162:/tmp
5.將複製過來的備份註冊到備庫的控制檔案中
[oracle@stand ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Mar 29 11:37:52 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1484954774, not open)
RMAN> CATALOG START WITH '/tmp/ForStandby';
using target database control file instead of recovery catalog
searching for all files that match the pattern /tmp/ForStandby
List of Files Unknown to the Database
=====================================
File Name: /tmp/ForStandby_08sv0bdj_1_1
File Name: /tmp/ForStandby_07sv0bcg_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: /tmp/ForStandby_08sv0bdj_1_1
File Name: /tmp/ForStandby_07sv0bcg_1_1
6.使用增量備份恢復備庫
RMAN> RECOVER DATABASE NOREDO;
Starting recover at 29-MAR-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=16 device type=DISK
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /u01/app/oracle/oradata/rzorcl/system01.dbf
destination for restore of datafile 00002: /u01/app/oracle/oradata/rzorcl/sysaux01.dbf
destination for restore of datafile 00003: /u01/app/oracle/oradata/rzorcl/undotbs01.dbf
destination for restore of datafile 00004: /u01/app/oracle/oradata/rzorcl/users01.dbf
destination for restore of datafile 00005: /u01/app/oracle/oradata/rzorcl/example01.dbf
destination for restore of datafile 00006: /u01/app/oracle/oradata/rzorcl/odc_tps01.dbf
destination for restore of datafile 00007: /u01/app/oracle/oradata/rzorcl/test01.dbf
destination for restore of datafile 00008: /u01/app/oracle/oradata/rzorcl/big01.dbf
destination for restore of datafile 00009: /u01/app/oracle/oradata/rzorcl/big02.dbf
channel ORA_DISK_1: reading from backup piece /tmp/ForStandby_07sv0bcg_1_1
channel ORA_DISK_1: piece handle=/tmp/ForStandby_07sv0bcg_1_1 tag=FORSTANDBY
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 29-MAR-18
7.在主庫為備庫重新備份控制檔案,並scp到備庫
RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/tmp/ForStandbyCTRL.bck';
Starting backup at 29-MAR-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=9 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including standby control file in backup set
channel ORA_DISK_1: starting piece 1 at 29-MAR-18
channel ORA_DISK_1: finished piece 1 at 29-MAR-18
piece handle=/tmp/ForStandbyCTRL.bck tag=TAG20180329T114413 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-MAR-18
[oracle@prim tmp]$ scp ForStandbyCTRL.bck 192.168.211.162:/tmp
oracle password:
ForStandbyCTRL.bck 100% 9856KB 9.6MB/s 00:00
8.備庫還原控制檔案:
RMAN> shutdown immediate;
database dismounted
Oracle instance shut down
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area 1002127360 bytes
Fixed Size 2259440 bytes
Variable Size 285214224 bytes
Database Buffers 708837376 bytes
Redo Buffers 5816320 bytes
RMAN> RESTORE STANDBY CONTROLFILE FROM '/tmp/ForStandbyCTRL.bck';
Starting restore at 29-MAR-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/rzorcl/control01.ctl
output file name=/u01/app/oracle/oradata/rzorcl/control02.ctl
Finished restore at 29-MAR-18
9.重啟備庫到mount
RMAN> SHUTDOWN;
RMAN> STARTUP MOUNT;
10.如果資料庫是用OMF方式管理資料檔案的,則需要在備庫的控制檔案中重新註冊下資料檔案,示例如下:
(如果資料檔案存放在檔案系統,沒有使用OMF,則跳過此步驟)
RMAN> CATALOG START WITH '+DATA/rzorcl/datafile/';
List of Files Unknown to the Database
=====================================
File Name: +data/rzorcl/DATAFILE/SYSTEM.309.685535773
File Name: +data/rzorcl/DATAFILE/SYSAUX.301.685535773
File Name: +data/rzorcl/DATAFILE/UNDOTBS1.302.685535775
File Name: +data/rzorcl/DATAFILE/SYSTEM.297.688213333
File Name: +data/rzorcl/DATAFILE/SYSAUX.267.688213333
File Name: +data/rzorcl/DATAFILE/UNDOTBS1.268.688213335
Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: +data/rzorcl/DATAFILE/SYSTEM.297.688213333
File Name: +data/rzorcl/DATAFILE/SYSAUX.267.688213333
File Name: +data/rzorcl/DATAFILE/UNDOTBS1.268.688213335
確保主庫在這個SCN之後沒有新增新的資料檔案,如果有則需要單獨進行備份和還原,參考文件文件 ID 836986.1
SQL> select file#,name from v$datafile where creation_change# > 3505254;
no rows selected
RMAN> SWITCH DATABASE TO COPY;
datafile 1 switched to datafile copy "+DATA/rzorcl/datafile/system.297.688213333"
datafile 2 switched to datafile copy "+DATA/rzorcl/datafile/undotbs1.268.688213335"
datafile 3 switched to datafile copy "+DATA/rzorcl/datafile/sysaux.267.688213333"
11. 若備庫開啟了閃回,需要重新開啟閃回
SQL> ALTER DATABASE FLASHBACK OFF;
SQL> ALTER DATABASE FLASHBACK ON;
12. 備庫clear standby log group
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 4;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 5;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 6;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 7;
13. 備庫開啟日誌應用,至此整個過程結束
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31530407/viewspace-2152934/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- dg丟失歸檔,使用rman增量備份恢復
- Oracle DataGuard歸檔日誌丟失處理方法Oracle
- RMAN-ERROR:因為找不到過期和丟失的歸檔日誌而備份失敗Error
- OGG整合抽取模式丟失歸檔處理模式
- rman 增量備份恢復
- DATAGUARD中手工處理日誌GAP
- rman開啟備份優化對備份歸檔的影響優化
- RMAN備份整庫和歸檔日誌的方法
- oracle10g RMAN增量備份策略Oracle
- Oracle設定多個歸檔路徑生成多份歸檔日誌,Rman備份時也只備份其中的一份歸檔日誌Oracle
- [20221028]rman使用tape與增量備份測試2.txt
- RMAN刪除歸檔日誌出現RMAN-0813錯誤的處理
- ORACLE NBU調取oracle rman指令碼備份歸檔不自動刪除歸檔Oracle指令碼
- 12 使用RMAN備份和恢復檔案
- oracle rman備份歸檔日誌需要先切換日誌嗎Oracle
- 【RMAN】RMAN的備份保留策略
- 世界備份日——如果您丟失了所有檔案
- 【備份】RMAN中對控制檔案的幾種備份方法
- 【BBED】丟失歸檔檔案情況下的恢復
- rman備份的時候讀取v$session_longops失敗導致備份失敗SessionGo
- 【RMAN】Oracle12c之後,rman備份Dataguard備端恢復可能出現邏輯錯誤Oracle
- oracle 如何不備份已經備份的歸檔Oracle
- 使用RMAN備份資料庫資料庫
- RMAN的備份原理
- 【RMAN】RMAN備份至ASMASM
- EXP增量備份
- Xtrabackup增量備份
- 關於丟失表空間資料檔案的處理方式
- RMAN備份概述
- DM7使用DMRMAN執行歸檔備份
- Oracle使用備份檔案集恢復歸檔日誌Oracle
- 【RMAN】Oracle中如何備份控制檔案?備份控制檔案的方式有哪幾種?Oracle
- Oracle歸檔檔案丟失導致OGG不用啟動Oracle
- RMAN備份恢復典型案例——RMAN備份&系統變慢
- [20221020]奇怪的增量備份.txt
- RMAN備份進度
- rman 備份指令碼指令碼
- RMAN 備份相關的概念