OGG-Oracle同步Sequence
一、需求,使用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的更多相关文章
- 【OGG】RAC环境下配置OGG单向同步 (四)
[OGG]RAC环境下配置OGG单向同步 (四) 一.1 BLOG文档结构图 一.2 前言部分 一.2.1 导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的 ...
- OGG实验:喂奶间隔数据表通过OGG配置同步
我之前在<使用SQL计算宝宝每次吃奶的时间间隔(数据保障篇)>中提到数据实时同步的方案,其中有一种是数据表通过OGG进行同步,当时没有详细展开测试,只给了之前学习OGG时的配置示例.由于之 ...
- oracle关于sequence的个人理解
oracle关于sequence的个人理解 1. sequence在多用户使用时的同步问题 个人感觉sequence是以连接(会话)为基础,类似于java中使用mysql的一个connection 网 ...
- JDBC读取新插入Oracle数据库Sequence值的5种方法
Oracle的sequence实现非常灵活,所以也带来一些易用性问题,如何取到新插入记录生成的sequence值与其它数据库有较大差别,本文详国介绍了5种实现读取新插入记录sequence值的方法. ...
- 【从翻译mos文章】在OGG (Oracle GoldenGate) 正在使用SCHEMATRANDATA如果,需要额外的db patch
在OGG (Oracle GoldenGate) 正在使用SCHEMATRANDATA如果.需要额外的db patch 参考原始: Patches needed to support SCHEMATR ...
- Hibernate用Oracle的sequence生成自增Id
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBL ...
- Oracle Metric sequence load elapsed time
Oracle Metric sequence load elapsed time The sequence load elapsed time Oracle metric is the amount ...
- oracle中sequence(自增序号)的用法
转载:https://www.cnblogs.com/liuzy2014/p/5794928.html 在oracle中sequence就是序号,每次取的时候它会自动增加.sequence与表没有关系 ...
- oracle创建sequence序列语法
在oracle中sequence就是序号,每次取的时候它会自动增加.sequence与表没有关系 1.create sequence create sequence SEQ_LOG_ID minval ...
随机推荐
- 漏洞复现-Bash之一键破壳
注:使用docker搭建测试环境 (1)访问搭建的环境网址:http://192.168.11.101:8081/ (2)使用burp拦截数据包,并修改User-Agent的内容: (3)使用 ...
- 一个mac软件合集的网站
https://github.com/jaywcjlove/awesome-mac/blob/master/README-zh.md
- Mysql将查询结果某个字段以逗号分隔,使用group_concat函数可以实现(配合group by使用)
示例:SELECT Id, GROUP_CONCAT(Name SEPARATOR ',') Names FROM some_table GROUP BY id
- Codeforces Round #557 B. Double Matrix
题面: 传送门 题目描述: 给出两个n*m的矩阵,问:是否能通过交换两个矩阵"对应"位置的元素,使两个矩阵都为"递增"矩阵. "递增"矩阵定 ...
- BIMFACE二次开发SDK 开源C#版
[ BIMFace.SDK.CSharp ] 是基于微软.NET 技术封装的用于 BIMFACE 二次开发的通用类库.其中封装了BIMFace服务端API,包含基础API.文件上传API.文件转换AP ...
- python 集合详解
字符串 一个个字符组成的有序的序列,时字符的集合 使用单引,双引,三引 引住的字符序列 字符时不可变的对象 bytes定义 bytes不可变字节序列 使用b前缀定义 只允许基本ASCII使用字符形式 ...
- ResNet的个人总结
ResNet可以说是我认真读过的第一篇paper,据师兄说读起来比较简单,没有复杂的数学公式,不过作为经典的网络结构还是有很多细节值得深究的.因为平时不太读英文文献,所以其实读的时候也有很多地方不是很 ...
- MySQL的安装及使用
安装MySQL 这里建议大家使用压缩版,安装快,方便.不复杂. 1.MySQL软件下载 mysql5.7 64位下载地址: https://dev.mysql.com/get/Downloads/My ...
- Git 上传项目到 Github
Git 上传项目到 Github 该文章主要讲解Git 上传项目到 Github,Gitee同理 配置Git 下载.安装Git 下载后一路(傻瓜式安装)直接安装即可 如果第一次使用git的话,需要设置 ...
- 远程线程注入dll,突破session 0
前言 之前已经提到过,远线程注入和内存写入隐藏模块,今天介绍突破session 0的dll注入 其实今天写这个的主要原因就是看到倾旋大佬有篇文章提到:有些反病毒引擎限制从lsass中dump出缓存,可 ...