为客户部署的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. 初试体验java多线程

    现在个人电脑以及服务器都是多核cpu,如何提高多核cpu的利用率,就要用到多线程技术了. public class TestThread1 { ; static class PThread exten ...

  2. VMware虚拟系统 bridged、NAT、host-only三种网络连接模式

    目录 前言 bridged(桥接模式) NAT(网络地址转换模式) host-only(仅主机模式) 总结 前言 如果你想利用VMWare安装虚拟机,或想创建一个与网内其他机器相隔离的虚拟系统,进行特 ...

  3. Linux下Memcached-1.4.10安装

    memcache是一款流行的缓存产品,它分为两个部分:一个是运行在服务器端的memcached进程,一个是在客户端进行调用获取缓存中数据客户端,例如比较常用的PHP客户端.这里,记录一下安装服务器端的 ...

  4. bzoj1382: [Baltic2001]Mars Maps

    Description 给出N个矩形,N<=10000.其坐标不超过10^9.求其面积并 Input 先给出一个数字N,代表有N个矩形. 接下来N行,每行四个数,代表矩形的坐标. Output ...

  5. 启动Memcache,出现memcached: error while loading shared libraries: libevent-1.4.so.1: cannot open shared

      1.有可能是装了多个 libevent而导致memcache无法识别哪一个,解决方法就是卸载掉一个libevent 2.只安装了一个libevent,但是也报这个错,解决方法 32位系统下:ln ...

  6. net farmework 4安装不了 原因是 HRESULT 0xc8000222

    1. Click Start, Run, type: cmd and press Enter. Please run the following command in the opened windo ...

  7. Perl调用外部命令的方式和区别

    主要的方式简述如下:1. system("command");使用该命令将开启一个子进程执行引号中的命令,父进程将等待子进程结束并继续执行下面的代码. 2. exec(" ...

  8. 【MySQL】技巧 之 count(*)、count(1)、count(col)

    只看结果的话,Select Count(*) 和 Select Count(1) 两着返回结果是一样的. 假如表沒有主键(Primary key), 那么count(1)比count(*)快,如果有主 ...

  9. 黄聪:C#如何操作JSON数据(读取、分析)

    使用开源的类库Newtonsoft.Json(下载地址http://json.codeplex.com/).下载后加入工程就能用.通常可以使用JObject, JsonReader, JsonWrit ...

  10. 黄聪:手机移动站Web响应式开发工具Viewport Resizer插件(360浏览器、谷歌Chrome浏览器兼容)

    插件作用: 移植自@MalteWassermann的脚本,一个可以测试响应式布局的chrome扩展. 插件截图: 插件下载地址(需FQ): https://chrome.google.com/webs ...