Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't think this can be done online on a single node(anyone?), but it is possible to do via a backup/restore in addition to running two nodes and adding table copies. In the <a href="http://erlang.org/doc/apps/mnesia/part_frame.html" rel="noreferrer">Mnesia User's guide</a> section 6.9.1 you'll find some code that uses mnesia:traverse_backup to alter the node names in the schema table (Shown below) in an mnesia backup file. The module name you should probably use is <code>mnesia_backup</code>.</p> <p>With this code you'll need to:</p> <pre><code>%% On mypl@machine1 mnesia:backup("/path/to/mnesia.backup"). change_node_name(mnesia_backup, mypl@machine1, mypl@machine2, "/path/to/mnesia.backup", "/path/to/new.mnesia.backup"). %% On mypl@machine2 mnesia:restore("/path/to/new.mnesia.backup", []). </code></pre> <p>I'm not sure if you need to create the schema first on <code>mypl@machine2</code>.</p> <p>The change node name code from the user's guide:</p> <pre><code>change_node_name(Mod, From, To, Source, Target) -&gt; Switch = fun(Node) when Node == From -&gt; To; (Node) when Node == To -&gt; throw({error, already_exists}); (Node) -&gt; Node end, Convert = fun({schema, db_nodes, Nodes}, Acc) -&gt; {[{schema, db_nodes, lists:map(Switch,Nodes)}], Acc}; ({schema, version, Version}, Acc) -&gt; {[{schema, version, Version}], Acc}; ({schema, cookie, Cookie}, Acc) -&gt; {[{schema, cookie, Cookie}], Acc}; ({schema, Tab, CreateList}, Acc) -&gt; Keys = [ram_copies, disc_copies, disc_only_copies], OptSwitch = fun({Key, Val}) -&gt; case lists:member(Key, Keys) of true -&gt; {Key, lists:map(Switch, Val)}; false-&gt; {Key, Val} end end, {[{schema, Tab, lists:map(OptSwitch, CreateList)}], Acc}; (Other, Acc) -&gt; {[Other], Acc} end, mnesia:traverse_backup(Source, Mod, Target, Mod, Convert, switched). </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload