一、需求,使用OGG同步软件,将Oracle 11g Sequence实时同步到19c新库中

参考文档

Implementing replication of cyclic sequences in GoldenGate (Doc ID 1321558.1)

二、测试同步

本次测试环境进行介绍:

DB,Source 11.2.0.4  Target 19.3

OGG,在第三台机器上,版本19.1,使用tns远程捕获及复制!

2.1 源端

2.1.1源库

sqlplus / as sysdba
运行SQL脚本,schema name输入OGG01
SQL>@sequence.sql
grant execute on OGG01.updateSequence to OGG01;
grant execute on OGG01.replicateSequence to OGG01;
alter table sys.seq$ add supplemental log data (primary key) columns;

权限!

GRANT SELECT ANY TRANSACTION TO "OGG01";

OGG是如何进行同步sequence值?

How to Set 'Cache Size' of a Sequence Object? (Doc ID 378302.1)
alter sequence slow_sequence nocache;
The drawback to this is that every call for a new value will result in an update to
the SYS.SEQ$ table; an overhead that is unlikely to be acceptable in a high-speed OLTP system.
In fact I often advise DBAs to check their database for sequences which are high-usage
but defined with the default cache size of 20 - the performance benefits of altering
the cache size of such a sequence can be noticeable: a cache size of 1,000 is usually
sufficient. (NOTE: increasing the cache size of a sequence does not waste space, the
cache is still defined by just two numbers, the last used and the high water mark; it is
just that the high water mark is jumped by a much larger value every time it is reached

截取部分是通过SYS.SEQ$基表的改变,实现sequence值的同步!
dba_sequences LAST_NUMBER 值!!!
如果存在cache的情况,next sequence不可能百分百源端目标端一致, 但是保障目标端next>=source就可以了

2.1.2源OGG Global配置

Global配置
抽取进程排除OGG用户,不对这个用户抽取DDL!
./ggsci
edit params ./GLOBALS
增加下面一行内容
GGSCHEMA OGG01
Use the GGSCHEMA parameter to specify the name of the schema that contains the database objects that are owned by Oracle
GoldenGate, such as those that support DDL replication for trigger based replication and those that are part of the heartbeat
table implementation.The schema name specified with GGSCHEMA will be considered an excluded schema. Tables in this schema can
only be captured if explicitly specified with a non-wildcarded inclusion specification.

2.1.3源OGG Extract配置

DDL &
INCLUDE OBJTYPE SEQUENCE &
INCLUDE MAPPED OPTYPE ALTER &
INCLUDE MAPPED OPTYPE CREATE &
INCLUDE MAPPED OPTYPE DROP &
INCLUDE MAPPED OBJTYPE 'TABLE' &
INCLUDE MAPPED OBJTYPE 'INDEX' &
EXCLUDE OPTYPE TRUNCATE &
EXCLUDE OPTYPE COMMENT
table testgbk1.*;
sequence testgbk1.*;
注意: SEQUENCE需要放前面! 如果放在INDEX下一行会被忽略,无法理解,但是就是这样。

可以重启抽取进程,开始抽取sequence的变化!

> FLUSH SEQUENCE testgbk1.seq5
2021-05-07 03:44:30 INFO OGG-15311 Successfully flushed 1 sequence(s) testgbk1.seq5. 这个步骤可以忽略! 详情可以看最开始的MOS文档
存在问题可以进行操作,并且如果提示GGSCHEMA XXX 参数未配置,但是实际配置了的情况下,需要exit,重新./ggsci,最好restart extract在进行刷新

2.2 目标端

2.2.1 目标数据库

GRANT CREATE ANY sequence TO "C##OGG1" container=all;
GRANT ALTER ANY sequence TO "C##OGG1" container=all;
GRANT DROP ANY sequence TO "C##OGG1" container=all;
GRANT SELECT ANY sequence TO "C##OGG1" container=all;

执行sequence脚本,建议在PDB中执行!
SQL>@sequence.sql
 
需要注意:其中ALTER 添加最小补充日志的操作,需要在CDB执行! 
grant execute on C##OGG1.updateSequence to C##OGG1; 
grant execute on C##OGG1.replicateSequence to C##OGG1;
alter table sys.seq$ add supplemental log data (primary key) columns;
SQL> ALTER TABLE "SYS"."SEQ$" ADD SUPPLEMENTAL LOG GROUP "GGS_100" ("OBJ#") ALWAYS /* GOLDENGATE_DDL_REPLICATION */;

2.2.2 复制进程配置

map testgbk1.*, target testgbk1.*,filter(@GETENV('TRANSACTION','CSN')>1027848);
本例是*,因此无需改变!
map testgbk1.seq5 , target testgbk1.seq5;
如果是基于每个表的操作,建议对每个seq和表一样的操作即可!

三、遇到的问题

3.1 权限不足,OGG复制进程不报错延迟一直递增

自从开始同步sequence后,复制进程重启后,Time Since Chkpt 一直递增,也不abend!!!???
REPLICAT RUNNING REP_DA 00:00:00 11:15:29

SESSION

SQL>  select INST_ID,sid,serial#,USERNAME,STATUS,MACHINE,SQL_ID,EVENT,(sysdate-LOGON_TIME)*86400 as "s",LAST_CALL_ET
from gv$session where status='ACTIVE' and username is not null;
USERNAME STATUS SQL_ID EVENT s LAST_CALL_ET
--------- --------------------- ------------------------ ------------
C##OGG1 ACTIVE 2shzygd7syhy2 latch: shared pool 69 35 ----------------------------------------------
SELECT "SEQ_SEQ".NEXTVAL FROM DUAL

DB ALERT

2021-05-07T02:25:58.096895-07:00
PDBODB(3):----- PL/SQL Call Stack -----
object line object
handle number name
0x678dd5e8 259 procedure C##OGG1.REPLICATESEQUENCE
0x67919d98 1 anonymous block
PDBODB(3):WARNING: too many parse errors, count=164500 SQL hash=0x4f8f43c2
PDBODB(3):PARSE ERROR: ospid=19982, error=1031 for statement:
2021-05-07T02:25:58.181508-07:00
PDBODB(3):SELECT "SEQ_SEQ".NEXTVAL FROM DUAL
PDBODB(3):Additional information: hd=0x67af0f58 phd=0x67b8ca40 flg=0x20 cisid=113 sid=113 ciuid=114 uid=114 sqlid=2shzygd7syhy2
PDBODB(3):...Current username=C##OGG1
PDBODB(3):...Application: GoldenGate Action: OGG$REP_DA - Apply Receiver
19C DB ALERT一直在刷屏!!! error !!!

权限TEST

Source
create sequence TESTGBK1.seq_seq minvalue 1 maxvalue 9999999999 start with 101 increment by 1 cache 50; Target
SQL> select SEQUENCE_OWNER,SEQUENCE_NAME from dba_sequences where SEQUENCE_OWNER='TESTGBK1';
SEQUENCE_OWNER SEQUENCE_NAME
-------------------- --------------------
TESTGBK1 SEQ_SEQ
SQL> conn C##OGG1/oracle@T2UTF8
SELECT TESTGBK1."SEQ_SEQ".NEXTVAL FROM DUAL;
ERROR at line 1:
ORA-01031: insufficient privileges

Temp handle

Target ogg replicat stop ,db session 还是存在的!
select 'alter system kill session '''||sid||','||serial#||''' immediate;' from v$session where username='C##OGG1';

Permanent treatment

GRANT SELECT ANY sequence TO "C##OGG1" container=all;

3.2 参数冲突

复制进程一直报啥调用REPLICATESEQUENCE遇到第七行XX报错!

PLS-00201: identifier 'OGG01.REPLICATESEQUENCE' must be declared

OGG-01004  Oracle GoldenGate Delivery for Oracle, repchl_c.prm:  Aborted grouped transaction on 'CHANNEL.SEQ_POLICY_REPORT',
Database error 6550 ().
OGG-01003  Oracle GoldenGate Delivery for Oracle, repchl_c.prm:  Repositioning to rba 28315843 in seqno 5.
OGG-01154  Oracle GoldenGate Delivery for Oracle, repchl_c.prm:  SQL error 6550 mapping CHANNEL.SEQ_POLICY_REPORT to
CHANNEL.SEQ_POLICY_REPORT.
OGG-01003  Oracle GoldenGate Delivery for Oracle, repchl_c.prm:  Repositioning to rba 29190828 in seqno 5.
OGG-01444  Oracle GoldenGate Delivery for Oracle, repchl_c.prm:  Error in replicating sequence value [ORA-06550: line 1, column 7:
PLS-00201: identifier 'OGG.REPLICATESEQUENCE' must be declared
ORA-06550: line 1, column 7: 处理方案:
1).结合报错中出现的ORA错误进行分析;
2).如果类似本次报出的PLS-00201则表示sequence.sql没有执行引起的
————————————————
版权声明:本文为CSDN博主「司马松儆」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/smasegain/article/details/47050769

有点类似上面的报错,但是sequence.sql执行n次了!!!

最终检查发现,源端目标端共享一个./GLOBALS参数!  参数里面 GGSCHEMA OGG01 写的是源端的OGG用户,注释参数后,问题解决!

OGG-Oracle同步Sequence的更多相关文章

  1. 【OGG】RAC环境下配置OGG单向同步 (四)

    [OGG]RAC环境下配置OGG单向同步 (四) 一.1  BLOG文档结构图 一.2  前言部分 一.2.1  导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的 ...

  2. OGG实验:喂奶间隔数据表通过OGG配置同步

    我之前在<使用SQL计算宝宝每次吃奶的时间间隔(数据保障篇)>中提到数据实时同步的方案,其中有一种是数据表通过OGG进行同步,当时没有详细展开测试,只给了之前学习OGG时的配置示例.由于之 ...

  3. oracle关于sequence的个人理解

    oracle关于sequence的个人理解 1. sequence在多用户使用时的同步问题 个人感觉sequence是以连接(会话)为基础,类似于java中使用mysql的一个connection 网 ...

  4. JDBC读取新插入Oracle数据库Sequence值的5种方法

    Oracle的sequence实现非常灵活,所以也带来一些易用性问题,如何取到新插入记录生成的sequence值与其它数据库有较大差别,本文详国介绍了5种实现读取新插入记录sequence值的方法. ...

  5. 【从翻译mos文章】在OGG (Oracle GoldenGate) 正在使用SCHEMATRANDATA如果,需要额外的db patch

    在OGG (Oracle GoldenGate) 正在使用SCHEMATRANDATA如果.需要额外的db patch 参考原始: Patches needed to support SCHEMATR ...

  6. Hibernate用Oracle的sequence生成自增Id

    <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBL ...

  7. Oracle Metric sequence load elapsed time

    Oracle Metric sequence load elapsed time The sequence load elapsed time Oracle metric is the amount ...

  8. oracle中sequence(自增序号)的用法

    转载:https://www.cnblogs.com/liuzy2014/p/5794928.html 在oracle中sequence就是序号,每次取的时候它会自动增加.sequence与表没有关系 ...

  9. oracle创建sequence序列语法

    在oracle中sequence就是序号,每次取的时候它会自动增加.sequence与表没有关系 1.create sequence create sequence SEQ_LOG_ID minval ...

