[erlang-questions] Simple question about nodes distribution

Chandru chandrashekhar.mullaparthi@REDACTED
Thu May 22 10:24:17 CEST 2008


2008/5/22 Alexander Lamb <alexander.lamb@REDACTED>:
> 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 alex@REDACTED
>
> then a second node like this:
>
> erl -mnesia -setcookie rodanotech -name alex2@REDACTED
>
> 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(alex2@REDACTED) from alex@REDACTED
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,'alex2@REDACTED',disc_copies).
>
> but it fails with: {aborted,{badarg,schema,disc_copies}}
>
> so I try:
>
> mnesia:add_table_copy(profiles,'alex2@REDACTED',disc_copies).
>
> But it also fails this time with: {aborted,
> {not_active,schema,alex2@REDACTED}}
>
> 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