为客户部署的Oracle GoldenGate在测试阶段出现如下的错误:

2012-04-24 10:45:20  ERROR   OGG-01168  Oracle GoldenGate Delivery for Oracle, rep1.prm:  Encountered an update for target table CCENSE.ST_CARDOPERATORSTATTMP, which has no unique key defined.  KEYCOLS can be used to define a key.  Use ALLOWNOOPUPDATES to process the update without applying it to the target database.  Use APPLYNOOPUPDATES to force the update to be applied using all columns in both the SET and WHERE clause.
        
        数据同步出问题的表没有主键,客户执行insert的时候没有问题,在执行update的时候报了上面的错误。以上的报错涉及三个参数,KEYCOLS,ALLOWNOOPUPDATES,APPLYNOOPUPDATES。下面我们分别讨论这3个参数:

1)KEYCOLS
        KEYCOLS关键字用于对没有主键的表,指定能够唯一标识数据的字段,这样Oracle GoldenGate同样可以完成数据的同步(同步UPDATE操作)。
        将目标数据库的replicat配置修改为:
MAP CCENSE.ST_CARDOPERATORSTATTMP, TARGET CCENSE.ST_CARDOPERATORSTATTMP, KEYCOLS(cardsfid)
        重启目标数据库的replicat进程即可完成数据的同步,但需要注意的是,使用这种方式必须把所有的表列出来,不能指定为<username>.*。

2)ALLOWNOOPUPDATES
        
        官方文档解释如下:

ALLOWNOOPUPDATES | NOALLOWNOOPUPDATES
Valid for Replicat
Use ALLOWNOOPUPDATES and NOALLOWNOOPUPDATES to control how Replicat responds to a “noop”
operation. A no-op operation is one in which there is no effect on the target table. The
following are some examples of how this can occur.
● The source table has a column that does not exist in the target table, or has a column
that was excluded from replication (with a COLSEXCEPT clause). In either case, if that
source column is updated, there will be no target column name to use in the SET clause
within the Replicat SQL statement.
● An update is made that sets a column to the same value as the current one. The
database does not log the new value, because it did not really change. However, Oracle
GoldenGate extracts the operation as a change record because the primary key was
logged — but there is no column value for the SET clause in the Replicat SQL statement.
By default (NOALLOWNOOPUPDATES), Replicat abends with an error because these types of
operations do not update the database. With ALLOWNOOPUPDATES, Replicat ignores the
operation instead of abending. The statistics reported by Replicat will show that an update
was made, but the database will not be updated.
You can use the internal parameter APPLYNOOPUPDATES to force the update to be applied.
APPLYNOOPUPDATES overrides ALLOWNOOPUPDATES. If both are specified then updates with
only key columns will be applied. By default, Oracle GoldenGate will abend with the
following message if it only has source key columns but there is no key defined for the target table.

2011-01-25 02:28:42 GGS ERROR 160 Encountered an update for target
table TELLER, which has no unique key defined. KEYCOLS can be used to
define a key. Use ALLOWNOOPUPDATES to process the update without applying
it to the target database. Use APPLYNOOPUPDATES to force the update to
be applied using all columns in both the SET and WHERE clause.
Exceptions when error-handling is in place
If ALLOWNOOPUPDATES is specified when the HANDLECOLLISIONS or INSERTMISSINGUPDATES
parameters are being used, and if Oracle GoldenGate has all of the target key values, then
Oracle GoldenGate will not ignore the update, but instead will apply it using all key
columns in the SET clause and the WHERE clause (invoking APPLYNOOPUPDATES behavior). This
is necessary so Oracle GoldenGate can detect if the row being updated is missing. If it is,
then Oracle GoldenGate turns the update into an insert.
Default NOALLOWNOOPUPDATES (only applies if the table does not have a key)

Syntax ALLOWNOOPUPDATES | NOALLOWNOOPUPDATES

该参数的含义就是在同步到目标数据库的时候忽略出现的NO-OP操作,NO-OP操作包括目标数据库没有主数据库的字段(两边数据库字段不同),还有一种情况是执行UPDATE语句修改的数据和原有数据一样,没有发生变化。以上两种情况叫做NO-OP操作,遭遇NO-OP操作gg会被终止。

         3)APPLYNOOPUPDATES 
        该参数的含义就是不忽略出现的NO-OP操作,而是在目标数据库强制执行UPDATE修改操作,且只更新键值数据(主键或KEYCOLS指定的键值),如果表没有主键,也没有使用KEYCOLS关键字指定字段,那么将更新表数据的所有字段,如果没有相应记录,将INSERT新插入一条。
        官方文档解释如下:

APPLYNOOPUPDATES | NOAPPLYNOOPUPDATES
Valid for Replicat
Use APPLYNOOPUPDATES to force a “no-op” update to be applied using all columns in both the
SET and WHERE clauses. See ALLOWNOOPUPDATES | NOALLOWNOOPUPDATES for a description of
“no-op.”
APPLYNOOPUPDATES uses whatever data is in the trail. If there is a primary key update
record, it uses the before columns from the source. If there is a regular (non-key) update,
it assumes that the after value is the same as the before value (otherwise it would be a
primary key update). The preceding assumes source and target keys are identical. If they
are not, you must use a KEYCOLS clause in the TABLE statement on the source.
Default NOAPPLYNOOPUPDATES
Syntax APPLYNOPUPDATES | NOAPPLYNOPUPDATES

请注意,我们在讨论NO-OP操作的时候,NO-OP操作并不包含UPDATE没有主键的表,所以我们遇到的这个问题和ALLOWNOOPUPDATES和APPLYNOOPUPDATES这两个参数没有关系。通过实践证明,在replicat配置文件中加入这两个参数(或只加入ALLOWNOOPUPDATE参数),在更新没有主键,也没有指定KEYCOLS字段的表的时候同样会报错。对没有主键,但加上了KEYCOLS字段后的表执行UPDATE操作成功同步了数据。

