你如何使两个相关但独立的系统保持相互同步?[英] How do you keep two related, but separate, systems in sync with each other?

本文是小编为大家收集整理的关于你如何使两个相关但独立的系统保持相互同步?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我目前的开发项目有两个方面.首先,有一个公共网站,外部用户可以在其中提交和更新信息出于各种目的.然后将此信息保存到COLO设施的本地SQL Server.

第二个方面是员工用来管理这些相同记录(概念上)并提供状态更新,批准等的内部应用程序.此应用程序托管在公司防火墙中,上面有其本地SQL Server数据库.

.

这两个网络是通过硬件VPN解决方案连接的,这是不错的,但显然不是世界上最快的东西.

两个数据库相似,并共享许多相同的表格,但它们的100%相同.双方的许多表都非常特定于内部或外部应用.

因此,问题是:当用户更新其信息或在公共网站上提交记录时,如何将数据传输到内部应用程序的数据库中,以便由内部人员管理?反之亦然...您如何将工作人员进行的更新返回网站?

值得一提的是,这些更新的"实时时间"越多,越好.并不是说它必须是即时的,只是很快.

到目前为止,我已经考虑使用以下类型的方法:

  1. 双向复制
  2. Web服务在两侧的界面与代码之间的界面,以同步更改(实时).
  3. Web服务在两侧的界面都与代码与异步同步更改(使用排队机制).

有建议吗?有人遇到过这个问题吗?您是否提出了一个对您有效的解决方案?

我相信

推荐答案

这是一个非常普遍的集成方案.就我个人而言,我认为使用队列的异步消息解决方案是理想的.

您应该能够实现接近实时同步,而无需复制之类的开销或复杂性.

同步Web服务不是理想的选择,因为您的代码必须非常复杂才能处理故障方案.当一个系统重新启动时,另一个系统继续发布更改时会发生什么?发送系统会超时吗?它如何处理这些?除非您准备丢失数据,否则您将希望某种交易队列(如MSMQ)接收更改通知并确保它们进入另一个系统.如果两个系统都关闭,则更改(通过消息传递)将只是积累,并且一旦建立连接,重新启动的服务器将处理所有排队的消息并赶上,从而使系统完整性变得更加易于实现.

有一些开源工具,如果您使用.NET,可以真正使您轻松(尤其是要使用MSMQ).

  1. nservicebus udi dahan
  2. 大众运输 Dru Sellers和Chris Patterson

也有商业产品,如果您正在考虑商业选项,请参见此处对于.NET上的选项列表.当然,WCF可以使用MSMQ绑定进行异步消息传递,但是Nservicebus或MassTransit之类的工具将为您提供非常简单的发送/接收或pub/sub API,这将使您的需求成为非常简单的工作.

>

>

如果您使用的是Java,则有许多开源服务总线实现将使这种双向,异步消息传递,例如mule或可能只是ActiveMQ.

.

您可能还想考虑阅读 udi dahan' S Blog,听他的一些播客.这是一些好的资源让您开始.

其他推荐答案

我正在中间通过一个类似的项目

首先,您需要跟踪更改,如果您可以使用SQL 2008(即使2GB限制不是问题,即使Express版本也足够),这将大大减轻痛苦,只需打开数据库上的更改跟踪桌子.我们正在总部使用SQL Server 2008,并在每个站点上使用扩展模式和SQL Express 2008,并使用一个子集和有限的模式.

其次,您需要跟踪更改, sync Services "> sync Services "> sync Services 技巧很好,并支持使用WCF网关进入主数据库.在此示例中,您需要使用使用SQL Express客户端示例作为起点,请注意,它基于SQL 2005,因此您需要更新它以利用它更改跟踪功能在2008年.默认情况下,同步服务在客户端上使用SQL CE,我敢肯定在您的情况下还不够.您需要在Web服务器上运行的服务(如果需要的话,则可能与每10秒一样频繁)运行Synchronize()方法.这将告诉您的主要数据库有关本地进行的更改,然后向服务器询问那里所做的所有更改.您可以设置GET并应用SQL代码以调用存储过程,并且可以添加事件处理程序以处理冲突(例如客户端更新与服务器更新)并在两端相应地解决它们.

其他推荐答案

我们有一家商店作为客户,三家商店连接到同一VPN
其中两家商店的计算机作为该商店的"服务器"运行,第三个商店具有"主数据库"
为了将全部同步到主人,我们没有最好的解决方案,但它有效:有一个专用的PC运行一个应用程序,该应用程序检查了两个商店中每个表中每个记录的时间戳您同步,它复制结果
请注意,这是双向工作的. IE.如果您在主数据库中更新产品,则此更改将传播到其他两家商店.如果您在其中一家商店中有新订单,则将传输给"主人".
通过一些优化,您可以使所有商店在大约20分钟内同步

