DataGuard主备归档存在gap的处理办法

2024-03-21 18:32

本文主要是介绍DataGuard主备归档存在gap的处理办法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

DataGuard主备之间可能由于网络等原因,造成备库和主库之间的归档日志不一致,这样就产生了gap。
解决gap的步骤:
1.在备库获得gap的详细信息
2.将需要的归档日志从主库拷贝到备库
3.备库将归档日志注册,然后应用。
 
--备库alert日志提示gap详情  
Media Recovery Waiting for thread 1 sequence 7057
Fetching gap sequence in thread 1, gap sequence 7057-7080
FAL[client]: Error fetching gap sequence, no FAL server specified
Mon Mar 24 11:39:40 CST 2014
FAL[client]: Failed to request gap sequence 
 GAP - thread 1 sequence 7057-7080
 DBID 768411208 branch 784810891
FAL[client]: All defined FAL servers have been attempted.

--也可以在备库查询gap
select * from v$archive_gap;

--为了方便,组装拷贝语句
--如果归档日志在ASM中,先通过rman将归档日志拷贝到OS,然后scp到备库standby归档目录;
--如果归档日志在OS上,直接scp到备库standby归档目录即可。
@Pirmary
select length('+DG1/primary/archivelog/2014_03_21/') from dual;
LENGTH('+DG1/PRIMARY/ARCHIVELOG/2014_03_21/')
---------------------------------------------
                                           35
  
--get copy command
select 'copy archivelog '''||NAME||''' to ''/tmp/'||substr(name,35)||''' ;' 
from v$archived_log 
where  SEQUENCE#>7060 
and SEQUENCE#<=7080 
and thread#=1 
and NAME<>'standby service name';

--copy archive logs from asm to OS
rman target / 
copy archivelog '+DG1/primary/archivelog/2014_03_21/thread_1_seq_7061.393.842805877' to '/tmp/thread_1_seq_7061.393.842805877' ;
copy archivelog '+DG1/primary/archivelog/2014_03_21/thread_1_seq_7062.472.842816319' to '/tmp/thread_1_seq_7062.472.842816319' ;
copy archivelog '+DG1/primary/archivelog/2014_03_21/thread_1_seq_7063.414.842825435' to '/tmp/thread_1_seq_7063.414.842825435' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7064.308.842843087' to '/tmp/thread_1_seq_7064.308.842843087' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7065.278.842847011' to '/tmp/thread_1_seq_7065.278.842847011' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7066.415.842847023' to '/tmp/thread_1_seq_7066.415.842847023' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7067.469.842850077' to '/tmp/thread_1_seq_7067.469.842850077' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7068.402.842864915' to '/tmp/thread_1_seq_7068.402.842864915' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7069.475.842868603' to '/tmp/thread_1_seq_7069.475.842868603' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7070.413.842869761' to '/tmp/thread_1_seq_7070.413.842869761' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7071.312.842871319' to '/tmp/thread_1_seq_7071.312.842871319' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7072.407.842874331' to '/tmp/thread_1_seq_7072.407.842874331' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7073.405.842874917' to '/tmp/thread_1_seq_7073.405.842874917' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7074.328.842875663' to '/tmp/thread_1_seq_7074.328.842875663' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7075.296.842876043' to '/tmp/thread_1_seq_7075.296.842876043' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7076.452.842886921' to '/tmp/thread_1_seq_7076.452.842886921' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7077.446.842906131' to '/tmp/thread_1_seq_7077.446.842906131' ;
copy archivelog '+DG1/primary/archivelog/2014_03_23/thread_1_seq_7078.348.842928271' to '/tmp/thread_1_seq_7078.348.842928271' ;
copy archivelog '+DG1/primary/archivelog/2014_03_23/thread_1_seq_7079.347.842928277' to '/tmp/thread_1_seq_7079.347.842928277' ;
copy archivelog '+DG1/primary/archivelog/2014_03_23/thread_1_seq_7080.367.842929387' to '/tmp/thread_1_seq_7080.367.842929387' ;


--send archive logs to standby
scp thread_1_seq_70* 10.1.1.10:/tmp

