增量备份恢复dg修复gap

环境:双节点rac+单节点dg

问题:主备不同步,备库dg mrp0进程停了好久才发现

备库查看未应用的SEQUENCE#
SQL> select process,status,sequence#,blocks from gv$managed_standby;

PROCESS   STATUS        SEQUENCE#     BLOCKS
--------- ------------ ---------- ----------
ARCH      CLOSING            2447          1
DGRD      ALLOCATED             0          0
DGRD      ALLOCATED             0          0
ARCH      CLOSING            2386         59
ARCH      CLOSING            2448        133
ARCH      CLOSING            2387        119
MRP0      WAIT_FOR_GAP       1315          0
RFS       IDLE               2388          1
RFS       IDLE                  0          0
RFS       IDLE               2449          1
RFS       IDLE                  0          0
RFS       IDLE                  0          0
RFS       IDLE                  0          0
RFS       IDLE                  0          0
RFS       IDLE                  0          0

主库查询scn
SQL> select COMPLETION_TIME ,sequence#,first_change# from gv$archived_log  where sequence#=1315 

COMPLETION_TIME          SEQUENCE#             FIRST_CHANGE#
------------------- ----------  -------------------------
2018-12-18 14:34:10                1315            15093158975847

确定主库是否添加数据文件
SQL> select FILE#,name from v$datafile where CREATION_CHANGE#>=15093158975847;

no rows selected

备库停止日志应用
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Database altered.

主库进行增量备份然后传输到备库上
Recovery Manager: Release 12.2.0.1.0 - Production on Wed Jan 9 16:50:50 2019

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: TSETDB (DBID=3213986754)

RMAN> backup as backupset INCREMENTAL from scn 15093158975847 database format '/dsg/rman/TSETDB%U';
......
Finished backup at 2019-01-09 16:53:47

scp * 192.1.1.15:/u01/app/rman

备库上进行恢复

rman target /

Recovery Manager: Release 12.2.0.1.0 - Production on Wed Jan 9 16:56:33 2019

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: TSETDB (DBID=3213986754)

RMAN> catalog start with '/u01/app/rman/';  

using target database control file instead of recovery catalog
searching for all files that match the pattern /u01/app/rman/

List of Files Unknown to the Database
=====================================
File Name: /u01/app/rman/TSETDB6etmtis0_1_1
File Name: /u01/app/rman/TSETDB6ftmtisp_1_1
File Name: /u01/app/rman/TSETDB6ctmtiqc_1_1
File Name: /u01/app/rman/TSETDB6dtmtiqs_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: /u01/app/rman/TSETDB6etmtis0_1_1
File Name: /u01/app/rman/TSETDB6ftmtisp_1_1
File Name: /u01/app/rman/TSETDB6ctmtiqc_1_1
File Name: /u01/app/rman/TSETDB6dtmtiqs_1_1

RMAN> shutdown immediate;     

database closed
database dismounted
Oracle instance shut down

RMAN> startup mount;

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area  128849018880 bytes

Fixed Size                    30035080 bytes
Variable Size              16931169144 bytes
Database Buffers          111803367424 bytes
Redo Buffers                  84447232 bytes

RMAN> recover database noredo; 

Starting recover at 2019-01-09 16:58:39
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1452 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
......
Finished recover at 2019-01-09 17:06:29

主库上创建standby controlfile文件并传输到备库
---其中有ORA-00245将snapshot controlfile配置到共享存储上
RMAN> backup current controlfile for standby format '/dsg/rman/standbyctl.bak';

scp standbyctl.bak 192.1.1.15:/u01/app/rman

备库恢复控制文件
备库关库,启动到nomount状态后恢复控制文件,最后启动到mount状态
RMAN> shutdown immediate;

using target database control file instead of recovery catal
database dismounted
Oracle instance shut down

RMAN> startup nomount;

connected to target database (not started)
Oracle instance started

Total System Global Area  128849018880 bytes

Fixed Size                    30035080 bytes
Variable Size              16931169144 bytes
Database Buffers          111803367424 bytes
Redo Buffers                  84447232 bytes

RMAN> restore standby controlfile from '/u01/app/rman/standbyctl.bak';

Starting restore at 2019-01-09 17:15:39
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=7541 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=+DATA/TSETDB/control01.ctl
output file name=+FRA/TSETDB/control02.ctl
Finished restore at 2019-01-09 17:15:40

RMAN> alter database mount;

Statement processed
released channel: ORA_DISK_1

查看主库redo大小以及blocksize
SQL> select group#,thread#,BYTES/1024/1024/1024 ,BLOCKSIZE,MEMBERS, status from v$log;

    GROUP#    THREAD# BYTES/1024/1024/1024  BLOCKSIZE    MEMBERS STATUS
---------- ---------- -------------------- ---------- ---------- ----------------
        10          1                   10       4096          1 INACTIVE
        11          1                   10       4096          1 ACTIVE

备库删除redo以及standby redo 并重建(blocksize主备要相同)
alter database drop logfile group 28;
......
alter database add logfile group 28 ('+DATA/TSETDB/redo10.log') size 10G blocksize 4096 reuse;
......
alter database drop standby logfile group 20;
......
alter database add standby logfile group 20 ('+DATA/TSETDB/standby_redo20.log') size 10G blocksize 4096 reuse;
......

备库重新接收并应用日志
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE using current logfile DISCONNECT FROM SESSION;

查看日志
Media Recovery Waiting for thread 2 sequence 2398 (in transit)
2019-01-09T18:33:23.614935+08:00
Completed: alter database recover managed standby database disconnect from session
2019-01-09T18:33:42.508496+08:00
Archived Log entry 55 added for thread 1 sequence 2492 rlc 991061314 ID 0xbf9209c2 LAD2 :
RFS[4]: Selected log 20 for T-1.S-2493 dbid 3213986754 branch 991061314
2019-01-09T18:33:42.744047+08:00
Archived Log entry 56 added for thread 2 sequence 2398 rlc 991061314 ID 0xbf9209c2 LAD2 :
RFS[3]: Selected log 21 for T-2.S-2399 dbid 3213986754 branch 991061314
2019-01-09T18:33:42.852293+08:00
Media Recovery Log +ARCH/TSETDB/archivelog/2398_2_991061314.arc
2019-01-09T18:33:42.949533+08:00
Media Recovery Log +ARCH/TSETDB/archivelog/2490_1_991061314.arc
2019-01-09T18:33:43.093349+08:00
Media Recovery Log +ARCH/TSETDB/archivelog/2491_1_991061314.arc
2019-01-09T18:33:43.241103+08:00
Media Recovery Log +ARCH/TSETDB/archivelog/2492_1_991061314.arc
Media Recovery Waiting for thread 1 sequence 2493 (in transit)
2019-01-09T18:33:43.403187+08:00
Recovery of Online Redo Log: Thread 1 Group 20 Seq 2493 Reading mem 0
  Mem# 0: +DATA/TSETDB/standby_redo20.log
Media Recovery Waiting for thread 2 sequence 2399 (in transit)
2019-01-09T18:33:43.530031+08:00
Recovery of Online Redo Log: Thread 2 Group 21 Seq 2399 Reading mem 0
......
备库重新开启read only模式

SQL> alter database RECOVER MANAGED STANDBY DATABASE CANCEL;

SQL> alter database open;

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE using current logfile DISCONNECT FROM SESSION;

主库创建测试表在备库可以查询到。
 

参考以及新增数据文件情况处理:

https://www.cnblogs.com/jyzhao/p/6088899.html

http://www.xifenfei.com/2011/07/data-guard出现gap-sequence修复.html

发布了47 篇原创文章 · 获赞 5 · 访问量 6927

猜你喜欢

转载自blog.csdn.net/whb234174124/article/details/86237144