本文地址:https://www.itbaoku.cn/post/597645.html

问题描述

My current development project has two aspects to it. First, there is a public website where external users can submit and update information for various purposes. This information is then saved to a local SQL Server at the colo facility.

The second aspect is an internal application which employees use to manage those same records (conceptually) and provide status updates, approvals, etc. This application is hosted within the corporate firewall with its own local SQL Server database.

The two networks are connected by a hardware VPN solution, which is decent, but obviously not the speediest thing in the world.

The two databases are similar, and share many of the same tables, but they are not 100% the same. Many of the tables on both sides are very specific to either the internal or external application.

So the question is: when a user updates their information or submits a record on the public website, how do you transfer that data to the internal application's database so it can be managed by the internal staff? And vice versa... how do you push updates made by the staff back out to the website?

It is worth mentioning that the more "real time" these updates occur, the better. Not that it has to be instant, just reasonably quick.

So far, I have thought about using the following types of approaches:

  1. Bi-directional replication
  2. Web service interfaces on both sides with code to sync the changes as they are made (in real time).
  3. Web service interfaces on both sides with code to asynchronously sync the changes (using a queueing mechanism).

Any advice? Has anyone run into this problem before? Did you come up with a solution that worked well for you?

推荐答案

This is a pretty common integration scenario, I believe. Personally, I think an asynchronous messaging solution using a queue is ideal.

You should be able to achieve near real time synchronization without the overhead or complexity of something like replication.

Synchronous web services are not ideal because your code will have to be very sophisticated to handle failure scenarios. What happens when one system is restarted while the other continues to publish changes? Does the sending system get timeouts? What does it do with those? Unless you are prepared to lose data, you'll want some sort of transactional queue (like MSMQ) to receive the change notices and take care of making sure they get to the other system. If either system is down, the changes (passed as messages) will just accumulate and as soon as a connection can be established the re-starting server will process all the queued messages and catch up, making system integrity much, much easier to achieve.

There are some open source tools that can really make this easy for you if you are using .NET (especially if you want to use MSMQ).

  1. nServiceBus by Udi Dahan
  2. Mass Transit by Dru Sellers and Chris Patterson

There are commercial products also, and if you are considering a commercial option see here for a list of of options on .NET. Of course, WCF can do async messaging using MSMQ bindings, but a tool like nServiceBus or MassTransit will give you a very simple Send/Receive or Pub/Sub API that will make your requirement a very straightforward job.

If you're using Java, there are any number of open source service bus implementations that will make this kind of bi-directional, asynchronous messaging a snap, like Mule or maybe just ActiveMQ.

You may also want to consider reading Udi Dahan's blog, listening to some of his podcasts. Here are some more good resources to get you started.

其他推荐答案

I'm mid-way through a similar project except I have multiple sites that need to keep in sync over slow connections (dial-up in some cases).

Firstly you need to track changes, if you can use SQL 2008 (even the Express version is enough if the 2Gb limit isn't a problem) this will ease the pain greatly, just turn on Change Tracking on the database and each table. We're using SQL Server 2008 at the head office with the extended schema and SQL Express 2008 at each site with a sub-set of data and limited schema.

Secondly you need to track your changes, Sync Services does the trick nicely and supports using a WCF gateway into the main database. In this example you will need to use the Sync using SQL Express Client sample as a starting point, note that it's based on SQL 2005 so you'll need to update it to take advantage of the Change Tracking features in 2008. By default the Sync Services uses SQL CE on the clients, which I'm sure isn't enough in your case. You'll need a service that runs on your Web Server that periodically (could be as often as every 10 seconds if you want) runs the Synchronize() method. This will tell your main database about changes made locally and then ask the server for all changes made there. You can set up the get and apply SQL code to call stored procedures and you can add event handlers to handle conflicts (e.g. Client Update vs Server Update) and resolve them accordingly at each end.

其他推荐答案

We have a shop as a client, with three stores connected to the same VPN
Two of the shops have a computer running as a "server" for that shop and the the third one has the "master database"
To synchronize all to the master we don't have the best solution, but it works: there is a dedicated PC running an application that checks the timestamp of every record in every table of the two stores and if it is different that the last time you synchronize, it copies the results
Note that this works both ways. I.e. if you update a product in the master database, this change will propagate to the other two shops. If you have a new order in one of the shops, it will be transmitted to the "master".
With some optimizations you can have all the shops synchronize in around 20minutes