sqlite 数据库的点对点复制
我正在寻找一种方法来跨同行复制小型且简单的关系数据库(如 SQLite)。这应该在网络连接不稳定的环境中工作,因此每个对等点都需要拥有数据库的完整副本。这应该允许对等点在网络故障时继续离线工作。
为了简单起见,复制应该只支持添加数据的复制,即仅支持插入,而不支持删除或更新。
有谁知道创建这样一个系统的良好且理想的跨平台技术或方法?我目前正在研究 JXTA 和 JXSE,但我对其复杂性以及 Oracle 收购 Sun 后其社区明显缺乏活力感到犹豫。
I am looking for a way to replicate a small and simple relational database (like SQLite) across peers. This should work in an environment with unstable network connections, hence the need for each peer to have a full copy of the database. This should allow a peer to continue working off-line in the event of network failure.
To keep things simple, replication should only have to support the replication of addition of data, i.e. only INSERTs, not DELETEs or UPDATEs.
Does anyone know of a good - and ideally cross-platform - technology or method of creating such a system? I am currently looking at JXTA and JXSE, but I am put off by its complexity and apparant lack of life in its community after the takeover of Sun by Oracle.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
rqlite 使用 raft 共识算法,因此它对于不稳定的网络连接应该具有相当的弹性。
另外,似乎可以将 rqlite 配置为 接受读取< /a> 即使在网络故障的情况下。
类似的项目 dqlite 作为一个库存在,提供多种语言版本,但似乎不太明确网络故障的情况。
rqlite uses the raft consensus algorithm, so it should be fairly resilient to unstable network connection.
Also, it seems to be possible to configure rqlite to accept reads even in the case of a network failure.
A similar project, dqlite, exists as a library, available in various languages, but it seems less explicit about the event of a network failure.
如果您不喜欢 JXTA,您可能需要探索通信层的 JGroups。对于复制,我认为您必须实现自己的代码。
You may want to explore JGroups for the communication layer if you don't like JXTA. For the replication, I think you will have to implement your own code.
我正在做类似的事情(尽管代码还远没有准备好)。我将描述一些关于我的预期方法,但这是否适合您取决于您需要考虑的一些关键设计点。不幸的是,我不知道有任何现成的项目可以做到这一点。
如果您能够使用 PHP,并且愿意手动对等节点对,那么我的方法可能会感兴趣。设置一个 ORM,例如 Doctrine、Propel 或 NotORM,并让每个节点定期与互联网时间源同步。对于数据库中的每个新行,获取数据(在数组或 ORM 对象中),将其序列化,并将其推送到与您有信任关系的所有节点。如果推送失败,请记录下来并定期重试(在远程节点无法回答大量重试后可能会放弃)。
推送可以由创建行的应用程序启动,也可以由每台计算机上可用的任何调度程序调用。推送消息可以是 XML,或者为了简单起见可以只是包含新行和任何元数据(例如保存的时间戳,以便解析来自多个节点的 INSERT 顺序)的 POST 消息。
如果您的节点没有静态 IP 地址,则可以使用动态 DNS 寻址服务注册它们,以便每个节点即使 IP 发生变化也可以与对等节点保持联系。您还可以考虑添加消息签名系统,以确保节点之间的消息是真实的。
I am working on something similar (though the code is far from ready). I'll describe a little about my intended approach, but whether that is suitable for you depends on some key design points you'd need to consider. I am not aware of any ready-built projects that will do this, unfortunately.
If you are able to use PHP, and are happy manually peering node pairs, then my approach may be of interest. Set up an ORM such as Doctrine, Propel or NotORM, and get each node to regularly sync with an internet time source. For each new row in a db, grab the data (either in an array or ORM object), serialise it, and push it out to all nodes that you have a trust relationship with. Where a push fails, keep a note of this and retry at periodic intervals (potentially giving up after a remote node fails to answer a large number of retries).
Pushes can either be kicked off by your application that creates the row, or can be called by whatever scheduler is available on each machine. A push message can be XML, or for simplicity can be just a POST message containing the new row and whatever metadata (e.g. timestamp of save, so as to resolve INSERT order from several nodes).
If your nodes do not have static IP addresses, they could be registered with a dynamic DNS addressing service so as to allow each node to stay in touch with peers even if their IP changes. You might also consider adding a message signing system, to ensure that messages between nodes are genuine.