[erlang-questions] Simple question about nodes distribution

Chandru <>
Thu May 22 10:24:17 CEST 2008


2008/5/22 Alexander Lamb <>:
> Hello list,
>
> Starting to experiment with multiple nodes (and Mnesia) and already
> stumbling on something:
>
> If I start a node like this:
>
> erl -mnesia -setcookie rodanotech -name 
>
> then a second node like this:
>
> erl -mnesia -setcookie rodanotech -name 
>
> Why, when I ask for nodes() on either system, does it answer with an
> empty list.

-mnesia is not a valid option. You have to have some communication
between the nodes for them to be aware of each other. An erlang node
starting on a host will not automatically know about all other nodes
on that machine. Try net_adm:ping() from 
and then check nodes().

>
> I experimented further with mnesia. I have a schema on node alex. I
> start mnesia.
> Then, on node alex2 I create a mnesia schema and start mnesia.
> Then from the node where Mnesia is running with existing tables I try:
>
> mnesia:add_table_copy(schema,'',disc_copies).
>
> but it fails with: {aborted,{badarg,schema,disc_copies}}
>
> so I try:
>
> mnesia:add_table_copy(profiles,'',disc_copies).
>
> But it also fails this time with: {aborted,
> {}}
>
> I must be getting something wrong initially...
>

If you want to share tables across nodes, the mnesia schema has to be
shared between them. You can do this by specifying the list of all
nodes when first creating the schema (See section 3.3.1 in the mnesia
user guide http://www.erlang.org/doc/apps/mnesia/Mnesia_chap3.html#3
), or you first add the new nodes to the schema before copying tables
across (http://www.erlang.org/doc/apps/mnesia/Mnesia_chap5.html#5.6).

Another thing to understand is if your schema is of type ram_copies,
you cannot have disk based tables.

cheers
Chandru



More information about the erlang-questions mailing list