Automatic mixed mode H2 with shared store JDBC Url 自动混合模式H2共享存储JDBC网址

huangapple go评论48阅读模式
英文:

Automatic mixed mode H2 with shared store JDBC Url

问题

建议使用基于网络的共享存储文件系统来创建和使用H2生成的DB文件,以实现持久的自动混合模式吗?

我有一个用于高可用性的服务器集群,所有节点都可以访问同一个共享目录,该目录位于网络附加存储中:jdbc:h2:file:\\networkstore\h2dir
这样,即使一个节点崩溃,集群仍然可以正常工作,因为另一个节点将成为主节点,并以嵌入模式加载DB。然而,如果网络连接在某个时刻中断,那么嵌入式服务器将失去与DB的连接。此外,已经观察到连接问题可能会导致数据库损坏,可能是由于DB文件中的部分写入引起的?我甚至能够通过拔掉以太网电缆来损坏H2文件。

自动混合模式是否应该在一组主应用程序的集群中使用,而不是在具有单个主节点的多服务应用程序中使用?

英文:

Is it recommended to use a network based shared storage file system to create and use the DB files generated by H2 in persistent automatic mixed mode?

I have a server cluster for high availability and all nodes view the same shared directory which is located in a network attached store: jdbc:h2:file:\\networkstore\h2dir.
This lets the cluster work fine even if a node crashes because another node will become the primary node and load the DB in embedded mode. However, if the network connection fails at some point then the embedded server loses DB connectivity. Additionally, it has been observed that connectivity issues can end up corrupting the database, maybe due to partial writes in the DB file? I have been able to corrupt the H2 file just by playing around with my ethernet cable.

Is automatic mixed mode supposed to be used in a cluster of Primary Applications instead of a multiservice application with a single primary node?

答案1

得分: 0

  1. 不管你选择哪种数据库管理系统,将数据库文件存储在网络文件系统上都是一个非常不明智的做法,数据库需要可靠的文件系统。
  2. H2 中的自动混合模式实际上并不安全,并且不支持从不同主机访问同一数据库。
  3. 如果你的应用程序可能会崩溃,不要在其中使用嵌入式的 H2,而应该使用与数据库服务器的远程连接。

你需要在可靠的主机上启动一个独立的 H2 服务器进程,并从你的节点使用客户端连接它。你还可以使用 H2 的集群功能来启动多个数据库服务器,但这个特性基本上没有维护,并且存在各种限制。也有第三方解决方案,如 HA-JDBC。另外,H2 可能并不适合你的需求。

英文:
  1. It's a very bad idea to store database files on network file systems, no matter which DBMS you choose, databases need reliable file systems.
  2. Automatic mixed mode in H2 isn't really safe and it doesn't support access to the same database from different hosts.
  3. If your application can crash, don't use embedded H2 in it, use remote connections to database server.

You need to start a standalone H2 Server process on some reliable host and use client connections to it from your nodes. You can also to use clustering capabilites of H2 to start more than one database server, but this feature is basically unmaintained and has various limitations. There are also third-party solutions such as HA-JDBC. It is also possible that H2 isn't really suitable for your needs.

huangapple
  • 本文由 发表于 2023年6月12日 23:41:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76458237.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定