Moving mnesia schema to another node

Erik Pearson erik@REDACTED
Fri Jan 11 20:05:56 CET 2002


Thanks for the pointer. I just returned from winter holiday and will apply 
this technique shortly. It seems like an awfully inefficient way of 
changing just the node for a table, especially if one is dealing with large 
tables.

(Should there not be a simpler technique for moving disc based tables from 
one node to another? E.g. substitution of table attributes at either backup 
or restore (and a table creation option for restore))

Erik.

--On Tuesday, December 25, 2001 9:17 AM +0000 Chandrashekhar Mullaparthi 
<Chandrashekhar.Mullaparthi@REDACTED> wrote:

> Look in the Mnesia user guide in Section 6.9.1
>
> The following example illustrates how mnesia:traverse_backup can be used
> to rename a db_node in a backup file:
>
> change_node_name(Mod, From, To, Source, Target) ->
>     Switch =
>         fun(Node) when Node == From -> To;
>            (Node) when Node == To -> throw({error, already_exists});
>            (Node) -> Node
>         end,
>     Convert =
>         fun({schema, db_nodes, Nodes}, Acc) ->
>                 {[{schema, db_nodes, lists:map(Switch,Nodes)}], Acc};
>            ({schema, version, Version}, Acc) ->
>                 {[{schema, version, Version}], Acc};
>            ({schema, cookie, Cookie}, Acc) ->
>                 {[{schema, cookie, Cookie}], Acc};
>            ({schema, Tab, CreateList}, Acc) ->
>                 Keys = [ram_copies, disc_copies, disc_only_copies],
>                 OptSwitch =
>                     fun({Key, Val}) ->
>                             case lists:member(Key, Keys) of
>                                 true -> {Key, lists:map(Switch, Val)};
>                                 false-> {Key, Val}
>                             end
>                     end,
>                 {[{schema, Tab, lists:map(OptSwitch, CreateList)}], Acc};
>            (Other, Acc) ->
>                 {[Other], Acc}
>         end,
>     mnesia:traverse_backup(Source, Mod, Target, Mod, Convert, switched).
>
> view(Source, Mod) ->
>     View = fun(Item, Acc) ->
>                    io:format("~p.~n",[Item]),
>                    {[Item], Acc + 1}
>            end,
>     mnesia:traverse_backup(Source, Mod, dummy, read_only, View, 0).
>
> cheers,
> Chandru
>
>> -----Original Message-----
>> From: Erik Pearson [mailto:erik@REDACTED]
>> Sent: 25 December 2001 02:19
>> To: erlang-questions@REDACTED
>> Subject: Moving mnesia schema to another node
>>
>>
>> Hi,
>>
>> I need to move a mnesia database from one node to another,
>> and haven't been
>> able to figure out how. Mnesia is okay if you move it around
>> on the same
>> machine (different directories), but doesn't like to be moved
>> to another
>> machine -- (e.g. tar it up and untar it somehwere else) --
>> even if the
>> database directory is accessed via a generic directory name
>> through an
>> explicit -mnesia dir 'dirname' or -config configfile.
>>
>> I've also tried restoring from a backup, but stopped that
>> after it ate up
>> all CPU on the server. I also tried using install_fallback,
>> but mnesia
>> complains with
>>
>> {"No disc resident schema on local node", [myoldnode]}
>>
>> The backup seems to keep a reference to the old node, and
>> doens't like to
>> be restored anywhere else...
>>
>> Does anyone know how to do a "redirected backup and restore"
>> from one node
>> to another?
>>
>> Thanks,
>>
>> Erik Pearson
>>
>
>
>
> NOTICE AND DISCLAIMER:
> This email (including attachments) is confidential.  If you have received
> this email in error please notify the sender immediately and delete this
> email from your system without copying or disseminating it or placing any
> reliance upon its contents.  We cannot accept liability for any breaches
> of confidence arising through use of email.  Any opinions expressed in
> this email (including attachments) are those of the author and do not
> necessarily reflect our opinions.  We will not accept responsibility for
> any commitments made by our employees outside the scope of our business.
> We do not warrant the accuracy or completeness of such information.
>



Erik Pearson
@ Adaptations
email     : erik@REDACTED
voice/fax : +1 510 527 5437
text page : page.erik@REDACTED




More information about the erlang-questions mailing list