ogg mysql表结构不一致_求助:OGG双向同步,数据不一致如何解决?(已解决)

在配置Oracle GoldenGate进行双向同步时,遇到数据不一致问题。当两边同时更新同一条记录,导致数据冲突。文章探讨了如何通过Timestamp priority解决这种冲突,包括确保所有数据库的时区一致,并在记录中包含用于比较的timestamp列。
摘要由CSDN通过智能技术生成

本帖最后由 hbm1985 于 2012-5-10 07:39 编辑

e317cfcf1d216b80b6a1f82cc4a820c8.gif本人在搭建oracle goldengate 双向同步时,遇到一个问题:当两边同时更新同一条记录时,会出现两边数据不一致的问题。

A库最终拿到的是B库数据更新的数据。B库最终拿到的是A库数据更新的数据。

拓扑如下:

A(test) <=======>B(dest)

均为oracle 10GR2

表VIP结构如下:

id                 notnull varchar2(10)

node            notnull varchar2(10)

name           varchar2(10)

ca                varchar2(10)

例如:

原始记录,此时两个库的数据是一致的

id   node  name   ca

001 A       BB       A

T1时间,在A库操作:

update vip set  name='A' where id ='001';

commit;

T2时间,在B库操作:

update   vip set name='B' where id ='001';

commit;

过了几秒他们相互同步了数据:

A库的结果是:

id   node  name   ca

001 A   B   A

B库的结果是:

id   node  name   ca

001 A   A   A

请问,怎么样配置才可以实现,以最后更新并commit的数据为最终数据?所谓的Timestamp priority怎么配置?谢谢!

以下是A库的配置:

GGSCI (test) 6> view params exta

extract exta

setenv (NLS_LANG="AMERICAN_AMERICA.AL32UTF8" )

GETENV (NLS_LANG)

--NOCOMPRESSUPDATES

userid ggate, password ggate

tranlogoptions excludeuser ggate

rmthost 192.168.1.151,mgrport 7809

rmttrail ./dirdat/td

table aa.vip;

GGSCI (test) 3> view params repa

replicat repa

setenv (NLS_LANG="AMERICAN_AMERICA.AL32UTF8" )

GETENV (NLS_LANG)

userid ggate, password ggate

handlecollisions

assumetargetdefs

discardfile ./dirrpt/repa.dsc,purge

map aa.vip, target aa.vip;

----------------------------------------------

B库的配置:

GGSCI (dest) 6> view params extb

extract extb

setenv (NLS_LANG="AMERICAN_AMERICA.AL32UTF8" )

GETENV (NLS_LANG)

--NOCOMPRESSUPDATES

userid ggate, password ggate

tranlogoptions excludeuser ggate

rmthost 192.168.1.141,mgrport 7809

rmttrail ./dirdat/tg

table aa.vip;

GGSCI (dest) 7> view params repb

replicat repb

setenv (NLS_LANG="AMERICAN_AMERICA.AL32UTF8" )

GETENV (NLS_LANG)

userid ggate, password ggate

handlecollisions

assumetargetdefs

discardfile ./dirrpt/repb.dsc,purge

map aa.vip, target aa.vip;

以下是官方文档的说明:

Methods conflict 一章的说明:

Methods for resolving conflict

The following are some methods that are typically used in conflict-resolution routines.

Different methods can be used in combination so that if one method fails, another method

is applied. If you need assistance with constructing your routines, contact GoldenGate

Technical Support.

Timestamp priority

You can resolve conflicts based on a timestamp, where the record that was modified first

(or in some cases, last) always takes priority. To use timestamp priority:

● Each record must contain a timestamp column that contains the date and time that the

record was inserted or updated. You can use a database trigger or you can modify the

application code to place the timestamp in the column.

● The timestamps on all databases must be identical, and all servers must be in the same

time zone.

To detect and resolve conflicts based on a timestamp, first, try to apply the row normally.

Compare the before image of the timestamp column in the replicated row to the current

timestamp column in the database.

● If they match, there is no conflict.

● If they are different, compare the timestamp of the row in the database to the after

image of the timestamp from the replicated row.

The row with the oldest timestamp (or newest timestamp, if that is your rule) takes

priority.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值