溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

使用RMAN增量備份處理Dataguard因歸檔丟失造成的gap如何處理

發(fā)布時(shí)間:2021-11-09 14:47:37 來源:億速云 閱讀:159 作者:小新 欄目:關(guān)系型數(shù)據(jù)庫

這篇文章給大家分享的是有關(guān)使用RMAN增量備份處理Dataguard因歸檔丟失造成的gap如何處理的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。

場景:

備庫執(zhí)行日志應(yīng)用出現(xiàn)如下報(bào)錯(cuò):

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.

查詢?nèi)笔У臍w檔日志:

SQL> select * from v$archive_gap;

THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
  1              183          185

去主庫查看歸檔,發(fā)現(xiàn)歸檔已丟失

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進(jìn)行基于SCN增量備份恢復(fù)的方式進(jìn)行恢復(fù),參考文檔 ID 836986.1

1.取消備庫日志應(yīng)用

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#)
-----------------------

(如果結(jié)果為空,重啟備庫到mount狀態(tài))
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

選擇以上結(jié)果中最小SCN作為增量備份的起點(diǎn)(此處是350524)。

3.在主庫上進(jìn)行基于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.使用增量備份恢復(fù)備庫

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@192.168.211.162's  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.如果數(shù)據(jù)庫是用OMF方式管理數(shù)據(jù)文件的,則需要在備庫的控制文件中重新注冊下數(shù)據(jù)文件,示例如下:

(如果數(shù)據(jù)文件存放在文件系統(tǒng),沒有使用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

確保主庫在這個(gè)SCN之后沒有添加新的數(shù)據(jù)文件,如果有則需要單獨(dú)進(jìn)行備份和還原,參考文檔文檔 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. 備庫開啟日志應(yīng)用,至此整個(gè)過程結(jié)束

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

感謝各位的閱讀!關(guān)于“使用RMAN增量備份處理Dataguard因歸檔丟失造成的gap如何處理”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI