oracle 11g ADG GAP修复---方法1

一、模拟产生GAP
备库停止DG同步进程:
SQL> alter database recover managed standby database cancel;

Database altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>


主库多次切换日志:
SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /

System altered.

SQL> /

System altered.

主库删除或者移动最近归档日志文件:
[oracle@dgdb1 archive]$ mv 1_87_1024761634.dbf 1_88_1024761634.dbf 1_89_1024761634.dbf /home/oracle

备库应用归档日志:
SQL> startup
ORACLE instance started.

Total System Global Area  584568832 bytes
Fixed Size                  2255432 bytes
Variable Size             226493880 bytes
Database Buffers          352321536 bytes
Redo Buffers                3497984 bytes
Database mounted.
Database opened.
SQL> alter database recover managed standby database using current logfile disconnect from session;

备库查询GAP:
SQL> select * from v$archive_gap;

   THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
         1            87             89

SQL> SELECT max(sequence#) from v$archived_log where applied='YES';

MAX(SEQUENCE#)
--------------
            86

主库查询缺失的归档日志:         
SQL> SELECT NAME FROM V$ARCHIVED_LOG WHERE THREAD#=1 AND DEST_ID=1 AND SEQUENCE# BETWEEN 87 AND 89 ;

NAME
--------------------------------------------------------------------------------
/oracle/archive/1_87_1024761634.dbf
/oracle/archive/1_88_1024761634.dbf
/oracle/archive/1_89_1024761634.dbf

主库把缺失的归档日志传输到备库:
[oracle@dgdb1 ~]$ scp 1_87_1024761634.dbf oracle@dgdb2:/home/oracle
oracle@dgdb2's password:
1_87_1024761634.dbf                                                                                                             100% 2048     2.0KB/s   00:00
[oracle@dgdb1 ~]$ scp 1_88_1024761634.dbf oracle@dgdb2:/home/oracle
oracle@dgdb2's password:
1_88_1024761634.dbf                                                                                                             100% 3584     3.5KB/s   00:00
[oracle@dgdb1 ~]$ scp 1_89_1024761634.dbf oracle@dgdb2:/home/oracle
oracle@dgdb2's password:
1_89_1024761634.dbf                                                                                                             100% 1536     1.5KB/s   00:00

二、修复GAP
备库注册从主库传输过来的归档日志:
SQL> ho ls /home/oracle
1_87_1024761634.dbf  1_88_1024761634.dbf  1_89_1024761634.dbf  incre_0t0t5vb9_1_1  incre_0u0t5vb9_1_1  incre_0v0t5vdb_1_1  standby.ctl

SQL>
SQL>
SQL> alter database register logfile '/home/oracle/1_87_1024761634.dbf';

Database altered.

SQL> select * from v$archive_gap;

   THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
         1            88             89

SQL> alter database register logfile '/home/oracle/1_88_1024761634.dbf';

Database altered.

SQL> select * from v$archive_gap;

   THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
         1            88             89

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /oracle/archive
Oldest online log sequence     86
Next log sequence to archive   0
Current log sequence           91
SQL> SELECT max(sequence#) from v$archived_log where applied='YES';

MAX(SEQUENCE#)
--------------
            88

SQL> alter database register logfile '/home/oracle/1_89_1024761634.dbf';

Database altered.

SQL> select * from v$archive_gap;

no rows selected

主库切换日志验证GAP是否修复完成:
SQL> alter system switch logfile;

System altered.

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /oracle/archive
Oldest online log sequence     90
Next log sequence to archive   92
Current log sequence           92

备库查看归档日志同步情况:
Tue Jun 21 20:32:44 2022
Tue Jun 21 20:32:44 2022
RFS[3]: Selected log 5 for thread 1 sequence 92 dbid -400525088 branch 1024761634
Media Recovery Waiting for thread 1 sequence 92 (in transit)
Tue Jun 21 20:32:44 2022
Archived Log entry 13 added for thread 1 sequence 91 ID 0xecb1f8cd dest 1:
Recovery of Online Redo Log: Thread 1 Group 5 Seq 92 Reading mem 0
  Mem# 0: /u01/app/oracle/oradata/rmanstd/stdby02.log
  
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /oracle/archive
Oldest online log sequence     90
Next log sequence to archive   0
Current log sequence           92

从日志和归档情况可以看到日志传输正常,DG GAP修复完成。

  

posted @ 2022-06-28 22:04  orcl  阅读(395)  评论(0编辑  收藏  举报