处理Dataguard日志传输gap一例

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介: 制造gap在主库上停止向备库传输日志

制造gap

在主库上停止向备库传输日志

SQL>  alter system set log_archive_dest_state_2=defer  scope=memory;
System altered.

在主库进行几次日志切换,并将切换的日志删除,在错误备库的错误日志中可以看到:

Archived Log entry 20 added for thread 1 sequence 123 rlc 913820033 ID 0x55ec8100 dest 2:
Tue Jan 21 10:58:49 2020
Fetching gap sequence in thread 1, gap sequence 120-121
Tue Jan 21 11:00:40 2020
FAL[client]: Failed to request gap sequence
 GAP - thread 1 sequence 120-121
 DBID 1441600768 branch 913820033
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.
------------------------------------------------------------
Tue Jan 21 11:05:48 2020
Archived Log entry 21 added for thread 1 sequence 124 rlc 913820033 ID 0x55ec8100 dest 2:
RFS[5]: No standby redo logfiles created for thread 1



在备库中检查视图发现:


select * from v$archive_gap;
   THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
  1      120     121

从主库进行增量SCN的备份

如果能找到日志文件,将其传输过去,注册即可。


SQL> alter database register logfile ‘<File-Specification>’;


如果找不到日志文件,可以按备库当前的SCN号从主库生成一个增量备份恢复到主库 参见文档:https://docs.oracle.com/cd/B19306_01/server.102/b14239/scenarios.htm#CIHIAADC

停止备库的日志应用

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.
SQL>  select * from v$archive_gap;
   THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
  1      120     121
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY


找出备库当前的SCN号:

SQL> SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
-----------
    3085099


查看datafile中有无没有记录log的scn

SQL> SELECT MIN(FIRST_NONLOGGED_SCN) FROM V$DATAFILE WHERE FIRST_NONLOGGED_SCN>0;
MIN(FIRST_NONLOGGED_SCN)
------------------------
SQL>

运气不错,没有,好了,现在确定最小的SCN是3085099,从主库以这个SCN开始进行增量备份。

RMAN> BACKUP INCREMENTAL FROM SCN 3085099  DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY';
Starting backup at 21-JAN-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=46 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-JAN-20
channel ORA_DISK_1: finished piece 1 at 21-JAN-20
piece handle=/tmp/ForStandby_0iumhqn9_1_1 tag=FORSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 21-JAN-20
channel ORA_DISK_1: finished piece 1 at 21-JAN-20
piece handle=/tmp/ForStandby_0jumhqo2_1_1 tag=FORSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-JAN-20
[oracle@rhel65 orcl]$ ls -l /tmp/ForStandby_*
-rw-r----- 1 oracle oinstall 14376960 1月  21 14:34 /tmp/ForStandby_0iumhqn9_1_1
-rw-r----- 1 oracle oinstall 10027008 1月  21 14:34 /tmp/ForStandby_0jumhqo2_1_1


把备份的文件传输到备库的机器上


在备库上恢复

将传输的文件在备库上注册。


RMAN> catalog start with '/tmp/ForStandby';
searching for all files that match the pattern /tmp/ForStandby
List of Files Unknown to the Database
=====================================
File Name: /tmp/ForStandby_0jumhqo2_1_1
File Name: /tmp/ForStandby_0iumhqn9_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_0jumhqo2_1_1
File Name: /tmp/ForStandby_0iumhqn9_1_1



使用report schema检查备库是rman target,并检查文件名。


list backup
.....
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8       Incr    9.55M      DISK        00:00:00     21-JAN-20      
        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: FORSTANDBY
        Piece Name: /tmp/ForStandby_0jumhqo2_1_1
  Control File Included: Ckp SCN: 3104501      Ckp time: 21-JAN-20
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9       Incr    13.70M     DISK        00:00:00     21-JAN-20      
        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: FORSTANDBY
        Piece Name: /tmp/ForStandby_0iumhqn9_1_1
  List of Datafiles in backup set 9
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Incr 3104431    21-JAN-20 /u01/app/oracle/oradata/orcl/system01.dbf
  2       Incr 3104431    21-JAN-20 /u01/app/oracle/oradata/orcl/sysaux01.dbf
  3       Incr 3104431    21-JAN-20 /u01/app/oracle/oradata/orcl/undotbs01.dbf
  4       Incr 3104431    21-JAN-20 /u01/app/oracle/oradata/orcl/users01.dbf
  5       Incr 3104431    21-JAN-20 /u01/app/oracle/oradata/orcl/example01.dbf



这里注意检查control file的文件名是’/tmp/ForStandby_0jumhqo2_1_1’,下面恢复的时候要用这个文件名。

