Question

I would like to know, if i can run Mnesia with out replication. Say i have cluster of nodes one of the nodes host mNesia server with disc-copies - lets call this node as mNode. The remaining nodes(Service Nodes) should load the schema from the mNode and should not maintain any local copy.

I looked at mNesia documentation but could not find a way to do that.

Was it helpful?

Solution 2

Read the documentation http://www.erlang.org/doc/apps/mnesia/Mnesia_chap5.html#id76406 Disc-less Nodes section talks about how to implement this use case. Below steps setup such environment.

 1. Start mNode
 erl -sname m_node -mnesia dir "/tmp/funky/"

 2.Start Service node
 erl -sname s1

 3. Create Cluster 
 net_adm:ping('s1@_)').

 4. On m_node run 
  mnesia:change_config(extra_db_nodes, ['s1@_']).  
  mnesia:create_table(funky, []).

 5. On s1 node 
   mnesia:start().
   mneisa:info().

  remote             = [funky]     // Points to Remote table funky on node m_node
  ram_copies         = [schema]    // Ram copy of schema is kept in each service node.

OTHER TIPS

Yes! You create the schema over all the nodes but define the tables to only have ram/disc copies on the m_node. In this way they can reached from all the nodes but only store data on one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top