[erlang-questions] Mnesia clustering script

Erik Hoogeveen erik.h.hoogeveen@REDACTED
Mon Oct 13 12:10:41 CEST 2014


I am trying to automate the procedure for a MongooseIM node to join another node. More precisely I’m trying to automate the procedure described here: https://github.com/esl/MongooseIM/wiki/Cluster-configuration-and-node-management#connecting-nodes

I've made a small function that executes the logic to copy the tables and then stop the VM it looks like this:

join_cluster_node([Node]) ->
	io:format("Node: ~p", [Node]),
	case net_adm:ping(list_to_atom(Node)) of
		pang ->
			io:format("Node: ~p is not reachable", [Node]);
		pong ->
			connect_node(list_to_atom(Node))
	end,
	init:stop().

connect_node(OtherNode) ->
	mnesia:start(),
	{ok, [OtherNode]} = mnesia:change_config(extra_db_nodes, [OtherNode]),
	mnesia:change_table_copy_type(schema, node(), disc_copies),
	Result = [mnesia:add_table_copy(Tab, node(), ram_copies) ||
    Tab <- [
    	acl,
    	config,
    	iq_response,
    	local_config,
    	node,
    	route,
    	s2s,
        session,
        sql_pool,
        component,
        offline_jingle,
        presence_subscription]],
    stopped = mnesia:stop().


I invoke this bit of code like this:

erts-6.1/bin/erlexec -boot releases/start_clean -mode embedded -config etc/app.config -args_file etc/vm.args -noshell -run admin join_cluster_node mongooseim@REDACTED — console_clean

This is run before the node starts for the first time.

When ran it works for the most part. Everything works fine except that the connecting node doesn’t write the Mnesia.mongooseim@REDACTED folder.

So when the connecting node starts it still thinks it’s all alone in the universe. As shown by amnesia info:
running db nodes   = ['mongooseim@REDACTED']
stopped db nodes   = [] 

The node that was being connected into did get the changes but it thinks the new node is still down:
running db nodes   = ['mongooseim@REDACTED']
stopped db nodes   = ['mongooseim@REDACTED'] 

It seems to me that amnesia can’t write out it’s changes in time before the VM stops. But I’m completely at a loss as to why this happens. When I perform the whole operation manually from the shell it seems to work just fine. I’m kind of new at this does anybody have some suggestions that could be helpfull please?

Thanks,
Erik Hoogeveen




More information about the erlang-questions mailing list