环境:
oracle 11.2.0.4 dg
主:172.16.10.217
备:172.16.10.213
问题:
主备同步断开过长,再次开启同步时,备库报错。
alter database recover managed standby database using current logfile disconnect from session
Attempt to start background Managed Standby Recovery process (orcl)
Thu May 12 16:20:26 2022
MRP0 started with pid=31, OS id=32363
MRP0: Background Managed Standby Recovery process started (orcl)
started logmerger process
Thu May 12 16:20:31 2022
Managed Standby Recovery starting Real Time Apply
Parallel Media Recovery started with 8 slaves
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Media Recovery Waiting for thread 1 sequence 17388
Fetching gap sequence in thread 1, gap sequence 17388-17487
Completed: alter database recover managed standby database using current logfile disconnect from session
Thu May 12 16:22:21 2022
FAL[client]: Failed to request gap sequence
GAP - thread 1 sequence 17388-17487
DBID 1593932103 branch 1066151367
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 STATUS, GAP_STATUS FROM V$ARCHIVE_DEST_STATUS WHERE DEST_ID = 2;
STATUS GAP_STATUS
--------- ------------------------
VALID UNRESOLVABLE GAP
SQL> select thread#, sequence# from v$thread;
THREAD# SEQUENCE#
---------- ----------
1 22449
SQL> alter system switch logfile;
**切换主库日志时,新日志会传到备库的目录中,说明dg链接是通的。
**由于停止同步时间太长,远远超出了archivelog在controlfile中的记录时长。所以,当再次开启同步时,就算主备一直保留期间的archivelog ,备库也无法找到所缺的archivelog。
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
SQL> select * from v$archive_gap;
THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
1 17387 20205
**于是,在主库catalog一下归档日志
主:
rman taget /
catalog start with '/data01/arch01/orcl/';
然后发现之前缺失的日志开始传到了备库,备库开始应用日志追赶主库。
备:
SQL> select process, status, thread#, sequence# from v$managed_standby where process='MRP0';
PROCESS STATUS THREAD# SEQUENCE#
--------- ------------ ---------- ----------
MRP0 APPLYING_LOG 1 17498
SQL> /
PROCESS STATUS THREAD# SEQUENCE#
--------- ------------ ---------- ----------
MRP0 APPLYING_LOG 1 17509
SQL> /
PROCESS STATUS THREAD# SEQUENCE#
--------- ------------ ---------- ----------
MRP0 APPLYING_LOG 1 17510
SQL>
SQL> select * from v$archive_gap;
no rows selected
SQL> select process, status, thread#, sequence# from v$managed_standby where process='MRP0';
PROCESS STATUS THREAD# SEQUENCE#
--------- ------------ ---------- ----------
MRP0 APPLYING_LOG 1 22451
SQL>
主:
SQL> SELECT STATUS, GAP_STATUS FROM V$ARCHIVE_DEST_STATUS WHERE DEST_ID = 2;
STATUS GAP_STATUS
--------- ------------------------
VALID NO GAP
SQL>