为客户部署的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. Hadoop学习地址

    hortonworks: http://zh.hortonworks.com/hdp/downloads/ http://zh.hortonworks.com/hadoop-tutorial/supe ...

  2. android 各国语言对应的缩写

    android资源文件夹的写法规则: 语言缩写-国家地区缩写 语言缩写 藏语:bo_CN en 英文 en_US 英文 (美国) ar 阿拉伯文 ar_AE 阿拉伯文 (阿拉伯联合酋长国) ar_BH ...

  3. 转:Why SeaJS

    原文地址:http://chaoskeh.com/blog/why-seajs.html Why SeaJS 前言 本文主要面向刚接触 SeaJS 的同学.文章会先提出传统 Javascript 开发 ...

  4. MySql服务基础

           MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品.MySQL 最流行的关系型数据库管理系统,在 WEB 应用方面MySQL是最好的 ...

  5. 剑指offer系列57---整数中1出现的次数

    [题目]求出1~n的整数中1出现的次数.(10进制) package com.exe11.offer; /** * [题目]求出1~n的整数中1出现的次数. * @author WGS * */ pu ...

  6. Erlang库 -- 有意思的库汇总

    抄自这里 首先,库存在的目的大致可分为:1.提供便利2.尽可能解决一些痛点 首先,我们先明确一下Erlang编程语言的一些痛点(伪痛点):1,单进程问题Erlang虚拟机属于抢占式调度,抢占式调度有很 ...

  7. HAML学习

    来源:http://ningandjiao.iteye.com/blog/1772845 一个技术能够风靡,一定是有它的原因的,在熟悉之前,我们没有资格去对它做任何的判断. Haml 是一种简洁优美的 ...

  8. grep 与正则表达式

    正则表达式只是字符串的一种描述,只有和支持正则表达式的工具相结合才能进行字符串处理.本文以grep为例来讲解正则表达式. grep命令 功能:输入文件的每一行中查找字符串. 基本用法: grep [- ...

  9. OkHttp 源码分析

    在工作中用到封装HTTP传输的OkHTTP,OkHttp是相对成熟的解决方案,同时也是开源项目.本文将从源码角度看下OkHttp是如何实现一些网络操作的. HTTP GET: OkHttpClient ...

  10. HDU 1532 (Dinic算法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1532 题目大意: 就是由于下大雨的时候约翰的农场就会被雨水给淹没,无奈下约翰不得不修建水沟,而且是网络 ...