Distributing a Mnesia schema/Discless nodes
From Erlang Community
| Revision as of 17:24, 18 July 2006 (edit) 213.171.204.166 (Talk) ← Previous diff |
Current revision (16:56, 14 November 2007) (edit) (undo) Telarson (Talk | contribs) m (fixed link at buttom of page) |
||
| (One intermediate revision not shown.) | |||
| Line 11: | Line 11: | ||
| > % still on alpha | > % still on alpha | ||
| - | > mnesia:add_table_copy(schema, | + | > mnesia:add_table_copy(schema, kappa@localhost, ram_copies). |
| - | If | + | 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 | + | erl -sname kappa |
| > mnesia:start(). | > mnesia:start(). | ||
| > mnesia:info(). | > mnesia:info(). | ||
| Line 21: | Line 21: | ||
| 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: | 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 | + | > % still on kappa |
| > mnesia:change_config(extra_db_nodes, [alpha@localhost]). | > mnesia:change_config(extra_db_nodes, [alpha@localhost]). | ||
| > mnesia:info(). | > mnesia:info(). | ||
| - | And you should have a working disc-less node running on | + | And you should have a working disc-less node running on ''kappa''. Enjoy. |
| - | Alternatively you can start up | + | Alternatively you can start up ''kappa'' like this: |
| - | erl -sname | + | erl -sname kappa -mnesia extra_db_nodes "[alpha@localhost]" |
| - | For more information see http://erlang.org/ | + | For more information see |
| + | http://www.erlang.org/documentation/doc-5.0.1/lib/mnesia-3.9.2/doc/html/Mnesia_chap5.html#5.5 . | ||
Current revision
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 http://www.erlang.org/documentation/doc-5.0.1/lib/mnesia-3.9.2/doc/html/Mnesia_chap5.html#5.5 .

Digg It
Del.icio.us
Reddit
Facebook
Stumble Upon
Technorati