随机推荐

  1. 如何获取下载 FreeBSD

    『如何获取下载 FreeBSD 』 『如何获取下载 FreeBSD 』 FreeBSD 是免费获取的. [下载地址] O网页链接 版本选择,尽量选择较新版本,桌面用户可选择 current 版本.st ...

  2. 三分钟教你提升应用推送的ROI

    推送是App应用性价比最高也是最直接的营销运营手段,其细节颇多,非常考验运营人员的功力,本文将从ROI角度来分析怎么提升营销类推送的收益.(非IM类.系统类等功能服务型推送) 以一个日活100万的应用 ...

  3. Codeforces Round #558 B2. Cat Party (Hard Edition)

    题面: 传送门 题目描述: 题意:确定最大的x,使去除掉前x天的其中一天后,所有不同数字的数量相等.   题目分析: 可能是我太久没打cf了,水题都做不出来. 这道题的关键在于:要记录相同数量,的不同 ...

  4. Vue 全家桶学习资源(转)

    companion: React 全家桶学习资源(持续更新) 下面整理了一些关于Vue以及Vue衍生的学习资源: 官网文档 官网API ECMAScript 6 入门 30分钟掌握ES6/ES2015 ...

  5. Python中的描述器

    21.描述器:Descriptors 1)描述器的表现 用到三个魔术方法.__get__()   __set__()  __delete__() 方法签名如下: object.__get__(self ...

  6. css行高

    1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="U ...

  7. Hi3559AV100 NNIE开发(6)RFCN中NNIE实现关键线程函数->SAMPLE_SVP_NNIE_Rfcn_ViToVo()进行数据流分析

    前面随笔给出了NNIE开发的基本知识,下面几篇随笔将着重于Mobilefacenet NNIE开发,实现mobilefacenet.wk的chip版本,并在Hi3559AV100上实现mobilefa ...

  8. 论Redis分布式锁的正确使用姿势

    前言 日常开发中,秒杀下单.抢红包等等业务场景,都需要用到分布式锁.而Redis非常适合作为分布式锁使用.本文将分七个方案展开,跟大家探讨Redis分布式锁的正确使用方式.如果有不正确的地方,欢迎大家 ...

  9. InlineHook

    前言 IATHOOK局限性较大,当我们想HOOK一个普通函数,并不是API,或者IAT表里并没有这个API函数(有可能他自己LoadLibrary,自己加载的),那我们根本就从导入表中找不到这个函数, ...

  10. 【Visual Studio调教小记录】C++指针靠前靠后??

    本文地址:https://www.cnblogs.com/oberon-zjt0806/p/14631149.html 甜咸之争 经常写C++的基本上避不开使用指针,而且C++中指针类型的写法大体上有 ...