Erlang Central

Distributing a Mnesia schema/Discless nodes

Revision as of 17:24, 18 July 2006 by (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Disc-less nodes are useful but require some extra steps.

First of all, we have to have a working Mnesia database with a disc_copy of a schema.

erl -sname alpha
> mnesia:create_schema([alpha@localhost]).
> mnesia:start().
> % now create some tables

Next we need to tell mnesia that the disc-less node will exist in the future. To do that we use add_table_copy on the schema.

> % still on alpha
> mnesia:add_table_copy(schema, beta@localhost, ram_copies).

If beta were up and running and received a disk copy of the schema we would be done right now. However, disc-less nodes are a little special and require this extra step. Let's go ahead and start up our beta node. Obviously we need to leave the alpha node running.

erl -sname beta
> mnesia:start().
> mnesia:info().

Notice that mnesia here is completely unaware that it is supposed to be a disc-less node of the system running on alpha. Here's the money line:

> % still on beta
> mnesia:change_config(extra_db_nodes, [alpha@localhost]).
> mnesia:info().

And you should have a working disc-less node running on beta. Enjoy.

Alternatively you can start up beta like this:

erl -sname beta -mnesia extra_db_nodes "[alpha@localhost]"

For more information see .