什么是Mnesia复制策略?

cit*_*txx 4 erlang mnesia

  1. Mnesia使用什么策略来定义将存储特定表副本的节点?
  2. 我可以强制Mnesia为每个表使用特定数量的副本吗?可以动态更改此数字吗?
  3. 是否有任何资源(除了源代码之外)都具有Mnesia内部算法的详细说明(而不仅仅是概述)?

ers*_*zcz 5

  1. 手册。您负责指定复制到何处。
  2. 是的,如上所述,手动操作。可以动态更改。
  3. 恐怕(尽管可能是错误的)除了源代码外,没有其他东西。就文档而言,整个Erlang发行版几乎不是软件领域的领导者。

Mnesia does not automatically manage the number of replicas of a given table. You are responsible for specifying each node that will store a table replica (hence their number). A replica may be then:

  • stored in memory,
  • stored on disk,
  • stored both in memory and on disk,
  • not stored on that node - in this case the table will be accessible but data will be fetched on demand from some other node(s).

It's possible to reconfigure the replication strategy when the system is running, though to do it dynamically (based on a node-down event for example) you would have to come up with the solution yourself.

The Mnesia system events could be used to discover a situation when a node goes down; given you know what tables were stored on that node you could check the number of their online replicas based on the nodes which were still online and then perform a replication if needed.

I'm not aware of any application/library which already manages this kind of stuff and it seems like a quite an advanced (from my point of view, at least) endeavor to make one.

However, Riak is a database which manages data distribution among it's nodes transparently from the user and is configurable with respect to the options you mentioned. That may be the way to go for you.