123
返回列表 发新帖
楼主: macrozeng

[精华] 案例:DB2 三点 SQL 复制,APPLY 状态 -1

[复制链接]
论坛徽章:
42
ITPUB元老
日期:2005-09-09 13:45:35马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14优秀写手
日期:2013-12-18 09:29:09ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:32版主3段
日期:2012-05-15 15:24:112012新春纪念徽章
日期:2012-02-13 15:13:362012新春纪念徽章
日期:2012-02-13 15:13:36
21#
 楼主| 发表于 2010-2-8 13:24 | 只看该作者
这个问题原因根本就和主键无关,主键通过 offset 的设置,已经不会出现冲突的问题。
现在的问题是应用无法保证插入的 content 值唯一。有可能在两点或者三点上同时插入 content 相同的值,从而造成了相互复制失败。

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
1
2010系统架构师大会纪念
日期:2010-09-03 16:39:57
22#
发表于 2010-2-8 15:55 | 只看该作者
你可以把表和复制的定义导出来,大家先看看。
对于双向复制比较重要的一点是要设置冲突检测,来避免同时更新或者写入造成的失败。
在冲突检测上Q复制比sql复制强。
sql复制中默认冲突检测没启用,先确认你启用了冲突检测。前提是复制中不能包含lob数据。

使用道具 举报

回复
论坛徽章:
42
ITPUB元老
日期:2005-09-09 13:45:35马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14优秀写手
日期:2013-12-18 09:29:09ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:32版主3段
日期:2012-05-15 15:24:112012新春纪念徽章
日期:2012-02-13 15:13:362012新春纪念徽章
日期:2012-02-13 15:13:36
23#
 楼主| 发表于 2010-2-8 19:15 | 只看该作者
Q 复制是加了时间戳来解决冲突。 还是讲回来 SQL P2P Rep 吧,现在把场景简化下,2 点之间的 P2P SQL 复制,ID 字段没有做 Offset , 在两个点上同时插入 1,a(插入到P1) 和 1,b (插入到P2) ,这样就发生了冲突,这样复制的结果有可能是 1,b 到了 P1 上, 而 1,a 到了 P2 上 ,有什么冲突检测机制在两点对等的情况下去解决呢? :-)

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
1
2010系统架构师大会纪念
日期:2010-09-03 16:39:57
24#
发表于 2010-2-9 08:51 | 只看该作者
具体到你这个case,macrozeng 老兄先把表和复制的定义来贴上来让大家先看看吧.具体场景不清楚,感觉就像打醉拳
对于双向sql复制,冲突检测有两种:
Standard detection :
The Apply program checks for conflicts based on the changes captured to this point. The Apply program will reverse any conflicting transaction at the replica, as well as any transactions with dependencies on the conflicting transaction. Changes captured after the Apply program begins conflict detection will not be checked during this Apply cycle.
Enhanced detection :
The Apply program waits until the Capture program captures all changes from the log or journal (see description of the SYNCHTIME column) and then does a standard conflict detection as when set to 1. During the wait time, the Apply program holds a LOCK on the source tables to ensure that no changes are made during the conflict detection process.
原理类似:
During each Apply cycle, the Apply program compares the key values in the master’s CD table with those in the replica’s CD table. If the same key value exists in both CD tables, it is a conflict. In case of a conflict, the Apply program will undo the transaction that was previously committed at the replica by reading from the replica’s CD table and keeping only the changes that originated at the master.
如果诚如macrozeng 所说这个case是由于同时插入或者更新造成的,那要不设置conflict detection,手动删除一两条数据解决一个具体conflict也是治标不治本的,不能避免以后还发生类似情况

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
1
2010系统架构师大会纪念
日期:2010-09-03 16:39:57
25#
发表于 2010-2-9 09:48 | 只看该作者
在Q replication中bidirectional replication和Peer-to-peer replication是很不同的.
在SQL replaction中这一点做的差不少,多点的更新与复制更像是多个bidirectional replication.
我感觉在多点更新同步中Q replication是最可靠的,SQL replication在多点更新同步中的conflict detection 理论上就有缺陷.
类似如macrozeng 说的多点插入或更新中冲突中SQL replication的conflict detection 能解决部分问题,但不能解决所有问题.点越多问题越严重
在多点P2P环境中强烈推荐Q replication

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表