[erlang-questions] Mnesia distributed fragmented table
Hakan Mattsson
<
>
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> (
and
) and with 20 fragments. I need all 20
EU> fragments in
, so that even if the
goes down,
EU> still I can use the full database in
When both the nodes
EU> are available, any update to test_table in
will get
EU> reflected in
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
and
(
)9> mnesia:create_table(t, [{frag_properties, [{n_fragments, 20},
{node_pool, [
]},
{n_ram_copies, 2}]}]).
{atomic,ok}
(
)10> [{T, mnesia:table_info(T, ram_copies)} || T <- mnesia:system_info(tables),
lists:prefix("t", atom_to_list(T))].
[{t,[
]},
{t_frag2,[
]},
{t_frag3,[
]},
{t_frag4,[
]},
{t_frag5,[
]},
{t_frag6,[
]},
{t_frag7,[
]},
{t_frag8,[
]},
{t_frag9,[
]},
{t_frag10,[
]},
{t_frag11,[
]},
{t_frag12,[
]},
{t_frag13,[
]},
{t_frag14,[
]},
{t_frag15,[
]},
{t_frag16,[
]},
{t_frag17,[
]},
{t_frag18,[
]},
{t_frag19,[
]},
{t_frag20,[
]}]
/Håkan
More information about the erlang-questions
mailing list