Mnesia 表复制/共享
假设我们有 N 个 erlang 节点,运行相同的应用程序。 我想 与所有 N 个节点共享 mnesia 表 T1,我认为这没有问题。 但是,我想与节点对共享另一个 mnesia 表 T2。 我的意思是 T2 的内容将相同并复制到/与 只共享一对。 换句话说,我想要 N/2 个不同的内容 T2表。 这对于 mnesia 来说是可能的吗,而不是通过为每个重命名 T2 来实现 不同的节点对?
Assume that we have N erlang nodes, running same application. I want
to share an mnesia table T1 with all N nodes, which I see no problem.
However, I want to share another mnesia table T2 with pairs of nodes.
I mean the contents of T2 will be identical and replicated to/with
only sharing pair. In another words, I want N/2 different contents for
T2 table. Is this possible with mnesia, not with renaming T2 for each
distinct pair of nodes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一张表始终是一张表,无论与多少个节点共享。 如果您希望节点对共享一个表,则必须为每对节点创建一个唯一的表。
不过,您可以对所有这些表使用相同的设置(记录等),因此不应该有太多的工作来完成它。
One table is always one table, no matter how many nodes you share it with. If you want pairs of nodes sharing a table, you would have to create a unique table for each pair of nodes.
You can use the same settings (records etc) for all those tables though, so there shouldn't be so much more work to get it done.
如果使用 mnesia_frag_hash 回调行为,则可以通过 mnesia 的表碎片来实现此目的。 这允许您控制密钥的分配,并且可以构造密钥,以便回调能够确定应使用哪个节点对(以及哪个片段)。
这是否适用于您的特定情况取决于您的访问模式和数据集。 很可能这是一种相当复杂的方法,并且简单地使用不同的表名会更好。
It's possible to do this with mnesia's table fragmentation, if one makes use of the
mnesia_frag_hash
callback behaviour. This allows you to control the distribution of keys, and it would be possible to construct the keys such that the callback is able to determine which node pair (and thus, which fragment) should be used.Whether or not this works in your particular case depends on your access patterns and data set. Chances are that it's a pretty convoluted approach, and that you'd be better served by simply using different table names instead.