mnesia node replication
Fredrik Thulin
<
>
Wed Apr 26 08:09:50 CEST 2006
On Tuesday 25 April 2006 22:02, Tony Zheng wrote:
> Hi
>
> I created two mnesia nodes(
and
) and they can
> replicate very well. I want to add a new node on
> server3(
) and make it to replicate all data from
>
or
, how can I do it?
> I used mnesia:create_schema([
]) and
> mnesia:add_table_copy(Tab,
, Type), but it didn't work.
>
> Thanks.
>
> tony
Roughly (on
) :
mnesia:start(),
mnesia:change_config(extra_db_nodes, [MasterNode]),
DiscC = mnesia:table_info(Table, disc_copies),
case lists:member(node(), DiscC) of
true ->
%% table already present on node
ok;
false ->
RamC = mnesia:table_info(Table, ram_copies),
case lists:member(node(), RamC) of
true ->
mnesia:change_table_copy_type(Table, node(),
disc_copies);
false ->
mnesia:add_table_copy(Table, node(), disc_copies)
end
end.
That is how I do it in YXA (see src/bootstrap.erl). It converts RAM
copies to disc copies, or just add a disc copy if table is not present
on node().
/Fredrik
More information about the erlang-questions
mailing list