如果没有在源数据库启用记录表的supplement log,同样会收到以上的报错,原因是在于没有记录没有主键表的supplement log数据,并将其传递到目标数据库,执行以下操作可以启用记录表的supplement log:
cd $GGHOME
./ggsci
dblogin userid <username>,password <password>
add trandata <username>.<tablename>
         完成以上操作之后,可以解决由此问题导致的update不能同步。

结论
        在处理没有主键的表,且对表有UPDATE操作的时候,应该为这些表在replicat配置文件的MAP设置中加上KEYCOLS关键字,后面的跟上能够唯一标识数据的一个字段或多个字段,甚至可以把表的所有字段加在KEYCOLS关键字后面。 
http://blog.itpub.net/23135684/viewspace-722194/

Oracle GoldenGate 11.2 OGG-01168(转)的更多相关文章

  1. Oracle GoldenGate (ogg) 11.2.1.0.20 是最后一个支持oracle db 10g的 ogg版本号

    參考原文: Oracle GoldenGate 11.2.1.0.22 Patch Set Availability (Doc ID 1669160.1) 该文章不做翻译,只摘录当中有价值的信息,例如 ...

  2. oracle ogg 单实例双向复制搭建(oracle-oracle)--Oracle GoldenGate

    oracle ogg 单实例双向复制搭建(oracle-oracle)--Oracle GoldenGate --继昨天的测试,这一篇实施单实例双向复制(完全重新搭建) --环境不变 db1,db2( ...

  3. 76 道 Oracle Goldengate 面试问题

    基础 12c新特性 性能 Troubleshoot 其它 1. Oracle Goldengate 支持部署到哪些拓扑? GoldenGate supports the following topol ...

  4. oracle goldengate技术架构-简单试验(全)

    一  GoldenGate简介 Oracle Golden Gate软件是一种基于日志的结构化数据复制备份软件,它通过解析源 数据库在线日志或归档日志获得数据的增量变化,再将这些变化应用到目标数据库, ...

  5. oracle goldengate安装

    1.ftp工具上传ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip分别到source和target服务器 [oracle@localhost mnt]$ ll ...

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

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

  7. Oracle GoldenGate (以下简称ogg)在异种移植os同一种db之间的数据同步。

    Oracle GoldenGate (以下简称ogg)在异种移植os同一种db之间的数据同步. ogg要实现的功能: 同步可以细化到单个表,满足特定的where条件rows同步,称号column同步. ...

  8. 『OGG 03』Win7 配置 Oracle GoldenGate 一次性成功(包括Adapter Java)

    安装Oracle: 安装 Oracle_11g 32位[Oracle 32位的话,OGG 也必须是 32位,否则会有0xc000007b无法正常启动 错误] 安装目录为 D:\oracle\produ ...

  9. 『OGG 02』Win7 配置 Oracle GoldenGate Adapter Java 踩坑指南

    上一文章 <__Win7 配置OGG(Oracle GoldenGate).docx>定下了 两个目标: 目标1: 给安装的Oracle_11g 创建 两个用户 admin 和 root ...

随机推荐

  1. shiro权限验证标签

    实例: spring-shiro.xml /admin/repairType/index = roles["ROLE_ADMIN"] /admin/user=roles[" ...

  2. R(一): R基础知识

    R 是一门拥有统计分析及作图功能的免费软件,主要用于数学建模.统计计算.数据处理.可视化等方向.据 IEEE Spectrum发布的2016年编程语言前10位排名来看,R语言由2015年排名第6位上升 ...

  3. 转载:mybatis自动生成

    MyBatis Generator中文文档 MyBatis Generator中文文档地址: http://generator.sturgeon.mopaas.com/ 该中文文档由于尽可能和原文内容 ...

  4. OpenCV图像处理篇之边缘检测算子

    OpenCV图像处理篇之边缘检测算子 转载: http://xiahouzuoxin.github.io/notes/ 3种边缘检测算子 一阶导数的梯度算子 高斯拉普拉斯算子 Canny算子 Open ...

  5. IntelliJ IDEA以不同格式导出数据库的数据

    在数据表内容上点击右键,弹出窗口中先选择Data Extractor SQL Inserts,二级菜单会列出导出数据的类型,这里选择SQL Inserts 然后选择Dump Data菜单中的To Fi ...

  6. bzoj 3920: Yuuna的礼物

    Description 转眼就要到Karin的生日了!Yuuna她们想为她准备生日礼物!现在有许多礼物被排列成了一个一维序列,每个礼物都有一个价值.Yuuna对这个序列十分感兴趣.因此,你需要多次回答 ...

  7. activiti自定义流程之Spring整合activiti-modeler5.16实例(六):启动流程

    注:(1)环境搭建:activiti自定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建        (2)创建流程模型:activiti自定义流程之Spring ...

  8. 深度优化LNMP

    优化前准备工作 Centos准备及配置 准备安装包及软件:http://pan.baidu.com/s/1chHQF  下载解压到U盘即可安装http://pan.baidu.com/s/15TUWf ...

  9. 补一篇关于Jackson和Gson的文章

    一.关于Gson的问题 问题1. 如果对象属性里有[],表示它是一个列表,需要用List对象进行封装,不能用String来定义,不然转不了 问题2. Gson在解析的时候,如果json中有转义字符 \ ...

  10. win764上vs2010+opencv2.4.11安装配置

    1:准备工作 1)opencv的官网下载你所要版本的opencv库文件,运行安装解压到自定义的一个文件夹里(D:\Program Files). 2)安装vs2010. 二:配置 1.计算机环境变量: ...