i assume that you probably meant replicated
table. Suppose you have your mnesia table on node: nodea@127.0.0.1
with -setcookie mycookie
, whether its replicated on another node or not, if i want to access the records from another terminal, then i have to use erlang in this other terminal as well by creating a node, connecting this node to our node with the table (you ensure that they all have the same cookie), then you call a method on the remote node.
Lets say you want to use a method add_record
in module mydatabase.erl
on the node nodea@127.0.0.1
which is having the mnesia table, the i open a linux terminal and i enter the following:
$ erl -name remote@127.0.0.1 -setcookie mycookie
Eshell V5.8.4 (abort with ^G)
1> N = 'nodea@127.0.0.1'.
'nodea@127.0.0.1'
2> net_adm:ping(N).
pong
3> rpc:call(N,mydatabase,add_record,[RECORD]).
{atomic,ok}
4>
with this module (rpc
), you can call any method on a remote node, if the two nodes are connected using the same cookie. start by calling this method on the remote node:
rpc:call('nodea@127.0.0.1',mnesia,info,[]).
It should display everything in your remote terminal. I suggest that probably, you first go through this lecture:
Distributed Erlang Programming and then you will be able to see how replicated mnesia tables are managed. Go through that entire tutorial on that domain.