将 Berkeley DB 与 Mysql 同步
我有一个遗留系统,已移植到现代系统并使用伯克利数据库。它是用 open cobol 编译的。
在以前的系统中,序列化的固定数据 CISAM 文件每天使用 ACCESS 宏转换一次到 Microsoft 数据库,以便从简单的 Web 前端使用。(一种方式) 我想创建一个新的 Web 前端,并且希望数据实时更新...
问题是berkeley数据库是键值数据库,不支持sql。
所以这里的问题是 我应该创建一个使用 Berkeley 数据库向 Web 前端提供数据的 Web 服务吗? 或者 我应该将伯克利数据库与关系数据库(Mysql,postgresql)同步吗?
在第一种情况下,不会有同步问题。但问题是灵活性非常有限......例如,按未索引的列排序需要自定义排序功能...对某些字段求和需要读取所有记录数据,然后手动求和。
在第二种情况下,简单的方法是读取并转换为数据库。我无法找到一种方法来检查已更新的内容...插入或删除的内容。
但我更倾向于第二种方法..使用以下算法 每 5 分钟检查一次文件修改日期... 打开已修改的文件...然后获取所有键并与缓存的键数组进行比较。 然后循环遍历每条记录并检查数据哈希是否与缓存哈希相同。
然后删除/插入..
还有其他想法吗?
I have a legacy system that has been ported to a modern system and uses berkeley database. It is compiled with open cobol.
In the previous system the serialized fixed data CISAM files were converted one time per day to microsoft database using ACCESS macros in order to be used from a simple web front end.(one way)
I want to create a new web front end and i want data to be real time updated...
The problem is that berkeley database is key value database and doesnt support sql.
So the problem here is
Should i create a web service that provides data to the web front end using Berkeley database ?
OR
Should i synchronize berkeley database with a relational Database (Mysql,postgresql)
In the first case there wouldnt be a synchronization issue.But the problem is that flexibility is very limited... For example sorting by a collumn that it is not indexed requires custom sorting function... Summing some fields requires reading all the record data and then summing manually..
In the second case the simple way is to just read and convert to database . I cant figure out a way to check what has been updated...inserted or deleted.
But i tend more to second method.. using the following algorithm
Check every 5 minutes the file modifation date...
Open files that have been modified... Then get all the keys and compare to cached keys array.
Then loop through each record and check if data hash is the same with cached hash.
Then delete/insert ..
ANy other ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为什么不将源代码引入 berkely-db 数据库驱动系统,并找到一种方法来编写 SOAP 查询并使用该应用程序处理它。现在您有了一个可以直接读取此 BSDDB 的 Web 服务,并且不需要同步。
即使您没有原始应用程序的源代码,如果您可以自己弄清楚如何解压 BSDDB 键/值存储的内容,您也可以轻松地(例如使用 Python)编写一个简单的 Web 服务应用程序使用 SOAP 提供 BSDDB 数据库的内容。我将首先编写几行 Python 代码来打开 BSDDB 值,并转储键值及其关联的有效负载。 (“值”值,如果您愿意的话)。
Why not take the source code to the berkely-db database driven system, and find a way to write a SOAP query and handle it using that application. Now you have a web service that can read this BSDDB directly and you don't need synchronization.
Even if you DON'T have the source code for the original application, if you can figure out how to unpack the content of the BSDDB key/value store yourself, you could easily (in Python for example) write a simple web service app that serves up the contents of your BSDDB database using SOAP. I would start by writing a few lines of Python that open up the BSDDB value, and dumps the Key-values, and their associated payloads. (The "Value" values, if you like).
您的选择是拥有两个存储库并同步它们,或者让您的 Web 应用程序直接向/从 Berkeley DB 键值数据存储显示和存储数据。
如果您决定使用单独的 RDBMS 存储库来维护和同步 Berkeley DB 中以键值格式存储的数据,那么您需要编写一个可以为您执行同步的应用程序。键值数据存储和 RDBMS 数据存储之间的映射需要由同步应用程序按照您已经概述的方式执行。您可以按照您的建议扫描/比较/对比两个存储库,也可以创建一个可以通过同步读取和应用的“应用程序数据日志”。这种方法的问题是您最终可能会花费大量时间和精力来尝试同步两个存储库。
另一种选择是编写 Web 应用程序,以便它可以直接与 Berkeley DB 存储库通信(如 Warren 建议的那样)。有多种脚本语言具有 Berkeley DB 绑定(Perl、PHP、Python、TCL 和 Ruby 等)。如果让 Web 应用程序直接与 Berkeley DB 存储库通信是一个问题,那么您始终可以编写一个简单的服务器应用程序,它与 BDB 存储库通信并可以处理来自 Web 应用程序的 HTTP 请求(基本上是 Warren 建议的 SOAP 解决方案) 。
我认为您会发现从长远来看,拥有一个存储库更容易管理,即使这意味着短期内需要一些额外的应用程序开发工作。
Your choices are to have two repositories and synchronize them or make your web application display and store data directly to/from the Berkeley DB key-value data store.
If your your decision is to maintain and synchronize the data stored in a key-value format within Berkeley DB with a separate RDBMS repository then you'll need to write an application that can perform the synchronization for you. The mapping between the key-value data store and the RDBMS data store will need to be performed by your synchronization application along the lines that you've already outlined. You can either scan/compare/contrast the two repositories as you propose or create an "application data log" that can be read and applied by your synchronization. The problem with this approach is that you may end up spending a lot of time and effort trying to synchronize the two repositories.
Another option is to write your Web application so that it can communicate directly with the Berkeley DB respository (as suggested by Warren). There are several scripting languages that have Berkeley DB bindings (Perl, PHP, Python, TCL and Ruby to mention a few). If having the web application communicate with the Berkeley DB repository directly is a problem, you can always write a simple server application which talks to the BDB repository and that can process HTTP requests from the web application (basically, the SOAP solution suggested by Warren).
I think that you'll find that having a single repository is much easier to manage in the long run, even if it means some additional application development work in the short run.
嗯,Berkeley DB 确实有 SQL API(自 2010 年春季起)。请参阅 http://www.oracle.com/technetwork/database/berkeleydb /overview/index.html 了解更多详细信息。
另外,我建议将您的问题发布到 Berkeley DB 论坛
http://forums.oracle.com/forums/forum.jspa?forumID=271
Well, Berkeley DB does have an SQL API (since spring 2010). Please see http://www.oracle.com/technetwork/database/berkeleydb/overview/index.html for more details.
Also, I'd recommend posting your question to the Berkeley DB forum
http://forums.oracle.com/forums/forum.jspa?forumID=271