Erlang Central

Difference between revisions of "Distributing a Mnesia schema/Discless nodes"

From ErlangCentral Wiki

(changed beta to kappa. "beta" is confusing on first read. Overloaded word.)
m (fixed link at buttom of page)
Line 31:Line 31:
  erl -sname kappa -mnesia extra_db_nodes "[alpha@localhost]"
  erl -sname kappa -mnesia extra_db_nodes "[alpha@localhost]"
For more information see .
For more information see  
 + .

Revision as of 16:56, 14 November 2007

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, kappa@localhost, ram_copies).

If kappa 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 kappa node. Obviously we need to leave the alpha node running.

erl -sname kappa
> 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 kappa
> mnesia:change_config(extra_db_nodes, [alpha@localhost]).
> mnesia:info().

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

Alternatively you can start up kappa like this:

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

For more information see .