简体   繁体   English

如何实时更新数据到主仓库

[英]How to get real time update of data to main warehouse

All, Need some info. 全部,需要一些信息。

We have stores at multiple locations and use client server app installed for sales activity. 我们在多个位置都有商店,并使用安装的客户端服务器应用程序进行销售活动。 sales data is stored in database which is setup in all stores... @ end of day - a batch pulls data from all of the store locations and update main warehouse database. 销售数据存储在所有商店都已设置的数据库中……@一天结束-一批从所有商店位置提取数据并更新主仓库数据库。

We want to have real time implementation so that whenever there is transcation @ any store... data will update immediately to main warehouse repository. 我们希望实时实施,以便每当任何商店发生交易时,数据将立即更新到主仓库存储库。

Any clue as how can we achive real time update of data to main warehouse ? 有什么线索可以告诉我们如何实时更新主仓库的数据?

Thanks in advance... 提前致谢...

One approach to this is called replication . 一种解决方法称为复制 There are several ways to do it in SQL Server. 在SQL Server中有几种方法可以做到这一点。 You're probably looking for transaction replication or merge replication. 您可能正在寻找事务复制或合并复制。

Here's a place to start in the SQL Server 2012 documentation. 这是 SQL Server 2012文档中的起点 And here's a fairly recent overview that might be helpful. 这是一个相当近期的概述 ,可能会有所帮助。

You should make sure you understand what "real time" means, and how real time you really need to be. 您应该确保您了解“实时”的含义以及真正需要的实时程度。 If you are not pre aggregating data and then storing it in the WH, then you should be able to set up replication between the database servers (if they can talk to each other). 如果您没有预先聚合数据,然后将其存储在WH中,那么您应该能够在数据库服务器之间建立replication (如果它们可以互相通信)。 If you are loading an aggregate, then it gets tricky because you have to merge the measures (facts) into the warehouses existing measures, which is tough. 如果要加载聚合,那么它将变得很棘手,因为您必须将度量(事实)合并到仓库中现有度量中,这很困难。 If you don't need true real time, just a slow trickle, then consider simply running your current process on a schedule in sql agent. 如果您不需要真正的实时,只需缓慢地进行滴答,然后考虑在sql agent中按计划简单地运行当前进程。

First off - why not run the batch multiple times a day. 首先-为什么不每天运行该批处理多次。 It would not really be "real-time" but might yield good enough real world results. 它不是真正的“实时”,但可能会产生足够好的实际结果。

One option would be to implement master-master replication provided by the SQL engine in use. 一种选择是实施使用中的SQL引擎提供的主-主复制。 Though this probably means that some steps need to be taken to guard against duplicate IDs, auto increment mismatch etc. For example we have a master-master system set up so that one produces entries with odd IDs, the other with even. 尽管这可能意味着需要采取一些措施来防止重复的ID,自动增量不匹配等。例如,我们设置了一个master-master系统,以便一个生成具有奇数ID的条目,另一个生成具有偶数ID的条目。

Another approach could be that all reads are performed against local databases, and all writes are performed into the single remote master. 另一种方法可能是对本地数据库执行所有读取,而对单个远程主服务器执行所有写入。 Data would be replicated as a master-slave setup. 数据将作为主从设置进行复制。 This would provide best data consistency, but slow network would make any writes slow. 这样可以提供最佳的数据一致性,但是慢速的网络会使写入速度变慢。 We have this kind of a setup implemented atop of the master-master replication as most interaction are reads. 由于大多数交互都是读取的,因此我们在主-主复制之上实现了这种设置。

One real world use case I have actually come across for a similar stores/warehouse setup was based on Firebird SQL. 我实际上在类似的商店/仓库设置中遇到的一个现实用例是基于Firebird SQL的。 Every single table had triggers implemented to store every action on local databases in so called log tables. 每个表都实现了触发器,以将对本地数据库的所有操作存储在所谓的日志表中。 And there was a replication application running at all times, regularly checking these log tables, updating the data to a remote database and pulling in new data from the remote (which had it's own log tables). 而且有一个复制应用程序始终在运行,定期检查这些日志表,将数据更新到远程数据库,并从远程数据库(具有自己的日志表)中提取新数据。 But as a downside it was a horror to maintain as triggers needed to be updated when something changed in the database setup and the replication application would fail/hang at times. 但是不利的一面是,由于数据库设置中发生某些更改而复制应用程序有时会失败/挂起时,需要更新触发器,因此很难维护。 But data consistency was maintained well and resolved by negative IDs being used for local database and positive for master/remote. 但是,数据一致性得到了很好的维护,并通过将负ID用于本地数据库和将正ID用于主数据库/远程数据库来解决。 But in the end it did not really provide real "real-time". 但是最后它并没有真正提供真正的“实时”。

In the end - there is no one-shoe-fits-all answer and books could probably be written on the topic. 最终-没有一个适合所有人的答案,并且很可能就该主题写了一些书。 Research and Google are your friends. Research和Google是您的朋友。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM