使用java同步不同服务器中的两个表的有效方法
我们有一个从各种外部系统更新的源表。我要求目标表(在不同的服务器中)与此源表同步。目标表不是源表的精确副本,在将数据插入/更新到目标表之前必须完成一些数据处理。
我每 15 分钟就会想到以下逻辑
,我们运行这个 java 消费者代码,该代码会获取创建时间戳的记录(而不是先前更新的记录)并将其存储在 CachedRowSet 中。并以 CachedRowSet 作为参数调用存储过程,其中完成数据处理并将数据插入/更新到目标表中。
您认为上述是一种有效的方法吗,因为我们每次更新都会处理超过一百万条记录?
另外,当源表中的记录被删除时,上述方法也不会被复制!你能建议在这种情况下该怎么做吗
we have a source table which is updated from various external systems. i require the destination table (in different server) to be in sync with this source table. the destination table is not an exact replica of the source table, some data processing has to be done before the data is inserted/updated into destination table.
i have thought of the following logic
every 15min we run this java consumer code which fetches the records where the timestamp is created than that of previous update and stored in a CachedRowSet
. and call a stored procedure with CachedRowSet
as parameter, where the data processing is done and the data is inserted/updated into the destination table.
do you believe above mentioned is an efficient way as we are dealing over a million records every update ?
also when a record is deleted in the source table in would not be replicated in the above method ! can you suggest what to do in such scenario
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
类似于数据库用于保存点和回滚的技术。
每当源表中有一些更改(例如 CRUD)时。根据目标表所需的格式保留更改脚本。您可以定期将这些更改推送到目标服务器。由于源表由各种外部系统更新,因此您需要在源表上有触发器来保存脚本日志。
Something similar to technique used by database for save point and rollback.
Whenever there is some change in the source table e.g. CRUD. keep the scripts of change as per format required to the target table. periodically you can push those changes to the target server. As your source table is updated by various external system, you'll need to have trigger on your source table for keeping script logs.
您可能想从 Maatkit 工具中查看 mk-table-sync:
http:// www.maatkit.org/doc/mk-table-sync.html
您需要小心表格差异。
You might want to check out mk-table-sync from Maatkit tools:
http://www.maatkit.org/doc/mk-table-sync.html
You'd need to be careful around your table differences.
以下是一些现有的解决方案:
https://www.symmetryds.org/
http://opensource.replicator.daffodilsw.com/
Here are some existing solutions:
https://www.symmetricds.org/
http://opensource.replicator.daffodilsw.com/