<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Hi Yash,</span><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">(forwarding my reply to the list this time to see if there is any feedback on this advice)</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Unfortunately the mnesia schema lists which nodes are associated with which tables.  In your case your new node (node2) will look at the schema and know that it does not have any tables.  It would be able to have remote access to the tables if node1 was still running, but this does not suit your use case.</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">If you want to move a mnesia database from one node to another, I have found that you need to follow there are three steps:</div>
<div style="font-family:arial,sans-serif;font-size:13px">1) backup the current database with mnesia:backup</div><div style="font-family:arial,sans-serif;font-size:13px">2) rewrite the schema table in your backup (to replace node1 with node2) using mnesia:traverse_backup </div>
<div style="font-family:arial,sans-serif;font-size:13px">3) restore the backup to your new node with mnesia:restore</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
For step 2, see the function change_node_name in the code example in <a href="http://www.erlang.org/doc/apps/mnesia/Mnesia_chap7.html#id78880" target="_blank">http://www.erlang.org/doc/apps/mnesia/Mnesia_chap7.html#id78880</a> </div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Regards</div><div style="font-family:arial,sans-serif;font-size:13px">Philip</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Sep 23, 2013 at 7:58 AM, Yash Ganthe <span dir="ltr"><<a href="mailto:yash_ganthe@persistent.co.in" target="_blank">yash_ganthe@persistent.co.in</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">






<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">On a node named node1@localhost I created an Mnesia schema using:<u></u><u></u></p>
<p class="MsoNormal">mnesia:create_schema([node()]).<u></u><u></u></p>
<p class="MsoNormal">and created a table using:<u></u><u></u></p>
<p class="MsoNormal">mnesia:create_table(tab1, [{disc_copies, [node()]}, {attributes, record_info(fields, tab1)}]).<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The mnesia directory was set to "mnesia_node1". The directory was created and the DB files were created inside it.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Once the node was stopped, the DB files still exist in the directory. I hoped to re-use the DB as the mnesia DB for another node, node2.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">So I started the other node using:<u></u><u></u></p>
<p class="MsoNormal">erl -name node2 -mnesia dir "mnesia_node1".<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">On node2 when I start mnesia and do a tv:start(), I see the tab1 listed in the schema. However, it shows no records. I was expecting Mnesia to use the directory as the location of all DB files.<u></u><u></u></p>

<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Is there something I have missed?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal">Yash<u></u><u></u></p>
</div>
<p>DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.
</p>
</div>

<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>