SQL>  startup force nomount;
ORACLE instance started.
Total System Global Area  417546240 bytes
Fixed Size      2253824 bytes
Variable Size    331353088 bytes
Database Buffers    79691776 bytes
Redo Buffers      4247552 bytes
RMAN>   restore standby controlfile from '/tmp/ForStandby_0jumhqo2_1_1';   
Starting restore at 21-JAN-20
using channel ORA_DISK_1
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/orcl/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/orcl/control02.ctl
Finished restore at 21-JAN-20
RMAN> ALTER DATABASE MOUNT;
database mounted
released channel: ORA_DISK_1
RMAN> RECOVER DATABASE NOREDO;
Starting recover at 21-JAN-20
Starting implicit crosscheck backup at 21-JAN-20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=28 device type=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 21-JAN-20
Starting implicit crosscheck copy at 21-JAN-20
using channel ORA_DISK_1
Crosschecked 4 objects
Finished implicit crosscheck copy at 21-JAN-20
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
Finished recover at 21-JAN-20
RMAN>


noredo的意思上后续不要apply archivelog。

注意recover时要小心主库和备库的文件名不一样的情况,要用 SET NEWNAME指定不同的路径再recover database,可以先用report schema查询。


SET NEWNAME FOR DATAFILE 1 TO '/oradata1/system01.dbf';
SET NEWNAME FOR DATAFILE 2 TO '/oradata2/undotbs01.dbf';
SET NEWNAME FOR DATAFILE 3 TO '/oradata3/cwmlite01.dbf';
SET NEWNAME FOR DATAFILE 4 TO '/oradata4/drsys01';
SET NEWNAME FOR DATAFILE 5 TO '/oradata5/example01.dbf';
SET NEWNAME FOR TEMPFILE 1 TO '/disk2/temp01.dbf';

后续检查

SQL> select * from v$archive_gap;
no rows selected
SQL>  ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered.
相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
NoSQL Redis 索引
Filebeat收集日志数据传输到Redis,通过Logstash来根据日志字段创建不同的ES索引
Filebeat收集日志数据传输到Redis,通过Logstash来根据日志字段创建不同的ES索引
179 0
|
4月前
|
存储 关系型数据库 分布式数据库
PolarDB-SCC使用问题之为什么PolarDB-SCC选择基于RDMA的日志传输
PolarDB-SCC使用问题之为什么PolarDB-SCC选择基于RDMA的日志传输
|
4月前
|
缓存 数据库 RDMA
PolarDB-SCC使用问题之为什么PolarDB-SCC选择使用基于RDMA的日志传输
PolarDB-SCC使用问题之为什么PolarDB-SCC选择使用基于RDMA的日志传输
|
消息中间件 存储 Kafka
MQ 学习日志(六) 保证消息的可靠性传输
消息的可靠性传输 简述
117 0
|
Oracle 关系型数据库 数据库
使用日志传输的方法在两个数据库之间同步数据
源 oracle18:oracle18c-standby 192.168.17.26 目标 oracle18-2:oracle18c-primary 192.168.17.109
136 0
|
Go 数据库
|
Oracle 关系型数据库
|
16天前
|
XML 安全 Java
【日志框架整合】Slf4j、Log4j、Log4j2、Logback配置模板
本文介绍了Java日志框架的基本概念和使用方法,重点讨论了SLF4J、Log4j、Logback和Log4j2之间的关系及其性能对比。SLF4J作为一个日志抽象层,允许开发者使用统一的日志接口,而Log4j、Logback和Log4j2则是具体的日志实现框架。Log4j2在性能上优于Logback,推荐在新项目中使用。文章还详细说明了如何在Spring Boot项目中配置Log4j2和Logback,以及如何使用Lombok简化日志记录。最后,提供了一些日志配置的最佳实践,包括滚动日志、统一日志格式和提高日志性能的方法。
135 30
【日志框架整合】Slf4j、Log4j、Log4j2、Logback配置模板
|
1月前
|
XML JSON Java
Logback 与 log4j2 性能对比:谁才是日志框架的性能王者?
【10月更文挑战第5天】在Java开发中,日志框架是不可或缺的工具,它们帮助我们记录系统运行时的信息、警告和错误,对于开发人员来说至关重要。在众多日志框架中,Logback和log4j2以其卓越的性能和丰富的功能脱颖而出,成为开发者们的首选。本文将深入探讨Logback与log4j2在性能方面的对比,通过详细的分析和实例,帮助大家理解两者之间的性能差异,以便在实际项目中做出更明智的选择。
234 3
|
1月前
|
存储 缓存 关系型数据库
MySQL事务日志-Redo Log工作原理分析
事务的隔离性和原子性分别通过锁和事务日志实现,而持久性则依赖于事务日志中的`Redo Log`。在MySQL中,`Redo Log`确保已提交事务的数据能持久保存,即使系统崩溃也能通过重做日志恢复数据。其工作原理是记录数据在内存中的更改,待事务提交时写入磁盘。此外,`Redo Log`采用简单的物理日志格式和高效的顺序IO,确保快速提交。通过不同的落盘策略,可在性能和安全性之间做出权衡。
1638 14
下一篇
无影云桌面