我想你可能是指replicated
桌子。假设您的 mnesia 表位于节点上:[email protected] /cdn-cgi/l/email-protection
with -setcookie mycookie
,无论是否在另一个节点上复制,如果我想从另一个终端访问记录,那么我也必须在另一个终端中使用 erlang 通过创建一个节点,将该节点连接到我们的节点与表(你确保它们都有相同的 cookie),然后调用远程节点上的方法。
假设您想使用一种方法add_record
在模块中mydatabase.erl
在节点上[email protected] /cdn-cgi/l/email-protection
其中有 mnesia 表,我打开一个 Linux 终端并输入以下内容:
$ erl -name [email protected] /cdn-cgi/l/email-protection -setcookie mycookie
Eshell V5.8.4 (abort with ^G)
1> N = '[email protected] /cdn-cgi/l/email-protection'.
'[email protected] /cdn-cgi/l/email-protection'
2> net_adm:ping(N).
pong
3> rpc:call(N,mydatabase,add_record,[RECORD]).
{atomic,ok}
4>
有了这个模块(rpc
),如果两个节点使用相同的 cookie 连接,则可以调用远程节点上的任何方法。首先在远程节点上调用此方法:
rpc:call('[email protected] /cdn-cgi/l/email-protection',mnesia,info,[]).
It should display everything in your remote terminal. I suggest that probably, you first go through this lecture:
Distributed Erlang Programming http://learnyousomeerlang.com/distribunomicon#setting-up-an-erlang-cluster and then you will be able to see how replicated mnesia tables are managed. Go through that entire tutorial on that domain.