[erlang-questions] Mnesia distributed fragmented table

Hakan Mattsson hakan@REDACTED
Fri Aug 3 16:02:56 CEST 2007

On Fri, 3 Aug 2007, Eranga Udesh wrote:

EU> How do I create a fragmented distributed table in multiple Erlang nodes,
EU> where each node will have the full set of fragments, so that even without
EU> other nodes, that node can run in isolation?
EU> For eg. I want to create test_table distributed in 2 Erlang nodes
EU> (node1@REDACTED and node2@REDACTED) and with 20 fragments. I need all 20
EU> fragments in node1@REDACTED, so that even if the node2@REDACTED goes down,
EU> still I can use the full database in node1@REDACTED When both the nodes
EU> are available, any update to test_table in node1@REDACTED will get
EU> reflected in node2@REDACTED and vice versa (distributed).

Read about n_fragments, node_pool and n_ram_copies in the
Mnesia Users Guide in the chapter about fragmented tables:


The following create_table command creates a table with
20 fragments where each fragment has a ram_copies
replica on both node a@REDACTED and b@REDACTED 

  (a@REDACTED)9> mnesia:create_table(t, [{frag_properties, [{n_fragments, 20},
                                                         {node_pool, [a@REDACTED,b@REDACTED]},
                                                         {n_ram_copies, 2}]}]).
  (a@REDACTED)10> [{T, mnesia:table_info(T, ram_copies)} || T <- mnesia:system_info(tables),
                                                         lists:prefix("t", atom_to_list(T))].


More information about the erlang-questions mailing list