Search code examples
erlangmnesia

Is it possible to run Mnesia with out replication in a cluster


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.


Solution

  • 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.