[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>
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:
http://www.erlang.org/doc/apps/mnesia/Mnesia_chap5.html#5.3
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}]}]).
{atomic,ok}
(a@REDACTED)10> [{T, mnesia:table_info(T, ram_copies)} || T <- mnesia:system_info(tables),
lists:prefix("t", atom_to_list(T))].
[{t,[b@REDACTED,a@REDACTED]},
{t_frag2,[b@REDACTED,a@REDACTED]},
{t_frag3,[b@REDACTED,a@REDACTED]},
{t_frag4,[b@REDACTED,a@REDACTED]},
{t_frag5,[b@REDACTED,a@REDACTED]},
{t_frag6,[b@REDACTED,a@REDACTED]},
{t_frag7,[b@REDACTED,a@REDACTED]},
{t_frag8,[b@REDACTED,a@REDACTED]},
{t_frag9,[b@REDACTED,a@REDACTED]},
{t_frag10,[b@REDACTED,a@REDACTED]},
{t_frag11,[b@REDACTED,a@REDACTED]},
{t_frag12,[b@REDACTED,a@REDACTED]},
{t_frag13,[b@REDACTED,a@REDACTED]},
{t_frag14,[b@REDACTED,a@REDACTED]},
{t_frag15,[b@REDACTED,a@REDACTED]},
{t_frag16,[b@REDACTED,a@REDACTED]},
{t_frag17,[b@REDACTED,a@REDACTED]},
{t_frag18,[b@REDACTED,a@REDACTED]},
{t_frag19,[b@REDACTED,a@REDACTED]},
{t_frag20,[b@REDACTED,a@REDACTED]}]
/Håkan
More information about the erlang-questions
mailing list