--get  standby register archivelog command
--同样在主库执行,获得注册语句
select 'ALTER DATABASE REGISTER PHYSICAL LOGFILE ''/tmp/'||substr(name,35)||''';' from v$archived_log where  SEQUENCE#>7060 and SEQUENCE#<=7080 and thread#=1 and NAME<>'standby service name';

ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7061.393.842805877';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7062.472.842816319';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7063.414.842825435';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7064.308.842843087';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7065.278.842847011';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7066.415.842847023';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7067.469.842850077';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7068.402.842864915';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7069.475.842868603';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7070.413.842869761';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7071.312.842871319';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7072.407.842874331';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7073.405.842874917';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7074.328.842875663';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7075.296.842876043';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7076.452.842886921';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7077.446.842906131';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7078.348.842928271';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7079.347.842928277';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7080.367.842929387';



@Standby
--register gap archivelog to standby
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7061.393.842805877';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7062.472.842816319';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7063.414.842825435';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7064.308.842843087';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7065.278.842847011';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7066.415.842847023';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7067.469.842850077';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7068.402.842864915';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7069.475.842868603';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7070.413.842869761';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7071.312.842871319';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7072.407.842874331';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7073.405.842874917';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7074.328.842875663';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7075.296.842876043';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7076.452.842886921';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7077.446.842906131';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7078.348.842928271';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7079.347.842928277';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7080.367.842929387';

--if standby is real apply,then standby will AUTO Apply archivelog
--if not,please open real apply 
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

--get real apply info
set linesize 200
col name for a70
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
select  NAME,THREAD#,FIRST_TIME,sequence#,applied from v$archived_log order by  FIRST_TIME,THREAD#,sequence#,DEST_ID;

--you can see alert log ,it also show archivelog apply info
tail -f alert.log

--make sure no gap between Primary and Standby
SQL> select * from v$archive_gap;

--Clean
@Priamry
cd /tmp
rm thread_*

RMAN> crosscheck archivelog all;
RMAN> list archivelog all;
RMAN> delete expired archivelog all;

这篇关于DataGuard主备归档存在gap的处理办法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/833534

相关文章

Python FastAPI+Celery+RabbitMQ实现分布式图片水印处理系统

《PythonFastAPI+Celery+RabbitMQ实现分布式图片水印处理系统》这篇文章主要为大家详细介绍了PythonFastAPI如何结合Celery以及RabbitMQ实现简单的分布式... 实现思路FastAPI 服务器Celery 任务队列RabbitMQ 作为消息代理定时任务处理完整

C#使用SQLite进行大数据量高效处理的代码示例

《C#使用SQLite进行大数据量高效处理的代码示例》在软件开发中,高效处理大数据量是一个常见且具有挑战性的任务,SQLite因其零配置、嵌入式、跨平台的特性,成为许多开发者的首选数据库,本文将深入探... 目录前言准备工作数据实体核心技术批量插入:从乌龟到猎豹的蜕变分页查询:加载百万数据异步处理:拒绝界面

Springboot处理跨域的实现方式(附Demo)

《Springboot处理跨域的实现方式(附Demo)》:本文主要介绍Springboot处理跨域的实现方式(附Demo),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不... 目录Springboot处理跨域的方式1. 基本知识2. @CrossOrigin3. 全局跨域设置4.

MySQL INSERT语句实现当记录不存在时插入的几种方法

《MySQLINSERT语句实现当记录不存在时插入的几种方法》MySQL的INSERT语句是用于向数据库表中插入新记录的关键命令,下面:本文主要介绍MySQLINSERT语句实现当记录不存在时... 目录使用 INSERT IGNORE使用 ON DUPLICATE KEY UPDATE使用 REPLACE

python+opencv处理颜色之将目标颜色转换实例代码

《python+opencv处理颜色之将目标颜色转换实例代码》OpenCV是一个的跨平台计算机视觉库,可以运行在Linux、Windows和MacOS操作系统上,:本文主要介绍python+ope... 目录下面是代码+ 效果 + 解释转HSV: 关于颜色总是要转HSV的掩膜再标注总结 目标:将红色的部分滤

Python实现自动化接收与处理手机验证码

《Python实现自动化接收与处理手机验证码》在移动互联网时代,短信验证码已成为身份验证、账号注册等环节的重要安全手段,本文将介绍如何利用Python实现验证码的自动接收,识别与转发,需要的可以参考下... 目录引言一、准备工作1.1 硬件与软件需求1.2 环境配置二、核心功能实现2.1 短信监听与获取2.

Python使用date模块进行日期处理的终极指南

《Python使用date模块进行日期处理的终极指南》在处理与时间相关的数据时,Python的date模块是开发者最趁手的工具之一,本文将用通俗的语言,结合真实案例,带您掌握date模块的六大核心功能... 目录引言一、date模块的核心功能1.1 日期表示1.2 日期计算1.3 日期比较二、六大常用方法详

利用Go语言开发文件操作工具轻松处理所有文件

《利用Go语言开发文件操作工具轻松处理所有文件》在后端开发中,文件操作是一个非常常见但又容易出错的场景,本文小编要向大家介绍一个强大的Go语言文件操作工具库,它能帮你轻松处理各种文件操作场景... 目录为什么需要这个工具?核心功能详解1. 文件/目录存javascript在性检查2. 批量创建目录3. 文件

Oracle存储过程里操作BLOB的字节数据的办法

《Oracle存储过程里操作BLOB的字节数据的办法》该篇文章介绍了如何在Oracle存储过程中操作BLOB的字节数据,作者研究了如何获取BLOB的字节长度、如何使用DBMS_LOB包进行BLOB操作... 目录一、缘由二、办法2.1 基本操作2.2 DBMS_LOB包2.3 字节级操作与RAW数据类型2.

Java使用多线程处理未知任务数的方案介绍

《Java使用多线程处理未知任务数的方案介绍》这篇文章主要为大家详细介绍了Java如何使用多线程实现处理未知任务数,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 知道任务个数,你可以定义好线程数规则,生成线程数去跑代码说明:1.虚拟线程池:使用 Executors.newVir